Merge "Refactor: remove unused functions"
This commit is contained in:
commit
59bb62d1ee
@ -124,57 +124,6 @@ function eval_run_d () {
|
|||||||
trap - ERR
|
trap - ERR
|
||||||
}
|
}
|
||||||
|
|
||||||
# Usage: map_nbd $image
|
|
||||||
# Returns nbd device path
|
|
||||||
function map_nbd {
|
|
||||||
(lsmod | grep '^nbd ' >/dev/null) || sudo modprobe nbd max_part=16
|
|
||||||
|
|
||||||
if [[ $(qemu-nbd --help | grep cache) == *writeback* ]] ; then
|
|
||||||
CACHE="--cache=writeback"
|
|
||||||
else
|
|
||||||
echo "Warning: qemu-nbd without --cache=writeback is /slow/."
|
|
||||||
CACHE=""
|
|
||||||
fi
|
|
||||||
NBD_DEV=
|
|
||||||
for i in `seq 0 15`; do
|
|
||||||
if [ ! -e /sys/block/nbd$i/pid ]; then
|
|
||||||
NBD_DEV=/dev/nbd$i
|
|
||||||
# Connect to nbd and wait till it is ready
|
|
||||||
sudo qemu-nbd -c $NBD_DEV $CACHE $1
|
|
||||||
if ! timeout 60 sh -c "while ! [ -e /sys/block/nbd$i/pid ]; do sleep 1; done"; then
|
|
||||||
echo "Couldn't connect $NBD_DEV"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if [ -z "$NBD_DEV" ]; then
|
|
||||||
echo "No free NBD slots"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Delete and unmount the working dir used in extracting kernel/initrd
|
|
||||||
function unmount_qcow_image () {
|
|
||||||
sudo umount $WORK_DIR || true
|
|
||||||
sudo qemu-nbd -d $NBD_DEV >/dev/null || true
|
|
||||||
sudo rm -rf $WORK_DIR
|
|
||||||
|
|
||||||
trap - SIGHUP SIGINT SIGTERM EXIT
|
|
||||||
}
|
|
||||||
|
|
||||||
function mount_qcow_image() {
|
|
||||||
trap unmount_qcow_image SIGHUP SIGINT SIGTERM EXIT
|
|
||||||
|
|
||||||
WORK_DIR=$(mktemp -d)
|
|
||||||
map_nbd $1
|
|
||||||
if [ -e "${NBD_DEV}p1" ]; then
|
|
||||||
sudo mount ${NBD_DEV}p1 $WORK_DIR
|
|
||||||
else
|
|
||||||
sudo mount ${NBD_DEV} $WORK_DIR
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function cleanup_build_dir () {
|
function cleanup_build_dir () {
|
||||||
if ! timeout 5 sh -c " while ! sudo rm -rf $TMP_BUILD_DIR/built; do sleep 1; done"; then
|
if ! timeout 5 sh -c " while ! sudo rm -rf $TMP_BUILD_DIR/built; do sleep 1; done"; then
|
||||||
echo "ERROR: unable to cleanly remove $TMP_BUILD_DIR/built"
|
echo "ERROR: unable to cleanly remove $TMP_BUILD_DIR/built"
|
||||||
|
@ -52,21 +52,6 @@ function cleanup () {
|
|||||||
cleanup_image_dir
|
cleanup_image_dir
|
||||||
}
|
}
|
||||||
|
|
||||||
function ensure_nbd () {
|
|
||||||
NBD=`which qemu-nbd` || true
|
|
||||||
if [ -z "$NBD" ]; then
|
|
||||||
echo "qemu-nbd is not found in your PATH"
|
|
||||||
echo "Please install it on your system"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
# prep nbd for mounting
|
|
||||||
(lsmod | grep '^nbd ' >/dev/null) || sudo modprobe nbd max_part=16
|
|
||||||
}
|
|
||||||
|
|
||||||
function ensure_sudo () {
|
|
||||||
sudo echo "Ensuring sudo is available"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Helper function to run a command inside the chroot
|
# Helper function to run a command inside the chroot
|
||||||
function run_in_target () {
|
function run_in_target () {
|
||||||
cmd="$@"
|
cmd="$@"
|
||||||
|
Loading…
Reference in New Issue
Block a user