system

the Chamesle handbook, init, live ISO and install helpers
git clone https://github.com/tortr-rs/system
Log | Files | Refs | README | LICENSE

mkpkgs (7492B)


      1 #!/bin/sh
      2 # mkpkgs ARCH OUT: Chamesle's own packages for one arch, signed with KEY, and the index of OUT.
      3 #   KEY=~/.chamesle-keys/chamesle-20261118.rsa MAG=~/src/mag/mag RIFLE=~/src/rifle/rifle mkpkgs x86_64 repo/x86_64
      4 # RIFLE is the rifle binary for this ARCH (x86_64, or i386 from ./build.sh 32 for x86). REL is the -rN of the base's version.
      5 # REACH is reach built on c.h for ARCH (./build.sh, or ./build.sh 32 for x86); it is static, the same for musl and glibc
      6 # WMREL makes slate too, with that -rN; DOCKAPPS is what desktop/slate/dockapps built for this arch, for chamesle-dockapps.
      7 # LIBC=glibc makes the packages of the glibc Chamesle instead, for repo/glibc. KEYRINGS is a directory with artix.gpg and
      8 # archlinux.gpg (from a root where mag installed artix-keyring and archlinux-keyring): the base gets them so its
      9 # chamesle-bootstrap can make a glibc system
     10 set -e
     11 here=$(cd "$(dirname "$0")/.." && pwd)
     12 [ $# = 2 ] && [ -f "$KEY" ] && [ -x "$MAG" ] || { echo "usage: KEY=... MAG=... [RIFLE=...] mkpkgs ARCH OUT" >&2; exit 2; }
     13 arch=$1 out=$2
     14 mkdir -p "$out"
     15 tmp=$(mktemp -d "$out/.mkpkgs.XXXXXX")
     16 trap 'rm -rf "$tmp"' EXIT
     17 mkapk() { "$here/tools/mkapk" -k "$KEY" -a "$arch" -o "$out" "$@"; }
     18 
     19 mkdir -p "$tmp/mag/usr/bin"
     20 install -m755 "$MAG" "$tmp/mag/usr/bin/mag"
     21 mkapk -n mag -v "$("$MAG" --version | cut -d' ' -f2)" -d "the package manager" -s "$here/pkg/mag" -t /etc/init.d "$tmp/mag"
     22 
     23 if [ -n "$REACH" ]; then
     24 	mkdir -p "$tmp/reach/usr/bin"
     25 	install -m755 "$REACH" "$tmp/reach/usr/bin/reach"
     26 	[ "$LIBC" = glibc ] && ssh=openssh || ssh=openssh-client-default
     27 	mkapk -n reach -v 1 -d "ssh by name on the local network" -D "$ssh" "$tmp/reach"
     28 fi
     29 
     30 # the files every base has: the tools, the handbook, what makes a glibc system
     31 common() {
     32 	mkdir -p "$1/etc/mag/keys" "$1/usr/bin" "$1/usr/share/doc/chamesle" "$1/usr/share/chamesle"
     33 	cp "$here/keys/"*.pub "$1/etc/mag/keys/"
     34 	cp "$here/pkg/chamesle-base/os-release" "$1/etc/"
     35 	for t in chamesle-bootstrap chamesle-disk chamesle-boot chamesle-install; do install -m755 "$here/tools/$t" "$1/usr/bin/$t"; done
     36 	cp "$here/handbook/handbook.md" "$1/usr/share/doc/chamesle/handbook.md"
     37 	cp "$here/files/usr/share/chamesle/logo.txt" "$1/usr/share/chamesle/"
     38 	if [ -n "$KEYRINGS" ]; then
     39 		mkdir -p "$1/usr/share/chamesle/glibc/keys"
     40 		cp "$here/pkg/chamesle-base-glibc/repos" "$1/usr/share/chamesle/glibc/repos"
     41 		cp "$here/keys/"*.pub "$KEYRINGS/artix.gpg" "$KEYRINGS/archlinux.gpg" "$1/usr/share/chamesle/glibc/keys/"
     42 	fi
     43 }
     44 
     45 if [ "$LIBC" = glibc ]; then
     46 	[ -n "$RIFLE" ] && [ -n "$KEYRINGS" ] || { echo "mkpkgs: LIBC=glibc needs RIFLE and KEYRINGS" >&2; exit 2; }
     47 	r=$tmp/rifle
     48 	mkdir -p "$r/usr/bin" "$r/usr/lib/rifle/bin" "$r/etc/profile.d"
     49 	install -m755 "$RIFLE" "$r/usr/bin/rifle"
     50 	for t in $("$RIFLE" --list); do ln -s ../../../bin/rifle "$r/usr/lib/rifle/bin/$t"; done
     51 	cp "$here/pkg/chamesle-base-glibc/rifle.sh" "$r/etc/profile.d/"
     52 	mkapk -n rifle -v "$("$RIFLE" --version | head -n 1 | cut -d' ' -f2)" -d "the coreutils, in one program" "$r"
     53 	# the 64-bit base rides on Artix (openrc, elogind, the service scripts); there is no Artix for i686, so the
     54 	# 32-bit base takes its packages from Arch Linux 32 (systemd) and gets openrc from Chamesle's own repo (Gentoo
     55 	# binpkg, see mkopenrc). base and mkinitcpio pull systemd on arch32, so the essentials are named by hand and
     56 	# dracut makes the initramfs. the per-daemon openrc scripts arch32 lacks (dhcpcd) are baked into the base.
     57 	if [ "$arch" = x86 ]; then
     58 		gconf=chamesle-base-glibc32
     59 		# no pacman: it hard-pulls systemd on arch32, and mag is the package manager and runs the alpm hooks itself.
     60 		# the keyring packages pull pacman too, so the base bakes the arch32 and arch keyrings in (below) instead.
     61 		gdeps="filesystem glibc bash coreutils util-linux shadow procps-ng iproute2 iputils findutils grep sed gawk tar gzip xz bzip2 file pciutils psmisc licenses dracut kmod opendoas dhcpcd nftables e2fsprogs dosfstools curl mag rifle openrc"
     62 	else
     63 		gconf=chamesle-base-glibc
     64 		gdeps="base openrc elogind-openrc mkinitcpio dhcpcd dhcpcd-openrc opendoas arch-install-scripts artix-keyring archlinux-keyring e2fsprogs dosfstools curl mag rifle"
     65 	fi
     66 	b=$tmp/base
     67 	common "$b"
     68 	[ -d "$here/pkg/$gconf/files" ] && cp -R "$here/pkg/$gconf/files/." "$b/"
     69 	# the secure defaults the musl base gets from its files overlay: the firewall and the umask (sysctl is below)
     70 	mkdir -p "$b/etc/profile.d"
     71 	cp "$here/files/etc/nftables.nft" "$b/etc/"
     72 	cp "$here/files/etc/profile.d/00-umask.sh" "$b/etc/profile.d/"
     73 	if [ "$arch" = x86 ]; then
     74 		# the running system verifies arch32 packages with these, baked in since the keyring packages pull pacman
     75 		mkdir -p "$b/usr/share/pacman/keyrings"
     76 		cp "$KEYRINGS/archlinux32.gpg" "$KEYRINGS/archlinux.gpg" "$b/usr/share/pacman/keyrings/"
     77 	fi
     78 	cp "$here/pkg/$gconf/repos" "$b/etc/mag/repos"
     79 	mkdir -p "$b/usr/lib/chamesle" "$b/usr/share/libalpm/hooks"
     80 	install -m755 "$here/pkg/chamesle-base-glibc/brand" "$b/usr/lib/chamesle/brand"
     81 	cp "$here/pkg/chamesle-base-glibc/brand.hook" "$b/usr/share/libalpm/hooks/zz-chamesle-brand.hook"
     82 	cp "$here/pkg/chamesle-base/os-release" "$b/usr/share/chamesle/os-release"
     83 	mkdir -p "$b/etc/xdg/fastfetch"
     84 	cp "$here/files/etc/xdg/fastfetch/config.jsonc" "$b/etc/xdg/fastfetch/"
     85 	mkdir -p "$b/etc/sysctl.d" "$b/var/lib/pacman/local"
     86 	cp "$here/files/etc/sysctl.d/10-chamesle.conf" "$b/etc/sysctl.d/"
     87 	echo 9 > "$b/var/lib/pacman/local/ALPM_DB_VERSION"
     88 	mkapk -n chamesle-base -v "$(date +%Y%m%d)-r${REL:-0}" -d "the files in /etc and the tools of Chamesle, on glibc" \
     89 		-D "$gdeps" -s "$here/pkg/chamesle-base-glibc" "$b"
     90 	"$here/tools/mkrepo" "$out" "$KEY"
     91 	exit 0
     92 fi
     93 
     94 mkdir -p "$tmp/init"
     95 mkapk -n chamesle-init -v 1 -d "moves a base from before r20 over to OpenRC" -s "$here/pkg/chamesle-init" "$tmp/init"
     96 
     97 deps="alpine-baselayout busybox busybox-binsh busybox-suid doas mksh agetty bash mount umount findmnt util-linux-misc chamesle-init openrc busybox-openrc eudev eudev-openrc udev-init-scripts udev-init-scripts-openrc dhcpcd-openrc kmod dhcpcd nftables nftables-openrc e2fsprogs dosfstools curl mag"
     98 if [ -n "$RIFLE" ]; then
     99 	mkdir -p "$tmp/rifle/usr/bin"
    100 	install -m755 "$RIFLE" "$tmp/rifle/usr/bin/rifle"
    101 	for t in $("$RIFLE" --list); do ln -s rifle "$tmp/rifle/usr/bin/$t"; done
    102 	mkapk -n rifle -v "$("$RIFLE" --version | head -n 1 | cut -d' ' -f2)" -d "the coreutils, in one program" "$tmp/rifle"
    103 	deps="$deps rifle"
    104 fi
    105 
    106 b=$tmp/base
    107 cp -R "$here/files" "$b"
    108 rm -f "$b/etc/hosts" "$b/etc/services"
    109 common "$b"
    110 mkdir -p "$b/etc/apk"
    111 ln -s ../mag/keys "$b/etc/apk/keys"
    112 cp "$here/pkg/chamesle-base/repos" "$b/etc/mag/repos"
    113 cp "$here/pkg/chamesle-base/issue" "$b/etc/"
    114 mkapk -n chamesle-base -v "$(date +%Y%m%d)-r${REL:-0}" -d "the files in /etc and the tools of Chamesle" \
    115 	-D "$deps" -s "$here/pkg/chamesle-base" "$b"
    116 
    117 if [ -n "$WMREL" ]; then
    118 	d=$tmp/slate
    119 	DESTDIR=$d "$here/desktop/slate/install" /usr
    120 	cp -Rp "$here/desktop/slate/chamesle/." "$d/"
    121 	mkapk -n slate -v "$(date +%Y%m%d)-r$WMREL" -d "Window Maker with the dock apps and the NeXT look" \
    122 		-D "windowmaker st xfe xsetroot xmessage xdm tint2 dunst xscreensaver arandr pavucontrol font-urw-base35 font-misc-misc${DOCKAPPS:+ chamesle-dockapps}" "$d"
    123 fi
    124 if [ -n "$WMREL" ] && [ -n "$DOCKAPPS" ]; then
    125 	mkapk -n chamesle-dockapps -v "$(date +%Y%m%d)-r$WMREL" -d "wmclock, wmcpuload, wmmemload, wmnet, wmix, wmbattery and wmsystemtray" \
    126 		-D "libx11 libxext libxpm alsa-lib upower" "$DOCKAPPS"
    127 fi
    128 "$here/tools/mkrepo" "$out" "$KEY"