-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathfetchdata.sh
80 lines (66 loc) · 2.5 KB
/
fetchdata.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
#!/bin/bash
FETCH="wget -c"
# use this for more parallelism
CORES=${CORES-1}
MAKE=${MAKE-make}
if [[ $# -ne 1 ]];
then
echo "Usage: $0 icuver"
echo "Example: $0 62.1"
exit 1
fi
MAJOR=$(echo $1 | cut -d. -f1)
if [[ -f icudt${MAJOR}b.dat ]] && [[ -f icudt${MAJOR}l.dat ]];
then
echo "icudt${MAJOR}b.dat / icudt${MAJOR}l.dat already exist."
else
#ICUURL=https://ssl.icu-project.org/files/icu4c/${1}/icu4c-$(echo $1 | tr . _)-src.tgz
ICUURL=https://github.com/unicode-org/icu/releases/download/release-$(echo $1 | tr . -)/icu4c-$(echo $1 | tr . _)-src.tgz
ICUTGZ=$(basename $ICUURL)
if [[ ! -f tmp/${ICUTGZ} ]];
then
echo "Fetching $ICUURL"
mkdir -p tmp
( cd tmp ; $FETCH $ICUURL && exit 1 ) && (echo could not fetch $ICUURL; exit 1 )
fi
if [[ ! -f tmp/icupkg ]];
then
echo "building ICU so we get icupkg"
# make sure we have a work location
if [[ ! -d tmp/icu ]];
then
echo "Unpacking $ICUTGZ"
mkdir -p tmp
( cd tmp ; $FETCH $ICUURL && exit 1 ) && (echo could not fetch $ICUURL; exit 1 )
( cd tmp ; tar xfpz $ICUTGZ || exit 1 )
if [[ ! -d tmp/icu ]];
then
echo "unpack failed (no file tmp/icu)"
exit 1
fi
fi
if [[ ! -f tmp/icubuild/config.status ]];
then
mkdir -p tmp/icubuild
( cd tmp/icubuild ; ../icu/source/configure --disable-debug --enable-static --disable-shared --disable-extras --disable-layoutex --disable-tests --disable-samples --with-data-packaging=files || exit 1)
fi
if [[ ! -f tmp/icubuild/bin/icupkg ]];
then
# skip data build
${MAKE} -C tmp/icubuild/ -j${CORES} DATASUBDIR= || exit 1
fi
ln -v tmp/icubuild/bin/icupkg tmp/icupkg
echo "Cleaning up tmp/icubuild and tmp/icu"
rm -rf tmp/icubuild tmp/icu
fi
# set -x
# now extract just the target
rm -rf tmp/${MAJOR} && mkdir -p tmp/${MAJOR} || exit 1
echo Extracting from $ICUURL
(cd tmp/${MAJOR} ; tar --strip-components=4 -x -v -p -z -f ../${ICUTGZ} icu/source/data/in/icudt${MAJOR}l.dat && ln -f -v icudt${MAJOR}l.dat ../.. ) || exit 1
# now make big endian
tmp/icupkg -tb ./icudt${MAJOR}l.dat ./icudt${MAJOR}b.dat || exit 1
ls -lh ./icudt${MAJOR}[lb].dat
fi
echo "Now run npm run gen -- icudt${MAJOR}b.dat (and its output)"
echo "Then run npm run gen -- icudt${MAJOR}l.dat (and its output)"