From c44affa1ed1c9c629f6859dd8a7ed4d67e3bb862 Mon Sep 17 00:00:00 2001 From: sergiotarxz Date: Mon, 24 Jun 2024 17:17:00 +0200 Subject: [PATCH] Adding initial flatpak support. --- cpan.pl | 141 +++++++++++ generated-sources.json | 400 ++++++++++++++++++++++++++++++++ lib/JapaChar.pm | 2 +- lib/JapaChar/DB.pm | 9 +- me.sergiotarxz.JapaChar.desktop | 6 + me.sergiotarxz.JapaChar.svg | 67 ++++++ me.sergiotarxz.JapaChar.yml | 98 ++++++++ run.sh | 3 + 8 files changed, 724 insertions(+), 2 deletions(-) create mode 100644 cpan.pl create mode 100644 generated-sources.json create mode 100644 me.sergiotarxz.JapaChar.desktop create mode 100644 me.sergiotarxz.JapaChar.svg create mode 100644 me.sergiotarxz.JapaChar.yml create mode 100755 run.sh diff --git a/cpan.pl b/cpan.pl new file mode 100644 index 0000000..9576cc6 --- /dev/null +++ b/cpan.pl @@ -0,0 +1,141 @@ +#!/usr/bin/env perl + +use v5.14; + +use strict; +use warnings; + +use Digest::SHA; +require File::Temp; +use File::Temp (); + +use Getopt::Long::Descriptive; +use JSON::MaybeXS; +use LWP::UserAgent; +use MetaCPAN::Client; +use Capture::Tiny qw(tee); + + +sub scan_deps { + my @deps = grep(/^Successfully installed/, @_); + + for (@deps) + { + s/^Successfully installed (\S+).*/$1/; + } + + @deps +} + +sub get_url_sha256 { + my ($url) = @_; + + my $state = Digest::SHA->new(256); + my $ua = LWP::UserAgent->new; + $ua->env_proxy; + + my $resp = $ua->get($url, ':read_size_hint' => 1024, + ':content_cb' => sub { + my ($data) = @_; + $state->add($data); + }); + + die "Failed to get sha256 of $url: @{[$resp->status_line]}\n" if !$resp->is_success; + $state->hexdigest; + +} +sub get_source_for_dep { + my ($cpan, $dep, $outdir) = @_; + my $release_set = $cpan->release({ name => $dep }); + + die "Unexpected @{[$release_set->total]} releases for $dep" + if $release_set->total != 1; + my $release = $release_set->next; + + my $url = $release->download_url; + my $sha256 = get_url_sha256 $url; + + { + type => 'archive', + url => $url, + sha256 => $sha256, + dest => "$outdir/@{[$release->distribution]}", + }; +} + +sub write_module_to_file { + my ($output, $root) = @_; + + my $serializer = JSON::MaybeXS->new(indent => 1, space_after => 1, canonical => 1); + my $json = $serializer->encode($root); + + open my $fh, '>', $output or die "Could not open $output for writing\n"; + print $fh $json; + close $fh; +} + +sub main { + my ($opts, $usage) = describe_options( + 'flatpak-cpan-generator %o ', + ['output|o=s', 'The generated sources file', { default => 'generated-sources.json' }], + ['dir|d=s', 'The output directory used inside the sources file', { default => 'perl-libs' }], + ['help|h', 'Show this screen', { shortcircuit => 1, hidden => 1 }], + ); + + if ($opts->help) { + print $usage->text; + exit; + } + + die "At least one package is required.\n" if @ARGV == 0; + + my $cpan = MetaCPAN::Client->new; + + say '** Installing dependencies with cpanm...'; + + my $tmpdir = File::Temp->newdir; + my ($stdout, $stderr, $exit) = tee { + system ('cpanm', '-n', '-L', $tmpdir, "--", @ARGV); + }; + die "cpanm failed with exit status $exit\n" if $exit != 0; + + say '** Scanning dependencies...'; + + my @stdout = split "\n", $stdout; + my @deps = scan_deps @stdout; + # my @deps = scan_deps 'lib'; + my @sources = (); + + foreach my $dep (@deps) { + say "** Processing: $dep"; + my $source = get_source_for_dep $cpan, $dep, $opts->dir; + push @sources, $source; + } + + push @sources, { + type => 'script', + dest => $opts->dir, + 'dest-filename' => 'install.sh', + commands => [ + "set -e", + "function make_install {", + " mod_dir=\$1", + " cd \$mod_dir", + " if [ -f 'Makefile.PL' ]; then", + " perl Makefile.PL PREFIX=\${FLATPAK_DEST} && make install PREFIX=\${FLATPAK_DEST}", + " elif [ -f 'Build.PL' ]; then", + " perl Build.PL && ./Build && ./Build install", + " else", + " echo 'No Makefile.PL or Build.PL found. Do not know how to install this module'", + " exit 1", + " fi", + "}", + map { "(make_install $_->{dest})" } @sources + ], + }; + + write_module_to_file $opts->output, \@sources; +} + +main; + diff --git a/generated-sources.json b/generated-sources.json new file mode 100644 index 0000000..0fbc25c --- /dev/null +++ b/generated-sources.json @@ -0,0 +1,400 @@ +[ + { + "dest": "perl-libs/DBI", + "sha256": "8a2b993db560a2c373c174ee976a51027dd780ec766ae17620c20393d2e836fa", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/T/TI/TIMB/DBI-1.643.tar.gz" + }, + { + "dest": "perl-libs/DBD-SQLite", + "sha256": "8994997d84b9feb4547795f78746c661fb72e3cb6a25dbdd789b731f5688a4dd", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/I/IS/ISHIGAKI/DBD-SQLite-1.74.tar.gz" + }, + { + "dest": "perl-libs/ExtUtils-PkgConfig", + "sha256": "bbeaced995d7d8d10cfc51a3a5a66da41ceb2bc04fedcab50e10e6300e801c6e", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/X/XA/XAOC/ExtUtils-PkgConfig-1.16.tar.gz" + }, + { + "dest": "perl-libs/ExtUtils-Depends", + "sha256": "673c4387e7896c1a216099c1fbb3faaa7763d7f5f95a1a56a60a2a2906c131c5", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/X/XA/XAOC/ExtUtils-Depends-0.8001.tar.gz" + }, + { + "dest": "perl-libs/Glib", + "sha256": "d715f5a86bcc187075de85e7ae5bc07b0714d6edc196a92da43986efa44e5cbb", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/X/XA/XAOC/Glib-1.3294.tar.gz" + }, + { + "dest": "perl-libs/Cairo", + "sha256": "8219736e401c2311da5f515775de43fd87e6384b504da36a192f2b217643077f", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/X/XA/XAOC/Cairo-1.109.tar.gz" + }, + { + "dest": "perl-libs/Cairo-GObject", + "sha256": "8d896444d71e1d0bca3d24e31e5d82bd0d9542aaed91d1fb7eab367bce675c50", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/X/XA/XAOC/Cairo-GObject-1.005.tar.gz" + }, + { + "dest": "perl-libs/Glib-Object-Introspection", + "sha256": "6569611dcc80ac1482c7c22264b1ae8c9c351d4983511eb9a6c5f47a10150089", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/X/XA/XAOC/Glib-Object-Introspection-0.051.tar.gz" + }, + { + "dest": "perl-libs/Glib-IO", + "sha256": "f40facf4d4b2e5125dbebde51b5e4ed35f8394bc43316ca7be743b9bb70f7443", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/X/XA/XAOC/Glib-IO-0.002.tar.gz" + }, + { + "dest": "perl-libs/JSON", + "sha256": "df8b5143d9a7de99c47b55f1a170bd1f69f711935c186a6dc0ab56dd05758e35", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/I/IS/ISHIGAKI/JSON-4.10.tar.gz" + }, + { + "dest": "perl-libs/Role-Tiny", + "sha256": "d7bdee9e138a4f83aa52d0a981625644bda87ff16642dfa845dcb44d9a242b45", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/H/HA/HAARG/Role-Tiny-2.002004.tar.gz" + }, + { + "dest": "perl-libs/Class-Method-Modifiers", + "sha256": "65cd85bfe475d066e9186f7a8cc636070985b30b0ebb1cde8681cf062c2e15fc", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/E/ET/ETHER/Class-Method-Modifiers-2.15.tar.gz" + }, + { + "dest": "perl-libs/Sub-Quote", + "sha256": "94bebd500af55762e83ea2f2bc594d87af828072370c7110c60c238a800d15b2", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/H/HA/HAARG/Sub-Quote-2.006008.tar.gz" + }, + { + "dest": "perl-libs/Moo", + "sha256": "fb5a2952649faed07373f220b78004a9c6aba387739133740c1770e9b1f4b108", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/H/HA/HAARG/Moo-2.005005.tar.gz" + }, + { + "dest": "perl-libs/YAML-PP", + "sha256": "a819465c52f6a341049a3942742c08e04f2894b2a66482e43a7f407ce10b4ea0", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/T/TI/TINITA/YAML-PP-v0.38.0.tar.gz" + }, + { + "dest": "perl-libs/Path-Tiny", + "sha256": "861ef09bca68254e9ab24337bb6ec9d58593a792e9d68a27ee6bec2150f06741", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/D/DA/DAGOLDEN/Path-Tiny-0.146.tar.gz" + }, + { + "dest": "perl-libs/Module-Build", + "sha256": "66aeac6127418be5e471ead3744648c766bd01482825c5b66652675f2bc86a8f", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/L/LE/LEONT/Module-Build-0.4234.tar.gz" + }, + { + "dest": "perl-libs/Module-Runtime", + "sha256": "68302ec646833547d410be28e09676db75006f4aa58a11f3bdb44ffe99f0f024", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/Z/ZE/ZEFRAM/Module-Runtime-0.016.tar.gz" + }, + { + "dest": "perl-libs/Class-XSAccessor", + "sha256": "99c56b395f1239af19901f2feeb125d9ecb4e351a0d80daa9529211a4700a6f2", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/S/SM/SMUELLER/Class-XSAccessor-1.19.tar.gz" + }, + { + "dest": "perl-libs/Sub-Name", + "sha256": "ecf36fba1c47ca93e1daa394968ed39c4186867459d9cd173c421e2b972043e8", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/E/ET/ETHER/Sub-Name-0.27.tar.gz" + }, + { + "dest": "perl-libs/Class-Accessor-Grouped", + "sha256": "35d5b03efc09f67f3a3155c9624126c3e162c8e3ca98ff826db358533a44c4bb", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/H/HA/HAARG/Class-Accessor-Grouped-0.10014.tar.gz" + }, + { + "dest": "perl-libs/Sub-Exporter-Progressive", + "sha256": "d535b7954d64da1ac1305b1fadf98202769e3599376854b2ced90c382beac056", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/F/FR/FREW/Sub-Exporter-Progressive-0.001013.tar.gz" + }, + { + "dest": "perl-libs/Devel-GlobalDestruction", + "sha256": "34b8a5f29991311468fe6913cadaba75fd5d2b0b3ee3bb41fe5b53efab9154ab", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/H/HA/HAARG/Devel-GlobalDestruction-0.14.tar.gz" + }, + { + "dest": "perl-libs/MRO-Compat", + "sha256": "0d4535f88e43babd84ab604866215fc4d04398bd4db7b21852d4a31b1c15ef61", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/H/HA/HAARG/MRO-Compat-0.15.tar.gz" + }, + { + "dest": "perl-libs/Test-Deep", + "sha256": "b6591f6ccdd853c7efc9ff3c5756370403211cffe46047f082b1cd1611a84e5f", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/R/RJ/RJBS/Test-Deep-1.204.tar.gz" + }, + { + "dest": "perl-libs/Sub-Uplevel", + "sha256": "b4f3f63b80f680a421332d8851ddbe5a8e72fcaa74d5d1d98f3c8cc4a3ece293", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/D/DA/DAGOLDEN/Sub-Uplevel-0.2800.tar.gz" + }, + { + "dest": "perl-libs/Test-Exception", + "sha256": "156b13f07764f766d8b45a43728f2439af81a3512625438deab783b7883eb533", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/E/EX/EXODIST/Test-Exception-0.43.tar.gz" + }, + { + "dest": "perl-libs/Clone-Choose", + "sha256": "5623481f58cee8edb96cd202aad0df5622d427e5f748b253851dfd62e5123632", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/H/HE/HERMES/Clone-Choose-0.010.tar.gz" + }, + { + "dest": "perl-libs/Hash-Merge", + "sha256": "ae0522f76539608b61dde14670e79677e0f391036832f70a21f31adde2538644", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/H/HE/HERMES/Hash-Merge-0.302.tar.gz" + }, + { + "dest": "perl-libs/SQL-Abstract", + "sha256": "35a642662c349420d44be6e0ef7d8765ea743eb12ad14399aa3a232bb94e6e9a", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/M/MS/MSTROUT/SQL-Abstract-2.000001.tar.gz" + }, + { + "dest": "perl-libs/Test-Warn", + "sha256": "98ca32e7f2f5ea89b8bfb9a0609977f3d153e242e2e51705126cb954f1a06b57", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/B/BI/BIGJ/Test-Warn-0.37.tar.gz" + }, + { + "dest": "perl-libs/SQL-Abstract-Classic", + "sha256": "4e3d1dfd095b2123268586bb06b86929ea571388d4e941acccbdcda1e108ef28", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/R/RI/RIBASUSHI/SQL-Abstract-Classic-1.91.tar.gz" + }, + { + "dest": "perl-libs/Variable-Magic", + "sha256": "9f7853249c9ea3b4df92fb6b790c03a60680fc029f44c8bf9894dccf019516bd", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/V/VP/VPIT/Variable-Magic-0.64.tar.gz" + }, + { + "dest": "perl-libs/Try-Tiny", + "sha256": "3300d31d8a4075b26d8f46ce864a1d913e0e8467ceeba6655d5d2b2e206c11be", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/E/ET/ETHER/Try-Tiny-0.31.tar.gz" + }, + { + "dest": "perl-libs/Module-Implementation", + "sha256": "c15f1a12f0c2130c9efff3c2e1afe5887b08ccd033bd132186d1e7d5087fd66d", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/D/DR/DROLSKY/Module-Implementation-0.09.tar.gz" + }, + { + "dest": "perl-libs/B-Hooks-EndOfScope", + "sha256": "edac77a17fc36620c8324cc194ce1fad2f02e9fcbe72d08ad0b2c47f0c7fd8ef", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/E/ET/ETHER/B-Hooks-EndOfScope-0.28.tar.gz" + }, + { + "dest": "perl-libs/Dist-CheckConflicts", + "sha256": "ea844b9686c94d666d9d444321d764490b2cde2f985c4165b4c2c77665caedc4", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/D/DO/DOY/Dist-CheckConflicts-0.11.tar.gz" + }, + { + "dest": "perl-libs/Package-Stash-XS", + "sha256": "26bad65c1959c57379b3e139dc776fbec5f702906617ef27cdc293ddf1239231", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/E/ET/ETHER/Package-Stash-XS-0.30.tar.gz" + }, + { + "dest": "perl-libs/Package-Stash", + "sha256": "5a9722c6d9cb29ee133e5f7b08a5362762a0b5633ff5170642a5b0686e95e066", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/E/ET/ETHER/Package-Stash-0.40.tar.gz" + }, + { + "dest": "perl-libs/namespace-clean", + "sha256": "8a10a83c3e183dc78f9e7b7aa4d09b47c11fb4e7d3a33b9a12912fd22e31af9d", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/R/RI/RIBASUSHI/namespace-clean-0.27.tar.gz" + }, + { + "dest": "perl-libs/Data-Dumper-Concise", + "sha256": "a6c22f113caf31137590def1b7028a7e718eface3228272d0672c25e035d5853", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/E/ET/ETHER/Data-Dumper-Concise-2.023.tar.gz" + }, + { + "dest": "perl-libs/Module-Pluggable", + "sha256": "b3f2ad45e4fd10b3fb90d912d78d8b795ab295480db56dc64e86b9fa75c5a6df", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/S/SI/SIMONW/Module-Pluggable-5.2.tar.gz" + }, + { + "dest": "perl-libs/Config-Any", + "sha256": "c0668eb5f2cd355bf20557f04dc18a25474b7a0bcfa79562e3165d9a3c789333", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/H/HA/HAARG/Config-Any-0.33.tar.gz" + }, + { + "dest": "perl-libs/Scope-Guard", + "sha256": "8c9b1bea5c56448e2c3fadc65d05be9e4690a3823a80f39d2f10fdd8f777d278", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/C/CH/CHOCOLATE/Scope-Guard-0.21.tar.gz" + }, + { + "dest": "perl-libs/Module-Find", + "sha256": "4bcaaa376915014728d4f533a98c5b59d665051cd3cdbafc960e5a66fd131092", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/C/CR/CRENZ/Module-Find-0.16.tar.gz" + }, + { + "dest": "perl-libs/Class-Inspector", + "sha256": "cc295d23a472687c24489d58226ead23b9fdc2588e522f0b5f0747741700694e", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/P/PL/PLICEASE/Class-Inspector-1.36.tar.gz" + }, + { + "dest": "perl-libs/Algorithm-C3", + "sha256": "aaf48467765deea6e48054bc7d43e46e4d40cbcda16552c629d37be098289309", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/H/HA/HAARG/Algorithm-C3-0.11.tar.gz" + }, + { + "dest": "perl-libs/Class-C3", + "sha256": "84053cf1a68fcc8c12056c2f120adf04f7f68e3be34f4408e95d026fee67e33e", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/H/HA/HAARG/Class-C3-0.35.tar.gz" + }, + { + "dest": "perl-libs/Class-C3-Componentised", + "sha256": "3051b146dc1efeaea1a9a2e9e6b1773080995b898ab583f155658d5fc80b9693", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/H/HA/HAARG/Class-C3-Componentised-1.001002.tar.gz" + }, + { + "dest": "perl-libs/Path-Class", + "sha256": "654781948602386f2cb2e4473a739f17dc6953d92aabc2498a4ca2561bc248ce", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/K/KW/KWILLIAMS/Path-Class-0.37.tar.gz" + }, + { + "dest": "perl-libs/Context-Preserve", + "sha256": "09914a4c2c7bdb99cab680c183cbf492ec98d6e23fbcc487fcc4ae10567dfd1f", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/E/ET/ETHER/Context-Preserve-0.03.tar.gz" + }, + { + "dest": "perl-libs/DBIx-Class", + "sha256": "341e0b6ecb29d8c49174a6c09d7c6dbf38729ba4015ee7fd70360a4ffee1f251", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/R/RI/RIBASUSHI/DBIx-Class-0.082843.tar.gz" + }, + { + "dest": "perl-libs/Pango", + "sha256": "34b0a422df3fecd7597587048552457d48ae764c43bbefd2a9d62ceb6c8bac71", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/X/XA/XAOC/Pango-1.227.tar.gz" + }, + { + "dest": "perl-libs/Crypt-URandom", + "sha256": "71a0350e237dabec8d95c4159cb77a2f20f4e81902c988438fbdd82cf65a8195", + "type": "archive", + "url": "https://cpan.metacpan.org/authors/id/D/DD/DDICK/Crypt-URandom-0.40.tar.gz" + }, + { + "commands": [ + "set -e", + "function make_install {", + " mod_dir=$1", + " cd $mod_dir", + " if [ -f 'Makefile.PL' ]; then", + " perl Makefile.PL PREFIX=${FLATPAK_DEST} && make install PREFIX=${FLATPAK_DEST}", + " elif [ -f 'Build.PL' ]; then", + " perl Build.PL && ./Build && ./Build install", + " else", + " echo 'No Makefile.PL or Build.PL found. Do not know how to install this module'", + " exit 1", + " fi", + "}", + "(make_install perl-libs/DBI)", + "(make_install perl-libs/DBD-SQLite)", + "(make_install perl-libs/ExtUtils-PkgConfig)", + "(make_install perl-libs/ExtUtils-Depends)", + "(make_install perl-libs/Glib)", + "(make_install perl-libs/Cairo)", + "(make_install perl-libs/Cairo-GObject)", + "(make_install perl-libs/Glib-Object-Introspection)", + "(make_install perl-libs/Glib-IO)", + "(make_install perl-libs/JSON)", + "(make_install perl-libs/Role-Tiny)", + "(make_install perl-libs/Class-Method-Modifiers)", + "(make_install perl-libs/Sub-Quote)", + "(make_install perl-libs/Moo)", + "(make_install perl-libs/YAML-PP)", + "(make_install perl-libs/Path-Tiny)", + "(make_install perl-libs/Module-Build)", + "(make_install perl-libs/Module-Runtime)", + "(make_install perl-libs/Class-XSAccessor)", + "(make_install perl-libs/Sub-Name)", + "(make_install perl-libs/Class-Accessor-Grouped)", + "(make_install perl-libs/Sub-Exporter-Progressive)", + "(make_install perl-libs/Devel-GlobalDestruction)", + "(make_install perl-libs/MRO-Compat)", + "(make_install perl-libs/Test-Deep)", + "(make_install perl-libs/Sub-Uplevel)", + "(make_install perl-libs/Test-Exception)", + "(make_install perl-libs/Clone-Choose)", + "(make_install perl-libs/Hash-Merge)", + "(make_install perl-libs/SQL-Abstract)", + "(make_install perl-libs/Test-Warn)", + "(make_install perl-libs/SQL-Abstract-Classic)", + "(make_install perl-libs/Variable-Magic)", + "(make_install perl-libs/Try-Tiny)", + "(make_install perl-libs/Module-Implementation)", + "(make_install perl-libs/B-Hooks-EndOfScope)", + "(make_install perl-libs/Dist-CheckConflicts)", + "(make_install perl-libs/Package-Stash-XS)", + "(make_install perl-libs/Package-Stash)", + "(make_install perl-libs/namespace-clean)", + "(make_install perl-libs/Data-Dumper-Concise)", + "(make_install perl-libs/Module-Pluggable)", + "(make_install perl-libs/Config-Any)", + "(make_install perl-libs/Scope-Guard)", + "(make_install perl-libs/Module-Find)", + "(make_install perl-libs/Class-Inspector)", + "(make_install perl-libs/Algorithm-C3)", + "(make_install perl-libs/Class-C3)", + "(make_install perl-libs/Class-C3-Componentised)", + "(make_install perl-libs/Path-Class)", + "(make_install perl-libs/Context-Preserve)", + "(make_install perl-libs/DBIx-Class)", + "(make_install perl-libs/Pango)", + "(make_install perl-libs/Crypt-URandom)" + ], + "dest": "perl-libs", + "dest-filename": "install.sh", + "type": "script" + } +] diff --git a/lib/JapaChar.pm b/lib/JapaChar.pm index cf6c2b9..5024833 100644 --- a/lib/JapaChar.pm +++ b/lib/JapaChar.pm @@ -222,7 +222,7 @@ sub _application_start($self, $app) { } sub start($self) { - my $app = Gtk::Application->new('me.sergiotarxz.japchar', 'default-flags'); + my $app = Gtk::Application->new('me.sergiotarxz.JapaChar', 'default-flags'); $app->signal_connect('activate' => sub { $self->_application_start($app); }); diff --git a/lib/JapaChar/DB.pm b/lib/JapaChar/DB.pm index 491c9cd..c4707ee 100644 --- a/lib/JapaChar/DB.pm +++ b/lib/JapaChar/DB.pm @@ -38,8 +38,15 @@ sub connect { sub _db_path($class) { my $home = $ENV{HOME}; + my $flatpak_config_dir = $ENV{XDG_CONFIG_HOME}; my $db_path = ''; - $db_path = $home . '/' if $home; + { + if ($flatpak_config_dir) { + $db_path = $flatpak_config_dir . '/'; + next; + } + $db_path = $home . '/' if $home; + } $db_path .= '.japachar/db.sqlite'; path($db_path)->parent->mkpath; return $db_path; diff --git a/me.sergiotarxz.JapaChar.desktop b/me.sergiotarxz.JapaChar.desktop new file mode 100644 index 0000000..4b3eefb --- /dev/null +++ b/me.sergiotarxz.JapaChar.desktop @@ -0,0 +1,6 @@ +[Desktop Entry] +Name=JapaChar +Exec=japachar +Type=Application +Icon=me.sergiotarxz.JapaChar +Categories=Education;Game diff --git a/me.sergiotarxz.JapaChar.svg b/me.sergiotarxz.JapaChar.svg new file mode 100644 index 0000000..1dbea2d --- /dev/null +++ b/me.sergiotarxz.JapaChar.svg @@ -0,0 +1,67 @@ + + + + + + + + + +   + + + diff --git a/me.sergiotarxz.JapaChar.yml b/me.sergiotarxz.JapaChar.yml new file mode 100644 index 0000000..40467a5 --- /dev/null +++ b/me.sergiotarxz.JapaChar.yml @@ -0,0 +1,98 @@ +id: "me.sergiotarxz.JapaChar" +branch: "main" +runtime: "org.gnome.Platform" +runtime-version: "46" +sdk: "org.gnome.Sdk" +finish-args: + - --share=ipc + - --socket=fallback-x11 + - --socket=wayland + - --filesystem=xdg-config/.japachar +command: '/app/JapaChar/run.sh' +modules: + - name: "perle" + no-autogen: true + config-opts: + - '-des' + # Build a shared library. + - '-Duseshrplib' + build-options: + cflags: '-fPIC' + ldflags: '-fpic' + sources: + - type: archive + url: https://www.cpan.org/src/5.0/perl-5.40.0.tar.gz + sha256: c740348f357396327a9795d3e8323bafd0fe8a5c7835fc1cbaba0cc8dfe7161f + - type: shell + commands: + # Have Flatpak run the GNU-compatible configure script. + - 'ln -s configure{.gnu,}' + # Restore write permission to the Perl libraries. + post-install: + - 'chmod -R u+w /app/lib/perl5' + # Clean up a bunch of stuff we don't need. Depending on your application, + # you may have to drop some of these (e.g. *.pod). + cleanup: + - '/bin/corelist' + - '/bin/cpan' + - '/bin/enc2xs' + - '/bin/encguess' + - '/bin/h2ph' + - '/bin/h2xs' + - '/bin/instmodsh' + - '/bin/json_pp' + - '/bin/libnetcfg' + - '/bin/perlbug' + - '/bin/perldoc' + - '/bin/perlivp' + - '/bin/perlthanks' + - '/bin/piconv' + - '/bin/pl2pm' + - '/bin/pod*' + - '/bin/prove' + - '/bin/ptar*' + - '/bin/shasum' + - '/bin/splain' + - '/bin/xsubpp' + - '/bin/zipdetails' + - '/include' + - '/man' + - '*.pod' + + # Installs the modules generated by flatpak-cpan-generator. + # Note that *any* Makefile.PL-style modules MUST be installed in this one step, + # as once perllocal.pod is written in one module, it cannot be modified by others. + - name: perl-libs + buildsystem: simple + build-commands: + - 'perl-libs/install.sh' + # Same as with the Perl module, we need to restore write permission. + # However, -f is now passed to avoid errors from trying to touch files from the + # above module that are now marked as read-only. + post-install: + - 'chmod -Rf u+w /app/lib/perl5/site_perl' + sources: + - generated-sources.json + # This step should be customized based on the CPAN packages you're using. + cleanup: + - '/bin' + - '/man' + - name: "japachar" + buildsystem: simple + build-commands: + - 'japachar/install.sh' + sources: + - type: "dir" + path: "." + dest: 'JapaCharSource' + - commands: + - 'set -e' + - 'cp -vr JapaCharSource ${FLATPAK_DEST}/JapaChar' + - 'mkdir -pv /app/share/applications' + - 'cp -v JapaCharSource/me.sergiotarxz.JapaChar.desktop /app/share/applications/' + - 'cp -v JapaCharSource/run.sh /app/bin/japachar' + - 'mkdir -pv /app/share/icons/hicolor/scalable/apps/' + - 'cp -pv JapaCharSource/me.sergiotarxz.JapaChar.svg /app/share/icons/hicolor/scalable/apps/' + dest: "japachar" + dest-filename: "install.sh" + type: "script" diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..de7e868 --- /dev/null +++ b/run.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +perl /app/JapaChar/scripts/japchar.pl