Permalink
Browse files

Refactor test install script to be DRYer

  • Loading branch information...
Patrick J Cherry
Patrick J Cherry committed Aug 21, 2018
1 parent c98797a commit d3180ec7c723a69752867de0c8b719ea8749cd1b
Showing with 21 additions and 32 deletions.
  1. +21 −32 test/internal-test.d/02-install-and-upgrade
@@ -24,49 +24,38 @@ APT_LIST=/etc/apt/sources.list.d/symbiosis.list
# upgrade - upgrade to latest from a symbiosis-stretch base
# dist-upgrade - upgrade to latest from symbiosis-jessie

if [ "upgrade" = "$ACTION" ] ; then
do_upgrade() {
echo "I: seed debconf"
debconf-set-selections < "$CONF/debconf-preseed"
debconf-set-selections < "$1/debconf-preseed"

echo "I: Install current symbiosis.bytemark.co.uk release"
echo "deb http://symbiosis.bytemark.co.uk/$DEBIAN_RELEASE/ ./" > $APT_LIST
echo "I: perform update"
apt-get $APT_OPTS update
apt-get $APT_OPTS install $(< $CONF/packages)

echo "I: Re-seed debconf"
debconf-set-selections < "$CONF/debconf-preseed"
echo "I: perform $2"
if [ "$2" = "install" ] ; then
apt-get $APT_OPTS install $(< $1/packages)
else
apt-get $APT_OPTS $2
fi
}

echo "I: Add new version's sources"
cp $CONF/sources.list $APT_LIST
echo "deb http://repo.bytemark.co.uk/open-source/symbiosis/$BRANCH_NAME/latest/ ./" >> $APT_LIST
apt-get $APT_OPTS upgrade
if [ "upgrade" = "$ACTION" ] ; then
echo "I: Install current symbiosis.bytemark.co.uk release"
echo "deb http://symbiosis.bytemark.co.uk/$DEBIAN_RELEASE/ ./" > $APT_LIST

elif [ "dist-upgrade" = "$ACTION" ] ; then
echo "I: seed debconf with $OLD_DEBIAN_RELEASE config"
debconf-set-selections < "$OLD_CONF/debconf-preseed"
do_upgrade $CONF install

elif [ "dist-upgrade" = "$ACTION" ] ; then
echo "I: Install $OLD_DEBIAN_RELEASE version of Symbiosis from symbiosis.bytemark.co.uk"
echo "deb http://symbiosis.bytemark.co.uk/$OLD_DEBIAN_RELEASE/ ./" > $APT_LIST
apt-get $APT_OPTS update
apt-get $APT_OPTS install $(< $OLD_CONF/packages)

echo "I: Re-seed debconf with $DEBIAN_RELEASE config"
debconf-set-selections < "$CONF/debconf-preseed"
do_upgrade $OLD_CONF install

echo "I: Add new version's sources"
cp $CONF/sources.list $APT_LIST
echo "deb http://repo.bytemark.co.uk/open-source/symbiosis/$BRANCH_NAME/latest/ ./" >> $APT_LIST
sed -e "s/$OLD_DEBIAN_RELEASE/$DEBIAN_RELEASE/g" -i /etc/apt/sources.list
cat /etc/apt/sources.list $APT_LIST

echo "I: Perform dist-upgrade"
apt-get $APT_OPTS update
apt-get $APT_OPTS dist-upgrade
else
echo "I: Install latest version of Symbiosis from repo.bytemark.co.uk"
cp $CONF/sources.list $APT_LIST
echo "deb http://repo.bytemark.co.uk/open-source/symbiosis/$BRANCH_NAME/latest/ ./" >> $APT_LIST
apt-get $APT_OPTS update
apt-get $APT_OPTS install $(< $CONF/packages)
fi

echo "I: $ACTION $BRANCH_NAME version of Symbiosis from repo.bytemark.co.uk"
cp $CONF/sources.list $APT_LIST
echo "deb http://repo.bytemark.co.uk/open-source/symbiosis/$BRANCH_NAME/latest/ ./" >> $APT_LIST

do_upgrade $CONF $ACTION

0 comments on commit d3180ec

Please sign in to comment.