Clean up apt package list 91/891/10
authorC.J. Collier <cjac@probook0.colliertech.org>
Sun, 24 Apr 2016 18:00:46 +0000 (11:00 -0700)
committerC.J. Collier <cjcollier@linuxfoundation.org>
Mon, 2 May 2016 22:02:47 +0000 (15:02 -0700)
* Combine all packages in to a single call to apt-get install
* Modify /etc/apt/apt.conf
* corrected a comment
* not doing redundant edit of /etc/sysctl.conf
* adding emacs files to .gitignore
* Exercised this code while producing a new base image for each targetted platform
* install java8 from official openjdk PPA if platform is 14.04
* detect correct python package to install in CentOS
* open (and later close) stdout and stderr logs for later review

Change-Id: I669c0c3043f0c90df7af5033b8e180b0e6dc696a
Signed-off-by: C.J. Collier <cjcollier@linuxfoundation.org>
.gitignore
vagrant/basebuild/Vagrantfile
vagrant/basebuild/bootstrap.sh

index 96b3329..4c0dafd 100644 (file)
@@ -13,3 +13,8 @@ target/
 # IntelliJ
 .idea/
 *.iml
+
+# Emacs
+*~
+\.\#*
+\#*
index e8d6a0a..0ee17e0 100644 (file)
@@ -44,8 +44,7 @@ Vagrant.configure(2) do |config|
   config.vm.synced_folder ".", "/vagrant"\r
   config.vm.synced_folder "../lib/", "/vagrant/lib"\r
 \r
-  # Do a full system update and force enforcing on (it's in permissive\r
-  # by default in the rackspace base images)\r
+  # Do a full system update and set enforcing on\r
   config.vm.provision 'shell', path: 'bootstrap.sh'\r
 \r
   #################\r
