You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.6 KiB

#!/bin/bash
set -eu
error=0
#DIST=buster
DIST=bullseye
if [ -z "$(which podman)" ]; then
echo "Need podman (apt-get install podman)" >&2
error=1
fi
if [ -z "$(which singularity)" ]; then
echo "Need singlarity :" >&2
echo "apt-get -y install squashfs-tools cryptsetup-bin"
echo "wget https://github.com/sylabs/singularity/releases/download/v3.10.0/singularity-ce_3.10.0-focal_amd64.deb" >&2
echo "dpkg -i singularity-ce_3.10.0-focal_amd64.deb" >&2
error=1
fi
echo
echo "==========================="
echo "Create debian:$DIST-slim podman container..."
podman --cgroup-manager=cgroupfs run --name vdn -v $HOME:/home/user:ro -p 2222:22 -d debian:$DIST-slim sleep 10d
# docker.io/library/debian/$DIST-slim
echo
echo "==========================="
echo "Install vdn dependencies..."
podman exec vdn /bin/bash /home/user/vdn-bullseye/tools/podman-exec-cmds.sh
echo
echo "==========================="
echo "Export..."
ionice -c 3 nice -10 podman export --output=/tmp/podman-vdn-$DIST.tar vdn
echo
echo "==========================="
echo "Import"
imgHash=$(podman import /tmp/podman-vdn-$DIST.tar | tail -n 1)
echo
echo "==========================="
echo "Save..."
rm -f rm /tmp/podman-vdn-$DIST-save.tar
ionice -c 3 nice -10 podman save --output=/tmp/podman-vdn-$DIST-save.tar $imgHash
echo
echo "==========================="
echo "Create sif image..."
rm -f /tmp/vdn-$DIST.sif
ionice -c 3 nice -10 singularity build --fakeroot /tmp/vdn-$DIST.sif docker-archive:///tmp/podman-vdn-$DIST-save.tar
rm -f /tmp/podman-vdn-$DIST-save.tar
podman rm -f vdn
podman image rm $imgHash