#!/bin/bash # packages/chroot-imagetools.sh — build the tools needed to make the live ISO: # static busybox (for the initramfs), squashfs-tools, mtools, xorriso (libburnia) # and grub's x86_64-efi target. Runs INSIDE the chroot. set -Eeuo pipefail export LC_ALL=POSIX MAKEFLAGS="${MAKEFLAGS:--j4}" SRC=/sources; STAMPS=/root/.base-stamps; mkdir -p "$STAMPS" once(){ local n="$1"; shift; [[ -f "$STAMPS/$n" ]] && { echo "skip $n"; return; }; "$@"; touch "$STAMPS/$n"; } find_tb(){ local m; shopt -s nocaseglob nullglob; local a=("$SRC/$1"-[0-9]*.tar.*) b=("$SRC/$1"*.tar.*); shopt -u nocaseglob nullglob; m="${a[0]:-${b[0]:-}}"; [[ -n "$m" ]] || { echo "MISSING SOURCE: $1" >&2; return 1; }; echo "$m"; } unp(){ cd /tmp; rm -rf bld-"$1"; mkdir bld-"$1"; tar -xf "$(find_tb "$1")" -C bld-"$1" --strip-components=1; cd bld-"$1"; } i_busybox(){ unp busybox make defconfig >/dev/null sed -i \ -e 's/^# CONFIG_STATIC is not set$/CONFIG_STATIC=y/' \ -e 's/^CONFIG_STATIC=.*/CONFIG_STATIC=y/' \ -e 's/^CONFIG_TC=y$/# CONFIG_TC is not set/' \ -e 's/^CONFIG_FEATURE_TC_INGRESS=y$/# CONFIG_FEATURE_TC_INGRESS is not set/' \ .config set +o pipefail yes "" 2>/dev/null | make oldconfig >/dev/null 2>&1 local oldconfig_status="${PIPESTATUS[1]}" set -o pipefail (( oldconfig_status == 0 )) make install -Dm755 busybox /usr/bin/busybox-static cd /; } i_squashfs(){ unp squashfs-tools; cd squashfs-tools 2>/dev/null || true make GZIP_SUPPORT=1 XZ_SUPPORT=1 ZSTD_SUPPORT=1 make GZIP_SUPPORT=1 XZ_SUPPORT=1 ZSTD_SUPPORT=1 \ INSTALL_PREFIX=/usr INSTALL_MANPAGES_DIR= install cd /; } i_libburn(){ unp libburn sed -i 's/^static void catch_int ()$/static void catch_int (int signum)/' test/poll.c ./configure --prefix=/usr --disable-static make; make install; cd /; } i_libisofs(){ unp libisofs; ./configure --prefix=/usr --disable-static; make; make install; cd /; } i_libisoburn(){ unp libisoburn; ./configure --prefix=/usr --disable-static; make; make install; cd /; } i_mtools(){ unp mtools; ./configure --prefix=/usr; make; make install; cd /; } i_grub_efi(){ unp grub : > grub-core/extra_deps.lst ./configure --prefix=/usr --sysconfdir=/etc --disable-werror \ --with-platform=efi --target=x86_64 make; make install; cd /; } echo "== image tools ==" once i-busybox i_busybox once i-squashfs i_squashfs once i-libburn i_libburn once i-libisofs i_libisofs once i-libisoburn i_libisoburn once i-mtools i_mtools once i-grub-efi i_grub_efi echo "image tools ready"