aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Makefile27
-rwxr-xr-xsrc/bin/paku.in154
-rwxr-xr-xtests/checks/apk.sh41
3 files changed, 219 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index ef7ae7b..24ba899 100644
--- a/Makefile
+++ b/Makefile
@@ -23,7 +23,7 @@ derived-assets = \
public \
-all: guix nix debian homebrew $(derived-assets)
+all: guix nix debian alpine homebrew $(derived-assets)
paku.lock: src/bin/paku Makefile
touch $@
@@ -85,6 +85,16 @@ debian.sentinel: debian.mk
debian: debian.sentinel
+alpine: alpine.sentinel
+
+alpine.sentinel: alpine.mk
+ @$(MAKE) -f alpine.mk
+ touch $@
+
+alpine.mk: paku.lock
+ paku alpine > $@
+
+
homebrew: Formula
Formula: paku.lock
@@ -98,11 +108,16 @@ public/debian: debian.sentinel
cp -R `cat debian.out.txt` $@
touch $@
+public/alpine: alpine.sentinel
+ mkdir -p $@
+ cp -R `cat alpine.out.txt` $@
+ touch $@
+
public/paku.html: paku.lock
mkdir -p $(@D)
paku html > $@
-public: public/debian public/paku.html
+public: public/debian public/alpine public/paku.html
upload: public
rsync -avzP --delete public/ euandre.org:/srv/www/s/package-repository/
@@ -150,4 +165,10 @@ check-debian-x86_64-deb:
check-debian: check-debian-x86_64-deb
-check: check-shellcheck check-guix check-ubuntu check-debian
+# FIXME: add -x
+check-alpine-x86_64-apk:
+ sh tests/vm-check.sh -H alpine-x86_64-headless -r $(HTTP-REMOTE) -t apk -- -k "`paku -C maintainer.email`"
+
+check-alpine: check-alpine-x86_64-apk
+
+check: check-shellcheck check-guix check-ubuntu check-debian check-alpine
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))
}
@@ -641,6 +763,17 @@ sub emit_html() {
<pre><code># apt install $pkg->{name}$apt_suffix</code></pre>
</section>
<section>
+ <h2>Alpine</h2>
+ <p>
+ After folowwing the
+ <a href="#alpine-instructions">Alpine instructions</a>
+ to include this repository to
+ <code>/etc/apk/repositories</code>, you can
+ install it:
+ </p>
+ <pre><code># apk add $pkg->{name}</code></pre>
+ </section>
+ <section>
<h2>Nix</h2>
<p>
After following the
@@ -723,6 +856,26 @@ sub emit_html() {
be available.
</p>
</article>
+ <article id="alpine-instructions">
+ <h2>Alpine instructions</h2>
+ <p>
+ Get my public key used to sign the repository:
+ </p>
+ <pre><code>\$ wget -qO- $json->{'base-url'}/alpine/$json->{maintainer}{email}.rsa.pub |
+ doas tee /etc/apk/keys/$json->{maintainer}{email}.rsa.pub</code></pre>
+ <p>
+ Then include this repository in the
+ <code>apk-repositories(5)</code> list that
+ <code>apk(8)</code> uses to retrive package files for
+ installation:
+ </p>
+ <pre><code>\$ echo '$json->{'base-url'}/alpine' |
+ doas tee -a /etc/apk/repositories</code></pre>
+ <p>
+ After that the packages frmo this repository will be
+ available.
+ </p>
+ </article>
<article id="nix-instructions">
<h2>Nix instructions</h2>
<p>
@@ -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,
);
diff --git a/tests/checks/apk.sh b/tests/checks/apk.sh
new file mode 100755
index 0000000..5acb479
--- /dev/null
+++ b/tests/checks/apk.sh
@@ -0,0 +1,41 @@
+#!/bin/sh
+set -eu
+
+
+while getopts 'k:' flag; do
+ case "$flag" in
+ k)
+ KEY="$OPTARG"
+ ;;
+ *)
+ exit 2
+ ;;
+ esac
+done
+shift $((OPTIND - 1))
+
+if [ -z "${KEY:-}" ]; then
+ echo 'Missing "-k KEY" argument.' >&2
+ exit 2
+fi
+
+set -x
+
+REPO="$1/alpine"
+
+if command -v remembering; then
+ echo 'remembering(1) is already installed.' >&2
+ exit 1
+fi
+
+if apk info remembering; then
+ echo 'remembering(1) is already in apk(8) list.' >&2
+ exit 1
+fi
+
+wget -qO- "$REPO"/"$KEY".rsa.pub | doas tee /etc/apk/keys/"$KEY".rsa.pub
+printf '%s\n' "$REPO" | doas tee -a /etc/apk/repositories
+doas apk add remembering
+
+remembering --help
+remembering -V