Openbmc clone occurs in build script using a repo cache
Will be adding a new variable for a directory that acts as a cache for
the OpenBMC repo. If this directory doesn't exists it will clone in like
before. If it exists it will not clone in the repo. There is a need for
the openbmc build directory to not be mounted externally in the
Kubernetes implementation. To satisfy this constraint the cache will be
used as a mounted directory which is used as a reference for the git
clone that will now occur in the build.sh to speed up the clone. Doing
it in the build.sh portion so that docker caching doesn't affect the
process. The old obmcdir will now be an internal directory in the build
container, it can be hardcoded into the build.sh/dockerfiles. Will be
leaving it intact in case we need it to be a variable.
Change-Id: I0446fa42a17ac9d577b3a3b26bd60fad890265ad
Signed-off-by: Alanny Lopez <alanny.lopez@ibm.com>
diff --git a/build-setup.sh b/build-setup.sh
index bcffc8d..27a9fa7 100755
--- a/build-setup.sh
+++ b/build-setup.sh
@@ -18,7 +18,8 @@
target=${target:-qemu}
distro=${distro:-ubuntu}
imgtag=${imgtag:-latest}
-obmcdir=${obmcdir:-openbmc}
+ocache=${ocache:-/home/openbmc}
+obmcdir=${obmcdir:-/tmp/openbmc}
WORKSPACE=${WORKSPACE:-${HOME}/${RANDOM}${RANDOM}}
http_proxy=${http_proxy:-}
PROXY=""
@@ -42,10 +43,10 @@
# Timestamp for job
echo "Build started, $(date)"
-# If there's no openbmc dir in WORKSPACE then just clone in master
-if [ ! -d ${WORKSPACE}/${obmcdir} ]; then
- echo "Clone in openbmc master to ${WORKSPACE}/${obmcdir}"
- git clone https://github.com/openbmc/openbmc ${WORKSPACE}/${obmcdir}
+# If the ocache directory doesn't exist clone it in, ocache will be used as a cache for git clones
+if [ ! -d ${ocache} ]; then
+ echo "Clone in openbmc master to ${ocache} to act as cache for future builds"
+ git clone https://github.com/openbmc/openbmc ${ocache}
fi
# Work out what build target we should be running and set BitBake command
@@ -195,7 +196,8 @@
set -xeo pipefail
-cd ${WORKSPACE}
+# Use the mounted repo cache to make an internal repo not mounted externally
+git clone --reference ${ocache} --dissociate https://github.com/openbmc/openbmc ${obmcdir}
# Go into the OpenBMC directory (the openbmc script will put us in a build subdir)
cd ${obmcdir}
@@ -249,16 +251,17 @@
# Kick off a build
bitbake ${BITBAKE_OPTS} obmc-phosphor-image
+# Copy images out of internal obmcdir into workspace directory
+cp -R ${obmcdir}/build/tmp/deploy/images ${WORKSPACE}/images/
+
EOF_SCRIPT
chmod a+x ${WORKSPACE}/build.sh
# Run the Docker container, execute the build script we just built
docker run --cap-add=sys_admin --net=host --rm=true -e WORKSPACE=${WORKSPACE} --user="${USER}" \
- -w "${HOME}" -v "${HOME}":"${HOME}" -t openbmc/${distro}:${imgtag}-${ARCH} ${WORKSPACE}/build.sh
-
-# Create link to images for archiving
-ln -sf ${WORKSPACE}/openbmc/build/tmp/deploy/images ${WORKSPACE}/images
+ -w "${HOME}" -v "${HOME}":"${HOME}" -v "${ocache}":"${ocache}" \
+ -t openbmc/${distro}:${imgtag}-${ARCH} ${WORKSPACE}/build.sh
# Timestamp for build
-echo "Build completed, $(date)"
\ No newline at end of file
+echo "Build completed, $(date)"