forked from blchinezu/pocketbook-coolreader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
updateReleases.sh
272 lines (229 loc) · 6.93 KB
/
updateReleases.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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
#!/bin/sh
# CD to the current script path
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
done
PBDEV_DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )/../../"
sdk="$PBDEV_DIR/sources/cr3-fork"
package="/tmp/cr3-package-$1"
releases="$PBDEV_DIR/releases/coolreader3"
cd "$sdk"
VERSION="`cat cr3gui/src/cr3pocketbook.h | grep CR_PB_VERSION | awk '{print $3}' | sed -e s/\\\"//g`"
DATE="`cat cr3gui/src/cr3pocketbook.h | grep CR_PB_BUILD_DATE | awk '{print $3}' | sed -e s/\\\"//g`"
function doUpdate {
sdk="$PBDEV_DIR/sources/cr3-fork"
package="/tmp/cr3-package-$1"
releases="$PBDEV_DIR/releases/coolreader3"
cd "$sdk"
VERSION="`cat cr3gui/src/cr3pocketbook.h | grep CR_PB_VERSION | awk '{print $3}' | sed -e s/\\\"//g`"
DATE="`cat cr3gui/src/cr3pocketbook.h | grep CR_PB_BUILD_DATE | awk '{print $3}' | sed -e s/\\\"//g`"
echo
echo "Version: $VERSION / $DATE / $1 / $2"
if [ -f "$sdk/pb$1/cr3gui/cr3-pb.app" ]; then
rm -rf "$package"
mkdir -p "$package"
echo
echo "Update dev package $1"
if [ ! -f "$sdk/pb$1/cr3gui/cr3-pb.app" ]; then
echo
echo " ERR: Binary not found!"
echo
exit
fi
if [ "`ls $sdk/pb$1/cr3gui/*.cr3skin`" = "" ]; then
echo
echo " ERR: Skins not found!"
echo
exit
fi
if [ "`ls $sdk/pb$1/i18n`" = "" ]; then
echo
echo " ERR: Translations not found!"
echo
exit
fi
echo " - translations > common"
rm -rf "$package/system/share/cr3/i18n/"*
ls "$sdk/pb$1/i18n" | xargs -I lang cp -f "$sdk/pb$1/i18n/lang/LC_MESSAGES/cr3.mo" "$sdk/data/common/system/share/cr3/i18n/lang.mo"
echo
echo " - common > package"
cp -rf "$sdk/data/common/"* "$package/"
if [ -d "$sdk/data/firmware-specific/$1" ]; then
echo
echo " - FIRMWARE $1 specific > package"
cp -rf "$sdk/data/firmware-specific/$1/"* "$package/"
fi
if [ "$2" != "" -a "$2" != "publish" -a -d "$sdk/data/device-specific/$2" ]; then
echo
echo " - DEVICE $2 specific > package"
cp -rf "$sdk/data/device-specific/$2/"* "$package/"
fi
echo " - binary > package"
rm -rf "$package/system/share/cr3/bin/"*
mkdir -p "$package/system/share/cr3/bin"
cp -f "$sdk/pb$1/cr3gui/cr3-pb.app" "$package/system/share/cr3/bin/"
echo " - skins > package"
rm -rf "$package/system/share/cr3/skins/"*
mkdir -p "$package/system/share/cr3/skins"
# if [ "$1" = "360" ]; then
cp -f "$sdk/pb$1/cr3gui/default.cr3skin" "$package/system/share/cr3/skins/"
# fi
if [ "$1" = "pro2" -o "$1" = "pro4" -o "$1" = "pro5" ]; then
cp -f "$sdk/pb$1/cr3gui/pb62x.cr3skin" "$package/system/share/cr3/skins/"
fi
if [ "$1" = "pro4" -o "$1" = "pro5" ]; then
cp -f "$sdk/pb$1/cr3gui/pb626fw5.cr3skin" "$package/system/share/cr3/skins/"
fi
if [ "$1" = "pro5" ]; then
cp -f "$sdk/pb$1/cr3gui/pb631fw5.cr3skin" "$package/system/share/cr3/skins/"
fi
echo " - package.version > package"
if [ "$2" = "" ]; then
echo "Version: $VERSION" > "$package/package.version"
echo "Date: `date +"%Y-%m-%d %H:%M:%S"`" >> "$package/package.version"
echo "Build: $1" >> "$package/package.version"
echo "Branch: dev" >> "$package/package.version"
else
echo "Version: $VERSION" > "$package/package.version"
echo "Date: $DATE" >> "$package/package.version"
echo "Build: $1" >> "$package/package.version"
echo "Branch: master" >> "$package/package.version"
fi
echo " - package > zip"
zip="$releases/dev/cr3-v$VERSION-$1.zip"
rm -f "$zip"
cd "$package"
zip -r "$zip" ./*
cd "$sdk"
if [ ! -f "$zip" ]; then
echo
echo "ERR: Couldn't create archive!"
echo
exit
fi
if [ "$2" = "publish" ]; then
echo " - dev > stable (dropbox)"
cp "$zip" "$releases/cr3-v$VERSION-$1.zip"
fi
if [ "$2" != "" -a "$2" != "publish" ]; then
echo " - dev > builds (git)"
rm -rf "$sdk/builds/$2/$1/"*
mkdir -p "$sdk/builds/$2/$1"
printf "yes" > "$sdk/builds/$2/$1/exists"
cp -f "$zip" "$sdk/builds/$2/$1/latest.zip"
fi
if [ "$2" = "" -a "$1" = "pro5" ]; then
old="`cat $sdk/cr3gui/po/cr3.pot | grep -v '#:' | grep -v '#, c-format' | grep -v 'POT-Creation-Date' | sort | uniq`"
new="`cat $sdk/pb$1/cr3gui/po/cr3.pot | grep -v '#:' | grep -v '#, c-format' | grep -v 'POT-Creation-Date' | sort | uniq`"
diff="`diff <(echo "$old" ) <(echo "$new")`"
if [ "$diff" != "" ]; then
echo " - update i18n template"
rm -f "$sdk/cr3gui/po/cr3.pot"
cat "$sdk/pb$1/cr3gui/po/cr3.pot" | grep -v '#, c-format' > "$sdk/cr3gui/po/cr3.pot"
cd "$sdk/cr3gui/po"
bash update-po
cd "$sdk"
fi
fi
if [ "`whoami`" = "brucelee" -a "$2" = "" -a "$1" = "pro5" -a -f "$releases/dev/cr3-v$VERSION-$1.zip" ]; then
echo
echo "Update git dev branch?"
select yn in "Yes" "No"; do
case $yn in
Yes )
echo
echo " - DEV: Update git build: $1"
rm -f "builds/626/$1/latest.zip"
cp "$releases/dev/cr3-v$VERSION-$1.zip" "builds/626/$1/latest.zip"
git commit "builds/626/$1/latest.zip" -m 'Auto update dev build [publish.sh]'
sleep 1s
git push
break;;
No )
break;;
esac
done
fi
fi
}
# Update all packages
if [ "$1" = "" ]; then
for TYPE in '360' 'pro2' 'pro4' 'pro5'; do
doUpdate "$TYPE"
done
# Update all builds and publish
elif [ "$1" = "publish" ]; then
printf "$VERSION" > "$sdk/builds/current.version"
echo
# Check firmware specific
for FIRMWARE in '360' 'pro2' 'pro4' 'pro5'; do
# Check if it's already published
echo " - Check if published: $FIRMWARE"
if [ -f "$releases/cr3-v$VERSION-$FIRMWARE.zip" ]; then
echo " ERR: Version already published!"
exit
fi
# Check if there's no binary
echo " - Check firmware binary: $FIRMWARE"
if [ ! -f "$sdk/pb$FIRMWARE/cr3gui/cr3-pb.app" ]; then
echo " ERR: No binary found!"
exit
fi
echo
done
# Move old builds
echo " - Move old builds"
mv "$releases/"*.zip "$releases/old/"
# Publish firmware specific (dropbox)
for TYPE in '360' 'pro2' 'pro4' 'pro5'; do
doUpdate "$TYPE" "publish"
done
# Publish device specific (git)
for DEVICE in '360'; do
for FIRMWARE in '360'; do
doUpdate "$FIRMWARE" "$DEVICE"
done
done
for DEVICE in '602'; do
for FIRMWARE in 'pro2'; do
doUpdate "$FIRMWARE" "$DEVICE"
done
done
for DEVICE in '515' '626'; do
for FIRMWARE in 'pro4' 'pro5'; do
doUpdate "$FIRMWARE" "$DEVICE"
done
done
for DEVICE in '631'; do
for FIRMWARE in 'pro5'; do
doUpdate "$FIRMWARE" "$DEVICE"
done
done
# # Wait for dropbox to catch on
# echo
# echo " - Wait for dropbox to catch on..."
# sleep 2s
# while [ "`dropbox status|grep "Up to date"`" = "" ]; do
# sleep 1s
# done
# # RELOAD DROPBOX
# sleep 1s
# echo " - Restart dropbox"
# dropbox stop
# sleep 1s
# dropbox start
# COMMIT GIT
cd "$sdk"
echo " - Commit to github"
git commit -a -m "Up version: $VERSION"
sleep 1s
echo " - Push to web"
git push
# Update a package
else
doUpdate "$1"
fi
echo