| # Copyright 2024 The Fuchsia Authors. All rights reserved. | |
| # Use of this source code is governed by a BSD-style license that can be | |
| # found in the LICENSE file. | |
| import sys | |
| import urllib.request | |
| CIPD_YAML = """# This file was auto-generated by update_ucd_prebuilt.py | |
| # For more information, see //src/storage/fxfs/unicode/scripts/ | |
| # | |
| # To upload the files in this CIPD package do: | |
| # | |
| # VERSION=version:{version} | |
| # cipd create -pkg-def cipd.yaml -tag $VERSION | |
| # | |
| package: fuchsia/third_party/ucd | |
| description: Unicode UCD data files. | |
| data: | |
| - file: LICENSE | |
| - file: README.fuchsia | |
| - file: UCD.zip | |
| """ | |
| README = """Name: Unicode UCD | |
| URL: https://www.unicode.org/Public/ | |
| URL: https://www.unicode.org/Public/{version}/ucd/ | |
| License: Unicode License V3 | |
| License: https://www.unicode.org/license.txt | |
| License File: LICENSE | |
| Description: | |
| This package contains the official UCD data set published by unicode.org. | |
| This data may be used to implement normalization, case folding, etc. | |
| """ | |
| def main(argv): | |
| if len(argv) != 2: | |
| # e.g. "12.1.0" | |
| print("Usage: %s <version>" % argv[0]) | |
| sys.exit(1) | |
| version = argv[1] | |
| url = "https://www.unicode.org/Public/%s/ucd/UCD.zip" % version | |
| urllib.request.urlretrieve(url, "/tmp/UCD.zip") | |
| urllib.request.urlretrieve( | |
| "https://www.unicode.org/license.txt", "/tmp/LICENSE" | |
| ) | |
| open("/tmp/cipd.yaml", "wt").write(CIPD_YAML.format(version=version)) | |
| open("/tmp/README.fuchsia", "wt").write(README.format(version=version)) | |
| if __name__ == "__main__": | |
| main(sys.argv) |