summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/Packaging')
-rwxr-xr-xSwift/Packaging/Debian/Testing/swift-distr-tests.sh97
-rw-r--r--Swift/Packaging/Debian/Testing/test-distr.sh88
2 files changed, 185 insertions, 0 deletions
diff --git a/Swift/Packaging/Debian/Testing/swift-distr-tests.sh b/Swift/Packaging/Debian/Testing/swift-distr-tests.sh
new file mode 100755
index 0000000..8d03282
--- /dev/null
+++ b/Swift/Packaging/Debian/Testing/swift-distr-tests.sh
@@ -0,0 +1,97 @@
+#!/usr/bin/env bash
+
+# Returns 0 if all releases are valid. Needs to be run with sudo
+# release_level is the level of the release to test.
+# 2 will test development stream only
+# 1 will test development and beta
+# 0 will test all three development, beta and release
+
+function finish {
+ if [ "$?" -eq 0 ] && [ "$CLEAN_INSTALL" = True ]; then
+ echo "No errors found, removing base systems."
+ rm -rf "Debian-Tests/"
+ fi
+}
+trap finish EXIT
+
+if [ "$#" -lt 2 ] || [ "$#" -gt 3 ]; then
+ echo "Usage $0 <release_tag> <release_level> [-c]"
+ echo "The -c flag will recreate all base systems."
+ exit 1
+fi
+RELEASE_LEVEL="$2"
+re='^[0-9]+$'
+if ! [[ "$RELEASE_LEVEL" =~ $re ]]; then
+ echo "error: release level is not a number" >&2; exit 1
+fi
+if [ "$RELEASE_LEVEL" -gt 2 ] || [ "$RELEASE_LEVEL" -lt 0 ]; then
+ echo "error: release level should be between 0 and 2" >&2; exit 1
+fi
+if [ "$3" == "-c" ]; then
+ echo "The script will create all base systems from scratch."
+ CLEAN_INSTALL=True
+else
+ CLEAN_INSTALL=False
+fi
+
+declare -A arr
+#Ubuntu xenial
+arr[0,0]="ubuntu"
+arr[0,1]="http://archive.ubuntu.com/ubuntu"
+arr[0,2]="xenial"
+
+#Ubuntu yakkety
+arr[1,0]="ubuntu"
+arr[1,1]="http://archive.ubuntu.com/ubuntu"
+arr[1,2]="yakkety"
+
+#Debian jessie
+arr[2,0]="debian"
+arr[2,1]="http://deb.debian.org/debian/"
+arr[2,2]="jessie"
+
+#Debian sid
+arr[3,0]="debian"
+arr[3,1]="http://deb.debian.org/debian/"
+arr[3,2]="sid"
+
+DIST="$1"
+RETURN_VALUE=0
+
+for counter in {0..3}
+do
+# for ARCH in "amd64" "i386"
+ for ARCH in "amd64"
+ do
+ echo "========================================"
+ echo "Testing ${arr[${counter},0]} ${arr[${counter},2]} $ARCH"
+ echo "========================================"
+ DIST_FOLDER="Debian-Tests/${arr[${counter},0]}_${arr[${counter},2]}_$ARCH"
+ if [ "$CLEAN_INSTALL" = True ] ; then
+ rm -rf "$DIST_FOLDER"
+ echo "Removing $DIST_FOLDER"
+ fi
+ if [ ! -d "$DIST_FOLDER" ]; then
+ echo "$DIST_FOLDER was not present. Creating Base system from scratch."
+ {
+ mkdir -p "$DIST_FOLDER"
+ debootstrap --arch=$ARCH ${arr[${counter},2]} $DIST_FOLDER ${arr[${counter},1]}
+ } &>/dev/null
+ echo "Setup complete."
+ fi
+ cp test-distr.sh "$DIST_FOLDER"
+
+ RELEASES_COUNT=0
+ for RELEASE in "development" "beta" "release"
+ do
+ if [[ "$RELEASES_COUNT" -le "$RELEASE_LEVEL" ]]; then
+ chroot $DIST_FOLDER bash test-distr.sh https://swift.im/packages/${arr[${counter},0]}/${arr[${counter},2]} ${arr[${counter},2]} $DIST $RELEASE
+ RETURN_VALUE=$((RETURN_VALUE + $?))
+ else
+ echo "Skipping stream: $RELEASE"
+ fi
+ RELEASES_COUNT=$((RELEASES_COUNT + 1))
+ done
+ done
+done
+exit $RETURN_VALUE
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