diff options
author | EuAndreh <eu@euandre.org> | 2023-03-21 17:23:07 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2023-03-21 17:23:07 -0300 |
commit | 17ae2a10e29f2c856bfe43602bba76245916fcb8 (patch) | |
tree | a1c9b0b7e6cbcda846bef1da546c991bfcc020c2 | |
parent | src/bin/paku: Use "label" field from paku.lock (diff) | |
download | package-repository-17ae2a10e29f2c856bfe43602bba76245916fcb8.tar.gz package-repository-17ae2a10e29f2c856bfe43602bba76245916fcb8.tar.xz |
src/bin/paku: Add "debian-packages" action, do not depend on dpkg-scanpackages
Diffstat (limited to '')
-rwxr-xr-x | src/bin/paku | 57 |
1 files changed, 49 insertions, 8 deletions
diff --git a/src/bin/paku b/src/bin/paku index cbc8df0..41b420f 100755 --- a/src/bin/paku +++ b/src/bin/paku @@ -79,16 +79,52 @@ if ($opts{h}) { my $dir = $opts{d} || '.paku'; my $fname = $opts{f} || 'paku.lock'; -my $json_str = do { - open my $fh, $fname or die "Failed opening \"$fname\""; - local $/; - <$fh>; -}; -my $json = JSON::decode_json($json_str); + my $action = $ARGV[0] or die "Missing ACTION"; +shift; + +sub load_json() { + my $json_str = do { + open my $fh, $fname or die "Failed opening \"$fname\""; + local $/; + <$fh>; + }; + return JSON::decode_json($json_str); +} + +sub emit_packages() { + for (@ARGV) { + my $fh; + my $size = (stat($_))[7]; + + open ($fh, '<', $_) or die "Can't open \"$_\": $!"; + my $md5 = Digest::MD5->new->addfile($fh)->hexdigest; + close $fh; + + open ($fh, '<', $_) or die "Can't open \"$_\": $!"; + my $sha1 = Digest::SHA->new(1)->addfile($fh)->hexdigest; + close $fh; + + open ($fh, '<', $_) or die "Can't open \"$_\": $!"; + my $sha256 = Digest::SHA->new(256)->addfile($fh)->hexdigest; + close $fh; + + open ($fh, '<', $_) or die "Can't open \"$_\": $!"; + my $sha512 = Digest::SHA->new(512)->addfile($fh)->hexdigest; + close $fh; + + print `ar -p $_ control.tar.xz | tar -xJO ./control`; + say "Filename: ./$_"; + say "Size: $size"; + say "MD5sum: $md5"; + say "SHA1: $sha1"; + say "SHA256: $sha256"; + print "\n"; + } +} sub emit_release() { - my $f = $ARGV[1]; + my $f = $ARGV[0]; my $name = File::Basename::basename $f; my $size = (stat($f))[7]; @@ -128,6 +164,7 @@ sub emit_release() { } sub emit_nix() { + my $json = load_json(); my $ns = $json->{namespace}; $ns =~ s/\./-/g; print <<~EOF; @@ -203,6 +240,7 @@ sub emit_nix() { } sub emit_guix() { + my $json = load_json(); my $ns = $json->{namespace}; $ns =~ s/\./ /g; print <<~EOF; @@ -295,6 +333,7 @@ sub emit_guix() { } sub emit_debian() { + my $json = load_json(); my %vars = ( tarballs => ["tarballs = \\\n"], checkouts => ["checkouts = \\\n"], @@ -404,7 +443,7 @@ sub emit_debian() { \$(DIR)/debian/Packages: \$(debs) - cd \$(\@D) && dpkg-scanpackages -m . > \$(\@F) + cd \$(\@D) && perl \$\$OLDPWD/src/bin/paku debian-packages *.deb > \$(\@F) \$(DIR)/debian/Release: \$(DIR)/debian/Packages perl src/bin/paku debian-release \$(DIR)/debian/Packages > \$\@ @@ -425,6 +464,7 @@ sub emit_debian() { } sub emit_html() { + my $json = load_json(); print <<~EOF; <!DOCTYPE html> <html lang="en"> @@ -590,6 +630,7 @@ sub emit_html() { my %actions = ( + 'debian-packages' => \&emit_packages, 'debian-release' => \&emit_release, nix => \&emit_nix, guix => \&emit_guix, |