jenkins: Add scripts from our jenkins installation
authorWerner Koch <wk@gnupg.org>
Thu, 8 Dec 2016 10:34:23 +0000 (11:34 +0100)
committerWerner Koch <wk@gnupg.org>
Thu, 8 Dec 2016 10:34:23 +0000 (11:34 +0100)
misc/jenkins/bin/build.bash [new file with mode: 0755]
misc/jenkins/bin/make-windows-cd.sh [new file with mode: 0644]
misc/jenkins/bin/python.txt [new file with mode: 0644]
misc/jenkins/bin/python3 [new file with mode: 0755]
misc/jenkins/bin/run-tests.bat [new file with mode: 0644]

diff --git a/misc/jenkins/bin/build.bash b/misc/jenkins/bin/build.bash
new file mode 100755 (executable)
index 0000000..23f78eb
--- /dev/null
@@ -0,0 +1,167 @@
+#!/bin/bash
+
+set -xe
+
+renice -n 10 -p $$
+
+PREFIX=$HOME/prefix/$XTARGET
+ORIGINAL_PREFIX=$HOME/prefix/$XTARGET
+export PATH=$PREFIX/bin:$PATH
+
+env
+
+# Tweak the prefix we're installing this project into.  For gnupg-1.4
+# and friends.
+case "$JOB_NAME" in
+    *-1.4*)
+        PREFIX=$PREFIX-1.4
+        ;;
+    *-2.0*)
+        PREFIX=$PREFIX-2.0
+        ;;
+    *-2.2*)
+        PREFIX=$PREFIX-2.2
+        ;;
+esac
+mkdir -p $PREFIX
+
+fix_permissions()
+{
+  find $1 -type d -exec chmod +w {} + || true
+}
+
+fix_permissions .
+git clean -fdx
+./autogen.sh
+
+MAKEFLAGS="-j2"
+SCANBUILD=
+if [ "$(uname)" = Linux ]; then
+    # XXX: We should really have an analyzer target
+    SCANBUILD="scan-build -o ${WORKSPACE}/clangScanBuildReports -v"
+fi
+CONFIGUREFLAGS=
+SANFLAGS=""
+if [ "$(uname)" = Linux ]; then
+    # XXX: We should really have an analyzer target
+    SANFLAGS="-fsanitize=undefined -fsanitize=address"
+fi
+
+if [ "$(uname)" = Darwin ]; then
+    # XXX until we properly set this somewhere else
+    cversion="_DARWIN_C_SOURCE=900000L"
+    CFLAGS="$CFLAGS -D$cversion"
+    CXXFLAGS="$CXXFLAGS -D$cversion"
+fi
+
+case "$JOB_NAME" in
+    *tgpg*)
+        MAKEFLAGS="$MAKEFLAGS GPG=/usr/bin/gpg2"
+        ;;
+    *gpgme*)
+        # using libasan for python broke again, so disable the python bindings for the native build
+        if [ "$XTARGET" = native ] && [ "$label" != macos ]; then
+            CONFIGUREFLAGS_0="--enable-languages=cpp qt"
+        fi
+        ;;
+    *gnupg*)
+        if [ "$XTARGET" = native ]; then
+            CONFIGUREFLAGS="--enable-wks-tools --enable-g13 --enable-symcryptrun --enable-gpg2-is-gpg"
+        fi
+        if [ "$XTARGET" = w32 ]; then
+            CONFIGUREFLAGS="--enable-wks-tools --enable-gpg2-is-gpg --with-zlib=$ORIGINAL_PREFIX --with-bzip2=$ORIGINAL_PREFIX"
+        fi
+       if [ "$NODE_NAME" = zygalski ]; then
+           CONFIGUREFLAGS="$CONFIGUREFLAGS --with-libiconv-prefix=$HOME/pkg"
+       fi
+        ;;
+esac
+
+abs_configure="$(pwd)/configure"
+mkdir -p obj
+cd obj
+
+case "$XTARGET" in
+    native)
+        ASAN_OPTIONS=detect_leaks=0 \
+        $SCANBUILD \
+            ../configure --prefix=$PREFIX --enable-maintainer-mode \
+                  $CONFIGUREFLAGS \
+                  "$CONFIGUREFLAGS_0" \
+                  CFLAGS="$CFLAGS $SANFLAGS -fPIC" \
+                  CXXFLAGS="$CXXFLAGS $SANFLAGS -fPIC -std=c++11"
+        $SCANBUILD make $MAKEFLAGS
+
+        # so make sure the asan runtime is there for e.g. python
+        PATH=/home/jenkins/bin:$PATH \
+        LD_LIBRARY_PATH=$PREFIX/lib \
+          make check verbose=2 LD_LIBRARY_PATH=$PREFIX/lib || true
+        # Jenkins looks for "tests? failed" to mark a build unstable,
+        # hence || true here
+
+        make install
+        ;;
+    w32)
+        export w32root=$PREFIX
+
+       # autogen.rc adds --with-gpg-error-prefix=@SYSROOT@, so we cannot
+       # install to a prefix that doesn't also contain all the dependencies,
+       # patch that out, so that the gpg-error-config and friends are located
+       # using PATH
+       if [ -f "/home/jenkins/bin/$(dirname $JOB_NAME)-w32.patch" ]; then
+         ( cd .. && patch -p1 <"/home/jenkins/bin/$(dirname $JOB_NAME)-w32.patch" )
+       fi
+       # We need to point it to npth and adns then...
+       CONFIGUREFLAGS="${CONFIGUREFLAGS} --with-npth-prefix=$ORIGINAL_PREFIX --with-adns=$ORIGINAL_PREFIX"
+
+        # gpg1's autogen.sh does not add --enable-maintainer-mode, so
+        # version.texi is not generated.  we add it here to be sure.
+        # likewise for --prefix
+        ../autogen.sh --build-w32 --enable-maintainer-mode --prefix=$PREFIX \
+          $CONFIGUREFLAGS
+        make $MAKEFLAGS
+        make install
+
+       case "$JOB_NAME" in
+               gnupg/*|gnupg-2.2/*)
+                       bash /home/jenkins/bin/make-windows-cd.sh
+                       ;;
+       esac
+        ;;
+    distcheck)
+        CONFIGUREFLAGS=
+       WORKDIR="$(mktemp -d)"
+       cleanup()
+       {
+         cd /tmp
+         fix_permissions "$WORKDIR"
+         rm -rf -- "$WORKDIR" || true
+       }
+       trap cleanup EXIT
+
+         cd "$WORKDIR"
+          $abs_configure --prefix=$PREFIX --enable-maintainer-mode \
+                   $CONFIGUREFLAGS LD_LIBRARY_PATH=$PREFIX/lib
+          make $MAKEFLAGS distcheck
+          tarname=$(awk <config.h '
+                    /^#define PACKAGE_TARNAME/ {gsub(/"/,"",$3);name=$3};
+                    /^#define PACKAGE_VERSION/ {gsub(/"/,"",$3);vers=$3};
+                    END {print name "-" vers}')
+         if [ -f "${tarname}.tar.bz2" ]; then
+            bzcat "${tarname}.tar.bz2" | tar xf -
+         elif [ -f "${tarname}.tar.gz" ]; then
+            zcat "${tarname}.tar.gz" | tar xf -
+          else
+            echo "No tarball named $tarname found - skipping installation" >&2
+            exit 0
+         fi
+         cd ${tarname}
+         ./configure --prefix=$PREFIX $CONFIGUREFLAGS LD_LIBRARY_PATH=$PREFIX/lib
+         make $MAKEFLAGS
+         make $MAKEFLAGS install
+
+        ;;
+    *)
+        echo "Bad XTARGET: '$XTARGET'"
+        exit 2
+esac
diff --git a/misc/jenkins/bin/make-windows-cd.sh b/misc/jenkins/bin/make-windows-cd.sh
new file mode 100644 (file)
index 0000000..a66c38a
--- /dev/null
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+set -ex
+
+if ! [ -f config.log ] || ! grep -q mingw config.log; then
+    echo "must be run from a configured windows build environment"
+fi
+
+[ -z "$w32root" ] && w32root="$HOME/w32root"
+ADDITIONAL_FILES=
+IMAGE=gnupg-test.iso
+
+[ -f make-windows-cd.rc ] && . make-windows-cd.rc
+
+# we pick binaries from the prefix, so make sure they are current.
+make install
+
+WORKDIR="$(mktemp --directory)"
+TARGET="${WORKDIR}/gnupg"
+
+mkdir "$TARGET"
+
+[ "$ADDITIONAL_FILES" ] && cp -v $(ls -1 $ADDITIONAL_FILES) $TARGET
+cp -v $w32root/bin/*.exe $w32root/bin/*.dll $TARGET
+cp -v tests/gpgscm/*.exe $TARGET
+# XXX mk-tdata is on the way out
+cp -v tools/mk-tdata.exe $TARGET || true
+cp -v agent/gpg-preset-passphrase.exe $TARGET
+cp -v -a ../tests $TARGET
+cp -v tests/openpgp/fake-pinentry.exe $TARGET
+cp -v /home/jenkins/bin/run-tests.bat $WORKDIR
+genisoimage --output "$IMAGE" -J "$WORKDIR"
+[ "${WORKDIR}" ] && rm -rf -- "${WORKDIR}"
diff --git a/misc/jenkins/bin/python.txt b/misc/jenkins/bin/python.txt
new file mode 100644 (file)
index 0000000..6eaf41a
--- /dev/null
@@ -0,0 +1 @@
+leak:python
diff --git a/misc/jenkins/bin/python3 b/misc/jenkins/bin/python3
new file mode 100755 (executable)
index 0000000..fed5c24
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/sh
+LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libasan.so.2 \
+LSAN_OPTIONS=suppressions=/home/jenkins/bin/python.txt \
+exec /usr/bin/python3 "$@"
diff --git a/misc/jenkins/bin/run-tests.bat b/misc/jenkins/bin/run-tests.bat
new file mode 100644 (file)
index 0000000..d88e197
--- /dev/null
@@ -0,0 +1,27 @@
+@echo off
+cd /d d:\
+
+set TARGET=gnupg-test
+
+set GNUPGHOME=c:/%TARGET%/tests/openpgp
+c:/%TARGET%/gpg-connect-agent.exe killagent /bye
+rem is there a nicer way to sleep?
+ping -n 1 localhost > nul
+set GNUPGHOME=
+
+rmdir /q /s c:\%TARGET%
+mkdir c:\%TARGET%
+xcopy /q /s d:\gnupg c:\%TARGET%
+
+set GPGSCM_PATH=c:/%TARGET%/tests/gpgscm;c:/%TARGET%/tests/openpgp
+set EXEEXT=.exe
+set srcdir=/%TARGET%/tests/openpgp
+set BIN_PREFIX=c:/%TARGET%
+set TMP=c:\temp
+mkdir %TMP%
+
+cd /d c:\%TARGET%
+c:\%TARGET%\gpgscm.exe --verbose tests/gpgscm/t-child.scm
+
+cd /d c:\%TARGET%\tests\openpgp
+c:\%TARGET%\gpgscm.exe run-tests.scm --shared version.scm mds.scm decrypt.scm decrypt-dsa.scm sigs.scm sigs-dsa.scm encrypt.scm encrypt-dsa.scm seat.scm clearsig.scm encryptp.scm detach.scm detachm.scm armsigs.scm armencrypt.scm armencryptp.scm signencrypt.scm signencrypt-dsa.scm armsignencrypt.scm armdetach.scm armdetachm.scm genkey1024.scm conventional.scm conventional-mdc.scm multisig.scm verify.scm gpgv-forged-keyring.scm armor.scm import.scm ecc.scm 4gb-packet.scm tofu.scm gpgtar.scm use-exact-key.scm default-key.scm export.scm ssh.scm quick-key-manipulation.scm issue2015.scm issue2346.scm issue2417.scm issue2419.scm