Files
meteor/scripts/admin/build-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

54 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
set -e
set -u
# cd to top level dir
cd "`dirname "$0"`"
cd ../..
TOPDIR=$(pwd)
OUTDIR="$TOPDIR/dist"
rm -rf "$OUTDIR"
mkdir -p "$OUTDIR"
UNAME=$(uname)
ARCH=$(uname -m)
export PLATFORM="${UNAME}_${ARCH}"
# Node, in its infinite wisdom, creates some hard links in some of its binary
# output (eg, kexec.node). These hard links are across directories. Some
# filesystems (eg, AFS) don't support hard links across directories, so make
# sure that on Linux, our tarballs don't have hard links. (Why only on Linux?
# Because neither /usr/bin/tar nor /usr/bin/gnutar on Mac appear to have this
# flag or an equivalent. And we don't care too much about AFS support on Mac
# anyway.)
if [ "$UNAME" = "Linux" ]; then
TAR="tar --hard-dereference"
else
TAR=tar
fi
export TAR
scripts/admin/build-tools-tarballs.sh
TOOLS_VERSION=$(cat "$TOPDIR/.tools_version")
scripts/admin/build-package-tarballs.sh
MANIFEST_PACKAGE_CHUNK=$(cat "$TOPDIR/.package_manifest_chunk")
# don't keep these around since they get outdated
rm "$TOPDIR/.tools_version"
rm "$TOPDIR/.package_manifest_chunk"
cat > "$OUTDIR/release.json-$PLATFORM" <<ENDOFMANIFEST
{
"tools": "$TOOLS_VERSION",
"packages": {
$MANIFEST_PACKAGE_CHUNK
},
"upgraders": ["app-packages", "no-preserve-inputs"]
}
ENDOFMANIFEST
cat "$OUTDIR/release.json-$PLATFORM"