tools: fix [some] shell quoting problems

There were problems with these tools if the path had a space.  This should
make these tools safe.  There are others that still have problems.
This commit is contained in:
Scott Moser 2013-04-09 17:57:41 -04:00
parent 0137249133
commit 09285a4f6f
4 changed files with 14 additions and 24 deletions

View File

@ -10,16 +10,12 @@ EOF
} }
topdir="$PWD" topdir="$PWD"
tag=${1} tag="$1"
[ -n "$tag" ] || { Usage 1>&2 ; exit 1; } [ -n "$tag" ] || { Usage 1>&2 ; exit 1; }
tmpd=$(mktemp -d ); out="${topdir}/cloud-init-${tag}.tar.gz"
trap "rm -Rf '${tmpd}'" 0
out=${topdir}/cloud-init-${tag}.tar.gz bzr export --format=tgz --root="cloud-init-$tag" \
"--revision=tag:${tag}" "$out" "$topdir" &&
cd ${tmpd} &&
bzr branch -r "tag:${tag}" "${topdir}" ./cloud-init-${tag} &&
tar czf "${out}" cloud-init-${tag}/ --exclude cloud-init-${tag}/.bzr &&
echo "Wrote ${out}" echo "Wrote ${out}"

View File

@ -18,18 +18,16 @@ if ! find_root; then
exit 1; exit 1;
fi fi
REVNO=$(bzr revno "$ROOT_DIR")
if [ ! -z "$1" ]; then if [ ! -z "$1" ]; then
ARCHIVE_FN="$1" ARCHIVE_FN="$1"
else else
REVNO=$(bzr revno $ROOT_DIR) VERSION=$("$ROOT_DIR/tools/read-version")
VERSION=$($ROOT_DIR/tools/read-version)
ARCHIVE_FN="$PWD/cloud-init-$VERSION~bzr$REVNO.tar.gz" ARCHIVE_FN="$PWD/cloud-init-$VERSION~bzr$REVNO.tar.gz"
fi fi
FILES=$(cd $ROOT_DIR && bzr ls --versioned --recursive) bzr export --format=tgz --root="cloud-init-$VERSION~bzr$REVNO" \
echo "$FILES" | tar czf $ARCHIVE_FN \ "--revision=${REVNO}" "${ARCHIVE_FN}" "$ROOT_DIR"
-C "$ROOT_DIR" \
--transform "s,^,cloud-init-$VERSION~bzr$REVNO/," \
--no-recursion --files-from -
echo "$ARCHIVE_FN" echo "$ARCHIVE_FN"

View File

@ -21,15 +21,11 @@ fi
REQUIRES="$ROOT_DIR/Requires" REQUIRES="$ROOT_DIR/Requires"
if [ ! -e "$REQUIRES" ] if [ ! -e "$REQUIRES" ]; then
then
echo "Unable to find 'Requires' file located at $REQUIRES" echo "Unable to find 'Requires' file located at $REQUIRES"
exit 1 exit 1
fi fi
# Filter out comments and empty liens # Filter out comments and empty liens
DEPS=$(cat $REQUIRES | grep -Pv "^\s*#" | grep -Pv '^\s*$') DEPS=$(grep -Pv "^\s*#" "$REQUIRES" | grep -Pv '^\s*$')
echo "$DEPS" | sort -d -f echo "$DEPS" | sort -d -f

View File

@ -27,5 +27,5 @@ then
exit 1 exit 1
fi fi
VERSION=$(grep -P "\d+.\d+.\d+:" $CHNG_LOG | cut -f1 -d ":" | head -n 1) VERSION=$(grep -P "\d+.\d+.\d+:" "$CHNG_LOG" | cut -f1 -d ":" | head -n 1)
echo $VERSION echo "$VERSION"