Fix FreeBSD ONE image build script

This commit is contained in:
fnux 2020-07-21 10:55:49 +02:00
parent 3ff2b138cb
commit 7e55e76b14

View file

@ -9,15 +9,13 @@ set -x
# XXX: Handle command-line arguments? # XXX: Handle command-line arguments?
RELEASE=12.1-RELEASE RELEASE=12.1-RELEASE
ARCH=amd64 ARCH=amd64
IMAGE_PATH=freebsd-$RELEASE-$(date +%+F).img.qcow2 IMAGE_PATH=freebsd-$RELEASE-$(date -I).img.qcow2
IMAGE_SIZE=10G IMAGE_SIZE=10G
DIST_BASE="https://download.freebsd.org/ftp/releases/$ARCH/$RELEASE" DIST_BASE="https://download.freebsd.org/ftp/releases/$ARCH/$RELEASE"
PORTS_BASE="https://download.freebsd.org/ftp/snapshots/$ARCH/12.1-STABLE" PORTS_BASE="https://download.freebsd.org/ftp/snapshots/$ARCH/12.1-STABLE"
# TODO: find the package definition and built ourself, publish in some RPM repository. ONE_CONTEXT_PKG_URL="https://github.com/OpenNebula/addon-context-linux/releases/download/v5.12.0/one-context-5.12.0_1.txz"
ONE_CONTEXT_RPM_URL="https://github.com/OpenNebula/addon-context-linux/releases/download/v5.10.0/one-context-5.10.0-1.el8.noarch.rpm"
ONE_CONTEXT_RPM_PATH=/root/one-context.rpm
cleanup() { cleanup() {
sync || true sync || true
@ -70,7 +68,7 @@ growfs_enable=YES
hostname="freebsd" hostname="freebsd"
EOF EOF
cp /etc/resolv.conf > /mnt/etc/resolv.conf cp /etc/resolv.conf /mnt/etc/resolv.conf
tzsetup -s -C /mnt UTC tzsetup -s -C /mnt UTC
cat >>/mnt/etc/ssh/sshd_config <<EOF cat >>/mnt/etc/ssh/sshd_config <<EOF
@ -98,7 +96,11 @@ then
fi fi
env ASSUME_ALWAYS_YES=YES pkg -c /mnt bootstrap -f env ASSUME_ALWAYS_YES=YES pkg -c /mnt bootstrap -f
env ASSUME_ALWAYS_YES=YES pkg -c /mnt install bash env ASSUME_ALWAYS_YES=YES pkg -c /mnt install bash curl
curl -L "$ONE_CONTEXT_PKG_URL" -o /mnt/one-context.txz
env ASSUME_ALWAYS_YES=YES pkg -c /mnt add one-context.txz
rm /mnt/one-context.txz
fetch -m -o "$dist_dir/ports.txz" "$PORTS_BASE/ports.txz" fetch -m -o "$dist_dir/ports.txz" "$PORTS_BASE/ports.txz"
tar -C /mnt -xJf "$dist_dir/ports.txz" tar -C /mnt -xJf "$dist_dir/ports.txz"
@ -107,8 +109,8 @@ cleanup
trap : EXIT trap : EXIT
mkdir -p "$ARCH" mkdir -p "$ARCH"
qemu-img convert -f raw -O qcow2 $disk "$ARCH"/root.img.qcow2 qemu-img convert -f raw -O qcow2 "$disk" "$IMAGE_PATH"
rm $disk rm "$disk"
# Filesystem will be enlarged by growfs(7) on next startup # Filesystem will be enlarged by growfs(7) on next startup
qemu-img resize $IMAGE_PATH $IMAGE_SIZE qemu-img resize "$IMAGE_PATH" "$IMAGE_SIZE"