summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbill-auger <mr.j.spam.me@gmail.com>2020-03-31 12:13:42 -0400
committerbill-auger <mr.j.spam.me@gmail.com>2020-03-31 19:04:24 -0400
commit03a480a8947edd34830f77a9ba51140673104089 (patch)
treedf79659e162cbdd792264a373e6aeda53a423db9
parent29567e455db8e6b2b233af931125392a5a9b581d (diff)
housekeepingv20200331
-rw-r--r--src/pvm-common.sh.inc29
-rwxr-xr-xsrc/pvm2tarball.sh4
-rwxr-xr-xsrc/pvmboot.sh4
-rwxr-xr-xsrc/pvmbootstrap.sh28
4 files changed, 47 insertions, 18 deletions
diff --git a/src/pvm-common.sh.inc b/src/pvm-common.sh.inc
index aaf932e..6da7685 100644
--- a/src/pvm-common.sh.inc
+++ b/src/pvm-common.sh.inc
@@ -1,3 +1,25 @@
+#!/bin/bash
+###############################################################################
+# parabola-vmbootstrap -- create and start parabola virtual machines #
+# #
+# Copyright (C) 2017 - 2019 Andreas Grapentin #
+# Copyright (C) 2019 - 2020 bill-auger #
+# #
+# This program is free software: you can redistribute it and/or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation, either version 3 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+###############################################################################
+
+
# readonly DATA_IMG=./pvmdata.img # optional large qemu disk
readonly THIS_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
readonly UNPRIVILEGED_ERR_MSG="This program must be run as a regular user"
@@ -15,8 +37,8 @@ pvm_get_script() # (script_name)
local intree_script=$THIS_DIR/$script_name.sh
local installed_script=$script_name
- [[ -f "$intree_script" ]] && echo "$intree_script" && return "$EXIT_SUCCESS"
- type -p $installed_script &>/dev/null && echo "$installed_script" && return "$EXIT_SUCCESS"
+ [[ -f "$intree_script" ]] && echo "$intree_script" && return "$EXIT_SUCCESS"
+ type -p $installed_script &>/dev/null && echo "$installed_script" && return "$EXIT_SUCCESS"
error "can not find $script_name" && return "$EXIT_FAILURE"
}
@@ -197,7 +219,8 @@ pvm_cleanup() # unsets: $loopdev , untraps: INT TERM EXIT
trap - INT TERM EXIT
pvm_umount
- sudo losetup -d "$loopdev"
+
+ sudo losetup -d "$loopdev" &> /dev/null
pvm_check_no_mounts || return "$EXIT_FAILURE"
unset loopdev
diff --git a/src/pvm2tarball.sh b/src/pvm2tarball.sh
index dfb3113..f3612f1 100755
--- a/src/pvm2tarball.sh
+++ b/src/pvm2tarball.sh
@@ -100,8 +100,8 @@ EOF
}
-if source /usr/lib/parabola-vmbootstrap/pvm-common.sh.inc 2> /dev/null || \
- source "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"/pvm-common.sh.inc 2> /dev/null
+if source "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"/pvm-common.sh.inc 2> /dev/null || \
+ source /usr/lib/parabola-vmbootstrap/pvm-common.sh.inc 2> /dev/null
then main "$@"
else echo "can not find pvm-common.sh.inc" && exit 1
fi
diff --git a/src/pvmboot.sh b/src/pvmboot.sh
index a403910..d37554a 100755
--- a/src/pvmboot.sh
+++ b/src/pvmboot.sh
@@ -175,8 +175,8 @@ main() # ( [cli_options] imagefile qemu_args )
}
-if source /usr/lib/parabola-vmbootstrap/pvm-common.sh.inc 2> /dev/null || \
- source "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"/pvm-common.sh.inc 2> /dev/null
+if source "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"/pvm-common.sh.inc 2> /dev/null || \
+ source /usr/lib/parabola-vmbootstrap/pvm-common.sh.inc 2> /dev/null
then main "$@"
else echo "can not find pvm-common.sh.inc" && exit 1
fi
diff --git a/src/pvmbootstrap.sh b/src/pvmbootstrap.sh
index f269156..9ead4f9 100755
--- a/src/pvmbootstrap.sh
+++ b/src/pvmbootstrap.sh
@@ -75,16 +75,17 @@ usage()
echo
echo "Supported options:"
echo " -b <base-set> Select one of the pre-defined package-sets described below"
- echo " (default: 'standard')"
+ echo " (default: '$PKG_SET_STD')"
echo " -h Display this help and exit"
echo " -H <hook> Enable a hook to customize the created image. This can be"
echo " the path to a script, which will be executed once within"
echo " the running VM, or one of the pre-defined hooks described"
echo " below. This option can be specified multiple times."
- echo " -k <kernel> Specify an additional kernel package (default: $DEF_KERNEL)."
+ echo " -k <kernel> Specify a kernel package (default: ''). "
echo " This option can be specified multiple times; but note that"
echo " '$DEF_KERNEL' will be installed as part of the '$PKG_SET_STD' and"
- echo " '$PKG_SET_DEV' package sets, regardless of this option."
+ echo " '$PKG_SET_DEV' package sets, regardless of this option,"
+ echo " and no kernel is installed as part of the '$PKG_SET_MIN' package set."
echo " -M <mirror> Specify a different mirror from which to fetch packages"
echo " (default: $DEF_MIRROR)"
echo " -O Bootstrap an openrc system instead of a systemd one"
@@ -120,14 +121,14 @@ pvm_bootstrap() # assumes: $arch $imagefile $loopdev $workdir , traps: INT TERM
mkdir -p "$(dirname "$imagefile")" || return "$EXIT_FAILURE"
pvm_prompt_clobber_file "$imagefile" || return "$EXIT_FAILURE"
- msg "starting build for %s image: %s" "$arch" "$imagefile"
+ # prepare for cleanup
+ trap 'pvm_bootstrap_cleanup' INT TERM RETURN
- # create the raw image file
local img_mb=$(( $BootSizeMb + $SwapSizeMb + $RootSizeMb ))
- qemu-img create -f raw "$imagefile" "${img_mb}M" || return "$EXIT_FAILURE"
+ msg "starting build for %s image: %s (%sMB)" "$arch" "$imagefile" "$img_mb"
- # prepare for cleanup
- trap 'pvm_bootstrap_cleanup' INT TERM RETURN
+ # create the raw image file
+ qemu-img create -f raw "$imagefile" "${img_mb}M" || return "$EXIT_FAILURE"
# mount the virtual disk
local bootdir workdir loopdev
@@ -468,7 +469,12 @@ main() # ( [cli_options] imagefile arch )
# create the virtual machine
if pvm_bootstrap; then
- if pvm_bootstrap_preinit; then
+ if ! (( ${#Kernels[@]} )) ; then
+ msg "bootstrap complete for image: %s" "$imagefile"
+ warning "the preinit procedure was not run because no kernel was installed and no initcpio exists"
+ warning "the preinit procedure will run when the image is booted for the first time"
+ exit "$EXIT_SUCCESS"
+ elif pvm_bootstrap_preinit; then
msg "bootstrap complete for image: %s" "$imagefile"
exit "$EXIT_SUCCESS"
else
@@ -482,8 +488,8 @@ main() # ( [cli_options] imagefile arch )
}
-if source /usr/lib/parabola-vmbootstrap/pvm-common.sh.inc 2> /dev/null || \
- source "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"/pvm-common.sh.inc 2> /dev/null
+if source "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"/pvm-common.sh.inc 2> /dev/null || \
+ source /usr/lib/parabola-vmbootstrap/pvm-common.sh.inc 2> /dev/null
then main "$@"
else echo "can not find pvm-common.sh.inc" && exit 1
fi