VPP: new clang job offloading current build
[ci-management.git] / packer / provision / baseline.sh
index 82edb3f..2546d44 100644 (file)
@@ -120,12 +120,13 @@ EOF
     cat << 'EOF' >> /usr/local/bin/apt-get
 #!/bin/bash
 
+TTY=$(tty)
+test -z "$TTY" && TERM=dumb
+
 i=0
 tput sc
-LOCKFILES="/var/lib/dpkg/lock /var/lib/apt/lists/lock"
-WASLOCKED=0
-while [ fuser ${LOCKFILES} >/dev/null 2>&1 ]; do
-    WASLOCKED=$?
+LOCKFILES="/var/lib/dpkg/lock /var/lib/apt/lists/lock /var/cache/apt/archives/lock"
+while fuser ${LOCKFILES} >/dev/null 2>&1 ; do
     case $(($i % 4)) in
         0 ) j="-" ;;
         1 ) j="\\" ;;
@@ -138,10 +139,11 @@ while [ fuser ${LOCKFILES} >/dev/null 2>&1 ]; do
     ((i=i+1))
 done
 
-if [ $WASLOCKED==0 ]
+if [ $i==0 ]
 then
   /usr/bin/apt-get "$@"
 else
+  sleep 1
   exec /usr/local/bin/apt-get "$@"
 fi
 
@@ -206,6 +208,38 @@ EOF
 
 }
 
+opensuse_systems() {
+    # SELinux?
+
+    # Replacing cloud.cfg, it's not supported by cloud-init
+    cp /etc/cloud/cloud.cfg /etc/cloud/cloud.cfg.orig
+
+    # Clean and add repos and refresh
+    zypper clean -a
+    zypper --non-interactive --gpg-auto-import-keys ar \
+        http://download.opensuse.org/update/leap/42.3/oss/openSUSE:Leap:42.3:Update.repo
+    zypper --gpg-auto-import-keys ref
+    zypper --non-interactive --gpg-auto-import-keys ar \
+        http://download.opensuse.org/repositories/Cloud:/Tools/openSUSE_Leap_42.3/ Cloud:Tools.repo
+
+    # Add in components we need or want on systems
+    echo "---> Installing base packages"
+    zypper -n install unzip xz puppet perl-XML-XPath
+
+    # Instlal tools
+    echo "---> Installing tools packages"
+    zypper -n install git git-review wget libstdc++-devel ruby-devel
+
+    # All of our systems require Java (because of Jenkins)
+    echo "---> Configuring OpenJDK"
+    zypper -n install 'java-*-openjdk-devel'
+
+    # Needed to parse OpenStack commands used by infra stack commands
+    # to initialize Heat template based systems.
+    zypper -n install jq
+
+}
+
 all_systems() {
     # Allow jenkins access to update-alternatives command to switch java version
     cat <<EOF >/etc/sudoers.d/89-jenkins-user-defaults
@@ -236,10 +270,15 @@ echo "---> Attempting to detect OS"
 ORIGIN=$(if [ -e /etc/redhat-release ]
     then
         echo redhat
-    else
+    else [ -e /etc/os-release ]
+      DIST="$(grep "\<ID\>" /etc/os-release)"
+      if [ $DIST = "ID=ubuntu" ]
+      then
         echo ubuntu
+      else
+        echo opensuse
+      fi
     fi)
-#ORIGIN=$(logname)
 
 case "${ORIGIN}" in
     fedora|centos|redhat)
@@ -250,6 +289,10 @@ case "${ORIGIN}" in
         echo "---> Ubuntu system detected"
         ubuntu_systems
     ;;
+    opensuse)
+        echo "---> openSuSE system detected"
+        opensuse_systems
+    ;;
     *)
         echo "---> Unknown operating system"
     ;;