From 9ee1f63705b562093f7c2a6fc6d7cc456bd65128 Mon Sep 17 00:00:00 2001 From: Axel Beckert Date: Sun, 3 Feb 2019 20:45:56 +0100 Subject: [PATCH] Create hooks/artful with new 40-setup-networking-deb-netplan Since Ubuntu 17.10 Artful, Ubuntu has decided to use netplan instead of ifupdown. 40-setup-networking-deb-netplan has been contributed by Arno and Peter. (see https://github.com/xen-tools/xen-tools/issues/51#issuecomment-412019510) Closes xen-tools/xen-tools#51. Since we have to make a variant of hooks/karmic/ as hook/artful/, rename hooks/karmic/80-install-kernel (which previously was unique to hooks/karmic/) to hooks/common/80-install-kernel-ubuntu and add symlinks to it from hooks/karmic/ and hook/artful/. --- Makefile | 11 +- NEWS.markdown | 2 +- debian/changelog | 4 + hooks/artful/01-disable-daemons | 1 + hooks/artful/05-shadowconfig-on | 1 + hooks/artful/15-disable-hwclock | 1 + hooks/artful/20-setup-apt | 1 + hooks/artful/25-generate-locale | 1 + hooks/artful/30-disable-gettys | 1 + hooks/artful/35-setup-users | 1 + hooks/artful/40-setup-networking-deb-netplan | 128 ++++++++++++++++++ hooks/artful/50-setup-hostname | 1 + hooks/artful/60-copy-host-files | 1 + hooks/artful/65-copy-user-files | 1 + hooks/artful/70-install-ssh | 1 + hooks/artful/75-fixup-securetty | 1 + hooks/artful/80-install-kernel-ubuntu | 1 + hooks/artful/80-install-modules | 1 + hooks/artful/81-install-modules-init-tools | 1 + hooks/artful/82-install-grub-legacy | 1 + hooks/artful/90-make-fstab | 1 + hooks/artful/99-clean-image | 1 + hooks/artful/99-enable-daemons | 1 + .../80-install-kernel-ubuntu} | 0 hooks/karmic/80-install-kernel-ubuntu | 1 + 25 files changed, 159 insertions(+), 6 deletions(-) create mode 120000 hooks/artful/01-disable-daemons create mode 120000 hooks/artful/05-shadowconfig-on create mode 120000 hooks/artful/15-disable-hwclock create mode 120000 hooks/artful/20-setup-apt create mode 120000 hooks/artful/25-generate-locale create mode 120000 hooks/artful/30-disable-gettys create mode 120000 hooks/artful/35-setup-users create mode 100755 hooks/artful/40-setup-networking-deb-netplan create mode 120000 hooks/artful/50-setup-hostname create mode 120000 hooks/artful/60-copy-host-files create mode 120000 hooks/artful/65-copy-user-files create mode 120000 hooks/artful/70-install-ssh create mode 120000 hooks/artful/75-fixup-securetty create mode 120000 hooks/artful/80-install-kernel-ubuntu create mode 120000 hooks/artful/80-install-modules create mode 120000 hooks/artful/81-install-modules-init-tools create mode 120000 hooks/artful/82-install-grub-legacy create mode 120000 hooks/artful/90-make-fstab create mode 120000 hooks/artful/99-clean-image create mode 120000 hooks/artful/99-enable-daemons rename hooks/{karmic/80-install-kernel => common/80-install-kernel-ubuntu} (100%) create mode 120000 hooks/karmic/80-install-kernel-ubuntu diff --git a/Makefile b/Makefile index 1f899f0..1d239c2 100644 --- a/Makefile +++ b/Makefile @@ -219,11 +219,12 @@ install-hooks: -cd ${prefix}/usr/share/xen-tools/ && ln -s karmic.d xenial.d -cd ${prefix}/usr/share/xen-tools/ && ln -s karmic.d yakkety.d -cd ${prefix}/usr/share/xen-tools/ && ln -s karmic.d zesty.d - -cd ${prefix}/usr/share/xen-tools/ && ln -s karmic.d artful.d - -cd ${prefix}/usr/share/xen-tools/ && ln -s karmic.d bionic.d - -cd ${prefix}/usr/share/xen-tools/ && ln -s karmic.d cosmic.d - -cd ${prefix}/usr/share/xen-tools/ && ln -s karmic.d disco.d - -cd ${prefix}/usr/share/xen-tools/ && ln -s karmic.d devel.d + mkdir -p ${prefix}/usr/share/xen-tools/artful.d/ + cp -R hooks/karmic/*-* ${prefix}/usr/share/xen-tools/artful.d/ + -cd ${prefix}/usr/share/xen-tools/ && ln -s artful.d bionic.d + -cd ${prefix}/usr/share/xen-tools/ && ln -s artful.d cosmic.d + -cd ${prefix}/usr/share/xen-tools/ && ln -s artful.d disco.d + -cd ${prefix}/usr/share/xen-tools/ && ln -s artful.d devel.d cp hooks/common.sh ${prefix}/usr/share/xen-tools cp -r hooks/common ${prefix}/usr/share/xen-tools diff --git a/NEWS.markdown b/NEWS.markdown index 0e612a0..acb78a1 100644 --- a/NEWS.markdown +++ b/NEWS.markdown @@ -18,7 +18,7 @@ Distribution Releases Changes * Support for + Ubuntu 17.10 Artful Aardvark - + Ubuntu 18.04 Bionic Beaver (LTS) + + Ubuntu 18.04 Bionic Beaver (LTS) (GH #51) + Ubuntu 18.10 Cosmic Cuttlefish * Preliminary support for Ubuntu 19.04 Disco Dingo * Knows about code name for Debian 12 (Bookworm). diff --git a/debian/changelog b/debian/changelog index 7ae7444..c18cdb6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -11,6 +11,10 @@ xen-tools (4.8-1) UNRELEASED; urgency=medium [ Axel Beckert ] + Add preliminary support for future Debian 12 Bookworm release. + Add support for Ubuntu releases from 17.10 Artful to 19.04 Disco. + - Create hooks/artful with new 40-setup-networking-deb-netplan by + Arno Bakker and Peter. (Fixes xen-tools/xen-tools#51) + - Rename hooks/karmic/80-install-kernel to + hooks/common/80-install-kernel-ubu and add according symlinks. [ Axel Beckert ] * Fix wrong bug number for #849867 in previous changelog entry. diff --git a/hooks/artful/01-disable-daemons b/hooks/artful/01-disable-daemons new file mode 120000 index 0000000..44e36b0 --- /dev/null +++ b/hooks/artful/01-disable-daemons @@ -0,0 +1 @@ +../common/01-disable-daemons \ No newline at end of file diff --git a/hooks/artful/05-shadowconfig-on b/hooks/artful/05-shadowconfig-on new file mode 120000 index 0000000..d165812 --- /dev/null +++ b/hooks/artful/05-shadowconfig-on @@ -0,0 +1 @@ +../common/05-shadowconfig-on \ No newline at end of file diff --git a/hooks/artful/15-disable-hwclock b/hooks/artful/15-disable-hwclock new file mode 120000 index 0000000..0ecc42a --- /dev/null +++ b/hooks/artful/15-disable-hwclock @@ -0,0 +1 @@ +../common/15-disable-hwclock \ No newline at end of file diff --git a/hooks/artful/20-setup-apt b/hooks/artful/20-setup-apt new file mode 120000 index 0000000..a2bb0b9 --- /dev/null +++ b/hooks/artful/20-setup-apt @@ -0,0 +1 @@ +../common/20-setup-apt \ No newline at end of file diff --git a/hooks/artful/25-generate-locale b/hooks/artful/25-generate-locale new file mode 120000 index 0000000..91644b2 --- /dev/null +++ b/hooks/artful/25-generate-locale @@ -0,0 +1 @@ +../common/25-generate-locale \ No newline at end of file diff --git a/hooks/artful/30-disable-gettys b/hooks/artful/30-disable-gettys new file mode 120000 index 0000000..114c431 --- /dev/null +++ b/hooks/artful/30-disable-gettys @@ -0,0 +1 @@ +../common/30-disable-gettys \ No newline at end of file diff --git a/hooks/artful/35-setup-users b/hooks/artful/35-setup-users new file mode 120000 index 0000000..d9bff4c --- /dev/null +++ b/hooks/artful/35-setup-users @@ -0,0 +1 @@ +../common/35-setup-users \ No newline at end of file diff --git a/hooks/artful/40-setup-networking-deb-netplan b/hooks/artful/40-setup-networking-deb-netplan new file mode 100755 index 0000000..ab6a5f7 --- /dev/null +++ b/hooks/artful/40-setup-networking-deb-netplan @@ -0,0 +1,128 @@ +#!/bin/sh +# +# This script sets up the /etc/netplan/interface file for the new +# image. +# +# Steve +# -- +# https://steve.fi/ + + +prefix=$1 + +# +# Source our common functions +# +if [ -e /usr/share/xen-tools/common.sh ]; then + . /usr/share/xen-tools/common.sh +else + . ./hooks/common.sh +fi + +# From: https://serverfault.com/questions/54981/linux-command-line-tool-to-work-with-netmasks-cidr-notation +mask2cdr () +{ + # Assumes there's no "255." after a non-255 byte in the mask + local x=${1##*255.} + set -- 0^^^128^192^224^240^248^252^254^ $(( (${#1} - ${#x})*2 )) ${x%%.*} + x=${1%%$3*} + echo $(( $2 + (${#x}/4) )) +} + +# +# Log our start +# +logMessage Script $0 starting + + +# +# Make sure we have an /etc/netplan directory. +# +mkdir -p ${prefix}/etc/netplan + + +# +# A function to setup DHCP for our new image. +# +setupDynamicNetworking () +{ + # + # The host is using DHCP. + # + cat < ${prefix}/etc/netplan/01-netcfg.yaml +# Arno: Configure VM interface eth0 via DHCP +network: + version: 2 + renderer: networkd + ethernets: + eth0: + dhcp4: true +E_O_DHCP +} + + + +# +# A function to setup static IP addresses for our new image. +# +setupStaticNetworking () +{ + # Arno + cidr='24'; + if [ -n "${netmask}" ]; then + cidr="$(mask2cdr ${netmask})" + fi + + # + # We have a static IP address + # + cat <${prefix}/etc/netplan/01-netcfg.yaml +# Arno: Set static IP for VM interface eth0 +network: + version: 2 + renderer: networkd + ethernets: + eth0: + addresses: [${ip1}/${cidr}] + gateway4: ${gateway} + nameservers: + addresses: [${nameserver}] +E_O_STATIC + + # Arno: no support for multiple interfaces + + # + # Hooks are run chrooted, hence the resolv.conf is moved + # temporarily to /etc/resolv.conf.old. Use that file, it + # will be restored after hooks are run. + # + if [ '' != "$nameserver" ]; then + rm -f ${prefix}/etc/resolv.conf.old + for ns in $nameserver; do + echo "nameserver $ns" >>${prefix}/etc/resolv.conf.old + done + else + cp /etc/resolv.conf ${prefix}/etc/resolv.conf.old + fi +} + + + + +# +# Call the relevant function +# +if [ -z "${dhcp}" ]; then + logMessage "Setting up static networking" + setupStaticNetworking + +else + logMessage "Setting up DHCP networking" + setupDynamicNetworking +fi + + +# +# Log our finish +# +logMessage Script $0 finished diff --git a/hooks/artful/50-setup-hostname b/hooks/artful/50-setup-hostname new file mode 120000 index 0000000..961cef8 --- /dev/null +++ b/hooks/artful/50-setup-hostname @@ -0,0 +1 @@ +../common/50-setup-hostname-deb \ No newline at end of file diff --git a/hooks/artful/60-copy-host-files b/hooks/artful/60-copy-host-files new file mode 120000 index 0000000..0990ad8 --- /dev/null +++ b/hooks/artful/60-copy-host-files @@ -0,0 +1 @@ +../common/60-copy-host-files \ No newline at end of file diff --git a/hooks/artful/65-copy-user-files b/hooks/artful/65-copy-user-files new file mode 120000 index 0000000..afde6e2 --- /dev/null +++ b/hooks/artful/65-copy-user-files @@ -0,0 +1 @@ +../common/65-copy-user-files \ No newline at end of file diff --git a/hooks/artful/70-install-ssh b/hooks/artful/70-install-ssh new file mode 120000 index 0000000..7749dd0 --- /dev/null +++ b/hooks/artful/70-install-ssh @@ -0,0 +1 @@ +../common/70-install-ssh-deb \ No newline at end of file diff --git a/hooks/artful/75-fixup-securetty b/hooks/artful/75-fixup-securetty new file mode 120000 index 0000000..e793d9e --- /dev/null +++ b/hooks/artful/75-fixup-securetty @@ -0,0 +1 @@ +../common/75-fixup-securetty \ No newline at end of file diff --git a/hooks/artful/80-install-kernel-ubuntu b/hooks/artful/80-install-kernel-ubuntu new file mode 120000 index 0000000..8e66049 --- /dev/null +++ b/hooks/artful/80-install-kernel-ubuntu @@ -0,0 +1 @@ +../common/80-install-kernel-ubuntu \ No newline at end of file diff --git a/hooks/artful/80-install-modules b/hooks/artful/80-install-modules new file mode 120000 index 0000000..8826dcd --- /dev/null +++ b/hooks/artful/80-install-modules @@ -0,0 +1 @@ +../common/80-install-modules-deb \ No newline at end of file diff --git a/hooks/artful/81-install-modules-init-tools b/hooks/artful/81-install-modules-init-tools new file mode 120000 index 0000000..913d783 --- /dev/null +++ b/hooks/artful/81-install-modules-init-tools @@ -0,0 +1 @@ +../common/81-install-modules-init-tools \ No newline at end of file diff --git a/hooks/artful/82-install-grub-legacy b/hooks/artful/82-install-grub-legacy new file mode 120000 index 0000000..4cc2a3a --- /dev/null +++ b/hooks/artful/82-install-grub-legacy @@ -0,0 +1 @@ +../common/82-install-grub-legacy \ No newline at end of file diff --git a/hooks/artful/90-make-fstab b/hooks/artful/90-make-fstab new file mode 120000 index 0000000..7728b34 --- /dev/null +++ b/hooks/artful/90-make-fstab @@ -0,0 +1 @@ +../common/90-make-fstab \ No newline at end of file diff --git a/hooks/artful/99-clean-image b/hooks/artful/99-clean-image new file mode 120000 index 0000000..1523ab6 --- /dev/null +++ b/hooks/artful/99-clean-image @@ -0,0 +1 @@ +../common/99-clean-image-deb \ No newline at end of file diff --git a/hooks/artful/99-enable-daemons b/hooks/artful/99-enable-daemons new file mode 120000 index 0000000..ada8e1f --- /dev/null +++ b/hooks/artful/99-enable-daemons @@ -0,0 +1 @@ +../common/99-enable-daemons \ No newline at end of file diff --git a/hooks/karmic/80-install-kernel b/hooks/common/80-install-kernel-ubuntu similarity index 100% rename from hooks/karmic/80-install-kernel rename to hooks/common/80-install-kernel-ubuntu diff --git a/hooks/karmic/80-install-kernel-ubuntu b/hooks/karmic/80-install-kernel-ubuntu new file mode 120000 index 0000000..8e66049 --- /dev/null +++ b/hooks/karmic/80-install-kernel-ubuntu @@ -0,0 +1 @@ +../common/80-install-kernel-ubuntu \ No newline at end of file