Skip to content

Commit

Permalink
all distros somehow generted, no tests done
Browse files Browse the repository at this point in the history
  • Loading branch information
xorel committed Oct 20, 2023
1 parent 73cfd78 commit d5d5ae3
Show file tree
Hide file tree
Showing 36 changed files with 873 additions and 24 deletions.
11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ download: $(patsubst %, download-%, $(DISTROS))
download-%: ${DIR_BASE}/%.img
@${INFO} "Download ${*} done"

${DIR_BASE}/%.img:
${DIR_BASE}/%.img: validate-%
@${INFO} "Starting $* download"
curl -sS -L -f -o "$@" "${URL_${*}}"

Expand Down Expand Up @@ -89,6 +89,15 @@ context-linux: $(patsubst %, context-linux/out/%, $(LINUX_CONTEXT_PACKAGES))
context-linux/out/%:
cd context-linux; ./generate-all.sh

#------------------------------------------------------------------------------
# validate before download
#------------------------------------------------------------------------------
validate-%:
@if [[ ! "$(DISTROS)" == *"${*}"* ]]; then \
echo "[ERROR] Unknown distro ${*}"; \
exit 1; \
fi

#------------------------------------------------------------------------------
# help
#------------------------------------------------------------------------------
Expand Down
42 changes: 25 additions & 17 deletions Makefile.distros
Original file line number Diff line number Diff line change
@@ -1,26 +1,34 @@
DISTROS := alma8 alma9 \
alpine316 alpine317 \
alt9 alt10 \
debian10 debian11 debian12 \
devuan3 devuan4\
fedora37 fedora38 \
ol8 ol9 \
opensuse15 \
rocky8 rocky9 \
ubuntu2004 ubuntu2004min ubuntu2204 ubuntu2204min

