mkopenrc (2017B)
1 #!/bin/sh 2 # mkopenrc OUT: OpenRC for i686 glibc, repackaged from Gentoo's x86 binary host into a Chamesle package in OUT, signed 3 # with KEY. the 32-bit glibc edition takes its packages from Arch Linux 32 (systemd), which ships no OpenRC, so the 4 # init comes from Gentoo, the one distro that still builds i686 glibc OpenRC. the per-daemon *-openrc scripts are noarch 5 # and come from Artix as usual. 6 # KEY=~/.chamesle-keys/chamesle-20261118.rsa mkopenrc ~/chamesle/docs/repo/glibc/x86 7 set -e 8 here=$(cd "$(dirname "$0")/.." && pwd) 9 bh=${BINHOST:-https://distfiles.gentoo.org/releases/x86/binpackages/23.0/i686} 10 [ $# = 1 ] && [ -f "$KEY" ] || { echo "usage: KEY=... mkopenrc OUT" >&2; exit 2; } 11 out=$1 12 tmp=$(mktemp -d) 13 trap 'rm -rf "$tmp"' EXIT 14 15 # the newest openrc in the host's index, and its version 16 curl -fsSL "$bh/Packages" -o "$tmp/Packages" 17 path=$(awk 'BEGIN{RS="";FS="\n"} /\nCPV: sys-apps\/openrc-[0-9]/{for(i=1;i<=NF;i++)if($i~/^PATH: /){sub(/^PATH: /,"",$i);print $i}}' "$tmp/Packages" | sort -V | tail -1) 18 [ -n "$path" ] || { echo "mkopenrc: no openrc in $bh" >&2; exit 1; } 19 ver=$(echo "$path" | sed -n 's#.*/openrc-\([0-9][^/]*\)-[0-9]*\.gpkg\.tar#\1#p') 20 echo "==> openrc $ver from $bh" 21 22 # a gpkg.tar holds image.tar.zst (the files); fold Gentoo's split bin/sbin into usr/bin, Arch32 is merged-usr 23 curl -fsSL "$bh/$path" -o "$tmp/o.gpkg.tar" 24 img=$(tar tf "$tmp/o.gpkg.tar" | grep '/image\.tar\.zst$') 25 mkdir "$tmp/i" 26 tar xf "$tmp/o.gpkg.tar" -O "$img" | zstd -dc | tar -C "$tmp/i" -xf - 27 stage=$tmp/stage 28 mkdir -p "$stage/usr/bin" 29 cp -a "$tmp/i/image/usr" "$stage/" 2>/dev/null || true 30 cp -a "$tmp/i/image/etc" "$stage/" 31 for d in bin sbin usr/sbin; do [ -d "$tmp/i/image/$d" ] && cp -an "$tmp/i/image/$d/." "$stage/usr/bin/"; done 32 rm -rf "$stage/usr/sbin" 33 34 mkdir -p "$out" 35 "$here/tools/mkapk" -k "$KEY" -a x86 -o "$out" -n openrc -v "$ver" \ 36 -d "OpenRC init for i686 glibc (Gentoo x86 binpkg), so the Arch32 userland has services" \ 37 -D "libcap pam glibc psmisc" "$stage" 38 "$here/tools/mkrepo" "$out" "$KEY"