• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2# Copyright (C) 2020 and later: Unicode, Inc. and others.
3
4# set VERSION to the ICU version. set top_srcdir to the parent of icurc
5# Note: You need to set LD_LIBRARY_PATH/etc before calling this script.
6export LD_LIBRARY_PATH=./lib:${LD_LIBRARY_PATH-/lib:/usr/lib:/usr/local/lib}
7export DYLD_LIBRARY_PATH=./lib:${DYLD_LIBRARY_PATH-/lib:/usr/lib:/usr/local/lib}
8
9if [ ! -d "${top_srcdir}" ]
10then
11    echo >&2 "$0: please set 'top_srcdir' to the icu/icu4c/source dir"
12    exit 1
13fi
14LICENSE=${LICENSE-${top_srcdir}/../LICENSE}
15
16if [ ! -f "${LICENSE}" ]
17then
18    echo >&2 "$0: could not load license file ${LICENSE}"
19    exit 1
20fi
21
22DATFILE=${DATFILE-$(ls data/out/tmp/icudt*.dat| head -1)}
23
24if [ ! -f "${DATFILE}" ]
25then
26    echo >&2 "$0: could not find DATFILE ${DATFILE}"
27    exit 1
28fi
29
30VERS=$(echo ${DATFILE} | tr -d a-z/.)
31VERSION=${VERSION-unknown}
32
33if [[ "${VERSION}" = "unknown" ]];
34then
35    VERSION=${VERS}.0
36    echo "$0: VERSION not set, using ${VERSION}"
37else
38    if [[ "${VERS}" != $(echo ${VERSION} | cut -d. -f1) ]]
39    then
40        echo >&2 "$0: Warning: Expected version ${VERSION} to start with ${VERS}..."
41    fi
42fi
43
44# yeah, override ENDIANS if you want a different flavor.
45#ENDIANS="b l e"
46ENDIANS=${ENDIANS-"b l"}
47DISTY_DIR=${DISTY_DIR-./dist/}
48
49if [ ! -x ./bin/icupkg ]
50then
51    echo >&2 "$0: could not find executable ./bin/icupkg"
52    exit 1
53fi
54
55echo "# Packing ${DATFILE} into data zips in dist/ for version ${VERSION}"
56mkdir -p ${DISTY_DIR}/tmp
57
58for endian in $ENDIANS;
59do
60    base=icu4c-${VERSION}-data-bin-${endian}.zip
61    filename=icudt${VERS}${endian}.dat
62    if [ -f ${DISTY_DIR}/${base} ];
63    then
64        echo ${DISTY_DIR}/${base} exists, skipping
65        continue
66    fi
67    rm -f ${DISTY_DIR}/tmp/${filename}
68    echo ./bin/icupkg -t${endian} ${DATFILE} ${DISTY_DIR}/tmp/${filename}
69    ./bin/icupkg -t${endian} ${DATFILE} ${DISTY_DIR}/tmp/${filename}
70    README=icu4c-${VERSION}-data-bin-${endian}-README.md
71    cat >> ${DISTY_DIR}/tmp/${README} <<EOF
72# ICU Data Zip for ${VERSION}
73
74For information on Unicode ICU, see [http://icu-project.org](http://icu-project.org)
75
76## Contents
77
78This .zip file contains:
79
80- this README
81- [LICENSE](./LICENSE)
82- ${filename}
83
84## How to use this file
85
86This file contains prebuilt data in form **${endian}**.
87("l" for Little Endian, "b" for Big Endian, "e" for EBCDIC.)
88It may be used to simplify build and installation of ICU.
89See [http://icu-project.org](http://icu-project.org) for further information.
90
91## License
92
93See [LICENSE](./LICENSE).
94
95> Copyright © 2016 and later Unicode, Inc. and others. All Rights Reserved.
96Unicode and the Unicode Logo are registered trademarks
97of Unicode, Inc. in the U.S. and other countries.
98[Terms of Use and License](http://www.unicode.org/copyright.html)
99
100EOF
101    zip -v -j ${DISTY_DIR}/${base} \
102        ${LICENSE} \
103        ${DISTY_DIR}/tmp/${README} \
104        ${DISTY_DIR}/tmp/${filename}
105    ls -lh ${DISTY_DIR}/${base}
106done
107