# URLS
URL_alma8 ?= https://repo.almalinux.org/almalinux/8/cloud/x86_64/images/AlmaLinux-8-OpenNebula-latest.x86_64.qcow2
URL_alma9 ?= https://repo.almalinux.org/almalinux/9/cloud/x86_64/images/AlmaLinux-9-OpenNebula-latest.x86_64.qcow2
URL_alpine316 ?= https://dl-cdn.alpinelinux.org/alpine/v3.16/releases/x86_64/alpine-virt-3.16.7-x86_64.iso
URL_alpine317 ?= https://dl-cdn.alpinelinux.org/alpine/v3.17/releases/x86_64/alpine-virt-3.17.5-x86_64.iso
URL_debian10 ?= https://cdimage.debian.org/cdimage/openstack/current-10/debian-10-openstack-arm64.qcow2
URL_debian11 ?= https://cdimage.debian.org/cdimage/cloud/bullseye/latest/debian-11-generic-amd64.qcow2
URL_debian12 ?= https://cdimage.debian.org/cdimage/cloud/bookworm/latest/debian-12-generic-amd64.qcow2
URL_fedora37 ?= https://download.fedoraproject.org/pub/fedora/linux/releases/37/Cloud/x86_64/images/Fedora-Cloud-Base-37-1.7.x86_64.qcow2
URL_fedora38 ?= https://download.fedoraproject.org/pub/fedora/linux/releases/38/Cloud/x86_64/images/Fedora-Cloud-Base-38-1.6.x86_64.qcow2
URL_ol8 ?= https://yum.oracle.com/templates/OracleLinux/OL8/u7/x86_64/OL8U7_x86_64-kvm-b148.qcow
URL_ol9 ?= https://yum.oracle.com/templates/OracleLinux/OL9/u1/x86_64/OL9U1_x86_64-kvm-b158.qcow
URL_rocky ?= https://download.rockylinux.org/pub/rocky/8/isos/x86_64/Rocky-x86_64-boot.iso
URL_rocky ?= https://download.rockylinux.org/pub/rocky/9/isos/x86_64/Rocky-x86_64-boot.iso
ONE_ubuntu2004 ?= https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img
ONE_ubuntu2204 ?= https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img
ONE_ubuntu2004min ?= https://cloud-images.ubuntu.com/minimal/releases/focal/release/ubuntu-20.04-minimal-cloudimg-amd64.img
ONE_ubuntu2204min ?= https://cloud-images.ubuntu.com/minimal/releases/jammy/release/ubuntu-22.04-minimal-cloudimg-amd64.img
URL_alma8 := https://repo.almalinux.org/almalinux/8/cloud/x86_64/images/AlmaLinux-8-OpenNebula-latest.x86_64.qcow2
URL_alma9 := https://repo.almalinux.org/almalinux/9/cloud/x86_64/images/AlmaLinux-9-OpenNebula-latest.x86_64.qcow2
URL_alpine316 := https://dl-cdn.alpinelinux.org/alpine/v3.16/releases/x86_64/alpine-virt-3.16.7-x86_64.iso
URL_alpine317 := https://dl-cdn.alpinelinux.org/alpine/v3.17/releases/x86_64/alpine-virt-3.17.5-x86_64.iso
URL_alt9 := https://mirror.yandex.ru/altlinux/p9/images/cloud/x86_64/alt-p9-cloud-x86_64.qcow2
URL_alt10 := https://mirror.yandex.ru/altlinux/p10/images/cloud/x86_64/alt-p10-cloud-x86_64.qcow2
URL_debian10 := https://cdimage.debian.org/cdimage/openstack/current-10/debian-10-openstack-arm64.qcow2
URL_debian11 := https://cdimage.debian.org/cdimage/cloud/bullseye/latest/debian-11-generic-amd64.qcow2
URL_debian12 := https://cdimage.debian.org/cdimage/cloud/bookworm/latest/debian-12-generic-amd64.qcow2
URL_devuan3 := https://files.devuan.org/devuan_beowulf/installer-iso/devuan_beowulf_3.1.1_amd64_server.iso
URL_devuan4 := https://files.devuan.org/devuan_chimaera/installer-iso/devuan_chimaera_4.0.0_amd64_server.iso
URL_fedora37 := https://download.fedoraproject.org/pub/fedora/linux/releases/37/Cloud/x86_64/images/Fedora-Cloud-Base-37-1.7.x86_64.qcow2
URL_fedora38 := https://download.fedoraproject.org/pub/fedora/linux/releases/38/Cloud/x86_64/images/Fedora-Cloud-Base-38-1.6.x86_64.qcow2
URL_ol8 := https://yum.oracle.com/templates/OracleLinux/OL8/u7/x86_64/OL8U7_x86_64-kvm-b148.qcow
URL_ol9 := https://yum.oracle.com/templates/OracleLinux/OL9/u1/x86_64/OL9U1_x86_64-kvm-b158.qcow
URL_opensuse15 := https://download.opensuse.org/distribution/leap/15.5/appliances/openSUSE-Leap-15.5-Minimal-VM.x86_64-Cloud.qcow2
URL_rocky := https://download.rockylinux.org/pub/rocky/8/isos/x86_64/Rocky-x86_64-boot.iso
URL_rocky := https://download.rockylinux.org/pub/rocky/9/isos/x86_64/Rocky-x86_64-boot.iso
URL_ubuntu2004 := https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img
URL_ubuntu2004min := https://cloud-images.ubuntu.com/minimal/releases/focal/release/ubuntu-20.04-minimal-cloudimg-amd64.img
URL_ubuntu2204 := https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img
URL_ubuntu2204min := https://cloud-images.ubuntu.com/minimal/releases/jammy/release/ubuntu-22.04-minimal-cloudimg-amd64.img
2 changes: 1 addition & 1 deletion Makefile.distros-nonfree
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifeq (${NONFREE}, yes)
-include
-include Makefile.secrets
DISTROS += rhel8 rhel9
URL_rhel8 := http://storage/images/base/rhel8.qcow2
URL_rhel9 := http://storage/images/base/rhel9.qcow2
Expand Down
1 change: 1 addition & 0 deletions guestfish/alt10
19 changes: 19 additions & 0 deletions guestfish/alt9/10-upgrade-distro.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

