From c73a063f52e5db1e420121f529c1e98a9a781f74 Mon Sep 17 00:00:00 2001
From: Manuel Montecelo <mmontecelo@sipwise.com>
Date: Mon, 3 May 2021 12:12:29 +0200
Subject: [PATCH] TT#118659 Add options to install bullseye

Add options to install bullseye in all places where buster is used, use
it as default when possible, and keep these for the moment.

Switch to bullseye in Dockerfile.

Change-Id: I2f693982ba92a671a6f2254c5a245a1d05231404
---
 build_iso.sh                             |  4 ++--
 build_templates.sh                       |  2 +-
 grml_build/Dockerfile                    | 10 ++++-----
 grub.cfg                                 | 16 +++++++++++++-
 isolinux.cfg                             | 27 +++++++++++++++++++++++-
 t/Dockerfile                             | 12 +++++------
 templates/scripts/includes/deployment.sh |  6 ++++--
 7 files changed, 59 insertions(+), 18 deletions(-)

diff --git a/build_iso.sh b/build_iso.sh
index 9544bf7..29bf786 100755
--- a/build_iso.sh
+++ b/build_iso.sh
@@ -20,7 +20,7 @@ GRML2USB_VERSION='v0.18.3'
 
 usage () {
   echo "Usage: $0 compat <grml.iso> <mr version> <Debian dist>"
-  echo "Sample: $0 compat 'grml64-full_2014.11.iso' mr6.2.1 buster"
+  echo "Sample: $0 compat 'grml64-full_2014.11.iso' mr6.2.1 bullseye"
   exit 1
 }
 
@@ -116,7 +116,7 @@ mkdir -p artifacts
 echo "*** Moving ${SIPWISE_ISO} ${SIPWISE_ISO}.sha1 ${SIPWISE_ISO}.md5 to artifacts/ ***"
 mv "${SIPWISE_ISO}" "${SIPWISE_ISO}.sha1" "${SIPWISE_ISO}.md5" artifacts/
 
-docker run --rm -i --privileged -v "$(pwd)":/code/ docker.mgm.sipwise.com/deployment-iso-buster:latest \
+docker run --rm -i --privileged -v "$(pwd)":/code/ docker.mgm.sipwise.com/deployment-iso-bullseye:latest \
   /code/t/iso-tester /code/artifacts/"${SIPWISE_ISO}" /code/artifacts/memtest.jpg /code/t/screenshots/01-memtest.jpg
 
 popd &>/dev/null
diff --git a/build_templates.sh b/build_templates.sh
index 496711f..05af7e7 100755
--- a/build_templates.sh
+++ b/build_templates.sh
@@ -5,7 +5,7 @@ BASE="$(dirname "$0")"
 TEMPLATES="${TEMPLATES:-templates}"
 BOOT="${BASE}/${TEMPLATES}/boot"
 MR="${MR:-trunk}"
-DIST="${DIST:-buster}"
+DIST="${DIST:-bullseye}"
 
 echo "*** grub templates for RELEASE:${MR} DIST:${DIST} ***"
 
diff --git a/grml_build/Dockerfile b/grml_build/Dockerfile
index 0361e81..6c0d50c 100644
--- a/grml_build/Dockerfile
+++ b/grml_build/Dockerfile
@@ -1,11 +1,11 @@
-# DOCKER_NAME=grml-build-buster
-FROM docker.mgm.sipwise.com/sipwise-buster:latest
+# DOCKER_NAME=grml-build-bullseye
+FROM docker.mgm.sipwise.com/sipwise-bullseye:latest
 
 # Important! Update this no-op ENV variable when this Dockerfile
 # is updated with the current date. It will force refresh of all
 # of the base images and things like `apt-get update` won't be using
 # old cached versions when the Dockerfile is built.
-ENV REFRESHED_AT 2021-03-12
+ENV REFRESHED_AT 2021-05-04
 
 # tools for building and testing
 RUN apt-get update && apt-get install --assume-yes --no-install-recommends \
@@ -35,7 +35,7 @@ RUN apt-get update && apt-get install --assume-yes --no-install-recommends \
   wget \
   xorriso
 
