From e6aff494a6a3d8a9d99e66d3083858e906ec06b1 Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Mon, 1 Jul 2019 15:45:10 +0200 Subject: common.sh: add docker_images_require Clone docker-playground.git, source its jenkins-common.sh and run docker_images_require from there. This will make it possible to run osmocom-release-tarballs.sh in a docker container, for which the Dockerfile is stored in docker-playground.git. Related: OS#3870 Change-Id: Ic4519ccb6978793054869862f8ca0e21d9cf5be4 --- .gitignore | 1 + scripts/common.sh | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/.gitignore b/.gitignore index ff207ee..459f2c9 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ __pycache__/ _temp/ _deps/ _release_tarballs/ +_docker_playground # osmocom-nightly-packages.sh nightly-3g_* diff --git a/scripts/common.sh b/scripts/common.sh index 2cf31a5..bf24fc4 100644 --- a/scripts/common.sh +++ b/scripts/common.sh @@ -27,6 +27,8 @@ OSMO_RELEASE_REPOS=" osmocom-bb " +OSMO_BRANCH_DOCKER_PLAYGROUND="${OSMO_BRANCH_DOCKER_PLAYGROUND:-master}" + # Print commit of HEAD for an Osmocom git repository, e.g.: # "f90496f577e78944ce8db1aa5b900477c1e479b0" # $1: repository @@ -96,3 +98,27 @@ osmo_source_subdir() { ;; esac } + +# Build docker images from docker-playground.git. +# $1...$n: docker image names (e.g. "debian-stretch-build") +docker_images_require() { + local oldpwd="$PWD" + + # Get docker-plaground.git + if [ -d "_docker_playground" ]; then + git -C _docker_playground fetch + else + git clone https://git.osmocom.org/docker-playground/ _docker_playground + fi + cd _docker_playground + git checkout "$OSMO_BRANCH_DOCKER_PLAYGROUND" + git reset --hard "origin/$OSMO_BRANCH_DOCKER_PLAYGROUND" + + # jenkins-common.sh expects to run from a subdir in docker-playground.git + cd "$1" + + # Subshell: run docker_images_require from jenkins-common.sh, pass all arguments + (. ../jenkins-common.sh; docker_images_require "$@") + + cd "$oldpwd" +} -- cgit v1.2.3