summaryrefslogtreecommitdiff
path: root/tools/make-tarball
diff options
context:
space:
mode:
Diffstat (limited to 'tools/make-tarball')
-rwxr-xr-xtools/make-tarball29
1 files changed, 15 insertions, 14 deletions
diff --git a/tools/make-tarball b/tools/make-tarball
index aef95d47..09742dc7 100755
--- a/tools/make-tarball
+++ b/tools/make-tarball
@@ -1,22 +1,24 @@
#!/bin/sh
-
set -e
-ROOT_DIR=""
-if [ -e "setup.py" ]
-then
- ROOT_DIR="$PWD"
-elif [ -e "../setup.py" ]
-then
- ROOT_DIR="$PWD/../"
-else
+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."
- exit 1
+ "exist in the cloud-init root directory." 1>&2
+ exit 1;
fi
-if [ ! -z "$1" ]
-then
+if [ ! -z "$1" ]; then
ARCHIVE_FN="$1"
else
REVNO=$(bzr revno $ROOT_DIR)
@@ -31,4 +33,3 @@ echo "$FILES" | tar czf $ARCHIVE_FN \
--no-recursion --files-from -
echo "$ARCHIVE_FN"
-