-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrefresh.sh
executable file
·217 lines (191 loc) · 6.21 KB
/
refresh.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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
#!/bin/bash
echo Refresh / clean / build the Bibledit kernel source for iOS.
IOSSOURCE=`dirname $0`
if [ $? -ne 0 ]; then exit; fi
cd $IOSSOURCE
if [ $? -ne 0 ]; then exit; fi
IOSSOURCE=`pwd`
if [ $? -ne 0 ]; then exit; fi
echo The source path is $IOSSOURCE
KERNELSOURCE=../cloud
KERNELDEST=Bibledit/kernel
WEBROOT=Bibledit/webroot
echo Copying Bibledit kernel files from $KERNELSOURCE to $KERNELDEST
mkdir -p $KERNELDEST
if [ $? -ne 0 ]; then exit; fi
rsync --archive --delete --exclude bridging_header.h --exclude cpp_file.* $KERNELSOURCE/ $KERNELDEST/
if [ $? -ne 0 ]; then exit; fi
# List distinct file suffixes:
# find . -name '*.?*' -type f | rev | cut -d. -f1 | rev | sort | uniq
echo Prepare and clean the Bibledit kernel code
pushd $KERNELDEST
if [ $? -ne 0 ]; then exit; fi
rm -rf .git
if [ $? -ne 0 ]; then exit; fi
echo Configure Bibledit in client mode
echo Run only one parallel task so the interface is more responsive
echo Enable the single-tab browser
./configure --enable-ios
if [ $? -ne 0 ]; then exit; fi
make clean
if [ $? -ne 0 ]; then exit; fi
echo Switch to MbedTLS 2.x
rm -rf mbedtls
if [ $? -ne 0 ]; then exit; fi
mv mbedtls2 mbedtls
if [ $? -ne 0 ]; then exit; fi
echo Remove all files except C and C++ source code
find . -type f ! -name '*.h' ! -name '*.hpp' ! -name '*.c' ! -name '*.cpp' ! -name '*.cxx' -delete
rm -f .DS_Store
if [ $? -ne 0 ]; then exit; fi
rm -rf .github
if [ $? -ne 0 ]; then exit; fi
rm -rf autom4te.cache
if [ $? -ne 0 ]; then exit; fi
rm -rf xcode.xcodeproj
if [ $? -ne 0 ]; then exit; fi
rm -rf unittests
if [ $? -ne 0 ]; then exit; fi
rm -rf sources
if [ $? -ne 0 ]; then exit; fi
rm -rf executable
if [ $? -ne 0 ]; then exit; fi
find . -name .deps -type d -delete
if [ $? -ne 0 ]; then exit; fi
find . -name exampleProgram.cpp -delete
if [ $? -ne 0 ]; then exit; fi
find . -name shell.c -delete
if [ $? -ne 0 ]; then exit; fi
rm -rf i18n
if [ $? -ne 0 ]; then exit; fi
echo Update the configuration: No external SWORD / ICU / UTF8PROC / PUGIXML libraries
sed -i.bak '/HAVE_SWORD/d' config.h
if [ $? -ne 0 ]; then exit; fi
sed -i.bak '/HAVE_ICU/d' config.h
if [ $? != 0 ]; then exit; fi
sed -i.bak '/HAVE_UTF8PROC/d' config.h
if [ $? != 0 ]; then exit; fi
sed -i.bak '/HAVE_PUGIXML/d' config.h
if [ $? != 0 ]; then exit; fi
echo The embedded web view cannot upload files
sed -i.bak '/CONFIG_ENABLE_FILE_UPLOAD/d' config/config.h
if [ $? -ne 0 ]; then exit; fi
find . -name '*.bak' -delete
if [ $? -ne 0 ]; then exit; fi
popd
if [ $? -ne 0 ]; then exit; fi
echo Copying Bibledit kernel files from $KERNELSOURCE to $WEBROOT
mkdir -p $WEBROOT
if [ $? -ne 0 ]; then exit; fi
rsync --archive --delete $KERNELSOURCE/ $WEBROOT/
if [ $? -ne 0 ]; then exit; fi
echo Prepare and clean the Bibledit kernel webroot
pushd $WEBROOT
if [ $? -ne 0 ]; then exit; fi
echo Build several databases and other data for inclusion with the iOS package
echo Building them on iOS would take a lot of time during the setup phase
echo Including pre-built data speeds up the setup phase of Bibledit on iOS
./configure
if [ $? -ne 0 ]; then exit; fi
make --jobs=`sysctl -n hw.ncpu`
if [ $? -ne 0 ]; then exit; fi
./generate . locale
if [ $? -ne 0 ]; then exit; fi
./generate . mappings
if [ $? -ne 0 ]; then exit; fi
./generate . versifications
if [ $? -ne 0 ]; then exit; fi
echo Remove the journal entries that were logged in the process
rm -f logbook/1*
if [ $? -ne 0 ]; then exit; fi
make distclean
if [ $? -ne 0 ]; then exit; fi
rm -rf .git*
if [ $? -ne 0 ]; then exit; fi
echo Remove the C and C++ source code
find . -name '*.h' -delete
if [ $? -ne 0 ]; then exit; fi
find . -name '*.hpp' -delete
if [ $? -ne 0 ]; then exit; fi
find . -name '*.c' -delete
if [ $? -ne 0 ]; then exit; fi
find . -name '*.cpp' -delete
if [ $? -ne 0 ]; then exit; fi
find . -name '*.cxx' -delete
if [ $? -ne 0 ]; then exit; fi
rm -f .DS_Store
if [ $? -ne 0 ]; then exit; fi
rm -rf autom4te.cache
if [ $? -ne 0 ]; then exit; fi
rm -rf xcode.xcodeproj
if [ $? -ne 0 ]; then exit; fi
rm -rf unittests
if [ $? -ne 0 ]; then exit; fi
rm -rf sources
if [ $? -ne 0 ]; then exit; fi
rm -rf executable
if [ $? -ne 0 ]; then exit; fi
find . -name .deps -type d -delete
if [ $? -ne 0 ]; then exit; fi
rm -rf i18n
if [ $? -ne 0 ]; then exit; fi
find . -maxdepth 1 -type f -delete
if [ $? -ne 0 ]; then exit; fi
find . -name ".dirstamp" -delete
if [ $? -ne 0 ]; then exit; fi
rm locale/README
if [ $? -ne 0 ]; then exit; fi
find . -name '*.sh' -delete
if [ $? -ne 0 ]; then exit; fi
rm -rf mbedtls*
if [ $? -ne 0 ]; then exit; fi
find . -name .deps -ls -exec rm -rv {} +
if [ $? -ne 0 ]; then exit; fi
popd
if [ $? -ne 0 ]; then exit; fi
echo Convert the file hierarchy in the webroot to a flat structure
pushd $WEBROOT
if [ $? -ne 0 ]; then exit; fi
echo Creating array of directories in webroot
directories=($(find . -type d))
echo Creating array of files in webroot
files=($(find . -type f))
echo Iterate over the directories
echo Convert them to marked files
echo Always end with .res to ensure Xcode sees them as resources
echo Example:
echo Directory \"database/config\" becomes file \"dir#database#config.res\"
for directory in ${directories[@]}
do
# Remove the initial dot slash, e.g. change './help' to 'help'.
directory=${directory#./}
# Replace the slashes with '#', e.g. change 'mimetic098/rfc822' tp 'mimetic098#rfc822'.
directory=${directory//\//#}
# Create a filename like 'dir#help' or 'dir#mimetic098#ref822.res'.
file=dir#${directory}.res
echo folder > $file
done
echo Iterate over the files
echo Convert them to marked files
echo Always end with .res to ensure Xcode sees them as resources
echo Example:
echo Directory \"help/changelog.html\" becomes file \"file#help#changelog.html.res\"
for file in ${files[@]}
do
# Remove the initial dot slash, e.g. change './help/changelog.html' to 'help/changelog.html'.
file2=${file#./}
# Replace the slashes with '#', e.g. change 'help/changelog.html' tp 'help#changelog.html'.
file2=${file2//\//#}
# Move the original file to a new file like 'file#help#changelog.html.res'.
file2=file#${file2}.res
mv $file $file2
if [ $? -ne 0 ]; then exit; fi
done
echo Remove the now empty original directories
for directory in ${directories[@]}
do
rm -rf $directory
done
popd
if [ $? -ne 0 ]; then exit; fi
echo Succesfully refreshed the Bibledit kernel