index f289c63..140f4b0 100644 (file)
+#!/bin/bash -x
+
+# die on errors
+set -e
+
+# Redirect stdout ( 1> ) and stderr ( 2> ) into named pipes ( >() ) running "tee"
+exec 1> >(tee -i /tmp/bootstrap-out.log)
+exec 2> >(tee -i /tmp/bootstrap-err.log)
 
 ubuntu_systems() {
 
-    if [ "$(lsb_release -r | awk '{print $2}')" == "14.04" ]
+    LSB_PATH=$(which lsb_release)
+
+    if [ $? == 0 ]
+    then
+        VERSION=$(lsb_release -r | awk '{print $2}')
+        DIST=$(lsb_release -i | awk '{print $3}')
+        CODENAME=$(lsb_release -c | awk '{print $2}')
+    else
+        ISSUE_TXT=$(head -1 /etc/issue)
+        DIST=$(echo ${ISSUE_TXT} | awk '{print $1}')
+        if [ "$DIST" = "Ubuntu" ]
+        then
+            VERSION=$(echo ${ISSUE_TXT} | awk '{print $2}' | sed -e 's/^(\d+\.\d+)(\.\d+)?$/\1/')
+        elif [ "$DIST" = "Debian" ]
+        then
+            VERSION=$(echo ${ISSUE_TXT} | awk '{print $3}')
+        else
+            echo "Unrecognized distribution: ${DIST}"
+        fi
+    fi
+
+    echo "Detected [${DIST} v${VERSION} (${CODENAME})]"
+
+    export DEBIAN_FRONTEND=noninteractive
+    cat <<EOF >> /etc/apt/apt.conf
+APT {
+  Get {
+    Assume-Yes "true";
+    allow-change-held-packages "true";
+    allow-downgrades "true";
+    allow-remove-essential "true";
+  };
+};
+
+Dpkg::Options {
+   "--force-confdef";
+   "--force-confold";
+};
+
+EOF
+
+    # Install plymouth labels and themes to get rid of initrd warnings / errors
+    if [ "$VERSION" = '14.04' ]
     then
+
         # openjdk-8-jdk is not available in 14.04 repos by default
         add-apt-repository ppa:openjdk-r/ppa
+
+        # Install OpenJDK
+        PACKAGES="$PACKAGES openjdk-8-jdk"
+
+        # Install Oracle's jdk version 8
+#        apt-add-repository -y ppa:webupd8team/java
+#        apt-get -qq update
+#        echo "debconf shared/accepted-oracle-license-v1-1 select true
+#              debconf shared/accepted-oracle-license-v1-1 seen true" | sudo debconf-set-selections
+#        PACKAGES="$PACKAGES oracle-java8-installer"
+    else
+        # Install default jdk and plymouth packages
+        PACKAGES="$PACKAGES plymouth-themes plymouth-label default-jdk"
     fi
 
+
     # Standard update + upgrade dance
-    apt-get update
-    apt-get upgrade -y
+    apt-get -qq update
+    apt-get -qq upgrade
+    apt-get -qq dist-upgrade
 
     # Fix the silly notion that /bin/sh should point to dash by pointing it to bash
 
-    sudo update-alternatives --install /bin/sh sh /bin/bash 100
+    update-alternatives --install /bin/sh sh /bin/bash 100
 
     # Install build tools
-    apt-get install -y build-essential autoconf automake bison libssl-dev ccache libtool git dkms debhelper libganglia1-dev libapr1-dev libconfuse-dev dh-systemd
+    PACKAGES="build-essential autoconf automake bison libssl-dev ccache libtool git dkms debhelper libganglia1-dev libapr1-dev libconfuse-dev"
 
-    # Install other stuff
-    apt-get install -y --force-yes bridge-utils vim gdb iproute2
+    # Install interface manipulation tools, editor, debugger and lsb
+    PACKAGES="$PACKAGES iproute2 bridge-utils vim gdb lsb-release"
 
     # Install debian packaging tools
-    apt-get install -y debhelper dkms
+    PACKAGES="$PACKAGES debhelper dh-systemd dkms"
 
-    # Install uio
-    apt-get install -y linux-image-extra-`uname -r`
+    # Install latest kernel and uio
+    PACKAGES="$PACKAGES linux-image-extra-virtual"
 
-    # Install jdk and maven
-    apt-get install -y openjdk-8-jdk
     # $$$ comment out for the moment
-    # apt-get install -y --force-yes maven3
+    # PACKAGES="$PACKAGES maven3"
+
+    # Install virtualenv for test execution
+    PACKAGES="$PACKAGES python-virtualenv python-pip python-dev"
+
+    apt-get -qq install ${PACKAGES}
+    apt-get -qq autoremove
+    apt-get -qq clean
 
-    # Load the uio kernel module
-    modprobe uio_pci_generic
+    # It is not necessary to load the uio kernel module during the bootstrap phase
+#    modprobe uio_pci_generic
 
     # Make sure uio loads at boot time
     echo uio_pci_generic >> /etc/modules
 
-    # Setup for hugepages using upstart so it persists across reboots
+    # Setup for hugepages using sysctl so it persists across reboots
     sysctl -w vm.nr_hugepages=1024
+
     mkdir -p /mnt/huge
     echo "hugetlbfs       /mnt/huge  hugetlbfs       defaults        0 0" >> /etc/fstab
     mount /mnt/huge
 
-    # Install virtualenv for test execution
-    apt-get install -y --force-yes python-virtualenv python-pip python-dev python3-dev
 }
 
 rh_systems() {
@@ -58,7 +128,13 @@ rh_systems() {
     yum install -y java-1.8.0-openjdk-devel
 
     # Install python development
-    yum install -y python34-devel
+    yum search python34-devel 2>&1 | grep -q 'No matches'
+    if [ $? -eq 0 ]
+    then
+        yum install -y python-devel
+    else
+        yum install -y python34-devel
+    fi
 
     # Install EPEL
     yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
@@ -92,3 +168,10 @@ case "$OS" in
         echo "---> Unknown operating system"
     ;;
 esac
+
+echo "bootstrap process (PID=$$) complete."
+
+exec 1>&- # close STDOUT
+exec 2>&- # close STDERR
+
+exit 0