-RUN echo "SECURE_BOOT=disable ./grml-live -s buster -a amd64 -c GRMLBASE,SIPWISE,AMD64 -t /code/grml-live/templates/ -o /grml/ -r grml-sipwise -v 0.42" >/root/.bash_history && \
+RUN echo "SECURE_BOOT=disable ./grml-live -s bullseye -a amd64 -c GRMLBASE,SIPWISE,AMD64 -t /code/grml-live/templates/ -o /grml/ -r grml-sipwise -v 0.42" >/root/.bash_history && \
   echo "export LIVE_CONF=/code/grml-live/etc/grml/grml-live.conf" >>/root/.bash_history && \
   echo "export SCRIPTS_DIRECTORY=/code/grml-live/scripts"         >>/root/.bash_history && \
   echo "export GRML_FAI_CONFIG=/code/grml-live/etc/grml/fai"      >>/root/.bash_history && \
@@ -84,7 +84,7 @@ WORKDIR /code/grml-live
 # export SCRIPTS_DIRECTORY=$(pwd)/scripts
 # export LIVE_CONF=$(pwd)/etc/grml/grml-live.conf
 # cp /deployment-iso/grml_build/package_config/SIPWISE /code/grml-live/etc/grml/fai/config/package_config/SIPWISE
-# ./grml-live -s buster -a amd64 -c GRMLBASE,SIPWISE,AMD64 -t $(pwd)/templates/ -o /grml/ -r grml-sipwise -v 0.42
+# ./grml-live -s bullseye -a amd64 -c GRMLBASE,SIPWISE,AMD64 -t $(pwd)/templates/ -o /grml/ -r grml-sipwise -v 0.42
 #
 ## A successful run results in ISO file in /grml/grml_isos/ (inside container),
 ## available via volume folder also outside of docker container ($pwd/grml/grml_isos/).
diff --git a/grub.cfg b/grub.cfg
index 801b8be..0bfdbb4 100644
--- a/grub.cfg
+++ b/grub.cfg
@@ -39,7 +39,7 @@ menuentry "##VERSION## Sipwise C5 CARRIER (web01a)" {
 }
 
 ## submenus
