This repository has been archived by the owner on Jul 30, 2019. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
build-kiwix-release.sh
executable file
·179 lines (155 loc) · 4.24 KB
/
build-kiwix-release.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
#!/bin/bash
#Usage: build-kiwix-release.sh [static]
#
# Generates a bundle version of Kiwix. Default with shared linked libraries.
#
# You should run it from outside the moulinkiwix directory.
#
# --static creates a portable version of Kiwix
# --regular creates a normal (shared links) version of Kiwix
# --help displays this help message
#
VERSION="0.9x"
if [ "$2" ]
then
VERSION=$2
fi
if [ "$1" = "--static" ]
then
STATIC=1
elif [ "$1" = "--help" ]
then
head -n 12 $0 |grep -e '^#' |grep -v '^#!'|cut -c 2-
exit
else
STATIC=0
fi
if [ $STATIC -gt 0 ]
then
echo "Building a static (portable) version of Kiwix"
confopt=" --without-dependences"
else
echo "Building a regular (linked) version of Kiwix"
confopt=""
fi
function getFirefoxLocalization {
echo "Downloading Firefox for language code $CODE"
CODE=$1
#rm ff_$CODE-3.6.22.tar.bz2
if [ -f ff_$CODE-3.6.27.tar.bz2 ] ; then
echo "ff_$CODE-3.6.27.tar.bz2 exist."
else
wget -c http://download.kiwix.org/dev/mozilla.org/firefox/releases/3.6.27/linux-i686/$CODE/firefox-3.6.27.tar.bz2 -O ff_$CODE-3.6.27.tar.bz2
fi
rm -rf ./firefox
tar xf ff_$CODE-3.6.27.tar.bz2
cp ./firefox/chrome/$CODE.* ./kiwix/xulrunner/chrome/
}
bname=$(dirname $(readlink -f $0))
# make sure we're not in moulinkiwix folder
# as we want to copy that folder
if [ "$bname" = `pwd` ]
then
echo "/!\ WARNING: You seem to be running this script from within the \
moulinkiwix directory.
You must run it from another location; preferably its parent directory ("$(dirname $(pwd))")"
exit
fi
# Create and move to a staging directory
mkdir -p tmp
cd tmp
# Download code
echo "Grabbing Kiwix source code"
rm -rf moulinkiwix
if [ -d "../moulinkiwix" ]
then
rsync -ar ../moulinkiwix .
else
svn co https://kiwix.svn.sourceforge.net/svnroot/kiwix/moulinkiwix moulinkiwix
fi
# Prepares Makefiles
echo "Prepares Kiwix compilation"
cd ./moulinkiwix
if [ -f Makefile ]; then make clean; fi
./autogen.sh && ./configure $confopt
cd -
# Compile dependences
echo "Build Kiwix dependences"
cd ./moulinkiwix/src/dependences
make clean
make
cd -
# Relaunch configure with deps
cd ./moulinkiwix
./configure $confopt
cd -
# Compile components
echo "Build Kiwix components"
cd ./moulinkiwix
make
cd -
# Copy the kiwix directory
echo "Files clean up"
rm -rf ./kiwix
cp -r -L ./moulinkiwix/kiwix ./kiwix
# Remove svn/repo stuff
find ./kiwix -name '.svn' -exec rm -rf {} \;
find ./kiwix -name '*.inised' -exec rm -rf {} \;
find ./kiwix -name 'Makefile' -delete
find ./kiwix -name 'Makefile.in' -delete
find ./kiwix -name 'Makefile.am' -delete
# Replace logger
mv ./kiwix/chrome/content/main/js/logger_rlz.js ./kiwix/chrome/content/main/js/logger.js
# Download and copy xulrunner
echo "Grabbing XulRunner runtime"
if [ -f xulrunner-runtime.tar.bz2 ]
then
echo " already present"
else
wget -c http://download.kiwix.org/dev/xulrunner-1.9.2.13.en-US.linux-i686.sdk.tar.bz2 -O xulrunner-runtime.tar.bz2
fi
tar xf xulrunner-runtime.tar.bz2
chmod +x ./xulrunner/xulrunner ./xulrunner/xulrunner-bin
mv ./xulrunner/ ./kiwix/
# Additional dynlib symlinks
cd ./kiwix/xulrunner
cp -v libplc4.so libplc4.so.0d
cp -v libnspr4.so libnspr4.so.0d
cp -v libplds4.so libplds4.so.0d
cd -
# Create the kiwix binary
mv ./kiwix/xulrunner/xulrunner-stub ./kiwix/kiwix
# Use last version (at least 1.14.0) version of aria2c (staticaly compiled for x86_32)
wget -c http://download.kiwix.org/dev/aria2c -O ./kiwix/aria2c
#cp -v ./moulinkiwix/src/dependences/aria2-1.12.1/src/aria2c ./kiwix/
# Download the firefox en copy the locales JAR
getFirefoxLocalization de
getFirefoxLocalization it
getFirefoxLocalization fr
getFirefoxLocalization es-ES
getFirefoxLocalization ar
getFirefoxLocalization he
getFirefoxLocalization fa
getFirefoxLocalization zh-CN
# xapian-compact
mkdir ./kiwix/bin
cp moulinkiwix/src/dependences/xapian*/bin/.libs/xapian-compact ./kiwix/bin
#strip the binaries
for BINARY in `find src/ -executable -type f | grep -v ".sh" | grep -v ".py" | grep -v sugar`
do
strip $BINARY
done
# Tar & clean
echo "Clean Up"
aname="kiwix"
if [ $STATIC -gt 0 ]
then
aname="$aname-static"
fi
aname="$aname-$VERSION.tar.bz2"
rm $aname
tar -cvjf $aname ./kiwix
rm -rf ./firefox/
cd ..
ls -lh ./tmp/$aname
echo "All done. Your archive is ready in `readlink -f ./tmp/$aname`"