From 9699ecdf11572a3cdcb34ae022320a1fd18ad129 Mon Sep 17 00:00:00 2001 From: bill-auger Date: Tue, 17 Oct 2017 23:05:58 -0400 Subject: add rebuild helper and qemu boot scripts --- .gitignore | 5 +++- configs/profile/boot-iso.sh | 22 ++++++++++++++++ configs/profile/rebuild.sh | 64 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+), 1 deletion(-) create mode 100755 configs/profile/boot-iso.sh create mode 100755 configs/profile/rebuild.sh diff --git a/.gitignore b/.gitignore index c7c7494..59bd84b 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,7 @@ work out # package caches -configs/*/isorepo*/ +isorepo* + +# helpers +continue.sh diff --git a/configs/profile/boot-iso.sh b/configs/profile/boot-iso.sh new file mode 100755 index 0000000..15d1123 --- /dev/null +++ b/configs/profile/boot-iso.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +ISOS_DIR=$(dirname $0)/out +HD_IMG= +SSH_FWD_HOST_PORT= +ISO="$(ls -t $ISOS_DIR/*.iso | head -n 1)" +VIRTIO_NET_DEV="-netdev user,id=vmnic,hostfwd=tcp::$SSH_FWD_HOST_PORT-:22 \ + -device virtio-net,netdev=vmnic" +QEMU="qemu-system-x86_64 -enable-kvm" +MEM="-m 1G" +VIDEO="-vga std" +AUDIO="-soundhw hda " +WM_HIMTS="-display sdl -no-frame" # -show-cursor" +[ "$ISO" ] && CD="-cdrom $ISO -boot d" || CD='' +[ "$HD_IMG" ] && HD="-drive file=$HD_IMG,format=raw,cache=writeback" || HD='' +[ "$SSH_FWD_HOST_PORT" ] && NET_DEV="$VIRTIO_NET_DEV" || NET_DEV='' + + +[ ! "$ISO" ] && echo "no ISO found in ISOS_DIR: '$ISOS_DIR'" && exit + +CMD="$QEMU $MEM $HD $CD $NET_DEV $VIDEO $AUDIO $WM_HIMTS" +echo "$CMD" ; $CMD ; diff --git a/configs/profile/rebuild.sh b/configs/profile/rebuild.sh new file mode 100755 index 0000000..3f212c6 --- /dev/null +++ b/configs/profile/rebuild.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +readonly MODE='wipe' # total wipe of work dir preserving package cache +# readonly MODE='rebuild' # full update rebuild preserving work dir +# readonly MODE='tweak' # chroot customization tweaks only +readonly TARGET='dual' # dual-arch (default) +# readonly TARGET='i686' # i686 target only +# readonly TARGET='x86_64' # x86_64 target only +# readonly EDITION='OpenRC/CLI' # OpenRC/CLI init/WM-DE pair +# readonly EDITION='OpenRC/LXDE' # OpenRC/LXDE init/WM-DE pair +readonly EDITION='SystemD/CLI' # SystemD/CLI init/WM-DE pair (default) +# readonly EDITION='SystemD/LXDE' # SystemD/LXDE init/WM-DE pair +readonly CACHE='' # net-install (default) +# readonly CACHE='-O' # offline install +readonly VERSION="`date +%Y.%m.%d-%H.%M`-alpha" # ISO filename like: parabola---.iso + + +((`id -u`)) && echo "This script must be run with root privileges." && exit + +# cleanup in case of previous aborted run +while pids=$(pidof ./rebuild.sh || pidof sudo ./rebuild.sh) && pids=${pids/$PPID/} && [ "$pids" ] +do for pid in ${pids/$PPID/} ; do sudo kill -9 $pid ; done ; sleep 1 ; +done +for work_dir in "$PWD/work/i686" "$PWD/work/x86_64" +do declare -a mountpoints=() + for mnt in dev/pts dev/shm dev proc run sys tmp; do + mountpoint=$(findmnt --noheadings --output="TARGET" "${work_dir}/root-image/${mnt}" || true) + if [[ "${mountpoint}" != "" ]] ; then mountpoints=( ${mountpoints[@]} "${mountpoint}" ) ; fi ; + done + for mountpoint in ${mountpoints[@]} ; do umount "${mountpoint}" ; done ; +done + +if [ "$MODE" == 'wipe' ] +then for arch in i686 x86_64 + do isorepo=./work/${arch}/root-image/isorepo + [ -d $isorepo -a ! -d ./isorepo-${arch} ] && mv $isorepo ./isorepo-${arch} 2> /dev/null + done + + rm -rf ./work/ 2> /dev/null + + for arch in i686 x86_64 + do if [ -d ./isorepo-${arch} ] && [ "$TARGET" == 'dual' -o "$TARGET" == "${arch}" ] + then mkdir -p ./work/${arch}/root-image + mv ./isorepo-${arch} ./work/${arch}/root-image/isorepo + fi + done + +elif [ "$MODE" == 'rebuild' ] +then rm -v ./work/build.make_* + +elif [ "$MODE" == 'tweak' ] +then rm work/build.make_customize_root_image_$TARGET \ + work/build.make_prepare_$TARGET \ + work/build.make_iso* 2> /dev/null +fi + + +CMD="./build.sh -v -E $EDITION -T $TARGET $CACHE -V $VERSION" +if ${CMD} +then echo "success" ; rm ./continue.sh 2> /dev/null +else echo -e "failure - continue with: ./continue.sh" + echo -e "#!/bin/bash\n${CMD}" > ./continue.sh + chmod a+x ./continue.sh +fi -- cgit v1.2.2