From 8ff13c6ba6cc3eb35ca92682634425e2229486a6 Mon Sep 17 00:00:00 2001
From: EuAndreh
Date: Tue, 28 Mar 2023 12:21:20 -0300
Subject: src/bin/paku.in: Add WIP version of Alpine support, based off of
Debian
---
src/bin/paku.in | 154 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 154 insertions(+)
(limited to 'src')
diff --git a/src/bin/paku.in b/src/bin/paku.in
index 3b2d221..e7c43f3 100755
--- a/src/bin/paku.in
+++ b/src/bin/paku.in
@@ -32,6 +32,7 @@ sub help($fh) {
ACTION what to emit, one of:
- guix
- debian
+ - alpine
- nix
- html
- guix-channel-key
@@ -499,6 +500,127 @@ sub emit_debian() {
print @targets;
}
+sub emit_alpine() {
+ my $json = load_json();
+ my @apks = ();
+ my @targets = ();
+
+ for my $pkg (@{$json->{packages}}) {
+ push @targets, <<~EOF;
+ \$(DIR)/tarballs/$pkg->{fname}:
+ mkdir -p \$(\@D)
+ wget -O \$\@ \\
+ '$pkg->{url}'
+
+ \$(DIR)/checkouts/$pkg->{name}-$pkg->{version}: \$(DIR)/tarballs/$pkg->{fname}
+ mkdir -p \$(\@D)
+ tar -C \$(\@D) -xf \$(DIR)/tarballs/$pkg->{fname}
+ touch \$\@
+
+ EOF
+
+
+ next if $pkg->{architectures} ne 'any';
+
+
+ my $deb_name = "$pkg->{name}_" . (
+ $pkg->{label} eq 'latest' ? 'latest' : $pkg->{version}
+ ) . "_all.deb";
+ my $deb_path = "\$(DIR)/debian/$deb_name";
+
+ push @apks, "\t$deb_path \\\n";
+
+ my $ver = $pkg->{label} eq 'latest' ? '0.' . $pkg->{version} . '.latest' : $pkg->{version};
+ $ver =~ s/^v//;
+
+ push @targets, <<~EOF;
+ \$(DIR)/builddirs/$pkg->{name}-$pkg->{version}/DEBIAN: \$(DIR)/checkouts/$pkg->{name}-$pkg->{version}
+ \$(MAKE) \\
+ -C \$(DIR)/checkouts/$pkg->{name}-$pkg->{version} \\
+ install \\
+ PREFIX=/usr \\
+ DESTDIR="\$\$PWD"/\$(\@D)
+ mkdir -p \$\@
+ touch \$\@
+
+ \$(DIR)/builddirs/$pkg->{name}-$pkg->{version}/DEBIAN/control: \$(DIR)/builddirs/$pkg->{name}-$pkg->{version}/DEBIAN
+ printf '' > \$\@
+ printf 'Package: $pkg->{name}\\n' >> \$\@
+ printf 'Version: $ver\\n' >> \$\@
+ printf 'Section: custom\\n' >> \$\@
+ printf 'Depends:\\n' >> \$\@
+ printf 'Priority: optional\\n' >> \$\@
+ printf 'Architecture: all\\n' >> \$\@
+ printf 'Essential: no\\n' >> \$\@
+
+ printf 'Maintainer: ' >> \$\@
+ printf '$pkg->{"maintainer-b64"}' | base64 -d >> \$\@
+ printf '\\n' >> \$\@
+
+ printf 'Description: ' >> \$\@
+ printf '$pkg->{"description-b64"}' | base64 -d >> \$\@
+ printf '\\n' >> \$\@
+
+ printf '$pkg->{'long-description-b64'}' | \\
+ base64 -d | \\
+ sed 's|^\$\$|.|' | \\
+ sed 's|^| |' >> \$\@
+ printf '\\n' >> \$\@
+
+ \$(DIR)/builddirs/$pkg->{name}-$pkg->{version}.deb: \$(DIR)/builddirs/$pkg->{name}-$pkg->{version}/DEBIAN/control
+ dpkg-deb --build \$(DIR)/builddirs/$pkg->{name}-$pkg->{version}
+
+ $deb_path: \$(DIR)/builddirs/$pkg->{name}-$pkg->{version}.deb
+ mkdir -p \$(\@D)
+ cp \$(DIR)/builddirs/$pkg->{name}-$pkg->{version}.deb \$\@
+
+
+ EOF
+ }
+
+
+ print <<~EOF;
+ .POSIX:
+
+ DIR = $json->{datadir}
+
+ apks = \\
+ EOF
+
+ # print @apks, "\n";
+ print "\n\n";
+ print <<~EOF;
+ RSAKEY = '$json->{maintainer}{email}'
+
+
+ all: \$(DIR)/alpine/public/x86_64/APKINDEX.tar.gz \$(DIR)/alpine/public/\$(RSAKEY).rsa.pub
+
+ public-dir:
+ \@printf '\$(DIR)/alpine/public'
+
+
+ \$(DIR)/alpine/x86_64/APKINDEX: \$(apks)
+ mkdir -p \$(\@D) # FIXME
+ touch \$\@
+
+ \$(DIR)/alpine/x86_64/DESCRIPTION: \$(DIR)/alpine/x86_64/APKINDEX
+ echo xablau > \$\@
+
+ \$(DIR)/alpine/public/x86_64/APKINDEX.tar.gz: \$(DIR)/alpine/x86_64/APKINDEX \\
+ \$(DIR)/alpine/x86_64/DESCRIPTION
+ mkdir -p \$(\@D) # FIXME
+ tar -C \$(DIR)/alpine/x86_64 -cvf \$\@ APKINDEX DESCRIPTION
+
+
+ \$(DIR)/alpine/public/\$(RSAKEY).rsa.pub: \$(apks)
+ mkdir -p \$(\@D) # FIXME
+ gpg --export-ssh-key \$(RSAKEY) | ssh-keygen -f/dev/stdin -e -m pem > \$\@
+
+
+ EOF
+ # print @targets;
+}
+
sub pascal_case($s) {
return join('', map(ucfirst, split '-', $s))
}
@@ -640,6 +762,17 @@ sub emit_html() {
# apt install $pkg->{name}$apt_suffix
+
+ Alpine
+
+ After folowwing the
+ Alpine instructions
+ to include this repository to
+ /etc/apk/repositories
, you can
+ install it:
+
+ # apk add $pkg->{name}
+
Nix
@@ -723,6 +856,26 @@ sub emit_html() {
be available.
+
+ Alpine instructions
+
+ Get my public key used to sign the repository:
+
+ \$ wget -qO- $json->{'base-url'}/alpine/$json->{maintainer}{email}.rsa.pub |
+ doas tee /etc/apk/keys/$json->{maintainer}{email}.rsa.pub
+
+ Then include this repository in the
+ apk-repositories(5)
list that
+ apk(8)
uses to retrive package files for
+ installation:
+
+ \$ echo '$json->{'base-url'}/alpine' |
+ doas tee -a /etc/apk/repositories
+
+ After that the packages frmo this repository will be
+ available.
+
+
Nix instructions
@@ -793,6 +946,7 @@ my %actions = (
guix => \&emit_guix,
'guix-channel-key' => \&emit_guix_channel_key,
debian => \&emit_debian,
+ alpine => \&emit_alpine,
homebrew => \&emit_homebrew,
html => \&emit_html,
);
--
cgit v1.2.3