Files
meteor/scripts/admin/publish-release.sh
Felix Rabe 3431c66c16 Fix occurrences of "cd dirname $0"
They are not safe for spaces in paths. There might be other places to look for trouble.

I've run the following command to produce this commit: (on OS X, copy-and-pasting the below exactly)

    find . -type f -name '*.sh' -print0  |  # Find all .sh files
        xargs -0 fgrep -H -- '`'         |  # See all places with backticks in them
        fgrep 'cd `dirname $0'           |  # I deemed these problematic (variable assignments are safe)
        cut -d ':' -f 1                  |  # Take the <file> from <file>:<line> produced by "grep -H"
        tr '\n' '\0'                     |  # Also here, spaces can be problematic - always do "xargs -0"!
        xargs -0 -- sed -i '' 's/cd `dirname $0`/cd "`dirname "$0"`"/g'

The significance of adding the two levels of "'s can be verified by running the following in your Terminal:

    $ node -e 'console.log(process.argv.splice(1))' -- `echo 1   2`
    [ '1', '2' ]

    $ node -e 'console.log(process.argv.splice(1))' -- "`echo 1   2`"
    [ '1 2' ]

    $ node -e 'console.log(process.argv.splice(1))' -- "`echo "1   2"`"
    [ '1   2' ]
2014-05-07 17:51:09 -07:00

48 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
set -e
set -u
cd "`dirname "$0"`"
DIR="$(pwd)"
METEOR_DIR="$(pwd)/../.."
if [ $# -gt 2 ]; then
echo "usage: publish-release.sh [GIT-REV [RELEASE-NAME]]"
exit 1
fi
if [ $# -lt 1 ]; then
GIT_SHA="$(git rev-parse HEAD)"
else
GIT_SHA="$(git rev-parse "$1")"
fi
if [ $# -lt 2 ]; then
RELEASE_NAME="$GIT_SHA"
else
RELEASE_NAME="$2"
fi
# prepare settings file with git sha of last commit
PUBLISH_TMPDIR=$(mktemp -d -t meteor-publish-release-XXXXXXXX)
cat > "$PUBLISH_TMPDIR/settings.json" <<EOF
{"git-sha": "$GIT_SHA", "release-name": "$RELEASE_NAME"}
EOF
# ensure our 'awssum' smart package is up-to-date
cd $METEOR_DIR
git submodule init
git submodule update
# publish-release is a meteor app
cd $DIR/publish-release
# run it
#
# XXX when we support third-party packages use that mechanism instead
# of keeping the package in git.
#
# XXX it would be cool to be able to not listen on any port here. instead
# we use port 31337
$METEOR_DIR/meteor -p 31337 --once --settings=$PUBLISH_TMPDIR/settings.json