
The purpose of the "image" sub-command is to allow a user to create a raw disk-image from an ostree branch to be used by libvirt. This allows the user to test an ostree branch by making it bootable. The way that it works is that the user provides a debos configuration file in order to create a raw disk. A sample configuration file is included in this commit. In order to create a disk image apt-ostree will create a scratch ostree repository and copy the desired branch into the scratch repo. Once that happens debos will run with a specific branch chosen by the user. Debos is a golang based tool that allows the creation of Debian based OS images simpler. To build an image from a provided configuration file, one simply runs the following command: sudo apt-ostree compose image --repo <path to ostree repo> \ --base <path to configuration directory> \ <ostree branch> More details can be found in the man page. Testing: PASSED Installed apt-ostree from git repo. PASSED Run "apt-ostree compose image --base config/debian/image \ --repo=/repo test" PASSED Checked for raw disk image in /var/tmp/apt-ostree/build/test/image Story: 2010867 Task: 48556 Depends-On: https://review.opendev.org/c/starlingx/apt-ostree/+/890704 Change-Id: I4ce64214dc3bb59ef03b35c2c27def017ea35487 Signed-off-by: Charles Short <charles.short@windriver.com>
53 lines
1.5 KiB
Bash
Executable File
53 lines
1.5 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
# Based on original script from OStree upstream:
|
|
# https://github.com/ostreedev/ostree/blob/master/src/switchroot/switchroot.sh
|
|
# Copyright (C) 2013, 2016 Collabora Ltd
|
|
# Copyright (C) 2023 Wind River Systems, Inc.
|
|
|
|
set -eu
|
|
|
|
sysroot=${ROOTDIR}
|
|
|
|
osname=$1
|
|
|
|
bootconf=$sysroot/boot/loader/entries/ostree-1-${osname}.conf
|
|
|
|
if [ ! -f "$bootconf" ]; then
|
|
echo "OStree setup is not available!"
|
|
exit 1
|
|
fi
|
|
|
|
ostree=$(grep -o 'ostree=[/.[:alnum:]]\+' $bootconf)
|
|
ostree=${ostree#*=}
|
|
# Due symlink
|
|
ostree=$(realpath $sysroot$ostree)
|
|
|
|
mkdir -p $ostree/boot/efi
|
|
|
|
## /etc/machine-id must be writable to allow to work systemd-nspawn
|
|
# but original `machine-id` file must stay empty in build time.
|
|
touch /tmp/machine-id
|
|
mount --bind /tmp/machine-id $ostree/etc/machine-id
|
|
|
|
# NB: The native resolv.conf management is supported only from systemd v.232.
|
|
systemd-nspawn --resolv-conf=off -D $ostree systemd-machine-id-setup
|
|
|
|
# install EFI
|
|
systemd-nspawn \
|
|
--resolv-conf=off \
|
|
--bind $sysroot/boot:/boot \
|
|
--bind $sysroot/boot/efi:/boot/efi \
|
|
--bind $sysroot/ostree/deploy/${osname}/var:/var \
|
|
-D $ostree bootctl --path=/boot/efi install
|
|
|
|
umount $ostree/etc/machine-id
|
|
rmdir $ostree/boot/efi
|
|
|
|
# Copy config, kernel and initrd
|
|
# Change the name of config to unify with patch added in T4469
|
|
rsync -Pav $sysroot/boot/ostree $sysroot/boot/efi/
|
|
mkdir $sysroot/boot/efi/loader/entries/
|
|
cp $bootconf $sysroot/boot/efi/loader/entries/ostree-0-1.conf
|
|
rm -f $sysroot/boot/efi/loader/loader.conf
|