Skip to content

Commit

Permalink
export containers to installed rootfs
Browse files Browse the repository at this point in the history
  • Loading branch information
raoulh committed Dec 14, 2023
1 parent e2047a7 commit e66d1d0
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion scripts/calaos_install
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,20 @@ err_report() {
err "Error on line $1"
}

function podman_export()
{
local container_name="$1"
local image="$2"
local dest="$3/var/lib/cache/containers/"

mkdir -p ${dest}

echo " -> Export image: $container_name ($image)"

# Save image as oci-dir and compressed it
podman save --format oci-archive -o ${dest}/"$container_name".tar "$image"
}

trap 'err_report $LINENO' ERR

destination=$1
Expand Down Expand Up @@ -223,10 +237,12 @@ rsync -avh ${src}/ ${dst} \
--exclude /proc \
--exclude /sys \
--exclude /var/run/containers \
--exclude /var/run \
--exclude /media \
--exclude /mnt/destination_rootfs \
--exclude /mnt/origin_rootfs \
--exclude /var/lib/containers/storage/overlay
--exclude /var/lib/containers/storage/overlay \
--exclude /var/lib/containers

#Cleanup initramfs scrits not needed for installed rootfs
rm -rf ${dst}/.calaos-live \
Expand All @@ -249,6 +265,13 @@ sed -i 's/rootflags=subvol=${rootsubvol}//g' ${dst}/etc/grub.d/20_linux_xen
#regen mkinitcpio in rootfs
arch-chroot ${dst} update-initramfs -u

info "--> Exporting container images"
for file in /usr/share/calaos/*.source; do
container_name=$(basename "$file" .source)
source "$file"
podman_export "$container_name" "$IMAGE_SRC" "${dst}"
done

#Initialize Snapper. Unmount our predefined .snapshot folder, let snapper recreate it (it fails otherwise)
#remove the snapshot created by snapper, remount our .snapshot
info "--> Initializing Snapper"
Expand Down

0 comments on commit e66d1d0

Please sign in to comment.