forked from laurentj/slimerjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildpackage.sh
executable file
·197 lines (163 loc) · 4.85 KB
/
buildpackage.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#!/bin/bash
CURRENTDIR=`pwd`
SLIMERDIR=`dirname $0`
SLIMERDIR=`cd $SLIMERDIR;pwd`
XULRUNNER_VERSION="38.0.5"
XULRUNNER_DNL_URL="http://ftp.mozilla.org/pub/mozilla.org/xulrunner/releases/$XULRUNNER_VERSION/runtimes/"
XULRUNNER_PACK_NAME="xulrunner-$XULRUNNER_VERSION.en-US"
# specific version for Mac, since Xulrunner 34 to 39 does not work https://bugzilla.mozilla.org/show_bug.cgi?id=1105044
XULRUNNER_MAC_VERSION="33.1.1"
XULRUNNER_MAC_DNL_URL="http://ftp.mozilla.org/pub/mozilla.org/xulrunner/releases/$XULRUNNER_MAC_VERSION/runtimes/"
XULRUNNER_MAC_PACK_NAME="xulrunner-$XULRUNNER_MAC_VERSION.en-US"
cd $SLIMERDIR
BUILD_BIN_PACKAGE="y"
XRDIR=""
usage()
{
echo "buildpackage.sh [options] [xulrunner-bin-path]"
echo ""
echo "options:"
echo " --no-bin: don't build binary packages"
echo " -h: displays this help"
echo ""
echo "xulrunner-bin-path: the path where xulrunner packages can be found"
echo " or can be stored after downloading them from the mozilla site"
}
for i in $*
do
case $i in
--no-bin)
BUILD_BIN_PACKAGE="n"
;;
-h|--help)
usage
exit 0
;;
-*)
echo "ERROR: Unknown option: $i"
echo ""
usage
exit 1
;;
*)
if [ "$XRDIR" == "" ]; then
XRDIR=$i
else
echo "Warning: no supported parameter. $i ignored"
fi
;;
esac
done
VERSION=`grep "^Version=" src/application.ini`
VERSION=${VERSION:8}
TARGETDIR="$SLIMERDIR/_dist/slimerjs-$VERSION"
if [ "$XRDIR" == "" ]; then
XRDIR="$SLIMERDIR/_dist/xrbin"
fi
if [ -d "$TARGETDIR" ]
then
rm -rf $TARGETDIR/*
else
mkdir -p "$TARGETDIR"
fi
if [ ! -d "$XRDIR" ]
then
mkdir -p "$XRDIR"
fi
# copy files
cd src
cp application.ini $TARGETDIR
cp slimerjs $TARGETDIR
cp slimerjs.bat $TARGETDIR
cp slimerjs.py $TARGETDIR
cp LICENSE $TARGETDIR
cp README.md $TARGETDIR
mkdir -p $TARGETDIR/chrome/
cp -a chrome/icons $TARGETDIR/chrome/
# zip chrome files into omni.ja
zip -r $TARGETDIR/omni.ja chrome/ components/ defaults/ modules/ chrome.manifest --exclude @package_exclude.lst
# set the build date
cd $TARGETDIR
BUILDDATE=`date +%Y%m%d`
sed -i -e "s/BuildID=.*/BuildID=$BUILDDATE/g" application.ini
# create the final package
echo "Build the platform independant package..."
cd $SLIMERDIR/_dist
zip -r "slimerjs-$VERSION.zip" "slimerjs-$VERSION"
if [ "$BUILD_BIN_PACKAGE" != "y" ]; then
# the end
cd $CURRENTDIR
echo ""
echo "slimerjs-$VERSION.zip is in $SLIMERDIR/_dist/"
exit 0
fi
cd $XRDIR
if [ ! -f "$XRDIR/$XULRUNNER_PACK_NAME.linux-i686.tar.bz2" ]
then
wget "$XULRUNNER_DNL_URL/$XULRUNNER_PACK_NAME.linux-i686.tar.bz2"
fi
if [ ! -d $XULRUNNER_PACK_NAME.linux-i686 ]; then
tar xjf "$XULRUNNER_PACK_NAME.linux-i686.tar.bz2"
mv xulrunner $XULRUNNER_PACK_NAME.linux-i686
fi
if [ ! -f "$XRDIR/$XULRUNNER_PACK_NAME.linux-x86_64.tar.bz2" ]
then
wget "$XULRUNNER_DNL_URL/$XULRUNNER_PACK_NAME.linux-x86_64.tar.bz2"
fi
if [ ! -d $XULRUNNER_PACK_NAME.linux-x86_64 ]; then
tar xjf "$XULRUNNER_PACK_NAME.linux-x86_64.tar.bz2"
mv xulrunner $XULRUNNER_PACK_NAME.linux-x86_64
fi
if [ ! -f "$XRDIR/$XULRUNNER_MAC_PACK_NAME.mac.tar.bz2" ]
then
wget "$XULRUNNER_MAC_DNL_URL/$XULRUNNER_MAC_PACK_NAME.mac.tar.bz2"
fi
if [ ! -d $XULRUNNER_MAC_PACK_NAME.mac ]; then
tar xjf "$XULRUNNER_MAC_PACK_NAME.mac.tar.bz2"
mv XUL.framework/Versions/Current $XULRUNNER_MAC_PACK_NAME.mac
rm -rf XUL.framework
fi
if [ ! -f "$XRDIR/$XULRUNNER_PACK_NAME.win32.zip" ]
then
wget "$XULRUNNER_DNL_URL/$XULRUNNER_PACK_NAME.win32.zip"
fi
if [ ! -d $XULRUNNER_PACK_NAME.win32 ]; then
unzip "$XULRUNNER_PACK_NAME.win32.zip"
mv xulrunner $XULRUNNER_PACK_NAME.win32
fi
echo "Build linux-i686 package.."
cd $XRDIR
cp -a $XULRUNNER_PACK_NAME.linux-i686 $TARGETDIR/xulrunner
cd $TARGETDIR/..
tar cjf "slimerjs-$VERSION-linux-i686.tar.bz2" "slimerjs-$VERSION"
rm -rf $TARGETDIR/xulrunner
echo "Build linux-x86_64 package..."
cd $XRDIR
cp -a $XULRUNNER_PACK_NAME.linux-x86_64 $TARGETDIR/xulrunner
cd $TARGETDIR/..
tar cjf "slimerjs-$VERSION-linux-x86_64.tar.bz2" "slimerjs-$VERSION"
rm -rf $TARGETDIR/xulrunner
echo "Build MacOS package..."
cd $XRDIR
cp -a $XULRUNNER_MAC_PACK_NAME.mac $TARGETDIR/xulrunner
cp $SLIMERDIR/src/macos/Info.plist $TARGETDIR/xulrunner/
cd $TARGETDIR/..
tar cjf "slimerjs-$VERSION-mac.tar.bz2" "slimerjs-$VERSION"
rm -rf $TARGETDIR/xulrunner
echo "Build Windows package..."
# include exec file generated by pyinstaller if it exists
if [ -f $SLIMERDIR/src/slimerjs.exe ]; then
cp $SLIMERDIR/src/slimerjs.exe $TARGETDIR
else
if [ -f $SLIMERDIR/src/dist/slimerjs.exe ]; then
cp $SLIMERDIR/src/dist/slimerjs.exe $TARGETDIR
fi
fi
cd $XRDIR
cp -a $XULRUNNER_PACK_NAME.win32 $TARGETDIR/xulrunner
cd $TARGETDIR/..
zip -r "slimerjs-$VERSION-win32.zip" "slimerjs-$VERSION"
rm -rf $TARGETDIR/xulrunner
# the end
cd $CURRENTDIR
echo "Packages are in $SLIMERDIR/_dist/"