ironic-python-agent-builder/tinyipa/build-instance-images.sh
Riccardo Pittau 82a1ba0c78 Build tinyipa on focal
Use new ubuntu-focal nodeset to build tinyipa images.
This is needed to prepare to build tinyipa images based on
tinycore 11.x because we need the new kernel 5.x version to
be able to chroot.

Main changes:
- patching tce-load to conform to new squashfs options in the new
kernel
- installing python3-pip instead of python-pip

Story: 2007753
Task: 39943

Change-Id: I3d8a1ab84cae3c7185eb4f9bfefe239fab49a012
2020-07-03 09:28:58 +00:00

44 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
set -ex
WORKDIR=$(readlink -f $0 | xargs dirname)
DST_DIR=$(mktemp -d)
source ${WORKDIR}/common.sh
PARTIMG="$WORKDIR/tiny-instance-part${BRANCH_EXT}.img"
UECFILE="$WORKDIR/tiny-instance-uec${BRANCH_EXT}.tar.gz"
fs_type='ext4'
sudo rm -rf $PARTIMG $UECFILE
sudo truncate --size=150M $PARTIMG
sudo mkfs."${fs_type}" -F "$PARTIMG" -L "root"
sudo mount -o loop "$PARTIMG" "$DST_DIR/"
# Extract rootfs from .gz file
( cd "$DST_DIR" && zcat $WORKDIR/build_files/corepure64.gz | sudo cpio -i -H newc -d )
setup_tce $DST_DIR
# NOTE(rpittau) change ownership of the tce info dir to prevent writing issues
sudo chown $TC:$STAFF $DST_DIR/usr/local/tce.installed
# NOTE(rpittau) patch tce-load to adapt to changes in squashfs module in
# latest kernel
sudo patch ${DST_DIR}/usr/bin/tce-load < patches/tce-load_squashfs.patch
$TC_CHROOT_CMD tce-load -wci grub2-multi.tcz
cleanup_tce $DST_DIR
sudo umount $DST_DIR/
pushd $DST_DIR/
cp $WORKDIR/tinyipa${BRANCH_EXT}.gz $DST_DIR/tinyipa-initrd
cp $WORKDIR/tinyipa${BRANCH_EXT}.vmlinuz $DST_DIR/tinyipa-vmlinuz
cp $PARTIMG $DST_DIR/
tar -czf $UECFILE ./
popd
sudo rm -rf $DST_DIR