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
This commit is contained in:
Oliver Smith 2019-07-01 15:45:10 +02:00
parent 0a389c4083
commit e6aff494a6
2 changed files with 27 additions and 0 deletions

1
.gitignore vendored
View File

@ -9,6 +9,7 @@ __pycache__/
_temp/
_deps/
_release_tarballs/
_docker_playground
# osmocom-nightly-packages.sh
nightly-3g_*

View File

@ -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"
}