review jenkins scripts

Change-Id: I420910bd2d30e96605ecf3acb779ce726c75d912
diff --git a/contrib/jenkins-osmo-nitb.sh b/contrib/jenkins-osmo-nitb.sh
new file mode 100755
index 0000000..e655082
--- /dev/null
+++ b/contrib/jenkins-osmo-nitb.sh
@@ -0,0 +1,63 @@
+set -e -x
+
+base="$PWD"
+prefix="$base/inst-osmo-nitb"
+
+rm -f "$base/osmo-nitb*.tgz"
+
+deps="
+libosmocore
+libosmo-abis
+libosmo-netif
+openggsn
+libsmpp34
+libosmo-sccp
+openbsc
+"
+
+have_repo() {
+	repo="$1"
+	cd "$base"
+	if [ ! -e "$repo" ]; then
+		set +x
+		echo "MISSING REPOSITORY: $repo"
+		echo "should be provided by the jenkins workspace"
+		exit 1
+	fi
+	cd "$repo"
+	git clean -dxf
+	cd "$base"
+}
+
+rm -rf "$prefix"
+mkdir -p "$prefix"
+
+export PKG_CONFIG_PATH="$prefix/lib/pkgconfig"
+export LD_LIBRARY_PATH="$prefix/lib"
+
+for dep in $deps; do
+	have_repo "$dep"
+	cd "$dep"
+	rm -rf *
+	git checkout .
+
+	echo "$(git rev-parse HEAD) $dep" >> "$prefix/osmo-nitb_git_hashes.txt"
+
+	config_opts=""
+
+	case "$dep" in
+	'openbsc')
+		config_opts="$config_opts --enable-smpp --enable-osmo-bsc --enable-nat"
+		cd openbsc/
+	;;
+	esac
+
+	autoreconf -fi
+	./configure --prefix="$prefix" $config_opts
+	make -j8 || make  # libsmpp34 can't build in parallel
+	make install
+done
+
+# build the archive that is going to be copied to the tester
+cd "$prefix"
+tar czf "$base/osmo-nitb.build-${BUILD_NUMBER}.tgz" *