commit adb3830eb17796d354a5ec5bf2362c7b7504bbb0
parent 75313ac41a42647aee6546f179e826e3d4fd1b59
Author: torter <koubbamohamedrayan@gmail.com>
Date: Fri, 23 Oct 2026 16:24:58 -0400
new signing key, publish packages without the whole repo here
the old key is gone. merge-index.sh takes the published index, puts the new packages in it and signs it
with the new key: the packages already on sourceforge stay, apk trusts them through the index. package
builds use the public repo when there's no full copy here, and upload.sh won't sync a partial repo
Diffstat:
4 files changed, 87 insertions(+), 2 deletions(-)
diff --git a/keys/apk/chamesle-20261023.rsa.pub b/keys/apk/chamesle-20261023.rsa.pub
@@ -0,0 +1,14 @@
+-----BEGIN PUBLIC KEY-----
+MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAkClC78835xlhshWWPBfR
+Xmo/wLnlZU3RV9xspj7ysYSNmMzxlyXu6MHtL4KJkdFMVuk4Jdct4fOIF6OHbznO
+C19JrUegbG0kU6yu9zrkopylzSg2lSHfr+fuVkuuxv8+Faxw/CGMVF/j3nbjTeO4
+beZVJExXhv4hStipc4VxQwMwHZu3oPGFYuo8fE9x0pG+1K277qpzc1pwGTHZY2ya
+Ui1yqlxwrBEFPX8tSDZWYf3X2fgOUtAIj3k7Qkm1UfNxhurLUO8XupdWGIGt32tI
+qVTmYo+eVBHL9pifyd/jlowlSMjhI12qXCRvA+Wg0+gXb+4X7TgWLMSB5edMiTqq
+9tuTzYgd2DA1N5A2LTzpGDxxCoufN0Mb2HPgiOmKRJU6XSOi4PONa1coD5bWt7z7
+lUbKzWDqTlvqbXc9xCEeUUWLRiZ+l6vWbZL2AmFpdKnZ1xyynelmdzQWXlVNoZmb
+QG5ytlPyFYWeH6Jg433rf5eP+xE+WeW2Ma4Vm2KYGHBV6wRWm+T5ke0FqOFlqY6O
+DFDXwX1QuObHSPc3h0CmL1/UCHIUQXtM9ZYXtMp3M3HZBcqA85EU5yr5rrdqK0oW
+Zre7+cxAs1A3gTklv35gC60guvsn5N73V+hlww6BTuGtcmffse319Ej7eNxOphvj
+vxUg6csQMBgOLUvRfkDJtGUCAwEAAQ==
+-----END PUBLIC KEY-----
diff --git a/tools/pkg/build.sh b/tools/pkg/build.sh
@@ -9,8 +9,10 @@ APK=${APK:-apk}
REPO=${REPO:-$TOP/work/repo}
SRC=${SRC_CACHE:-$HOME/.cache/chamesle-src}
KEYDIR=${KEYDIR:-$HOME/.config/chamesle}
-KEY=$(ls "$KEYDIR"/chamesle-*.rsa | head -n1)
+KEY=$(ls "$KEYDIR"/chamesle-*.rsa | sort | tail -n1)
ARCH=x86_64
+# what it builds with comes from the repo here, or the public one when there's no full copy here
+PULL=${PULL:-$( [ -f "$REPO/$ARCH/Packages.adb" ] && echo "$REPO" || echo https://downloads.sourceforge.net/project/chameslerepos)}
[ $# = 1 ] && [ -f "$HERE/$1/recipe" ] || { echo "usage: $0 NAME (one of: $(cd "$HERE" && ls */recipe | sed 's|/recipe||' | tr '\n' ' '))" >&2; exit 1; }
. "$HERE/$1/recipe"
@@ -28,7 +30,7 @@ unshare --map-root-user --map-auto rm -rf "$W"
ROOT=$W/root
mkdir -p "$ROOT/etc/apk/keys" "$ROOT/build/src" "$ROOT/build/pkg"
cp "$TOP"/keys/apk/*.pub "$ROOT/etc/apk/keys/"
-echo "v3 $REPO" > "$ROOT/etc/apk/repositories"
+echo "v3 $PULL" > "$ROOT/etc/apk/repositories"
if [ -n "${source:-}" ]; then
tar -xf "$file" -C "$ROOT/build/src"
else
@@ -61,6 +63,7 @@ sodeps=$(find "$PKG" -type f \( -perm -u+x -o -name '*.so*' \) -exec readelf -d
sed -n 's/.*(NEEDED).*\[\(.*\)\]/\1/p' | sort -u | grep -vxF "$own" | sed 's/^/so:/' | tr '\n' ' ' || true)
provides=$(for f in $own; do case $f in *.so.[0-9]*) echo "so:$f=${f#*.so.}" | sed 's/=\([0-9]*\).*/=\1/';; esac; done | tr '\n' ' ')
+mkdir -p "$REPO/$ARCH"
out=$REPO/$ARCH/$name-$version-r$rel.apk
info=(--info "name:$name" --info "version:$version-r$rel" --info "arch:$ARCH" --info "description:$desc"
--info "url:$url" --info "license:$license" --info "maintainer:Chamesle Linux <packages@chamesle.org>")
@@ -76,6 +79,10 @@ for k in pre-install post-install pre-upgrade post-upgrade pre-deinstall post-de
done
# packed as namespace root so the files are root's
unshare --map-root-user --map-auto "$APK" mkpkg --files "$PKG" --output "$out" --sign-key "$KEY" "${info[@]}"
+if [ "$PULL" != "$REPO" ]; then
+ # an index of just what's here would hide the rest of the repo
+ echo "built $out (put it in the public index with tools/repo/merge-index.sh)"; exit 0
+fi
"$APK" mkndx --keys-dir "$TOP/keys/apk" --sign-key "$KEY" --description "chamesle $(date +%Y-%m-%d)" \
--index "$REPO/$ARCH/Packages.adb" --output "$REPO/$ARCH/Packages.adb.new" "$REPO/$ARCH"/*.apk
mv "$REPO/$ARCH/Packages.adb.new" "$REPO/$ARCH/Packages.adb"
diff --git a/tools/repo/merge-index.sh b/tools/repo/merge-index.sh
@@ -0,0 +1,57 @@
+#!/bin/bash
+# put packages in the published repo without having the whole repo here: the index on sourceforge is taken
+# as it is, the new packages replace their old versions in it, and it's signed with your key
+# tools/repo/merge-index.sh work/repo/x86_64/foo-1.0-r1.apk ... -> work/publish/x86_64/
+# tools/repo/merge-index.sh just re-sign the published index (a new key)
+# then upload work/publish/x86_64/ (tools/repo/upload.sh publish). packages already there stay as they are:
+# apk trusts them through the hashes in the signed index, their own signatures don't matter
+set -euo pipefail
+HERE=$(cd "$(dirname "$0")" && pwd)
+TOP=$HERE/../..
+APK=${APK:-apk}
+INDEX=${INDEX:-https://downloads.sourceforge.net/project/chameslerepos/x86_64/Packages.adb}
+KEY=$(ls "$HOME"/.config/chamesle/chamesle-*.rsa | sort | tail -n1)
+OUT=${OUT:-$TOP/work/publish/x86_64}
+T=$(mktemp -d); trap 'rm -rf "$T"' EXIT
+
+curl -fsSL -o "$T/old.adb" "$INDEX"
+# only an index we signed: one of the keys in keys/apk has to check out
+"$APK" adbdump --keys-dir "$TOP/keys/apk" "$T/old.adb" > "$T/old.yaml"
+grep -q '^# sig .*: OK$' "$T/old.yaml" || { echo "merge-index: $INDEX isn't signed by a key in keys/apk" >&2; exit 1; }
+
+rm -rf "$OUT"; mkdir -p "$OUT"
+: > "$T/new.yaml"
+if [ $# -gt 0 ]; then
+ cp "$@" "$OUT/"
+ "$APK" mkndx --keys-dir "$TOP/keys/apk" --output "$T/new.adb" "$@"
+ "$APK" adbdump "$T/new.adb" > "$T/new.yaml"
+fi
+
+python3 - "$T/old.yaml" "$T/new.yaml" "chamesle $(date +%Y-%m-%d)" > "$T/index.yaml" <<'EOF'
+import sys
+def entries(path):
+ out, cur = {}, None
+ for line in open(path):
+ if line.startswith(' - name: '):
+ cur = line[10:].strip()
+ out[cur] = []
+ elif not line.startswith(' ') and not line.startswith(' - '):
+ cur = None
+ if cur:
+ out[cur].append(line)
+ return out
+old, new = entries(sys.argv[1]), entries(sys.argv[2])
+for name in new:
+ print(('replaced ' if name in old else 'added ') + name, file=sys.stderr)
+old.update(new)
+# adbgen needs to know what kind of file it's making
+print(next(l for l in open(sys.argv[1]) if l.startswith('#%SCHEMA')).strip())
+print('description: ' + sys.argv[3])
+print('packages: # %d items' % len(old))
+for name in sorted(old):
+ sys.stdout.write(''.join(old[name]))
+EOF
+"$APK" adbgen "$T/index.yaml" > "$OUT/Packages.adb"
+"$APK" adbsign --allow-untrusted --reset-signatures --sign-key "$KEY" "$OUT/Packages.adb"
+"$APK" adbdump --keys-dir "$TOP/keys/apk" "$OUT/Packages.adb" | grep -q '^# sig .*: OK$'
+echo "$(grep -c '^ - name: ' "$T/index.yaml") packages, signed with $(basename "$KEY"): $OUT"
diff --git a/tools/repo/upload.sh b/tools/repo/upload.sh
@@ -3,6 +3,7 @@
# tools/repo/upload.sh everything
# tools/repo/upload.sh core the index and what the editions use (~2G), the rest can follow later
# tools/repo/upload.sh iso just the isos
+# tools/repo/upload.sh publish what tools/repo/merge-index.sh made: the new index and packages, nothing else
# run it again if it stops, it carries on where it was
set -eu
cd "$(dirname "$0")/../.."
@@ -12,6 +13,10 @@ R=work/repo/x86_64
case "${1:-}" in
iso)
;;
+publish)
+ rsync -av --partial --progress -e ssh work/publish/x86_64/ "$DEST/x86_64/"
+ exit 0
+ ;;
core)
# names from the editions' package lists plus everything they pull in, then their files
list=$(mktemp)
@@ -27,6 +32,8 @@ EOF
rm -f "$list"
;;
*)
+ # with only a few packages here this would empty the repo on sourceforge
+ [ "$(ls "$R" | grep -c '\.apk$')" -gt 10000 ] || { echo "upload: $R isn't a full copy of the repo, use publish" >&2; exit 1; }
# --delete-after: versions the weekly sync replaced go from sourceforge too
rsync -av --partial --progress --delete-after -e ssh "$R/" "$DEST/x86_64/"
;;