add a couple of super hacky scripts for quickly testing subiquity changes

The first of these scripts mashes the current branch's code over that of
a pre-existing subiquity snap.

The second uses the first to mash the current branch's code over the
subiquity snap from an ISO and then creates a new ISO with this new
snap.

It's all a bit terrifying but being able to get your changes into a
bootable ISO in about 30s is quite a large improvement on building the
snap from scratch.
This commit is contained in:
Michael Hudson-Doyle 2021-03-09 17:31:21 +13:00
parent 3427ccf579
commit d645ca1642
2 changed files with 107 additions and 0 deletions

View File

@ -0,0 +1,47 @@
#!/bin/bash
set -eux
src="$(dirname "$(dirname "$(readlink -f "${0}")")")"
old_iso="$(readlink -f "${1}")"
new_iso="$(readlink -f "${2}")"
tmpdir="$(mktemp -d)"
cd "${tmpdir}"
_MOUNTS=()
do_mount_existing () {
local mountpoint="${!#}"
mount "$@"
_MOUNTS=("${mountpoint}" "${_MOUNTS[@]+"${_MOUNTS[@]}"}")
}
do_mount () {
local mountpoint="${!#}"
mkdir "${mountpoint}"
do_mount_existing "$@"
}
clean_mounts () {
for m in "${_MOUNTS[@]+"${_MOUNTS[@]}"}"; do
umount "${m}"
done
_MOUNTS=()
}
cleanup () {
clean_mounts
rm -rf "${tmpdir}"
}
trap cleanup EXIT
do_mount $old_iso old_iso
do_mount old_iso/casper/installer.squashfs installer
$src/scripts/slimy-update-snap.sh installer/var/lib/snapd/seed/snaps/subiquity_*.snap subiquity_new.snap
clean_mounts
$src/scripts/inject-subiquity-snap.sh $old_iso subiquity_new.snap $new_iso

60
scripts/slimy-update-snap.sh Executable file
View File

@ -0,0 +1,60 @@
#!/bin/bash
# slimy-update-snap.sh $old_snap $new_snap
set -eux
src="$(dirname "$(dirname "$(readlink -f "${0}")")")"
old="$(readlink -f "${1}")"
new="$(readlink -f "${2}")"
tmpdir="$(mktemp -d)"
cd "${tmpdir}"
_MOUNTS=()
do_mount_existing () {
local mountpoint="${!#}"
mount "$@"
_MOUNTS=("${mountpoint}" "${_MOUNTS[@]+"${_MOUNTS[@]}"}")
}
do_mount () {
local mountpoint="${!#}"
mkdir "${mountpoint}"
do_mount_existing "$@"
}
add_overlay() {
local lower="$1"
local mountpoint="$2"
local work="$(mktemp -dp "${tmpdir}")"
if [ -n "${3-}" ]; then
local upper="${3}"
else
local upper="$(mktemp -dp "${tmpdir}")"
fi
chmod go+rx "${work}" "${upper}"
do_mount -t overlay overlay -o lowerdir="${lower}",upperdir="${upper}",workdir="${work}" "${mountpoint}"
}
cleanup () {
for m in "${_MOUNTS[@]+"${_MOUNTS[@]}"}"; do
umount "${m}"
done
rm -rf "${tmpdir}"
}
trap cleanup EXIT
do_mount $old old
add_overlay old new
rm -rf new/lib/python3.6/site-packages/subiquity
rm -rf new/lib/python3.6/site-packages/subiquitycore
git -C $src archive HEAD subiquity subiquitycore | tar -C new/lib/python3.6/site-packages/ -x
mksquashfs new $new -comp gzip -Xcompression-level 3