[MERGED] openbsc[master]: jenkins.sh: remove code dup

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Thu Jul 14 01:45:27 UTC 2016


Neels Hofmeyr has submitted this change and it was merged.

Change subject: jenkins.sh: remove code dup
......................................................................


jenkins.sh: remove code dup

Have a bash function to build each dependency with the same commands.  There is
a tradeoff: having each dependency build with the same function means you can't
easily tweak one of the dependencies. OTOH having a unified function means a)
more readable script, b) that we're sure not to forget some steps and c) no
need to do the same edit n times.

Set the PKG_CONFIG_PATH globally. Also a tradeoff: if a future addition
wouldn't need the same PKG_CONFIG_PATH, this would make things ugly. But that
is actually quite unlikely, and the readability improvement is substantial.

Use env variables to remember local paths. That means we always are sure to cd
to the same absolute base path, which a 'cd ..' can't guarantee; also, we avoid
possible typos for e.g. "$deps/install".

Change-Id: Ib23f86c6cc1441d882de59bcdde5de87fa4e9fdf
---
M contrib/jenkins.sh
1 file changed, 50 insertions(+), 51 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Holger Freyther: Looks good to me, approved



diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index bde117c..00cf2c8 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -2,56 +2,55 @@
 
 set -ex
 
-rm -rf deps/install
-mkdir deps || true
-export LD_LIBRARY_PATH=$PWD/deps/install/lib
-cd deps
-osmo-deps.sh libosmocore
+base="$PWD"
+deps="$base/deps"
+inst="$deps/install"
 
-cd libosmocore
+mkdir "$deps" || true
+rm -rf "$inst"
+
+build_dep() {
+	project="$1"
+	branch="$2"
+	set +x
+	echo
+	echo
+	echo
+	echo " =============================== $project ==============================="
+	echo
+	set -x
+	if [ -z "$project" ]; then
+		echo "internal failure"
+		exit 1
+	fi
+	cd "$deps"
+	rm -rf "$project"
+	osmo-deps.sh "$project"
+	cd "$project"
+	if [ -n "$branch" ]; then
+		git checkout "$branch"
+	fi
+	git rev-parse HEAD
+	autoreconf --install --force
+	./configure --prefix="$inst"
+	$MAKE $PARALLEL_MAKE install
+}
+
+build_dep libosmocore
+
+# All below builds want this PKG_CONFIG_PATH
+export PKG_CONFIG_PATH="$inst/lib/pkgconfig:$PKG_CONFIG_PATH"
+
+build_dep libosmo-abis
+build_dep libosmo-netif
+build_dep libosmo-sccp
+PARALLEL_MAKE="" build_dep libsmpp34
+build_dep openggsn
+
+cd "$base"
+cd openbsc
 autoreconf --install --force
-./configure --prefix=$PWD/../install
-$MAKE $PARALLEL_MAKE install
-
-
-cd ../
-osmo-deps.sh libosmo-abis
-cd libosmo-abis
-autoreconf --install --force
-PKG_CONFIG_PATH=$PWD/../install/lib/pkgconfig ./configure --prefix=$PWD/../install  
-PKG_CONFIG_PATH=$PWD/..//install/lib/pkgconfig $MAKE $PARALLEL_MAKE install
-
-cd ../
-osmo-deps.sh libosmo-netif
-cd libosmo-netif
-autoreconf --install --force
-PKG_CONFIG_PATH=$PWD/../install/lib/pkgconfig ./configure --prefix=$PWD/../install  
-PKG_CONFIG_PATH=$PWD/..//install/lib/pkgconfig $MAKE $PARALLEL_MAKE install
-
-cd ../
-osmo-deps.sh libosmo-sccp
-cd libosmo-sccp
-autoreconf --install --force
-PKG_CONFIG_PATH=$PWD/../install/lib/pkgconfig ./configure --prefix=$PWD/../install  
-PKG_CONFIG_PATH=$PWD/..//install/lib/pkgconfig $MAKE $PARALLEL_MAKE install
-
-cd ../
-osmo-deps.sh libsmpp34
-cd libsmpp34
-autoreconf --install --force
-./configure --prefix=$PWD/../install
-$MAKE install
-
-cd ../
-osmo-deps.sh openggsn
-cd openggsn
-autoreconf --install --force
-PKG_CONFIG_PATH=$PWD/../install/lib/pkgconfig ./configure --prefix=$PWD/../install  
-PKG_CONFIG_PATH=$PWD/..//install/lib/pkgconfig $MAKE $PARALLEL_MAKE install
-
-cd ../../openbsc
-autoreconf --install --force
-PKG_CONFIG_PATH=$PWD/../deps/install/lib/pkgconfig ./configure --enable-osmo-bsc --enable-nat $SMPP $MGCP --enable-vty-tests --enable-external-tests
-PKG_CONFIG_PATH=$PWD/../deps/install/lib/pkgconfig $MAKE $PARALLEL_MAKE
-PKG_CONFIG_PATH=$PWD/../deps/install/lib/pkgconfig LD_LIBRARY_PATH=$PWD/../deps/install/lib $MAKE check
-PKG_CONFIG_PATH=$PWD/../deps/install/lib/pkgconfig LD_LIBRARY_PATH=$PWD/../deps/install/lib $MAKE distcheck
+./configure --enable-osmo-bsc --enable-nat $SMPP $MGCP --enable-vty-tests --enable-external-tests
+$MAKE $PARALLEL_MAKE
+LD_LIBRARY_PATH="$inst/lib" $MAKE check
+LD_LIBRARY_PATH="$inst/lib" $MAKE distcheck

-- 
To view, visit https://gerrit.osmocom.org/540
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib23f86c6cc1441d882de59bcdde5de87fa4e9fdf
Gerrit-PatchSet: 1
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Holger Freyther <holger at freyther.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list