Add DOCKER_REPO/REF to image directives file
Sriov-cni and sriov-network-device-plugin are the first two in what
might be a long list of third party packages that provide their own
Dockerfile.
This update extend the images directives file syntax by introducing
'DOCKER_REPO=<url>' and 'DOCKER_REF=<git_ref>'. The DOCKER_REPO will
be cloned into a working directory, the DOCKER_REF checked out,
the Dockerfile found and passed to docker build.
Change-Id: Iea5eae32bd245557a4b02c9825297343a001e778
Story: 2005208
Task: 33485
Signed-off-by: Scott Little <scott.little@windriver.com>
This commit is contained in:
parent
471afe69b5
commit
b8c3be9f3b
@ -86,49 +86,77 @@ function is_empty {
|
|||||||
test $# -eq 0
|
test $# -eq 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_loci {
|
#
|
||||||
# Use a specific HEAD of loci, to provide a stable builder
|
# get_git: Clones a git into a subdirectory of ${WORKDIR}, and
|
||||||
local LOCI_REF="432503259f5e624afdabd9dacc9d9b367dd95e96"
|
# leaves you in that directory. On error the directory
|
||||||
|
# is undefined.
|
||||||
|
#
|
||||||
|
function get_git {
|
||||||
|
local git_repo=${1}
|
||||||
|
local git_ref=${2:-master}
|
||||||
|
|
||||||
ORIGWD=${PWD}
|
local git_name
|
||||||
|
git_name=$(basename ${git_repo} | sed 's/[.]git$//')
|
||||||
|
|
||||||
if [ ! -d ${WORKDIR}/loci ]; then
|
if [ -z ${git_name} ] || \
|
||||||
cd ${WORKDIR}
|
[ "${git_name}" == "." ] || \
|
||||||
git clone --recursive https://github.com/openstack/loci.git
|
[ "${git_name}" == ".." ] || \
|
||||||
if [ $? -ne 0 ]; then
|
[ "${git_name}" == "*" ]; then
|
||||||
echo "Failed to clone loci. Aborting..." >&2
|
echo "git repo appears to be invalid: ${git_repo}. Aborting..." >&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd loci
|
if [ ! -d ${WORKDIR}/${git_name} ]; then
|
||||||
git checkout ${LOCI_REF}
|
cd ${WORKDIR}
|
||||||
|
|
||||||
|
git clone --recursive ${git_repo}
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "Failed to checkout loci base ref: ${LOCI_REF}" >&2
|
echo "Failed to clone ${git_repo}. Aborting..." >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd $git_name
|
||||||
|
git checkout ${git_ref}
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Failed to checkout '${git_name}' base ref: ${git_ref}" >&2
|
||||||
echo "Aborting..." >&2
|
echo "Aborting..." >&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
cd ${WORKDIR}/loci
|
cd ${WORKDIR}/${git_name}
|
||||||
local cur_head
|
|
||||||
cur_head=$(git rev-parse HEAD)
|
|
||||||
|
|
||||||
if [ "${cur_head}" != "${LOCI_REF}" ]; then
|
|
||||||
git fetch
|
git fetch
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "Failed to fetch loci. Aborting..." >&2
|
echo "Failed to fetch '${git_name}'. Aborting..." >&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
git checkout ${LOCI_REF}
|
git checkout ${git_ref}
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "Failed to checkout loci base ref: ${LOCI_REF}" >&2
|
echo "Failed to checkout '${git_name}' base ref: ${git_ref}" >&2
|
||||||
echo "Aborting..." >&2
|
echo "Aborting..." >&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_loci {
|
||||||
|
# Use a specific HEAD of loci, to provide a stable builder
|
||||||
|
local LOCI_REF="432503259f5e624afdabd9dacc9d9b367dd95e96"
|
||||||
|
local LOCI_REPO="https://github.com/openstack/loci.git"
|
||||||
|
|
||||||
|
local ORIGWD=${PWD}
|
||||||
|
|
||||||
|
get_git ${LOCI_REPO} ${LOCI_REF}
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Failed to clone or update loci. Aborting..." >&2
|
||||||
|
cd ${ORIGWD}
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd ${ORIGPWD}
|
cd ${ORIGWD}
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@ -353,6 +381,10 @@ function build_image_docker {
|
|||||||
#
|
#
|
||||||
local LABEL
|
local LABEL
|
||||||
LABEL=$(source ${image_build_file} && echo ${LABEL})
|
LABEL=$(source ${image_build_file} && echo ${LABEL})
|
||||||
|
local DOCKER_REPO
|
||||||
|
DOCKER_REPO=$(source ${image_build_file} && echo ${DOCKER_REPO})
|
||||||
|
local DOCKER_REF
|
||||||
|
DOCKER_REF=$(source ${image_build_file} && echo ${DOCKER_REF})
|
||||||
|
|
||||||
if is_in ${PROJECT} ${SKIP[@]} || is_in ${LABEL} ${SKIP[@]}; then
|
if is_in ${PROJECT} ${SKIP[@]} || is_in ${LABEL} ${SKIP[@]}; then
|
||||||
echo "Skipping ${LABEL}"
|
echo "Skipping ${LABEL}"
|
||||||
@ -367,7 +399,26 @@ function build_image_docker {
|
|||||||
echo "Building ${LABEL}"
|
echo "Building ${LABEL}"
|
||||||
|
|
||||||
local docker_src
|
local docker_src
|
||||||
|
if [ -z "DOCKER_REPO" ]; then
|
||||||
docker_src=$(dirname ${image_build_file})/docker
|
docker_src=$(dirname ${image_build_file})/docker
|
||||||
|
else
|
||||||
|
local ORIGWD=${PWD}
|
||||||
|
|
||||||
|
echo "get_git '${DOCKER_REPO}' '${DOCKER_REF}'"
|
||||||
|
get_git "${DOCKER_REPO}" "${DOCKER_REF}"
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Failed to clone or update ${DOCKER_REPO}. Aborting..." >&2
|
||||||
|
cd ${ORIGWD}
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
local DOCKER_FILE="${PWD}/Dockerfile"
|
||||||
|
if [ ! -f ${DOCKER_FILE} ]; then
|
||||||
|
DOCKER_FILE=$(find ${PWD} -type f -name Dockerfile | head -n 1)
|
||||||
|
fi
|
||||||
|
docker_src=$(dirname ${DOCKER_FILE})
|
||||||
|
cd ${ORIGWD}
|
||||||
|
fi
|
||||||
|
|
||||||
# Check for a Dockerfile
|
# Check for a Dockerfile
|
||||||
if [ ! -f ${docker_src}/Dockerfile ]; then
|
if [ ! -f ${docker_src}/Dockerfile ]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user