c81b003309
Use kilo upstream RPM packages Partially-implements: blueprint port-kilo Change-Id: Ia0b4db5dc8e40c01184871e77458dc718c3c46cd
127 lines
2.6 KiB
Bash
Executable File
127 lines
2.6 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
TOPDIR=$(git rev-parse --show-toplevel)
|
|
IMGDIR="$(cd "$(dirname "$0")" && pwd)"
|
|
|
|
RELEASE_NAMESPACE=kollaglue
|
|
NAMESPACE=kollaglue
|
|
PREFIX=centos-rdo-
|
|
TAG=$(git rev-parse --short HEAD)
|
|
RELEASE_TAG=kilo
|
|
|
|
usage () {
|
|
cat <<EOF
|
|
Usage: $0 [options]
|
|
|
|
Options:
|
|
|
|
--namespace, -n <namespace>
|
|
--tag, -t <tag>
|
|
--push, -p
|
|
--no-cache, -N
|
|
--release
|
|
--no-use-released-parent
|
|
EOF
|
|
}
|
|
|
|
[ -f $TOPDIR/.buildconf ] && . $TOPDIR/.buildconf
|
|
[ -f $IMGDIR/.buildconf ] && . $IMGDIR/.buildconf
|
|
|
|
ARGS=$(getopt -o hn:t:pN -l help,namespace:,push,release,tag:,no-cache,no-use-released-parent -- "$@") || { usage >&2; exit 2; }
|
|
|
|
eval set -- "$ARGS"
|
|
|
|
while :; do
|
|
case "$1" in
|
|
|
|
(--help|-h) usage
|
|
exit 0
|
|
;;
|
|
|
|
(--release) MODE=release
|
|
NAMESPACE=$RELEASE_NAMESPACE
|
|
TAG=$RELEASE_TAG
|
|
;;
|
|
|
|
(--tag|-t) shift
|
|
TAG="$1"
|
|
;;
|
|
|
|
(--push|-p) PUSH=1
|
|
;;
|
|
|
|
(--no-cache|-N)
|
|
BUILDFLAGS="${BUILDFLAGS} --no-cache"
|
|
;;
|
|
|
|
(--namespace|-n)
|
|
shift
|
|
NAMESPACE="$1"
|
|
;;
|
|
|
|
(--no-use-released-parent)
|
|
USE_CURRENT_TAG=1
|
|
;;
|
|
|
|
(--) break
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
done
|
|
|
|
if [[ $USE_CURRENT_TAG = 1 ]]; then
|
|
PARENT_TAG=$TAG
|
|
else
|
|
PARENT_TAG=$RELEASE_TAG
|
|
fi
|
|
|
|
if [ "$NAMESPACE" = "$RELEASE_NAMESPACE" ] \
|
|
&& [ "$TAG" = "$RELEASE_TAG" ] \
|
|
&& ! [ "$MODE" = "release" ]; then
|
|
|
|
echo "ERROR: use --release to build a release image" >&2
|
|
exit 1
|
|
fi
|
|
|
|
IMAGE="${PREFIX}${IMGDIR##*/}"
|
|
FULLIMAGE="${NAMESPACE}/${IMAGE}${TAG:+:${TAG}}"
|
|
|
|
cat <<EOF
|
|
======================================================================
|
|
$FULLIMAGE
|
|
======================================================================
|
|
|
|
EOF
|
|
|
|
if [ "$MODE" = "release" ]; then
|
|
echo "*** YOU ARE BUILDING A RELEASE IMAGE ***"
|
|
echo
|
|
fi
|
|
|
|
TMPDIR=$(mktemp -d /tmp/kolla-build.XXXXXXXXXX)
|
|
cp -aL $IMGDIR/* $TMPDIR
|
|
# Use an extension for in-place editing for portability, as GNU and BSD
|
|
# versions of sed behave differently otherwise
|
|
sed -i.bak "s/%%KOLLA_NAMESPACE%%/${NAMESPACE}/g" $TMPDIR/Dockerfile
|
|
sed -i.bak "s/%%KOLLA_PREFIX%%/${PREFIX}/g" $TMPDIR/Dockerfile
|
|
sed -i.bak "s/%%KOLLA_TAG%%/${PARENT_TAG}/g" $TMPDIR/Dockerfile
|
|
|
|
if ! docker build ${BUILDFLAGS} -t "$FULLIMAGE" $TMPDIR; then
|
|
echo "ERROR: failed to build $FULLIMAGE"
|
|
exit 1
|
|
fi
|
|
rm -rf $TMPDIR
|
|
|
|
echo "Built: $FULLIMAGE"
|
|
|
|
if [ "$PUSH" = 1 ]; then
|
|
if ! docker push "$FULLIMAGE"; then
|
|
echo "ERROR: failed to push $FULLIMAGE"
|
|
exit 1
|
|
fi
|
|
|
|
echo "Pushed: $FULLIMAGE"
|
|
fi
|