Skip to content

Commit 7bb154d

Browse files
committed
testing: allow installation of multiple distros in one setup run
1 parent c75c08e commit 7bb154d

File tree

2 files changed

+34
-19
lines changed

2 files changed

+34
-19
lines changed

testing/helpers/image.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,14 @@ if [ -d "${CHROOT_MNT}/zfsbootmenu" ]; then
241241
for f in vmlinuz-bootmenu initramfs-bootmenu.img; do
242242
file="${CHROOT_MNT}/zfsbootmenu/build/${f}"
243243
[ -f "${file}" ] || continue
244-
cp "${file}" "${TESTDIR}"
245-
chmod 644 "${TESTDIR}/${f}"
246-
chown "${USERGROUP}" "${TESTDIR}/${f}"
244+
245+
cp "${file}" "${TESTDIR}/${f}.${DISTRO}"
246+
chmod 644 "${TESTDIR}/${f}.${DISTRO}"
247+
chown "${USERGROUP}" "${TESTDIR}/${f}.${DISTRO}"
248+
249+
if [ ! -e "${TESTDIR}/${f}" ] || [ -L "${TESTDIR}/${f}" ]; then
250+
ln -sf "${f}.${DISTRO}" "${TESTDIR}/${f}"
251+
fi
247252
done
248253
fi
249254
fi

testing/setup.sh

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ IMAGE=0
77
CONFD=0
88
DRACUT=0
99
SIZE="5G"
10-
DISTRO="void"
1110
POOL_PREFIX="ztest"
1211

12+
DISTROS=()
13+
1314
# Dictionary for random pool names, provided by words-en
1415
dictfile="/usr/share/dict/words"
1516

@@ -30,7 +31,7 @@ Usage: $0 [options]
3031
-r Use a randomized pool name
3132
-x Use an existing pool image
3233
-k Populate host SSH host and authorized keys
33-
-o Specify another distribution
34+
-o Distribution to install (may specify more than one)
3435
[ void, void-musl, arch, debian, ubuntu ]
3536
EOF
3637
}
@@ -84,7 +85,7 @@ while getopts "heycgdaiD:s:o:lp:rxk" opt; do
8485
SIZE="${OPTARG}"
8586
;;
8687
o)
87-
DISTRO="${OPTARG}"
88+
DISTROS+=( "${OPTARG}" )
8889
;;
8990
l)
9091
LEGACY_POOL=1
@@ -109,9 +110,13 @@ while getopts "heycgdaiD:s:o:lp:rxk" opt; do
109110
esac
110111
done
111112

113+
if [ "${#DISTROS[@]}" -lt 1 ]; then
114+
DISTROS=( "void" )
115+
fi
116+
112117
# Assign a default dest directory if one was not provided
113118
if [ -z "${TESTDIR}" ]; then
114-
TESTDIR="./test.${DISTRO}"
119+
TESTDIR="./test.${DISTROS[0]}"
115120
fi
116121

117122
TESTDIR="$(realpath "${TESTDIR}")" || exit 1
@@ -211,17 +216,22 @@ if ((INCLUDE_KEYS)); then
211216
fi
212217
fi
213218

214-
# Create an image
219+
# Create image(s) for each specified distro
215220
if ((IMAGE)); then
216-
IMAGE_SCRIPT="./helpers/image-${DISTRO}.sh"
217-
if [ ! -x "${IMAGE_SCRIPT}" ]; then
218-
IMAGE_SCRIPT="./helpers/image.sh"
219-
fi
220-
221-
sudo unshare --fork --pid --mount env \
222-
ENCRYPT="${ENCRYPT}" \
223-
LEGACY_POOL="${LEGACY_POOL}" \
224-
EXISTING_POOL="${EXISTING_POOL}" \
225-
PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin" \
226-
"${IMAGE_SCRIPT}" "${TESTDIR}" "${SIZE}" "${DISTRO}" "${POOL_NAME}"
221+
for DISTRO in "${DISTROS[@]}"; do
222+
IMAGE_SCRIPT="./helpers/image-${DISTRO}.sh"
223+
if [ ! -x "${IMAGE_SCRIPT}" ]; then
224+
IMAGE_SCRIPT="./helpers/image.sh"
225+
fi
226+
227+
sudo unshare --fork --pid --mount env \
228+
ENCRYPT="${ENCRYPT}" \
229+
LEGACY_POOL="${LEGACY_POOL}" \
230+
EXISTING_POOL="${EXISTING_POOL}" \
231+
PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin" \
232+
"${IMAGE_SCRIPT}" "${TESTDIR}" "${SIZE}" "${DISTRO}" "${POOL_NAME}"
233+
234+
# All subsequent distros use the same pool
235+
EXISTING_POOL=1
236+
done
227237
fi

0 commit comments

Comments
 (0)