Sync from SUSE:ALP:Source:Standard:1.0 elemental-post-build-generate-rpi-image revision 1dd972e9005afa102873dba2016b3167

This commit is contained in:
Adrian Schröter 2024-04-23 13:24:55 +02:00
parent 2207db5483
commit f1d3a0bcb1
3 changed files with 44 additions and 11 deletions

View File

@ -1,13 +1,35 @@
-------------------------------------------------------------------
Mon Apr 22 17:04:44 UTC 2024 - Klaus Kämpf <kkaempf@suse.com>
- handle non-iso builds gracefully
-------------------------------------------------------------------
Thu Apr 11 11:21:33 UTC 2024 - David Cassany <dcassany@suse.com>
- Adapt to new rootfs.squashfs file path
------------------------------------------------------------------- -------------------------------------------------------------------
Tue Apr 2 09:39:22 UTC 2024 - Klaus Kämpf <kkaempf@suse.com> Tue Apr 2 09:39:22 UTC 2024 - Klaus Kämpf <kkaempf@suse.com>
- install to /usr/lib/build/post_build.d - install to /usr/lib/build/post_build.d
-------------------------------------------------------------------
Thu Mar 28 14:18:04 UTC 2024 - David Cassany <dcassany@suse.com>
- Copying required files only <EFI>/boot path. This prevents
dereferencing multiple links pointing to the same file, otherwise
kernel and initrd are duplicated.
------------------------------------------------------------------- -------------------------------------------------------------------
Thu Mar 28 10:07:17 UTC 2024 - Klaus Kämpf <kkaempf@suse.com> Thu Mar 28 10:07:17 UTC 2024 - Klaus Kämpf <kkaempf@suse.com>
- fix flavor extraction (micro version was added to filename) - fix flavor extraction (micro version was added to filename)
-------------------------------------------------------------------
Fri Mar 22 12:27:26 UTC 2024 - Klaus Kämpf <kkaempf@suse.com>
- follow symlinks when copying boot partition
------------------------------------------------------------------- -------------------------------------------------------------------
Thu Mar 14 13:49:59 UTC 2024 - David Cassany <dcassany@suse.com> Thu Mar 14 13:49:59 UTC 2024 - David Cassany <dcassany@suse.com>

View File

@ -19,13 +19,15 @@ Name: elemental-post-build-generate-rpi-image
Summary: Post build script to generate RPi image from Elemental ISO from a container Summary: Post build script to generate RPi image from Elemental ISO from a container
License: GPL-2.0-or-later License: GPL-2.0-or-later
Group: Development/Tools/Building Group: Development/Tools/Building
Version: 0.3 Version: 0.4
Release: 0 Release: 0
Requires: buildah Requires: buildah
# for truncate # for truncate
Requires: coreutils Requires: coreutils
# for mkfs.vfat # for mkfs.vfat
Requires: dosfstools Requires: dosfstools
# for mkfs.ext
Requires: e2fsprogs
# for sfdisk # for sfdisk
Requires: util-linux Requires: util-linux
# for grub manipulation # for grub manipulation
@ -55,5 +57,6 @@ install -D -m 755 generate-rpi-image.sh $RPM_BUILD_ROOT%{post_build_dir}/50-elem
%dir %{post_build_dir} %dir %{post_build_dir}
%{post_build_dir}/50-elemental-generate-rpi-image %{post_build_dir}/50-elemental-generate-rpi-image
%changelog %changelog

View File

@ -6,19 +6,22 @@ container="buildcont"
set -e set -e
echo "Looking for an ISO image ..."
# Only run the post build check for aarch64 # Only run the post build check for aarch64
[ "$(uname -m)" == "aarch64" ] || exit 0 [ "$(uname -m)" == "aarch64" ] || exit 0
# Build service provides the container image as a .tar file # Build service provides the container image as a .tar file
img=$(ls ${TOPDIR}/DOCKER/*.tar) img=$(ls ${TOPDIR}/DOCKER/*.tar) || true
echo "Found image '" ${img} "'"
[ -f "${img}" ] || exit 1
# Only consider images with 'iso' as part of the name # Only consider images with 'iso' as part of the name
echo "${img}" | grep -q iso || exit 0 echo "${img}" | grep -q iso || exit 0
[ -f "${img}" ] || exit 1
echo "Found image '" ${img} "'"
# import .tar with buildah # import .tar with buildah
buildah from --name "${container}" "docker-archive:${img}" buildah from --name "${container}" "docker-archive:${img}"
@ -57,7 +60,7 @@ mount -o loop "${iso}" iso
# create a mountpoint and mount the rootfs.squashfs that's inside the iso # create a mountpoint and mount the rootfs.squashfs that's inside the iso
mkdir rootfs mkdir rootfs
mount -o loop iso/rootfs.squashfs rootfs mount -o loop iso/boot/arm64/loader/rootfs.squashfs rootfs
# extract the image size from the "build config" # extract the image size from the "build config"
@ -94,9 +97,13 @@ mkfs -t vfat -n RPI_BOOT ${loop}p1
# create a mountpoint and mount the FAT partition # create a mountpoint and mount the FAT partition
mkdir img mkdir img
mount ${loop}p1 img mount ${loop}p1 img
# copy bootloader # copy EFI binaries
cp -a iso/EFI img cp --preserve=mode,ownership --recursive --dereference iso/EFI img
cp -a iso/boot img # copy kernel, initrd and kernel args
mkdir -p img/boot/arm64/loader
cp --preserve=mode,ownership --dereference iso/boot/arm64/loader/initrd img/boot/arm64/loader
cp --preserve=mode,ownership --dereference iso/boot/arm64/loader/linux img/boot/arm64/loader
cp --preserve=mode,ownership --dereference iso/boot/arm64/loader/bootargs.cfg img/boot/arm64/loader
sed -i "s/=ttyS0 /=ttyS0,115200 /g" img/EFI/BOOT/grub.cfg sed -i "s/=ttyS0 /=ttyS0,115200 /g" img/EFI/BOOT/grub.cfg
# and firmware files to the FAT partition # and firmware files to the FAT partition
# 'old' firmware # 'old' firmware
@ -121,7 +128,8 @@ umount img
mkfs -t ext3 -L COS_LIVE ${loop}p2 mkfs -t ext3 -L COS_LIVE ${loop}p2
mount ${loop}p2 img mount ${loop}p2 img
# copy the rootfs into this partition # copy the rootfs into this partition
cp iso/rootfs.squashfs img mkdir -p img/boot/arm64/loader
cp --preserve=mode,ownership --dereference iso/boot/arm64/loader/rootfs.squashfs img/boot/arm64/loader
# Install hook to copy rpi firmware in EFI partition # Install hook to copy rpi firmware in EFI partition
mkdir -p img/iso-config mkdir -p img/iso-config