Sync from SUSE:ALP:Source:Standard:1.0 elemental-post-build-generate-rpi-image revision 712c20e573d8828fb06f7518c75a52ee
This commit is contained in:
commit
2207db5483
23
.gitattributes
vendored
Normal file
23
.gitattributes
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
## Default LFS
|
||||||
|
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.bsp filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.gem filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.jar filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.lz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.lzma filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.obscpio filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.oxt filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pdf filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.png filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.rpm filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tbz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tbz2 filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.ttf filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.txz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.whl filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.zst filter=lfs diff=lfs merge=lfs -text
|
91
elemental-post-build-generate-rpi-image.changes
Normal file
91
elemental-post-build-generate-rpi-image.changes
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Tue Apr 2 09:39:22 UTC 2024 - Klaus Kämpf <kkaempf@suse.com>
|
||||||
|
|
||||||
|
- install to /usr/lib/build/post_build.d
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Thu Mar 28 10:07:17 UTC 2024 - Klaus Kämpf <kkaempf@suse.com>
|
||||||
|
|
||||||
|
- fix flavor extraction (micro version was added to filename)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Thu Mar 14 13:49:59 UTC 2024 - David Cassany <dcassany@suse.com>
|
||||||
|
|
||||||
|
- Fix generator script: Do not patch partition label setup from
|
||||||
|
grub.cfg.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Thu Jan 4 14:18:23 UTC 2024 - Klaus Kämpf <kkaempf@suse.com>
|
||||||
|
|
||||||
|
- fix grub2 root partition (rancher/elemental#1151)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Wed Jan 3 14:21:11 UTC 2024 - Klaus Kämpf <kkaempf@suse.com>
|
||||||
|
|
||||||
|
- switch ttyS0 baudrate to 115200 (standard for Raspberry Pi)
|
||||||
|
(rancher/elemental#1139)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Wed Dec 27 15:32:01 UTC 2023 - Klaus Kämpf <kkaempf@suse.com>
|
||||||
|
|
||||||
|
- iso name changed, adapt flavor extraction
|
||||||
|
|
||||||
|
- handle empty flavor
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Thu Sep 21 15:22:16 UTC 2023 - Klaus Kämpf <kkaempf@suse.com>
|
||||||
|
|
||||||
|
- fix copying of 'systemready' firmware
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Wed Sep 20 09:46:16 UTC 2023 - Klaus Kämpf <kkaempf@suse.com>
|
||||||
|
|
||||||
|
- move from parted to sfdisk (from util-linux)
|
||||||
|
- fix loop device setup
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Mon Apr 24 13:46:16 UTC 2023 - David Cassany <dcassany@suse.com>
|
||||||
|
|
||||||
|
- Adapt generation script to rancher/elemental-cli#404 so it makes
|
||||||
|
use of the proper paths in after-install hooks.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Tue Dec 27 10:58:02 UTC 2022 - Klaus Kämpf <kkaempf@suse.com>
|
||||||
|
|
||||||
|
- create checksum with .raw file.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Wed Dec 7 13:00:30 UTC 2022 - Klaus Kämpf <kkaempf@suse.com>
|
||||||
|
|
||||||
|
- add last project name element to image name.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Wed Dec 7 12:13:00 UTC 2022 - Klaus Kämpf <kkaempf@suse.com>
|
||||||
|
|
||||||
|
- create a timestamped image name.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Thu Dec 1 10:41:52 UTC 2022 - Klaus Kämpf <kkaempf@suse.com>
|
||||||
|
|
||||||
|
- label the boot partition as RPI_BOOT.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Tue Nov 29 11:05:20 UTC 2022 - Klaus Kämpf <kkaempf@suse.com>
|
||||||
|
|
||||||
|
- faking an .iso extension was a bad idea, breaks build service
|
||||||
|
trying to sign the image.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Mon Nov 28 15:27:36 UTC 2022 - Klaus Kämpf <kkaempf@suse.com>
|
||||||
|
|
||||||
|
- get image size from ~/.rpmmacros (Macros: in project config)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Mon Nov 28 10:56:13 UTC 2022 - Klaus Kämpf <kkaempf@suse.com>
|
||||||
|
|
||||||
|
- make it downloadable (by faking an .iso extension)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Sat Nov 26 12:17:56 UTC 2022 - Klaus Kämpf <kkaempf@suse.com>
|
||||||
|
|
||||||
|
- Initial version 0.1
|
59
elemental-post-build-generate-rpi-image.spec
Normal file
59
elemental-post-build-generate-rpi-image.spec
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
#
|
||||||
|
# spec file for package elemental-post-build-generate-rpi-image
|
||||||
|
#
|
||||||
|
# Copyright (c) 2022 SUSE LLC
|
||||||
|
#
|
||||||
|
# All modifications and additions to the file contributed by third parties
|
||||||
|
# remain the property of their copyright owners, unless otherwise agreed
|
||||||
|
# upon. The license for this file, and modifications and additions to the
|
||||||
|
# file, is the same license as for the pristine package itself (unless the
|
||||||
|
# license for the pristine package is not an Open Source License, in which
|
||||||
|
# case the license is the MIT License). An "Open Source License" is a
|
||||||
|
# license that conforms to the Open Source Definition (Version 1.9)
|
||||||
|
# published by the Open Source Initiative.
|
||||||
|
|
||||||
|
# Please submit bugfixes or comments via https://bugs.opensuse.org/
|
||||||
|
#
|
||||||
|
|
||||||
|
Name: elemental-post-build-generate-rpi-image
|
||||||
|
Summary: Post build script to generate RPi image from Elemental ISO from a container
|
||||||
|
License: GPL-2.0-or-later
|
||||||
|
Group: Development/Tools/Building
|
||||||
|
Version: 0.3
|
||||||
|
Release: 0
|
||||||
|
Requires: buildah
|
||||||
|
# for truncate
|
||||||
|
Requires: coreutils
|
||||||
|
# for mkfs.vfat
|
||||||
|
Requires: dosfstools
|
||||||
|
# for sfdisk
|
||||||
|
Requires: util-linux
|
||||||
|
# for grub manipulation
|
||||||
|
Requires: sed
|
||||||
|
|
||||||
|
%define post_build_dir /usr/lib/build/post_build.d
|
||||||
|
|
||||||
|
Source0: generate-rpi-image.sh
|
||||||
|
BuildArch: noarch
|
||||||
|
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||||
|
|
||||||
|
%description
|
||||||
|
An OBS post build hook that generates a RPi boot image from the Elemental ISO from a container.
|
||||||
|
The image is expected to be found at "/image/*.img".
|
||||||
|
|
||||||
|
%prep
|
||||||
|
cp %{S:0} .
|
||||||
|
|
||||||
|
%build
|
||||||
|
|
||||||
|
%install
|
||||||
|
install -D -m 755 generate-rpi-image.sh $RPM_BUILD_ROOT%{post_build_dir}/50-elemental-generate-rpi-image
|
||||||
|
|
||||||
|
%files
|
||||||
|
%defattr(-, root, root)
|
||||||
|
%dir /usr/lib/build
|
||||||
|
%dir %{post_build_dir}
|
||||||
|
%{post_build_dir}/50-elemental-generate-rpi-image
|
||||||
|
|
||||||
|
%changelog
|
||||||
|
|
182
generate-rpi-image.sh
Normal file
182
generate-rpi-image.sh
Normal file
@ -0,0 +1,182 @@
|
|||||||
|
#!/bin/bash -x
|
||||||
|
|
||||||
|
: ${TOPDIR:=/usr/src/packages}
|
||||||
|
|
||||||
|
container="buildcont"
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Only run the post build check for aarch64
|
||||||
|
[ "$(uname -m)" == "aarch64" ] || exit 0
|
||||||
|
|
||||||
|
# Build service provides the container image as a .tar file
|
||||||
|
|
||||||
|
img=$(ls ${TOPDIR}/DOCKER/*.tar)
|
||||||
|
|
||||||
|
echo "Found image '" ${img} "'"
|
||||||
|
|
||||||
|
[ -f "${img}" ] || exit 1
|
||||||
|
# Only consider images with 'iso' as part of the name
|
||||||
|
echo "${img}" | grep -q iso || exit 0
|
||||||
|
|
||||||
|
# import .tar with buildah
|
||||||
|
|
||||||
|
buildah from --name "${container}" "docker-archive:${img}"
|
||||||
|
|
||||||
|
# mount container to access its content
|
||||||
|
|
||||||
|
mnt=$(buildah mount "${container}")
|
||||||
|
|
||||||
|
# there must be an .iso file within
|
||||||
|
|
||||||
|
iso=$(ls "${mnt}"/elemental-iso/*.iso)
|
||||||
|
|
||||||
|
echo "Found ISO '" ${iso} "'"
|
||||||
|
|
||||||
|
# exit here if not
|
||||||
|
|
||||||
|
[ -f "${iso}" ] || exit 1
|
||||||
|
|
||||||
|
# something like sl-micro-6.0-base.aarch64-2.2.0-Build14.2
|
||||||
|
basename=$(basename ${iso} .iso)
|
||||||
|
# split at '.' into DOTS[]
|
||||||
|
IFS='.' read -ra DOTS <<< "${basename}"
|
||||||
|
# split "0-base" at '-' into DASHES[]
|
||||||
|
IFS='-' read -ra DASHES <<< "${DOTS[1]}"
|
||||||
|
# extract the flavor (base, rt, kvm, ...)
|
||||||
|
flavor="${DASHES[1]}"
|
||||||
|
# prepend dash if flavor is non-empty
|
||||||
|
# covers rpi.raw (for empty flavor) vs rpi-${flavor}.raw (for non-empty)
|
||||||
|
[ -n "$flavor" ] && flavor="-${flavor}"
|
||||||
|
|
||||||
|
mkdir -p "${TOPDIR}/OTHER/image"
|
||||||
|
|
||||||
|
# create a mountpoint and mount the iso
|
||||||
|
mkdir iso
|
||||||
|
mount -o loop "${iso}" iso
|
||||||
|
|
||||||
|
# create a mountpoint and mount the rootfs.squashfs that's inside the iso
|
||||||
|
mkdir rootfs
|
||||||
|
mount -o loop iso/rootfs.squashfs rootfs
|
||||||
|
|
||||||
|
# extract the image size from the "build config"
|
||||||
|
|
||||||
|
img_size=$(grep -m 1 "%img_size" ~/.rpmmacros | tr -d "\n" | cut -d " " -f 2)
|
||||||
|
|
||||||
|
# extract two last project path elements ({Stable,Staging,Dev}:TealXX)
|
||||||
|
# replace colon with dash
|
||||||
|
project=$(grep -m 1 "%_project" ~/.rpmmacros | tr -d "\n" | rev | cut -d ":" -f 1,2 | rev | tr ":" "-")
|
||||||
|
|
||||||
|
# create an empty image file and a respective loop device
|
||||||
|
truncate -s $((${img_size}*1024*1024)) rpi.img
|
||||||
|
|
||||||
|
# create a primary FAT partition with 256MB (for kernel + firmware)
|
||||||
|
# create a primary Linux partition covering the remainder
|
||||||
|
sfdisk rpi.img <<EOF
|
||||||
|
2048,+256M
|
||||||
|
;
|
||||||
|
EOF
|
||||||
|
# FAT32 LBA
|
||||||
|
sfdisk --part-type rpi.img 1 c
|
||||||
|
# Linux
|
||||||
|
sfdisk --part-type rpi.img 2 83
|
||||||
|
# Activate
|
||||||
|
sfdisk --activate rpi.img 1
|
||||||
|
|
||||||
|
# find first free loop device
|
||||||
|
loop=`losetup -f`
|
||||||
|
# connect it to rpi.img, scan partition table
|
||||||
|
losetup --partscan ${loop} rpi.img
|
||||||
|
|
||||||
|
# boot partition
|
||||||
|
#
|
||||||
|
mkfs -t vfat -n RPI_BOOT ${loop}p1
|
||||||
|
# create a mountpoint and mount the FAT partition
|
||||||
|
mkdir img
|
||||||
|
mount ${loop}p1 img
|
||||||
|
# copy bootloader
|
||||||
|
cp -a iso/EFI img
|
||||||
|
cp -a iso/boot img
|
||||||
|
sed -i "s/=ttyS0 /=ttyS0,115200 /g" img/EFI/BOOT/grub.cfg
|
||||||
|
# and firmware files to the FAT partition
|
||||||
|
# 'old' firmware
|
||||||
|
if [ -d rootfs/boot/vc ]; then
|
||||||
|
cp -a rootfs/boot/vc/* img
|
||||||
|
else
|
||||||
|
# systemready firmware
|
||||||
|
cp rootfs/boot/*.fd img
|
||||||
|
cp rootfs/boot/*.dtb img
|
||||||
|
cp rootfs/boot/config.txt img
|
||||||
|
cp rootfs/boot/fixup4.dat img
|
||||||
|
cp rootfs/boot/start4.elf img
|
||||||
|
cp -a rootfs/boot/firmware img
|
||||||
|
cp -a rootfs/boot/overlays img
|
||||||
|
fi
|
||||||
|
|
||||||
|
umount img
|
||||||
|
|
||||||
|
# root partition
|
||||||
|
#
|
||||||
|
# label it COS_LIVE
|
||||||
|
mkfs -t ext3 -L COS_LIVE ${loop}p2
|
||||||
|
mount ${loop}p2 img
|
||||||
|
# copy the rootfs into this partition
|
||||||
|
cp iso/rootfs.squashfs img
|
||||||
|
|
||||||
|
# Install hook to copy rpi firmware in EFI partition
|
||||||
|
mkdir -p img/iso-config
|
||||||
|
if [ -d rootfs/boot/vc ]; then
|
||||||
|
cat << HOOK > img/iso-config/01_rpi-install-hook.yaml
|
||||||
|
name: "Raspberry Pi after install hook"
|
||||||
|
stages:
|
||||||
|
after-install:
|
||||||
|
- ©firmware
|
||||||
|
name: "Copy firmware to EFI partition"
|
||||||
|
commands:
|
||||||
|
- cp -a /run/elemental/workingtree/boot/vc/* /run/elemental/efi
|
||||||
|
after-reset:
|
||||||
|
- <<: *copyfirmware
|
||||||
|
HOOK
|
||||||
|
else
|
||||||
|
cat << HOOK > img/iso-config/01_rpi-install-hook.yaml
|
||||||
|
name: "Raspberry Pi after install hook"
|
||||||
|
stages:
|
||||||
|
after-install:
|
||||||
|
- ©firmware
|
||||||
|
name: "Copy firmware to EFI partition"
|
||||||
|
commands:
|
||||||
|
- cp /run/elemental/workingtree/boot/*.fd /run/elemental/efi
|
||||||
|
- cp /run/elemental/workingtree/boot/*.dtb /run/elemental/efi
|
||||||
|
- cp /run/elemental/workingtree/boot/config.txt /run/elemental/efi
|
||||||
|
- cp /run/elemental/workingtree/boot/fixup4.dat /run/elemental/efi
|
||||||
|
- cp /run/elemental/workingtree/boot/start4.elf /run/elemental/efi
|
||||||
|
- cp -a /run/elemental/workingtree/boot/firmware /run/elemental/efi
|
||||||
|
- cp -a /run/elemental/workingtree/boot/overlays /run/elemental/efi
|
||||||
|
after-reset:
|
||||||
|
- <<: *copyfirmware
|
||||||
|
HOOK
|
||||||
|
fi
|
||||||
|
# undo all mounts, loopback devices, etc.
|
||||||
|
|
||||||
|
umount img
|
||||||
|
rmdir img
|
||||||
|
umount rootfs
|
||||||
|
rmdir rootfs
|
||||||
|
|
||||||
|
losetup -d ${loop}
|
||||||
|
umount iso
|
||||||
|
rmdir iso
|
||||||
|
|
||||||
|
# copy the image as rpi.raw (buildservice checks extensions)
|
||||||
|
|
||||||
|
mkdir -p "${TOPDIR}/OTHER"
|
||||||
|
rawname="rpi${flavor}.raw"
|
||||||
|
mv rpi.img ${rawname}
|
||||||
|
sha256sum ${rawname} > "${TOPDIR}/OTHER/${rawname}.sha256"
|
||||||
|
mv ${rawname} "${TOPDIR}/OTHER"
|
||||||
|
ln "${TOPDIR}/OTHER/${rawname}" "${TOPDIR}/OTHER/rpi${flavor}-${project}-`date +'%Y%m%d%H%M%S'`.raw"
|
||||||
|
|
||||||
|
# release the container
|
||||||
|
|
||||||
|
buildah umount "${container}"
|
||||||
|
buildah rm "${container}"
|
Loading…
Reference in New Issue
Block a user