forked from greasemonkey/greasemonkey
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·69 lines (60 loc) · 2 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/sh
# Set up variables
if [ "official" = "$1" ]; then
# For official builds, use the version in install.rdf.
GMVER=`sed -ne '/em:version/{ s/.*>\(.*\)<.*/\1/; p}' install.rdf`
else
# For beta builds, generate a version number.
BUILDTYPE="${1:-beta}"
GMVER=`date +"%Y.%m.%d.$BUILDTYPE"`
fi
GMXPI="greasemonkey-$GMVER.xpi"
# Copy base structure to a temporary build directory and change to it
echo "Creating working directory ..."
rm -rf build
mkdir build
cp -r \
chrome.manifest components content defaults install.rdf locale skin \
modules CREDITS LICENSE.bsd LICENSE.mit LICENSE.mpl \
build/
cd build
echo "Cleaning up unwanted files ..."
find . -depth -name '*~' -exec rm -rf "{}" \;
find . -depth -name '#*' -exec rm -rf "{}" \;
find . -depth -name '*.psd' -exec rm -rf "{}" \;
if [ "official" != "$1" ]; then
echo "Patching install.rdf version ..."
sed -e "s/<em:version>.*<\/em:version>/<em:version>$GMVER<\/em:version>/" \
install.rdf > tmp
cat tmp > install.rdf
rm tmp
fi
if [ "bz" == "$1" ]; then
# For babelzilla, only include en-US locale.
rm -r `find locale -type d -not -name locale -a -not -name en-US`
fi
echo "Gathering all locales into chrome.manifest ..."
for entry in locale/*; do
entry=`basename $entry`
if [ $entry != en-US ]; then
echo "locale greasemonkey $entry locale/$entry/" >> chrome.manifest
fi
done
echo "Creating greasemonkey.jar ..."
sed \
-e "s/^content *\([^ ]*\) *\([^ ]*\)/content \1 jar:chrome\/greasemonkey.jar!\/\2/" \
-e "s/^skin *\([^ ]*\) *\([^ ]*\) *\([^ ]*\)/skin \1 \2 jar:chrome\/greasemonkey.jar!\/\3/" \
-e "s/^locale *\([^ ]*\) *\([^ ]*\) *\([^ ]*\)/locale \1 \2 jar:chrome\/greasemonkey.jar!\/\3/" \
chrome.manifest > tmp
cat tmp > chrome.manifest
rm tmp
find content skin locale | sort | \
zip -qr0D@ "greasemonkey.jar"
rm -fr content/ skin/ locale/
mkdir chrome
mv greasemonkey.jar chrome/
echo "Creating $GMXPI ..."
zip -qr9DX "../$GMXPI" *
echo "Cleaning up temporary files ..."
cd ..
rm -rf build