17535: Modify the image-common script so it can work both in centos/debian
authorJavier Bértoli <jbertoli@curii.com>
Thu, 22 Jul 2021 15:37:19 +0000 (12:37 -0300)
committerJavier Bértoli <jbertoli@curii.com>
Thu, 22 Jul 2021 15:37:19 +0000 (12:37 -0300)
Arvados-DCO-1.1-Signed-off-by: Javier Bértoli <jbertoli@curii.com>

jenkins/packer-images/jenkins-image-common.sh

index b06512da885db377836e1a7807e640daa3e4bdeb..c7118d2c20d436db66bc83de9bedf058ae40f794 100755 (executable)
@@ -13,11 +13,25 @@ sudo su -c "echo ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDH8swFWEfEfHhA+C5ezV8SXO/
 echo "deb http://deb.debian.org/debian buster-backports main" | sudo tee /etc/apt/sources.list.d/buster-backports.list
 
 # Install a few dependency packages
-sudo su -c "apt-get update"
-sudo su -c "DEBIAN_FRONTEND=noninteractive apt install -y git netcat default-jdk"
-# Remove unattended-upgrades so that it doesn't interfere with our nodes at startup
-sudo su -c "DEBIAN_FRONTEND=noninteractive apt-get remove -y unattended-upgrades"
-sudo su -c "DEBIAN_FRONTEND=noninteractive apt-get autoremove -y"
+# First, let's figure out the OS we're working on
+OS_ID=$(grep ^ID= /etc/os-release |cut -f 2 -d \")
+case ${OS_ID} in
+  "centos")
+    PREINSTALL_CMD="/bin/true"
+    INSTALL_CMD="yum -y"
+    POSTINSTALL_CMD="/bin/true"
+    PKGS="git java-11-openjdk"
+  "debian","ubuntu")
+    INSTALL_CMD="DEBIAN_FRONTEND=noninteractive apt install -y"
+    # SUFFIX packages with - to remove them
+    # Remove unattended-upgrades so that it doesn't interfere with our nodes at startup
+    PKGS="git default-jdk unattended-upgrades-"
+    POSTINSTALL_CMD="DEBIAN_FRONTEND=noninteractive apt autopurge -y"
+esac
+
+sudo su -c "${PREINSTALL_CMD}"
+sudo su -c "${INSTALL_CMD} ${PKGS}"
+sudo su -c "${POSTINSTALL_CMD}"
 
 # create a reference repository (bare git repo)
 # jenkins will use this to speed up the checkout for each job