summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThanos Doukoudakis <thanos.doukoudakis@isode.com>2017-05-31 16:03:07 (GMT)
committerTobias Markmann <tm@ayena.de>2017-06-16 10:08:35 (GMT)
commitccefa0d4d90fd89a6d7e9cd6167066f3797020d7 (patch)
tree0e9b45b82af2f5fb46cbc53e75b0090406c1e319 /Swift/Packaging/Debian/Testing/test-distr.sh
parenta41e644c73b97fbac18479ec86cfb975c3758ae2 (diff)
downloadswift-ccefa0d4d90fd89a6d7e9cd6167066f3797020d7.zip
swift-ccefa0d4d90fd89a6d7e9cd6167066f3797020d7.tar.bz2
Add scripts that test Debian packages
Adding two scripts that will test Ubuntu(xenial – yakkety) and Debian(jessie - sid) distributions. The script will create a base system of the distribution and then add the swift distribution channels. It will then test the version of the binary and source packages that are available in the channel, and then it will attempt to install swift and all its dependencies. Test-Information: Tested on Ubuntu 16.04 (host) Change-Id: I977e72223a4688672d64b39c22c966aa143bc060
Diffstat (limited to 'Swift/Packaging/Debian/Testing/test-distr.sh')
-rw-r--r--Swift/Packaging/Debian/Testing/test-distr.sh88
1 files changed, 88 insertions, 0 deletions
diff --git a/Swift/Packaging/Debian/Testing/test-distr.sh b/Swift/Packaging/Debian/Testing/test-distr.sh
new file mode 100644
index 0000000..82d31ee
--- /dev/null
+++ b/Swift/Packaging/Debian/Testing/test-distr.sh
@@ -0,0 +1,88 @@
+#!/usr/bin/env bash
+
+# Return values
+# 0 if the package, source and installation were successful
+# 1 if the source packages are missing
+# 2 if the binary is not present in the repository
+# 3 if the binary and source packages are not present in the repository
+# 4 if the binary failed to install
+# 5 if the binary failed to install and the source package is not available.
+
+function finish {
+ rm /etc/apt/sources.list.d/swift-distr.list
+ if [[ "$1" != "*ubuntu*" ]]; then
+ rm /etc/apt/sources.list.d/ubuntu-universe.list
+ fi
+ {
+ rm -rf swift-im* packages.key*
+ apt-get remove -y swift-im
+ apt-get autoremove -y
+ } &>/dev/null
+}
+trap finish EXIT
+
+if [ "$#" -ne 4 ]; then
+ echo "Usage $0 <remote_repository> <dist_code_name> <swift_version> <release> "
+ exit 1
+fi
+RELEASE="$4"
+echo "Repository $1 build $RELEASE contents:"
+echo "------------------------"
+
+#Adding the swift repository
+echo deb $1 $RELEASE main >/etc/apt/sources.list.d/swift-distr.list
+echo deb-src $1 $RELEASE main >>/etc/apt/sources.list.d/swift-distr.list
+
+#Adding the ubuntu universe repository if it is not present.
+if [[ "$1" != "*ubuntu*" ]]; then
+ if ! grep -q '^deb http://archive.ubuntu.com/ubuntu '"$2"' universe' /etc/apt/sources.list /etc/apt/sources.list.d/*.list; then
+ echo deb http://archive.ubuntu.com/ubuntu $2 universe >/etc/apt/sources.list.d/ubuntu-universe.list
+ fi
+fi
+
+{
+ apt-get remove -y swift-im
+ apt-get autoremove -y
+ apt-get update
+ apt-get upgrade -y
+ apt-get install -y apt-transport-https wget
+ apt-get install -y dpkg-dev
+ wget http://swift.im/keys/packages.key
+ apt-key add packages.key
+ apt-get update
+} &>/dev/null
+
+RETURN_VALUE=0
+echo "Sources:"
+{
+ rm -rf swift-im*
+ apt-get source swift-im=$3
+} &>/dev/null
+if [ "$?" -eq 0 ]; then
+ echo "Sources files downloaded."
+else
+ echo "Sources files not present"
+ RETURN_VALUE=$((RETURN_VALUE + ((1 << 0))))
+fi
+
+echo "Binary:"
+{
+ apt-cache show swift-im=$3*
+} &>/dev/null
+if [ "$?" -ne 0 ]; then
+ echo "Swift package was not found in the repository."
+ RETURN_VALUE=$((RETURN_VALUE + ((1 << 1))))
+ exit $RETURN_VALUE
+fi
+echo "Installing binaries"
+{
+ apt-get install -y swift-im=$3*
+} &>/dev/null
+if [ "$?" -eq 0 ]; then
+ echo "Installation was successful."
+else
+ echo "Installation failed"
+ RETURN_VALUE=$((RETURN_VALUE + ((1 << 2))))
+fi
+echo "------------------------"
+exit $RETURN_VALUE