36b59c001c
There is a wide variety of tracing options through the various shell scripts. Some use "set -eux", others explicity set xtrace and others do nothing. There is a "-x" option to bin/disk-image-create but it doesn't flow down to the many scripts it calls. This adds a global integer variable set by disk-image-create DIB_DEBUG_TRACE. All scripts have a stanza added to detect this and turn on tracing. Any other tracing methods are rolled into this. So the standard header is --- if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then set -x fi set -eu set -o pipefail --- Multiple -x options can be specified to dib-create-image, which increases the value of DIB_DEBUG_TRACE. If script authors feel their script should only trace at higher levels, they should modify the "-gt" value. If they feel it should trace by default, they can modify the default value also. Changes to pachset 16 : scripts which currently trace themselves by default have retained this behaviour with DIB_DEBUG_TRACE defaulting to "1". This was done by running [1] on patch set 15. See the thread beginning at [2] dib-lint is also updated to look for the variable being matched. [1] https://gist.github.com/ianw/71bbda9e6acc74ccd0fd [2] http://lists.openstack.org/pipermail/openstack-dev/2014-November/051575.html Change-Id: I6c5a962260741dcf6f89da9a33b96372a719b7b0
64 lines
1.4 KiB
Bash
Executable file
64 lines
1.4 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
if [ ${DIB_DEBUG_TRACE:-1} -gt 0 ]; then
|
|
set -x
|
|
fi
|
|
set -eu
|
|
set -o pipefail
|
|
|
|
function clean_up_arch_emulation {
|
|
cat <<EOF >$TMP_MOUNT_PATH/tmp/clean_up_qemu_binary
|
|
#!/bin/bash
|
|
|
|
set -eux
|
|
set -o pipefail
|
|
|
|
sudo rm -rf "${TMP_MOUNT_PATH}${1}"
|
|
EOF
|
|
|
|
sudo chmod +x "$TMP_MOUNT_PATH/tmp/clean_up_qemu_binary"
|
|
}
|
|
|
|
function check_copy_file {
|
|
if [ -f "$1" ] ; then
|
|
if [ ! -f "${TMP_MOUNT_PATH}${1}" ]; then
|
|
sudo cp "$1" "$TMP_MOUNT_PATH/usr/bin"
|
|
clean_up_arch_emulation $1
|
|
fi
|
|
else
|
|
echo "qemu binary file not found."
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
function copy_binary {
|
|
echo "checking for architecture compatibility..."
|
|
img_arch=$2
|
|
if [[ "$host_arch" != "$img_arch" ]]; then
|
|
qemu_binary=$1
|
|
check_copy_file $qemu_binary
|
|
else
|
|
echo "Emulation not required for this host/image architecture combination"
|
|
fi
|
|
}
|
|
|
|
host_arch="$(uname -m)"
|
|
|
|
case "$ARCH" in
|
|
"i386" | "amd64")
|
|
qemu_binary_file="/usr/bin/qemu-i386-static"
|
|
copy_binary $qemu_binary_file $ARCH
|
|
;;
|
|
"armhf")
|
|
qemu_binary_file="/usr/bin/qemu-arm-static"
|
|
copy_binary $qemu_binary_file $ARCH
|
|
;;
|
|
"arm64")
|
|
qemu_binary_file="/usr/bin/qemu-aarch64-static"
|
|
copy_binary $qemu_binary_file $ARCH
|
|
;;
|
|
*)
|
|
echo "architecture not supported"
|
|
exit 1
|
|
;;
|
|
esac
|