Backport ubuntu-image 3.x support into jammy.

intel-iot-tests
Łukasz 'sil2100' Zemczak 6 months ago
parent c668946c66
commit 0eae42c67a

1
debian/control vendored

@ -40,7 +40,6 @@ Depends: ${misc:Depends},
squashfs-tools (>= 1:3.3-1), squashfs-tools (>= 1:3.3-1),
sudo, sudo,
u-boot-tools [armhf arm64], u-boot-tools [armhf arm64],
ubuntu-image [!i386 !riscv64],
python3-vmdkstream [amd64 i386], python3-vmdkstream [amd64 i386],
xz-utils, xz-utils,
zerofree zerofree

@ -87,11 +87,16 @@ fi
PREFIX="livecd.$PROJECT${SUBARCH:+-$SUBARCH}" PREFIX="livecd.$PROJECT${SUBARCH:+-$SUBARCH}"
if [ "${IMAGEFORMAT:-}" = "ubuntu-image" ]; then if [ "${IMAGEFORMAT:-}" = "ubuntu-image" ]; then
# Use ubuntu-image instead of live-build # Use ubuntu-image instead (or as part) of live-build
export SNAPPY_STORE_NO_CDN=1
LB_UBUNTU_IMAGE_CHANNEL="${LB_UBUNTU_IMAGE_CHANNEL:-stable}"
snap install \
--classic --channel="$LB_UBUNTU_IMAGE_CHANNEL" ubuntu-image
if [ "$PROJECT" = "ubuntu-core" ]; then if [ "$PROJECT" = "ubuntu-core" ]; then
env SNAPPY_STORE_NO_CDN=1 \ # Ubuntu Core images
ubuntu-image snap $UBUNTU_IMAGE_ARGS \ /snap/bin/ubuntu-image snap $UBUNTU_IMAGE_ARGS \
-O output "$PREFIX".model-assertion -O output "$PREFIX".model-assertion
# XXX: currently we only have one image generated, but really # XXX: currently we only have one image generated, but really
# we should be supporting more than one for models that # we should be supporting more than one for models that
@ -99,24 +104,32 @@ if [ "${IMAGEFORMAT:-}" = "ubuntu-image" ]; then
mv output/*.img "$PREFIX".img mv output/*.img "$PREFIX".img
xz -0 -T4 "$PREFIX".img xz -0 -T4 "$PREFIX".img
mv output/seed.manifest "$PREFIX".manifest mv output/seed.manifest "$PREFIX".manifest
# All the builds are finished now, exit
exit 0
else else
# First we need to build the gadget tree # Ubuntu classic preinstalled images
make -C "config/$PREFIX-gadget" \ /snap/bin/ubuntu-image classic --verbose $UBUNTU_IMAGE_ARGS \
ARCH=$ARCH SERIES=$SUITE $GADGET_TARGET -O output "$IMAGE_DEFINITION"
ubuntu-image classic $UBUNTU_IMAGE_ARGS \ # Since the output of the ubuntu-image call can vary based on what
-s $SUITE -p $PROJECT -a $ARCH --subarch $SUBARCH \ # kind of an image we build, the safest bet is to 'export' all the
-O output config/$PREFIX-gadget/install # artifacts from the output directory. The image definition file
# XXX: currently we only have one image generated, but really # should be what defines what is expected, so that we don't have
# we should be supporting more than one for models that # to tweak livecd-rootfs everytime a different type of artifact
# define those. # is needed.
mv output/*.img "$PREFIX".img for artifact in output/*; do
xz -0 -T4 "$PREFIX".img # We want to be dynamic, and want to support even
# Also link the output image to a filename that cdimage expects # two-part extensions.
ln "$PREFIX".img.xz livecd.ubuntu-cpc.disk1.img.xz filename=$(basename $artifact)
mv output/filesystem.manifest "$PREFIX".manifest noversion=$(echo $filename | sed 's/[0-9][0-9]\.[0-9][0-9]//')
extension=${noversion#*.}
mv $artifact "$PREFIX".$extension
done
[ -f $PREFIX.img ] && xz -0 -T4 "$PREFIX".img
# All the builds are finished now, exit
exit 0
fi fi
exit 0
fi fi
# Setup cleanup function # Setup cleanup function

@ -493,38 +493,22 @@ case $IMAGEFORMAT in
else else
# classic images # classic images
# Certain models have different names but are built from the same source gadget tree # Sometimes per-project quirks are necessary
BRANCH="classic" IMAGE_PROJECT=$PROJECT
case $MODEL in case "$IMAGE_PROJECT" in
pi|pi-arm64|pi3-arm64) ubuntu-cpc)
MODEL=pi IMAGE_PROJECT="ubuntu-server"
BRANCH="classic-22.04"
;;
intel-iot)
MODEL=pc
;; ;;
esac esac
GADGET_TARGET="server" LB_UBUNTU_IMAGES_REPO="${LB_UBUNTU_IMAGES_REPO:-git://git.launchpad.net/ubuntu-images}"
if [ "$SUBPROJECT" = "desktop-preinstalled" ]; then LB_UBUNTU_IMAGES_BRANCH="${LB_UBUNTU_IMAGES_BRANCH:-$SUITE}"
GADGET_TARGET="desktop" git clone "$LB_UBUNTU_IMAGES_REPO" -b "$LB_UBUNTU_IMAGES_BRANCH" image-definitions
fi IMAGE_DEFINITION="image-definitions/$IMAGE_PROJECT-$MODEL.yaml"
echo "IMAGE_DEFINITION=$IMAGE_DEFINITION" >> config/common
UBUNTU_IMAGE_ARGS="$UBUNTU_IMAGE_ARGS${SUBPROJECT:+ --subproject \"$SUBPROJECT\"}" echo "Configured ubuntu-image to use image definition file $IMAGE_DEFINITION which has the following contents:"
UBUNTU_IMAGE_ARGS="$UBUNTU_IMAGE_ARGS${PROPOSED:+ --with-proposed}" cat "$IMAGE_DEFINITION"
UBUNTU_IMAGE_ARGS="$UBUNTU_IMAGE_ARGS${EXTRA_PPAS:+ --extra-ppas \"$EXTRA_PPAS\"}" echo "----------------------------------------------------------"
# We need to look in two places for the gadget tree:
# - Launchpad hosted gadgets will be in the snap-gadget repo
# - Github hosted gadgets are mirrored into a github-mirror repo
git clone git://git.launchpad.net/~canonical-foundations/snap-$MODEL/+git/snap-$MODEL -b $BRANCH config/$PREFIX-gadget || git clone git://git.launchpad.net/~canonical-foundations/snap-$MODEL/+git/github-mirror -b $BRANCH config/$PREFIX-gadget || git clone git://git.launchpad.net/~canonical-foundations/snap-$MODEL/+git/github-mirror-$ARCH -b $BRANCH config/$PREFIX-gadget
echo "IMAGEFORMAT=$IMAGEFORMAT" >> config/common
echo "SUITE=$SUITE" >> config/common
echo "GADGET_TARGET=$GADGET_TARGET" >> config/common
echo "UBUNTU_IMAGE_ARGS=\"$UBUNTU_IMAGE_ARGS\"" >> config/common
echo "Configured ubuntu-image for the following gadget model: $MODEL"
fi fi
# Save the model name used for building, mostly for any model-specific hook execution # Save the model name used for building, mostly for any model-specific hook execution

Loading…
Cancel
Save