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 30# Short (major) version, i.e. 70 31VERS=$(echo ${DATFILE} | tr -d a-z/.) 32# Version number, i.e. 70.1 33VERSION=${VERSION-unknown} 34# Version number for files, i.e. 70_1 35VERSION_FILE=$(echo ${VERSION} | tr . _) 36 37if [[ "${VERSION}" = "unknown" ]]; 38then 39 VERSION=${VERS}.0 40 echo "$0: VERSION not set, using ${VERSION}" 41else 42 if [[ "${VERS}" != $(echo ${VERSION} | cut -d. -f1) ]] 43 then 44 echo >&2 "$0: Warning: Expected version ${VERSION} to start with ${VERS}..." 45 fi 46fi 47 48# yeah, override ENDIANS if you want a different flavor. 49#ENDIANS="b l e" 50ENDIANS=${ENDIANS-"b l"} 51DISTY_DIR=${DISTY_DIR-./dist/} 52 53if [ ! -x ./bin/icupkg ] 54then 55 echo >&2 "$0: could not find executable ./bin/icupkg" 56 exit 1 57fi 58 59echo "# Packing ${DATFILE} into data zips in dist/ for version ${VERSION}" 60mkdir -p ${DISTY_DIR}/tmp 61 62for endian in $ENDIANS; 63do 64 base=icu4c-${VERSION_FILE}-data-bin-${endian}.zip 65 filename=icudt${VERS}${endian}.dat 66 if [ -f ${DISTY_DIR}/${base} ]; 67 then 68 echo ${DISTY_DIR}/${base} exists, skipping 69 continue 70 fi 71 rm -f ${DISTY_DIR}/tmp/${filename} 72 echo ./bin/icupkg -t${endian} ${DATFILE} ${DISTY_DIR}/tmp/${filename} 73 ./bin/icupkg -t${endian} ${DATFILE} ${DISTY_DIR}/tmp/${filename} 74 README=icu4c-${VERSION_FILE}-data-bin-${endian}-README.md 75 cat >> ${DISTY_DIR}/tmp/${README} <<EOF 76# ICU Data Zip for ${VERSION} 77 78For information on Unicode ICU, see [http://icu-project.org](http://icu-project.org) 79 80## Contents 81 82This .zip file contains: 83 84- this README 85- [LICENSE](./LICENSE) 86- ${filename} 87 88## How to use this file 89 90This file contains prebuilt data in form **${endian}**. 91("l" for Little Endian, "b" for Big Endian, "e" for EBCDIC.) 92It may be used to simplify build and installation of ICU. 93See [http://icu-project.org](http://icu-project.org) for further information. 94 95## License 96 97See [LICENSE](./LICENSE). 98 99> Copyright © 2016 and later Unicode, Inc. and others. All Rights Reserved. 100Unicode and the Unicode Logo are registered trademarks 101of Unicode, Inc. in the U.S. and other countries. 102[Terms of Use and License](http://www.unicode.org/copyright.html) 103 104EOF 105 zip -v -j ${DISTY_DIR}/${base} \ 106 ${LICENSE} \ 107 ${DISTY_DIR}/tmp/${README} \ 108 ${DISTY_DIR}/tmp/${filename} 109 ls -lh ${DISTY_DIR}/${base} 110done 111