summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Sterling X. Winter <sterling.winter@gmail.com> 2009-05-15 04:14:46 -0500
committerAvatar Bryan Ƙstergaard <kloeri@exherbo.org> 2009-05-15 11:24:51 +0000
commitcfe2d5b607473eae7de2e2f63030a4219dbc9670 (patch)
tree975f8b5c753177bc17fe4aa46b1b4b579cb2e347
parent25118acafed63da89ffec665a0f9e7dd8554a6a2 (diff)
downloadexherbo-cfe2d5b607473eae7de2e2f63030a4219dbc9670.tar.gz
exherbo-cfe2d5b607473eae7de2e2f63030a4219dbc9670.tar.xz
Use full paths when checking for and calling external tools
-rwxr-xr-xscripts/create-kvm-image22
1 files changed, 14 insertions, 8 deletions
diff --git a/scripts/create-kvm-image b/scripts/create-kvm-image
index 2f2454c..5385751 100755
--- a/scripts/create-kvm-image
+++ b/scripts/create-kvm-image
@@ -44,26 +44,26 @@ function die() {
# check that all commands required are installed
function checkprerequisites() {
- [[ ! -x /usr/sbin/parted ]] && die "/usr/sbin/parted missing. Exiting."
- [[ ! -x /usr/bin/kvm-img ]] && die "/usr/bin/kvm-img missing. Exiting."
- [[ ! -x /sbin/kpartx ]] && die "/sbin/kpartx missing. Exiting."
+ for prereq in "${BIN_KPARTX}" "${BIN_KVMIMG}" "${BIN_PARTED}" ; do
+ [[ ! -x "${prereq}" ]] && die "${prereq} is missing. Exiting."
+ done
}
# makeimagefile /path/to/file size
function makeimagefile() {
- kvm-img create -f raw "$1" $2 || die "Failed to create kvm-img."
+ "${BIN_KVMIMG}" create -f raw "$1" $2 || die "Failed to create KVM image."
}
# makepartitiontable /path/to/imagefile
function makepartitiontable() {
- parted "$1" mklabel msdos || die "Failed to create partition table."
+ "${BIN_PARTED}" "$1" mklabel msdos || die "Failed to create partition table."
}
# makepartition /path/to/imagefile parttype fstype begin end
# begin and end defaults to MB
# example: makepartition /tmp/exherbo.img primary ext2 0 512
function makepartition() {
- parted "$1" mkpart $2 $3 $4 $5 || die "Failed to create partition."
+ "${BIN_PARTED}" "$1" mkpart $2 $3 $4 $5 || die "Failed to create partition."
}
# makefilesystem /dev/mapper/loopNn fstype
@@ -200,6 +200,12 @@ if [[ -z "$@" ]]; then
fi
getoptions "$@"
+
+# Full paths to non-basesystem binaries we depend on
+BIN_KPARTX=/sbin/kpartx
+BIN_KVMIMG=/usr/bin/kvm-img
+BIN_PARTED=/usr/sbin/parted
+
checkprerequisites
[[ -z ${KERNELVER} ]] && die "No kernel version specified."
@@ -227,7 +233,7 @@ makepartition "${KVMIMGNAME}" primary linux-swap 512 1024
makepartition "${KVMIMGNAME}" primary ext2 1024MB $((${KVMIMGSECTORS}-1))s
# Create a loopback for the image, set up a device mapping for each partition therein
-PARTITIONS=$(kpartx -av "${KVMIMGNAME}" || die "Failed to create device mappings.")
+PARTITIONS=$("${BIN_KPARTX}" -av "${KVMIMGNAME}" || die "Failed to create device mappings.")
DEVMAP_BOOT=/dev/mapper/$(echo "${PARTITIONS}" | sed "1!d" | cut -d' ' -f3)
DEVMAP_SWAP=/dev/mapper/$(echo "${PARTITIONS}" | sed "2!d" | cut -d' ' -f3)
DEVMAP_ROOT=/dev/mapper/$(echo "${PARTITIONS}" | sed "3!d" | cut -d' ' -f3)
@@ -289,4 +295,4 @@ umount "${KVMROOTFS}"
# Remove device mappings and loopback device
sleep 5
-kpartx -dv "${KVMIMGNAME}" || die "Failed to remove device mappings."
+"${BIN_KPARTX}" -dv "${KVMIMGNAME}" || die "Failed to remove device mappings."