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-sugar.sh
executable file
·62 lines (52 loc) · 1.89 KB
/
build-kiwix-sugar.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
#!/bin/bash
#Usage: build-kiwix-sugar.sh path/to/kiwix-static.tar.gz [VERSION]
#
# Generates an XO bundle version of Kiwix for Sugar.
#
# VERSION a numeric build number value
# --help displays this help message
#
# path to kiwix static archive is first arg
ARCHIVE=""
if [ "$1" ]
then
ARCHIVE=$1
else
head -n 9 $0 |grep -e '^#' |grep -v '^#!'|cut -c 2-
exit
fi
# version is sugar build version of the .xo file
VERSION=""
if [ "$2" ]
then
VERSION=$2
fi
# move to a safe place
rm -rf /tmp/Kiwix.activity
mkdir -p /tmp/Kiwix.activity
# extract kiwix-static
tar -xf $ARCHIVE -C /tmp/Kiwix.activity --strip-components=2
# copy sugar-specific files
cp -rv src/sugar/lib src/sugar/activity src/sugar/setup.py /tmp/Kiwix.activity/
cp -rv src/sugar/bin/* /tmp/Kiwix.activity/bin/
# if version specified, mark it in the info manifest
if [ "$VERSION" ]
then
sed -i -e "s/^activity_version = 1$/activity_version = $VERSION/" /tmp/Kiwix.activity/activity/activity.info
else
VERSION=`cat src/sugar/activity/activity.info |grep activity_version | cut -d " " -f3`
fi
# change default skin to sugar
sed -i -e "s/^pref(\"general.skins.selectedSkin\", \"default\");$/pref(\"general.skins.selectedSkin\", \"sugar\");/" /tmp/Kiwix.activity/defaults/preferences/preferences.js
sed -i -e "s/^resource defaultskin skin\/default\/$/resource defaultskin skin\/sugar\//" /tmp/Kiwix.activity/chrome/chrome.manifest
sed -i -e "s/^pref(\"kiwix.downloadRemoteCatalogs\", undefined);$/pref(\"kiwix.downloadRemoteCatalogs\", false);/" /tmp/Kiwix.activity/defaults/preferences/preferences.js
# build .xo (write the manifest and zip the package)
cd /tmp/Kiwix.activity
rm ./aria2c
find ./ -type f -o -type l | sed 's,^./,,g' | grep -v MANIFEST > MANIFEST
cd ..
zip -r Kiwix-$VERSION.xo Kiwix.activity
mv Kiwix-$VERSION.xo ./Kiwix.activity
cd Kiwix.activity
cd -
echo "All done. Your archive is ready in `readlink -f /tmp/Kiwix.activity/*.xo`"