diff options
author | Victor Chang <vichang@google.com> | 2023-09-08 13:15:23 +0100 |
---|---|---|
committer | Almaz Mingaleev <mingaleev@google.com> | 2024-05-07 09:23:41 +0100 |
commit | ddc7de24b7eea4dcbe6b5a7df6e73d576e095bdd (patch) | |
tree | acb000cf3a0243cf82e38b54e7d0e19cfeb38850 | |
parent | 3f12edbca6124319272d774c1744ea889d409d6b (diff) | |
download | icu-master.tar.gz |
Bug: 298349312
Bug: 319103072
Test: system/timezone/update-tzdata.py
Test: CtsIcuTestCases
Change-Id: I465ce82b44c2b6328480ccf7485e1c72a9100db1
-rw-r--r-- | android_icu4j/testing/src/android/icu/extratest/platform/AndroidDataFilesTest.java | 37 | ||||
-rw-r--r-- | icu4c/source/data/misc/zoneinfo64.txt | 2 | ||||
-rw-r--r-- | icu4j/main/shared/data/icudata.jar | bin | 12327199 -> 12327199 bytes | |||
-rw-r--r-- | tools/icuutil.py | 52 |
4 files changed, 27 insertions, 64 deletions
diff --git a/android_icu4j/testing/src/android/icu/extratest/platform/AndroidDataFilesTest.java b/android_icu4j/testing/src/android/icu/extratest/platform/AndroidDataFilesTest.java index 4092759de..190fb3d1b 100644 --- a/android_icu4j/testing/src/android/icu/extratest/platform/AndroidDataFilesTest.java +++ b/android_icu4j/testing/src/android/icu/extratest/platform/AndroidDataFilesTest.java @@ -20,6 +20,8 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; +import static java.util.stream.Collectors.toSet; + import android.icu.platform.AndroidDataFiles; import android.icu.testsharding.MainTestShard; import android.icu.util.VersionInfo; @@ -45,8 +47,12 @@ import java.util.stream.Stream; @RunWith(JUnit4.class) public class AndroidDataFilesTest { - private static final String TZDATA_DAT_PATH = - "/apex/com.android.tzdata/etc/icu/icu_tzdata.dat"; + private static final Set<String> TZDATA_RES_FILES = + Set.of( + "/apex/com.android.tzdata/etc/icu/metaZones.res", + "/apex/com.android.tzdata/etc/icu/windowsZones.res", + "/apex/com.android.tzdata/etc/icu/zoneinfo64.res", + "/apex/com.android.tzdata/etc/icu/timezoneTypes.res"); private static final String ICU_DAT_PATH = "/apex/com.android.i18n/etc/icu/icudt" + VersionInfo.ICU_VERSION.getMajor() + "l.dat"; @@ -62,20 +68,26 @@ public class AndroidDataFilesTest { String path = AndroidDataFiles.generateIcuDataPath(); String[] dataDirs = path.split(":"); - // List all readable".dat" files in the directories. - Set<String> datFiles = Arrays.stream(dataDirs) + // List all readable ".dat" and ".res" files in the directories. + Set<String> icuFiles = Arrays.stream(dataDirs) .filter((dir) -> dir != null && !dir.isEmpty()) .map((dir) -> new File(dir)) .filter((f) -> f.canRead() && f.isDirectory()) .map((f) -> f.listFiles()) .filter((files) -> files != null) .flatMap(files -> Stream.of(files)) - .filter((f) -> f != null && f.canRead() && f.getName().endsWith(".dat")) + .filter((f) -> f != null && f.canRead() && isIcuFile(f)) .map(f -> f.getPath()) - .collect(Collectors.toSet()); + .collect(toSet()); - assertContains(datFiles, TZDATA_DAT_PATH); - assertContains(datFiles, ICU_DAT_PATH); + for (String resFile : TZDATA_RES_FILES) { + assertContains(icuFiles, resFile); + } + assertContains(icuFiles, ICU_DAT_PATH); + } + + private static boolean isIcuFile(File file) { + return file.getName().endsWith(".res") || file.getName().endsWith(".dat"); } private static void assertContains(Set<String> set, String member) { @@ -110,15 +122,6 @@ public class AndroidDataFilesTest { assertNull(getData.invoke(icuDat, "timezoneTypes.res")); assertNull(getData.invoke(icuDat, "windowsZones.res")); assertNull(getData.invoke(icuDat, "zoneinfo64.res")); - - ByteBuffer tzDatBuffer = mmapPath(TZDATA_DAT_PATH); - assertTrue((Boolean) validate.invoke(null, tzDatBuffer)); - Object tzDat = constructor.newInstance(TZDATA_DAT_PATH, tzDatBuffer); - assertNull(getData.invoke(tzDat, "root.res")); - assertNotNull(getData.invoke(tzDat, "metaZones.res")); - assertNotNull(getData.invoke(tzDat, "timezoneTypes.res")); - assertNotNull(getData.invoke(tzDat, "windowsZones.res")); - assertNotNull(getData.invoke(tzDat, "zoneinfo64.res")); } private static ByteBuffer mmapPath(String path) throws IOException { diff --git a/icu4c/source/data/misc/zoneinfo64.txt b/icu4c/source/data/misc/zoneinfo64.txt index 9838ef48e..c75623e2e 100644 --- a/icu4c/source/data/misc/zoneinfo64.txt +++ b/icu4c/source/data/misc/zoneinfo64.txt @@ -3,7 +3,7 @@ // License & terms of use: http://www.unicode.org/copyright.html //--------------------------------------------------------- // Build tool: tz2icu -// Build date: Wed Feb 7 16:30:19 2024 +// Build date: Tue May 7 09:16:36 2024 // tz database: ftp://ftp.iana.org/tz/ // tz version: 2024a // ICU version: 75.1 diff --git a/icu4j/main/shared/data/icudata.jar b/icu4j/main/shared/data/icudata.jar Binary files differindex ad836705c..c6918076c 100644 --- a/icu4j/main/shared/data/icudata.jar +++ b/icu4j/main/shared/data/icudata.jar diff --git a/tools/icuutil.py b/tools/icuutil.py index 4821809ef..3164109b5 100644 --- a/tools/icuutil.py +++ b/tools/icuutil.py @@ -234,11 +234,10 @@ def CopyIcu4jDataFiles(): print('Copying %s to %s ...' % (jarfile, icu_jar_data_dir)) shutil.copy(jarfile, icu_jar_data_dir) -def MakeAndCopyOverlayTzIcuData(icu_build_dir, dest_file): - """Makes a .dat file containing just time-zone data. +def MakeAndCopyIcuTzFiles(icu_build_dir, res_dest_dir): + """Makes .res files containing just time zone data. - The overlay file can be used as an overlay of a full ICU .dat file - to provide newer time zone data. Some strings like translated + They provide time zone data only: some strings like translated time zone names will be missing, but rules will be correct. """ @@ -264,50 +263,11 @@ def MakeAndCopyOverlayTzIcuData(icu_build_dir, dest_file): sys.exit(1) icu_package = icu_package_dat[:-4] - # Create a staging directory to hold the files to go into the overlay .dat - res_staging_dir = '%s/overlay_res' % icu_build_dir - os.mkdir(res_staging_dir) - - # Copy all the .res files we need from, e.g. ./data/out/build/icudt55l, to the staging directory + # Copy all the .res files we need from, e.g. ./data/out/build/icudt55l, to the + # destination directory. res_src_dir = '%s/data/out/build/%s' % (icu_build_dir, icu_package) for tz_res_name in tz_res_names: - shutil.copy('%s/%s' % (res_src_dir, tz_res_name), res_staging_dir) - - # Create a .lst file to pass to pkgdata. - tz_files_file = '%s/tzdata.lst' % res_staging_dir - with open(tz_files_file, "a") as tz_files: - for tz_res_name in tz_res_names: - tz_files.write('%s\n' % tz_res_name) - - icu_lib_dir = '%s/lib' % icu_build_dir - pkg_data_bin = '%s/bin/pkgdata' % icu_build_dir - - # Run pkgdata to create a .dat file. - icu_env = os.environ.copy() - icu_env["LD_LIBRARY_PATH"] = icu_lib_dir - - # pkgdata treats the .lst file it is given as relative to CWD, and the path also affects the - # resource names in the .dat file produced so we change the CWD. - os.chdir(res_staging_dir) - - # -F : force rebuilding all data - # -m common : create a .dat - # -v : verbose - # -T . : use "." as a temp dir - # -d . : use "." as the dest dir - # -p <name> : Set the "data name" - p = subprocess.Popen( - [pkg_data_bin, '-F', '-m', 'common', '-v', '-T', '.', '-d', '.', '-p', - icu_package, tz_files_file], - env=icu_env) - p.wait() - if p.returncode != 0: - print('pkgdata failed with status code: %s' % p.returncode) - - # Copy the .dat to the chosen place / name. - generated_dat_file = '%s/%s' % (res_staging_dir, icu_package_dat) - shutil.copyfile(generated_dat_file, dest_file) - print('ICU overlay .dat can be found here: %s' % dest_file) + shutil.copy('%s/%s' % (res_src_dir, tz_res_name), res_dest_dir) # Switch back to the original working cwd. os.chdir(original_working_dir) |