# (Auto)Removes unneeded packages and upgrades
# the distro.

exec 1>&2
set -o errexit -o nounset -o pipefail
set -x

export DEBIAN_FRONTEND=noninteractive

apt-get update -y

apt-get install -y --fix-broken

# Ensure packages needed for post-processing scripts do exist.
apt-get install -y curl gawk grep jq sed

sync
53 changes: 53 additions & 0 deletions guestfish/alt9/11-update-grub.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env bash

# Sets kernel command line (net.ifnames=0 is particularily important),
# then updates initramfs/initrd and grub2.

exec 1>&2
set -o errexit -o nounset -o pipefail
set -x

rm -rf /etc/default/grub.d/

# Drop unwanted.

gawk -i inplace -f- /etc/sysconfig/grub2 <<'EOF'
/^GRUB_CMDLINE_LINUX[^=]*=/ { gsub(/\<quiet\>/, "") }
/^GRUB_CMDLINE_LINUX[^=]*=/ { gsub(/\<splash\>/, "") }
/^GRUB_CMDLINE_LINUX[^=]*=/ { gsub(/\<console=ttyS[^ ]*\>/, "") }
/^GRUB_CMDLINE_LINUX[^=]*=/ { gsub(/\<earlyprintk=ttyS[^ ]*\>/, "") }
/^GRUB_CMDLINE_LINUX[^=]*=/ { gsub(/\<crashkernel=[^ ]*\>/, "crashkernel=no") }
{ print }
EOF

# Ensure required.

gawk -i inplace -f- /etc/sysconfig/grub2 <<'EOF'
/^GRUB_CMDLINE_LINUX=/ { found = 1 }
/^GRUB_CMDLINE_LINUX=/ && !/net.ifnames=0/ { gsub(/"$/, " net.ifnames=0\"") }
/^GRUB_CMDLINE_LINUX=/ && !/biosdevname=0/ { gsub(/"$/, " biosdevname=0\"") }
{ print }
END { if (!found) print "GRUB_CMDLINE_LINUX=\" net.ifnames=0 biosdevname=0\"" >> FILENAME }
EOF

gawk -i inplace -f- /etc/sysconfig/grub2 <<'EOF'
BEGIN { update = "GRUB_TIMEOUT=0" }
/^GRUB_TIMEOUT=/ { $0 = update; found = 1 }
{ print }
END { if (!found) print update >> FILENAME }
EOF

# Cleanup.

gawk -i inplace -f- /etc/sysconfig/grub2 <<'EOF'
{ gsub(/(" *| *")/, "\""); gsub(/ */, " ") }
{ print }
EOF

INITRAMFS_IMG=$(find /boot/ -maxdepth 1 -name 'vmlinuz-*' | sort -V | tail -1)
INITRAMFS_VER=$(sed -e 's/^.*vmlinuz-//' <<< "$INITRAMFS_IMG")
make-initrd -k "$INITRAMFS_VER"

update-grub

sync
42 changes: 42 additions & 0 deletions guestfish/alt9/80-install-context.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash

# Downloads and installs the latest one-context package.

: "${CTX_INFIX:=alt}"

exec 1>&2
set -o errexit -o nounset -o pipefail
set -x

export DEBIAN_FRONTEND=noninteractive

if ! stat /context/one-context*$CTX_INFIX*; then (
install -d /context/ && cd /context/
curl -fsSL https://api.github.com/repos/OpenNebula/addon-context-linux/releases \
| jq -r ".[0].assets[].browser_download_url | select(test(\"$CTX_INFIX\"))" \
| xargs -r -n1 curl -fsSLO
) fi

apt-get remove --purge -y cloud-init
apt-get install -y /context/one-context*$CTX_INFIX* haveged open-vm-tools

systemctl enable haveged

