Skip to content

Commit

Permalink
Version replaced with a placeholder.
Browse files Browse the repository at this point in the history
  • Loading branch information
avian2 committed Apr 12, 2012
1 parent 74ee90d commit 3e95339
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
5 changes: 4 additions & 1 deletion makexpi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,16 @@ else
fi

# The name/version of the XPI we're building comes from src/install.rdf
XPI_NAME="$APP_NAME-`grep em:version xpi/install.rdf | sed -e 's/[<>]/ /g' | cut -f3`"
VERSION=`grep em:version xpi/install.rdf | sed -e 's/[<>]/ /g' | cut -f3`
XPI_NAME="$APP_NAME-$VERSION"
if [ "$1" ]; then
XPI_NAME="$XPI_NAME.xpi"
else
XPI_NAME="$XPI_NAME~pre.xpi"
fi

../version.sh --add "$VERSION" xpi

# Build the XPI!
rm -f "../$XPI_NAME"
(cd xpi/chrome && zip -q -r -m "noscript.jar" *)
Expand Down
31 changes: 31 additions & 0 deletions version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

if [ "$#" -ne 3 ]; then
echo "USAGE: version.sh [--add|--strip] version path"
exit 1
fi

CMD=$1
VERSION=$2
TARGET=$3

REGEX='.*\.\(dtd\|xul\|js\)'

PLACEHOLDER="@VERSION@"

if [ "$CMD" = "--add" ]; then
SED_SCRIPT="s/$PLACEHOLDER/$VERSION/g"
elif [ "$CMD" = "--strip" ]; then
SED_SCRIPT="s/$VERSION/$PLACEHOLDER/g"
if find "$TARGET" -regex "$REGEX" -print0 | xargs -0 grep "$PLACEHOLDER"; then
echo "Placeholder $PLACEHOLDER already present in source when stripping version!"
exit 1
fi

else
echo "Invalid option $CMD"
exit 1
fi

find "$TARGET" -regex "$REGEX" -print0 | \
xargs -0 sed -i -e "$SED_SCRIPT"

0 comments on commit 3e95339

Please sign in to comment.