cloud-init/tools/make-tarball
Scott Moser ed634a4760 tools/make-tarball: add ability to include uncommited changes
if you have UNCOMMITTED=1 in environment then the tree will
contain uncommitted changes.
2014-02-28 16:19:19 -05:00

40 lines
885 B
Bash
Executable File

#!/bin/sh
set -e
find_root() {
local topd
if [ -z "${CLOUD_INIT_TOP_D}" ]; then
topd=$(cd "$(dirname "${0}")" && cd .. && pwd)
else
topd=$(cd "${CLOUD_INIT_TOP_D}" && pwd)
fi
[ $? -eq 0 -a -f "${topd}/setup.py" ] || return
ROOT_DIR="$topd"
}
if ! find_root; then
echo "Unable to locate 'setup.py' file that should" \
"exist in the cloud-init root directory." 1>&2
exit 1;
fi
REVNO=$(bzr revno "$ROOT_DIR")
if [ ! -z "$1" ]; then
ARCHIVE_FN="$1"
else
VERSION=$("$ROOT_DIR/tools/read-version")
ARCHIVE_FN="$PWD/cloud-init-$VERSION~bzr$REVNO.tar.gz"
fi
export_uncommitted=""
if [ "${UNCOMMITTED:-0}" != "0" ]; then
export_uncommitted="--uncommitted"
fi
bzr export ${export_uncommitted} \
--format=tgz --root="cloud-init-$VERSION~bzr$REVNO" \
"--revision=${REVNO}" "${ARCHIVE_FN}" "$ROOT_DIR"
echo "$ARCHIVE_FN"