From 5a0dbe8f826648e4bc5a81905865ae46f4379895 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Floure?= Date: Thu, 11 Mar 2021 10:56:06 +0100 Subject: [PATCH] Cleaning and tweaking (missing one-context?) of arch ONE script --- .../arch-build-opennebula-image.sh | 40 ++++++++++--------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/opennebula-images/arch-build-opennebula-image.sh b/opennebula-images/arch-build-opennebula-image.sh index 00c454f..f809de5 100755 --- a/opennebula-images/arch-build-opennebula-image.sh +++ b/opennebula-images/arch-build-opennebula-image.sh @@ -9,14 +9,12 @@ set -e set -x # XXX: Handle command-line arguments? -ARCH=amd64 IMAGE_PATH=arch-$(date --iso-8601).img.qcow2 IMAGE_SIZE=10G NBD_DEVICE=/dev/nbd0 -# TODO: find the package definition and built ourself, publish in some RPM repository. -ONE_CONTEXT_DEB_URL="https://github.com/OpenNebula/addon-context-linux/releases/download/v5.10.0/one-context_5.10.0-1.deb" -ONE_CONTEXT_DEB_PATH=/root/one-context.deb +ONE_CONTEXT_VERSION=5.12.0.2 +ONE_CONTEXT_SOURCE_ARCHIVE="https://github.com/OpenNebula/addon-context-linux/archive/v$ONE_CONTEXT_VERSION.tar.gz" cleanup() { # The order here is important. @@ -42,9 +40,9 @@ if [ "$(whoami)" != 'root' ]; then exit 1 fi -if [ $(lsb_release --short --id) != "Arch" ]; then - echo "WARNING: this script has been designed to run on an Ubuntu system." >&2 - echo "WARNING: Not running Ubuntu. Giving you 5 seconds to abort." >&2 +if [ "$(lsb_release --short --id)" != "Arch" ]; then + echo "WARNING: this script has been designed to run on Arch Linux." >&2 + echo "WARNING: Not running Arch. Giving you 5 seconds to abort." >&2 sleep 5 fi @@ -75,7 +73,7 @@ mkdir /mnt/boot mount "${NBD_DEVICE}p1" /mnt/boot # Install base system. -pacstrap /mnt nbase base-devel openssh +pacstrap /mnt base base-devel openssh mount --bind /dev /mnt/dev mount --bind /dev/pts /mnt/dev/pts @@ -84,9 +82,6 @@ mount --bind /proc /mnt/proc mount --bind /run /mnt/run mount --bind /sys /mnt/sys -# Guest networking is to be handled by the one-context package. -# See https://github.com/OpenNebula/addon-context-linux for details. - # Required to resolve package mirror in chroot. cp /etc/resolv.conf /mnt/etc/resolv.conf @@ -105,16 +100,25 @@ cat > /mnt/etc/pacman.d/mirrorlist << EOF ## ## Switzerland -Server = http://pkg.adfinis-sygroup.ch/archlinux/$repo/os/$arch -Server = https://pkg.adfinis-sygroup.ch/archlinux/$repo/os/$arch -Server = http://mirror.init7.net/archlinux/$repo/os/$arch -Server = https://mirror.init7.net/archlinux/$repo/os/$arch -Server = http://mirror.puzzle.ch/archlinux/$repo/os/$arch -Server = https://mirror.puzzle.ch/archlinux/$repo/os/$arch -Server = https://mirror.ungleich.ch/mirror/packages/archlinux/$repo/os/$arch +Server = http://pkg.adfinis-sygroup.ch/archlinux/\$repo/os/\$arch +Server = https://pkg.adfinis-sygroup.ch/archlinux/\$repo/os/\$arch +Server = http://mirror.init7.net/archlinux/\$repo/os/\$arch +Server = https://mirror.init7.net/archlinux/\$repo/os/\$arch +Server = http://mirror.puzzle.ch/archlinux/\$repo/os/\$arch +Server = https://mirror.puzzle.ch/archlinux/\$repo/os/\$arch +Server = https://mirror.ungleich.ch/mirror/packages/archlinux/\$repo/os/\$arch EOF run_root pacman --sync --refresh --upgrade +# Guest networking is to be handled by the one-context package. +# See https://github.com/OpenNebula/addon-context-linux for details. +run_root pacman --sync curl tar +run_root curl -L "$ONE_CONTEXT_SOURCE_ARCHIVE" -o one-context.tar.gz +run_root tar xf one-context.tar.gz +run_root cp -rT addon-context-linux-${ONE_CONTEXT_VERSION}/src/ / +run_root rm -r addon-context-linux-${ONE_CONTEXT_VERSION} +run_root systemctl enable one-context.service + # Initalize base services. run_root systemd-machine-id-setup