# >>> Apply only on one-context >= 6.1 >>>
# - Fix Alt favour of NM by removing etcnet plugin and pointing to correct sysctl.conf
# - Disable Alt custom resolv.conf generation
if ! rpm -q --queryformat '%{VERSION}' one-context | grep -E '^([1-5]\.|6\.0\.)'; then
apt-get install -y NetworkManager
systemctl enable NetworkManager.service
sed -i -e 's/^\(\s*plugins\s*\)=.*/\1=keyfile/' /etc/NetworkManager/NetworkManager.conf
sed -i -e 's#^\(\s*NM_SYSCTL_CONF\)=.*#\1=/etc/sysctl.conf#' /etc/sysconfig/NetworkManager
systemctl mask altlinux-libresolv
systemctl mask altlinux-libresolv.path
systemctl mask altlinux-openresolv
systemctl mask altlinux-openresolv.path
systemctl mask altlinux-simpleresolv
systemctl mask altlinux-simpleresolv.path
fi
# <<< Apply only on one-context >= 6.1 <<<

sync
30 changes: 30 additions & 0 deletions guestfish/alt9/81-configure-ssh.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash

# Configures critical settings for OpenSSH server.

exec 1>&2
set -o errexit -o nounset -o pipefail
set -x

gawk -i inplace -f- /etc/openssh/sshd_config <<'EOF'
BEGIN { update = "PasswordAuthentication no" }
/^[#\s]*PasswordAuthentication\s*/ { $0 = update; found = 1 }
{ print }
END { if (!found) print update >> FILENAME }
EOF

gawk -i inplace -f- /etc/openssh/sshd_config <<'EOF'
BEGIN { update = "PermitRootLogin without-password" }
/^[#\s]*PermitRootLogin\s*/ { $0 = update; found = 1 }
{ print }
END { if (!found) print update >> FILENAME }
EOF

gawk -i inplace -f- /etc/openssh/sshd_config <<'EOF'
BEGIN { update = "UseDNS no" }
/^[#\s]*UseDNS\s*/ { $0 = update; found = 1 }
{ print }
END { if (!found) print update >> FILENAME }
EOF

sync
22 changes: 22 additions & 0 deletions guestfish/alt9/98-collect-garbage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

# Cleans APT caches, removes temporary files / logs,
# removes leftover / temporary unneeded packages.

exec 1>&2
set -o errexit -o nounset -o pipefail
set -x

export DEBIAN_FRONTEND=noninteractive

apt-get remove --purge -y cloud-init fwupd

apt-get autoremove -y

apt-get clean -y && rm -rf /var/lib/apt/lists/*

install -d /var/lib/apt/lists/partial/

rm -rf /context/

sync
37 changes: 37 additions & 0 deletions guestfish/devuan3/10-upgrade-distro.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash

# (Auto)Removes unneeded packages and upgrades
# the distro.

policy_rc_d_disable() (echo "exit 101" >/usr/sbin/policy-rc.d && chmod a+x /usr/sbin/policy-rc.d)
policy_rc_d_enable() (echo "exit 0" >/usr/sbin/policy-rc.d && chmod a+x /usr/sbin/policy-rc.d)

exec 1>&2
set -o errexit -o nounset -o pipefail
set -x

export DEBIAN_FRONTEND=noninteractive

sed -i '/^deb cdrom/d' /etc/apt/sources.list
echo "deb http://deb.devuan.org/merged beowulf main" >> /etc/apt/sources.list
echo "deb http://deb.devuan.org/merged beowulf-updates main" >> /etc/apt/sources.list
echo "deb http://deb.devuan.org/merged beowulf-security main" >> /etc/apt/sources.list

apt-get update -y

policy_rc_d_disable

debconf-set-selections <<< 'grub-pc grub-pc/install_devices multiselect /dev/sda'

apt-get install -y --fix-broken

apt-get upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold"

# Ensure packages needed for post-processing scripts do exist.
apt-get install -y curl gawk grep jq

policy_rc_d_enable

ln -sf /usr/share/zoneinfo/UTC /etc/localtime

sync
54 changes: 54 additions & 0 deletions guestfish/devuan3/11-update-grub.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env bash

# Sets kernel command line (net.ifnames=0 is particularily important),
# then updates initramfs/initrd and grub2.

exec 1>&2
set -o errexit -o nounset -o pipefail
set -x

rm -rf /etc/default/grub.d/

# Drop unwanted.

# NOTE: console=ttyS*, earlyprintk=ttyS* may cause kernel panic during first boot.
# The exact problem is identical to https://github.com/dmacvicar/terraform-provider-libvirt/issues/948.
# A correct workaround is described here: https://bugs.launchpad.net/ubuntu/+source/cloud-initramfs-tools/+bug/1123220.

gawk -i inplace -f- /etc/default/grub <<'EOF'
/^GRUB_CMDLINE_LINUX[^=]*=/ { gsub(/\<quiet\>/, "") }
/^GRUB_CMDLINE_LINUX[^=]*=/ { gsub(/\<splash\>/, "") }
/^GRUB_CMDLINE_LINUX[^=]*=/ { gsub(/\<console=ttyS[^ ]*\>/, "") }
/^GRUB_CMDLINE_LINUX[^=]*=/ { gsub(/\<earlyprintk=ttyS[^ ]*\>/, "") }
/^GRUB_TERMINAL=/ { gsub(/\<serial\>/, "") }
{ print }
EOF

# Ensure required.

gawk -i inplace -f- /etc/default/grub <<'EOF'
/^GRUB_CMDLINE_LINUX=/ { found = 1 }
/^GRUB_CMDLINE_LINUX=/ && !/net.ifnames=0/ { gsub(/"$/, " net.ifnames=0\"") }
/^GRUB_CMDLINE_LINUX=/ && !/biosdevname=0/ { gsub(/"$/, " biosdevname=0\"") }
{ print }
END { if (!found) print "GRUB_CMDLINE_LINUX=\" net.ifnames=0 biosdevname=0\"" >> FILENAME }
EOF

gawk -i inplace -f- /etc/default/grub <<'EOF'
BEGIN { update = "GRUB_TIMEOUT=0" }
/^GRUB_TIMEOUT=/ { $0 = update; found = 1 }
{ print }
END { if (!found) print update >> FILENAME }
EOF

# Cleanup.

gawk -i inplace -f- /etc/default/grub <<'EOF'
{ gsub(/(" *| *")/, "\""); gsub(/ */, " ") }
{ print }
EOF

update-initramfs -vu
update-grub2

sync
32 changes: 32 additions & 0 deletions guestfish/devuan3/80-install-context.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash

# Downloads and installs the latest one-context package.

: "${CTX_SUFFIX:=.deb}"

policy_rc_d_disable() (echo "exit 101" >/usr/sbin/policy-rc.d && chmod a+x /usr/sbin/policy-rc.d)
policy_rc_d_enable() (echo "exit 0" >/usr/sbin/policy-rc.d && chmod a+x /usr/sbin/policy-rc.d)

exec 1>&2
set -o errexit -o nounset -o pipefail
set -x

export DEBIAN_FRONTEND=noninteractive

if ! stat /context/one-context*$CTX_SUFFIX; then (
install -d /context/ && cd /context/
curl -fsSL https://api.github.com/repos/OpenNebula/addon-context-linux/releases \
| jq -r ".[0].assets[].browser_download_url | select(endswith(\"$CTX_SUFFIX\"))" \
| xargs -r -n1 curl -fsSLO
) fi

policy_rc_d_disable

dpkg -i /context/one-context*$CTX_SUFFIX || apt-get install -y -f
dpkg -i /context/one-context*$CTX_SUFFIX

apt-get install -y open-vm-tools

policy_rc_d_enable

sync
Loading

0 comments on commit d5d5ae3

Please sign in to comment.