1#!/bin/bash 2# Copyright (c) 2016 The Chromium Authors. All rights reserved. 3# Use of this source code is governed by a BSD-style license that can be 4# found in the LICENSE file. 5 6# This is used to prepare for a major version update of ICU (e.g. from 7# 54.1 to 56.1). Running this script is step 1 in README.chromium. 8 9if [ $# -lt 1 ]; 10then 11 echo "Usage: "$0" version (e.g. '56-1')" >&2 12 exit 1 13fi 14 15version="$1" 16 17# Makes ("68" "1") from "68-1". 18readonly major_minor_version=(${version//-/ }) 19 20# Just the major part of the ICU version number, e.g. "68". 21readonly major_version="${major_minor_version[0]}" 22 23repoprefix="https://github.com/unicode-org/icu/tags/release-" 24repo="${repoprefix}${version}/icu4c" 25treeroot="$(dirname "$0")/.." 26 27# Check if the repo for $version is available. 28svn ls "${repo}" > /dev/null 2>&1 || \ 29 { echo "${repo} does not exist." >&2; exit 2; } 30 31echo "Cleaning up source/ ..." 32for file in source LICENSE license.html readme.html APIChangeReport.html 33do 34 rm -rf "${treeroot}/${file}" 35done 36 37echo "Download ${version} from the upstream repository ..." 38for file in source LICENSE license.html readme.html APIChangeReport.html 39do 40 svn export --native-eol LF "${repo}/${file}" "${treeroot}/${file}" 41done 42 43echo "deleting directories we don't care about ..." 44for d in layoutex data/xml test allinone 45do 46 rm -rf "${treeroot}/source/${d}" 47done 48 49echo "deleting Visual Studio build files ..." 50find "${treeroot}/source" -name *vcxp* -o -name *sln | xargs rm 51 52echo "restoring local data and configuration files ..." 53while read line 54do 55 # $line is not quoted to expand "*html.ucm". 56 git checkout -- "${treeroot}/source/data/"${line} 57done < "${treeroot}/scripts/data_files_to_preserve.txt" 58 59echo "Patching configure to work without source/{layoutex,test} ..." 60sed -i.orig -e '/^ac_config_files=/ s:\ layoutex/Makefile::g' \ 61 -e '/^ac_config_files=/ s: test/.* samples/M: samples/M:' \ 62 "${treeroot}/source/configure" 63rm -f "${treeroot}/source/configure.orig" 64 65echo "git-adding new files" 66git status source | sed -n '/^Untracked/,$ p' | grep source | xargs git add 67 68cd "${treeroot}" 69 70echo "Updating sources.gni" 71 72find source/i18n -maxdepth 1 ! -type d | egrep '\.(c|cpp|h)$' |sort | \ 73 sed 's/^\(.*\)$/ "\1",/' > i18n_src.list 74ls source/i18n/unicode/*h | sort | sed 's/^\(.*\)$/ "\1",/' > i18n_hdr.list 75 76find source/common -maxdepth 1 ! -type d | egrep '\.(c|cpp|h)$' |sort | \ 77 sed 's/^\(.*\)$/ "\1",/' > common_src.list 78ls source/common/unicode/*h | sort | \ 79 sed 's/^\(.*\)$/ "\1",/' > common_hdr.list 80 81sed -i \ 82 '/I18N_SRC_START/,/I18N_SRC_END/ { 83 /I18N_SRC_START/ r i18n_src.list 84 /source.i18n/ d 85 } 86 /I18N_HDR_START/,/I18N_HDR_END/ { 87 /I18N_HDR_START/ r i18n_hdr.list 88 /source.i18n/ d 89 } 90 /COMMON_SRC_START/,/COMMON_SRC_END/ { 91 /COMMON_SRC_START/ r common_src.list 92 /source.common/ d 93 } 94 /COMMON_HDR_START/,/COMMON_HDR_END/ { 95 /COMMON_HDR_START/ r common_hdr.list 96 /source.common/ d 97 }' sources.gni 98 99echo "Updating icu.gyp* files" 100 101ls source/i18n/unicode/*h | sort | \ 102 sed "s/^.*i18n\/\(.*\)$/ '\1',/" > i18n_hdr.list 103ls source/common/unicode/*h | sort | \ 104 sed "s/^.*common\/\(.*\)$/ '\1',/" > common_hdr.list 105 106 107find source/i18n -maxdepth 1 ! -type d | egrep '\.(c|cpp)$' | \ 108 sort | sed "s/^\(.*\)$/ '\1',/" > i18n_src.list 109find source/common -maxdepth 1 ! -type d | egrep '\.(c|cpp)$' | \ 110 sort | sed "s/^\(.*\)$/ '\1',/" > common_src.list 111 112sed -i \ 113 '/I18N_HDR_START/,/I18N_HDR_END/ { 114 /I18N_HDR_START/ r i18n_hdr.list 115 /.unicode.*\.h.,$/ d 116 } 117 /COMMON_HDR_START/,/COMMON_HDR_END/ { 118 /COMMON_HDR_START/ r common_hdr.list 119 /.unicode.*\.h.,$/ d 120 }' icu.gyp 121 122sed -i \ 123 '/I18N_SRC_START/,/I18N_SRC_END/ { 124 /I18N_SRC_START/ r i18n_src.list 125 /source\/i18n/ d 126 } 127 /COMMON_SRC_START/,/COMMON_SRC_END/ { 128 /COMMON_SRC_START/ r common_src.list 129 /source\/common/ d 130 }' icu.gypi 131 132# Update the major version number registered in version.gni. 133cat << EOF > version.gni 134# Copyright 2020 The Chromium Authors. All rights reserved. 135# Use of this source code is governed by a BSD-style license that can be 136# found in the LICENSE file. 137 138declare_args() { 139 # Contains the major version number of the ICU library, for dependencies that 140 # need different configuration based on the library version. Currently this 141 # is only useful in Fuchsia. 142 icu_major_version_number = "${major_version}" 143} 144EOF 145 146echo "Done" 147