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