build-bootenv

reproducible boot environment with LVM2 and cryptsetup
git clone https://ccx.te2000.cz/git/build-bootenv
Log | Files | Refs | Submodules

build (2080B)


      1 #!/bin/sh
      2 set -x
      3 case $0 in (*/*) cd "${0%/*}" || exit $?;; esac
      4 JOBS=$(grep '^processor' /proc/cpuinfo | wc -l)
      5 : ${JOBS:=1}
      6 if test 1 -gt $JOBS; then
      7 	JOBS=1
      8 fi
      9 PKGS="busybox lvm cryptsetup pv"
     10 
     11 # musl-cross-make
     12 
     13 awk -vPWD="$PWD" '{gsub(/@@PWD@@/,PWD); print}' musl-cross-make.config.mak >musl-cross-make/config.mak.new || exit $?
     14 mv musl-cross-make/config.mak.new musl-cross-make/config.mak || exit $?
     15 make -C musl-cross-make -j$JOBS -l$JOBS || exit $?
     16 make -C musl-cross-make install || exit $?
     17 
     18 # build sabotabe packages
     19 
     20 awk -vPWD="$PWD" -vJOBS="$JOBS" '{gsub(/@@PWD@@/,PWD); gsub(/@@JOBS@@/,JOBS); print}' sabotage.config >sabotage/config.new || exit $?
     21 mv sabotage/config.new sabotage/config || exit $?
     22 . ./sabotage-env
     23 mkdir -p sabotage-image || exit $?
     24 sabotage/utils/setup-rootfs.sh || exit $?
     25 cp -a sabotage-pkg/* sabotage/pkg/ || exit $?
     26 butch install $PKGS || exit $?
     27 #for pkg in $PKGS; do
     28 #	butch reproduce $pkg || exit $?
     29 #done
     30 if test -z "$NO_VERIFY_CHECKSUMS"; then
     31 	if ! ( cd sabotage-image && sha512sum -c ../checksums/sabotage-opt.sha512 ) ; then
     32 		echo >&2 "Failed to reproducibly build necessary packages!"
     33 		exit 1
     34 	fi
     35 fi
     36 
     37 # prepare boot-image
     38 
     39 rm -rf boot-image || exit $?
     40 mkdir -p boot-image/opt || exit $?
     41 for pkg in $PKGS; do
     42 	cp -a sabotage-image/opt/$pkg boot-image/opt/ || exit $?
     43 done
     44 rm -rf boot-image/opt/*/share/man || exit $?
     45 rmdir boot-image/opt/*/share  # remove empty leftover dirs
     46 awk -vPWD="$PWD" -vJOBS="$JOBS" '{gsub(/@@PWD@@/,PWD); gsub(/@@JOBS@@/,JOBS); print}' sabotage-install.config >sabotage/install-config.new || exit $?
     47 mv sabotage/install-config.new sabotage/install-config || exit $?
     48 env CONFIG=$PWD/sabotage/install-config butch relink $PKGS || exit $?
     49 
     50 # remove empty directories
     51 rmdir boot-image/boot boot-image/libexec boot-image/sbin boot-image/var || exit $?
     52 ln -s . boot-image/boot || exit $?
     53 
     54 # check against boot-image listing
     55 if ! find boot-image -printf '\n%p\t%y%m\t%n\t%l\t' -type f -exec sha512sum '{}' \; | sort | diff -u - checksums/boot-image.lst; then
     56 	echo >&2 'Differences found in boot-image.'
     57 	exit 2
     58 fi