-submenu "Install Debian buster ... ->" --class=submenu {
+submenu "Install Debian buster or bullseye ... ->" --class=submenu {
 
 menuentry "Install Debian/buster 64bit" {
   echo 'Loading kernel...'
@@ -55,6 +55,20 @@ menuentry "Install Debian/buster 64bit - Puppet" {
   initrd /boot/%SHORT_NAME%/initrd.img
 }
 
+menuentry "Install Debian/bullseye 64bit" {
+  echo 'Loading kernel...'
+  linux /boot/%SHORT_NAME%/vmlinuz live-media-path=/live/%GRML_NAME%/ boot=live bootid=%BOOTID% apm=power-off mgag200.modeset=0 vga=791 quiet nomce net.ifnames=0 nongcp ssh=sipwise debianrelease=bullseye scripts 
+  echo 'Loading initrd...'
+  initrd /boot/%SHORT_NAME%/initrd.img
+}
+
+menuentry "Install Debian/bullseye 64bit - Puppet" {
+  echo 'Loading kernel...'
+  linux /boot/%SHORT_NAME%/vmlinuz live-media-path=/live/%GRML_NAME%/ boot=live bootid=%BOOTID% apm=power-off mgag200.modeset=0 vga=791 quiet nomce net.ifnames=0 nongcp ssh=sipwise debianrelease=bullseye scripts puppetenv=production dns=1.1.1.1,1.0.0.1 ip=10.15.20.123::10.15.20.1:255.255.255.0:puppet-client42:eth0:off 
+  echo 'Loading initrd...'
+  initrd /boot/%SHORT_NAME%/initrd.img
+}
+
 } # submenu "Install Debian ... ->"
 
 source /boot/grub/addons.cfg
diff --git a/isolinux.cfg b/isolinux.cfg
index ddb60c8..6190830 100644
--- a/isolinux.cfg
+++ b/isolinux.cfg
@@ -102,7 +102,7 @@ label carrier##VERSION##
 menu separator
 
 menu begin debian-options
-menu title Install Debian buster ...
+menu title Install Debian buster or bullseye ...
 
 label mainmenu
 menu label ^Back to main menu...
@@ -134,6 +134,31 @@ label busterpuppet
                                      IP address,...)
   endtext
 
+label bullseye
+  menu label Install Debian/bullseye  64bit
+  kernel /boot/%SHORT_NAME%/vmlinuz
+  append initrd=/boot/%SHORT_NAME%/initrd.img live-media-path=/live/%GRML_NAME%/ boot=live bootid=%BOOTID% apm=power-off mgag200.modeset=0 vga=791 quiet nomce net.ifnames=0 nongcp ssh=sipwise debianrelease=bullseye scripts 
+
+  text help
+                                     Install Debian bullseye, 64bit.
+                                     Does NOT install Sipwise C5 platform.
+  endtext
+
+label bullseyepuppet
+  menu label Install Debian/bullseye  64bit - Puppet
+  kernel /boot/%SHORT_NAME%/vmlinuz
+  append initrd=/boot/%SHORT_NAME%/initrd.img live-media-path=/live/%GRML_NAME%/ boot=live bootid=%BOOTID% apm=power-off mgag200.modeset=0 vga=791 quiet nomce net.ifnames=0 nongcp ssh=sipwise debianrelease=bullseye scripts puppetenv=production dns=1.1.1.1,1.0.0.1 ip=10.15.20.123::10.15.20.1:255.255.255.0:puppet-client42:eth0:off 
+
+  text help
+                                     Install Debian bullseye, 64bit using
+                                     integration in Puppet configuration
+                                     management environment.
+                                     Does NOT install Sipwise C5 platform.
+
+                                     Please adjust command line (hostname,
+                                     IP address,...)
+  endtext
+
 
 # back to main menu
 label quit
diff --git a/t/Dockerfile b/t/Dockerfile
index 1ee5662..a41a149 100644
--- a/t/Dockerfile
+++ b/t/Dockerfile
@@ -1,5 +1,5 @@
-# DOCKER_NAME=deployment-iso-buster
-FROM docker.mgm.sipwise.com/sipwise-buster:latest
+# DOCKER_NAME=deployment-iso-bullseye
+FROM docker.mgm.sipwise.com/sipwise-bullseye:latest
 
 # Important! Update this no-op ENV variable when this Dockerfile
 # is updated with the current date. It will force refresh of all
@@ -19,13 +19,13 @@ WORKDIR /code/
 # When you want to build the base image from scratch
 # jump to the next section if you don't want to build yourself!:
 #
-# % docker build --tag="deployment-iso-buster" -f t/Dockerfile .
-# % docker run --rm -i -t -v $(pwd):/code:rw deployment-iso-buster:latest bash
+# % docker build --tag="deployment-iso-bullseye" -f t/Dockerfile .
+# % docker run --rm -i -t -v $(pwd):/code:rw deployment-iso-bullseye:latest bash
 #
 # Use the existing docker image:
-# % docker pull docker.mgm.sipwise.com/deployment-iso-buster
+# % docker pull docker.mgm.sipwise.com/deployment-iso-bullseye
 # NOTE: run the following command from root folder of git repository:
-# % docker run --rm -i -t -v $(pwd):/code:rw docker.mgm.sipwise.com/deployment-iso-buster:latest bash
+# % docker run --rm -i -t -v $(pwd):/code:rw docker.mgm.sipwise.com/deployment-iso-bullseye:latest bash
 #
 # Inside docker (the command is in history, just press UP button):
 #   ./t/testrunner
diff --git a/templates/scripts/includes/deployment.sh b/templates/scripts/includes/deployment.sh
index 43b764a..b5796ea 100755
--- a/templates/scripts/includes/deployment.sh
+++ b/templates/scripts/includes/deployment.sh
@@ -282,7 +282,7 @@ ensure_packages_installed() {
       echo "Using ${deb_release} as Debian repository for ${FUNCNAME[0]}"
       ;;
     *)
-      deb_release='buster'
+      deb_release='bullseye'
       echo "Enabling fallback to Debian ${deb_release} repository for ${FUNCNAME[0]}"
       ;;
   esac
@@ -1215,7 +1215,7 @@ DHCP=false
 LOGO=true
 RETRIEVE_MGMT_CONFIG=false
 TRUNK_VERSION=false
-DEBIAN_RELEASE=buster
+DEBIAN_RELEASE=bullseye
 HALT=false
 REBOOT=false
 STATUS_DIRECTORY=/srv/deployment/
@@ -1600,6 +1600,8 @@ done
 
 ensure_packages_installed
 
+# this is important for "buster", do not update the string for "bullseye" or
+# future releases
 case "${DEBIAN_RELEASE}" in
   buster)
     UPGRADE_PACKAGES=()