From a3d93ed2f9c114634b749c1304039e709a21a270 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Mon, 11 Jul 2016 19:39:51 +0200 Subject: [PATCH] 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 --- contrib/jenkins.sh | 101 ++++++++++++++++++++++----------------------- 1 file changed, 50 insertions(+), 51 deletions(-) diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh index bde117c06..00cf2c8f2 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