-
Notifications
You must be signed in to change notification settings - Fork 22
/
build_icu.sh
executable file
·53 lines (45 loc) · 1.63 KB
/
build_icu.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
#!/usr/bin/env bash
if [[ -x $(which icuinfo) ]]; then
echo System ICU version: $(icuinfo | grep -o '"version">[^<]\+' | grep -o '[^"><]\+$')
else
echo 'System ICU not installed'
fi
if [[ "$1" == '' ]]; then
echo ''
echo 'Usage:'
echo ''
echo '1) bash icu-install.sh versions'
echo ''
echo '2) bash icu-install.sh install <version>'
fi
if [[ "$1" == 'versions' ]]; then
echo ''
echo 'Available ICU versions'
wget -O - https://icu.unicode.org/download 2>/dev/null | grep -P -o '(?<=http://site.icu-project.org/download/)\d+#TOC-ICU4C-Download.+;>\K[\d.]+'
fi
if [[ "$2" != "" && "$1" == 'install' ]]; then
which g++ || sudo apt install -y g++
ICU_VERSION=$2
ICU_SRC_FILE="icu4c-$(echo $ICU_VERSION | sed -e 's/\./_/')-src.tgz"
echo "Trying to install ICU version: $ICU_VERSION"
if [[ ! -e "$ICU_SRC_FILE" ]]; then
wget "https://github.com/unicode-org/icu/releases/download/release-$(echo $ICU_VERSION | sed -e 's/\./-/')/$ICU_SRC_FILE"
fi
if [[ ! -e "$ICU_SRC_FILE" ]]; then
exit 1;
fi
ICU_SRC_FOLDER="icu-release-$(echo $ICU_VERSION | sed -e 's/\./-/')"
tar zxvf "$ICU_SRC_FILE"
which g++ || sudo apt install -y g++
if [[ ! -e "/opt/icu$ICU_VERSION" ]]; then
pushd icu/source
sudo mkdir "/opt/icu$ICU_VERSION"
./configure --prefix="/opt/icu$ICU_VERSION" && make -j2 && sudo make install
ls -alh /opt/icu$ICU_VERSION/lib/
sudo cp -r /opt/icu$ICU_VERSION/lib/* /usr/local/lib
popd
else
echo "ICU already installed at (/opt/icu$ICU_VERSION)"
fi
rm -f "$ICU_SRC_FILE"
fi