forked from libapps/libapps-mirror
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfonts_create_bundle
More file actions
executable file
·56 lines (43 loc) · 1.56 KB
/
fonts_create_bundle
File metadata and controls
executable file
·56 lines (43 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env python3
# Copyright 2020 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Update our nassh fonts bundle. See ../docs/fonts.md."""
import logging
import sys
import nassh # pylint: disable=wrong-import-order
import libdot
def get_parser():
"""Get a command line parser."""
parser = libdot.ArgumentParser(description=__doc__)
return parser
def main(argv):
"""The main func!"""
parser = get_parser()
_opts = parser.parse_args(argv)
tar = nassh.DIR / "fonts.tar.xz"
libdot.pack(tar, ["fonts"], exclude=["fonts/.hash"], cwd=nassh.DIR)
new_hash = libdot.sha256(tar)
final_tar = nassh.DIR / f"fonts-{new_hash}.tar.xz"
tar.rename(final_tar)
manifest_path = nassh.DIR / "fetch.json"
manifest = libdot.ArtifactManifest.from_file(manifest_path)
artifact = manifest.files.get("fonts", libdot.Artifact())
artifact.size = final_tar.stat().st_size
artifact.url = "/".join(
(
"https://storage.googleapis.com",
"chromeos-localmirror/secureshell/distfiles",
final_tar.name,
)
)
artifact.hashes = {"sha256": new_hash}
manifest_path.write_text(manifest.toJSON(), encoding="utf-8")
(nassh.DIR / "fonts" / ".hash").write_text(new_hash, encoding="utf-8")
logging.info(
"To upload the new fonts:\ngsutil cp -a public-read %s %s",
final_tar,
"gs://chromeos-localmirror/secureshell/distfiles/",
)
if __name__ == "__main__":
sys.exit(main(sys.argv[1:]))