From 4d0d8914eb2b1b36bcc6d98acac36cc4af21b2a8 Mon Sep 17 00:00:00 2001 From: bill-auger Date: Sat, 21 Dec 2019 05:31:20 -0500 Subject: [PATCH] allow running in-tree --- src/pvm2tarball.sh | 0 src/pvmboot.sh | 0 src/pvmbootstrap.sh | 19 ++++++++++++------- 3 files changed, 12 insertions(+), 7 deletions(-) mode change 100644 => 100755 src/pvm2tarball.sh mode change 100644 => 100755 src/pvmboot.sh mode change 100644 => 100755 src/pvmbootstrap.sh diff --git a/src/pvm2tarball.sh b/src/pvm2tarball.sh old mode 100644 new mode 100755 diff --git a/src/pvmboot.sh b/src/pvmboot.sh old mode 100644 new mode 100755 diff --git a/src/pvmbootstrap.sh b/src/pvmbootstrap.sh old mode 100644 new mode 100755 index d104610..1bc96f5 --- a/src/pvmbootstrap.sh +++ b/src/pvmbootstrap.sh @@ -23,9 +23,14 @@ source "$(librelib messages)" +# defaults readonly DEF_MIRROR="https://repo.parabola.nu/\$repo/os/\$arch" readonly DEF_IMG_GB=64 +# misc +readonly THIS_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" + +# options Hooks=() Mirror=$DEF_MIRROR ImgSizeGb=$DEF_IMG_GB @@ -354,9 +359,9 @@ EOF # boot the machine to run the pre-init hooks local pvmboot_cmd local qemu_flags=(-no-reboot) - if [ -f "./src/pvmboot.sh" ]; then - pvmboot_cmd=(bash ./src/pvmboot.sh) - elif type -p pvmboot &>/dev/null; then + if [ -f "$THIS_DIR/pvmboot.sh" ]; then # in-tree + pvmboot_cmd=("$THIS_DIR/pvmboot.sh") + elif type -p pvmboot &>/dev/null; then # installed pvmboot_cmd=('pvmboot') else error "pvmboot not available -- unable to run hooks" @@ -399,10 +404,10 @@ main() { while getopts 'hOs:M:H:' arg; do case "$arg" in h) usage; return "$EXIT_SUCCESS";; - H) if [ -e "/usr/lib/libretools/pvmbootstrap/hook-$OPTARG.sh" ]; then - hooks+=("/usr/lib/libretools/pvmbootstrap/hook-$OPTARG.sh") - elif [ -e "./src/hooks/hook-$OPTARG.sh" ]; then - hooks+=("./src/hooks/hook-$OPTARG.sh") + H) if [ -e "$THIS_DIR/hooks/hook-$OPTARG.sh" ]; then # in-tree + Hooks+=("$THIS_DIR/hooks/hook-$OPTARG.sh") + elif [ -e "/usr/lib/libretools/pvmbootstrap/hook-$OPTARG.sh" ]; then # installed + Hooks+=("/usr/lib/libretools/pvmbootstrap/hook-$OPTARG.sh") elif [ -e "$OPTARG" ]; then Hooks+=("$OPTARG") else