blob: 269079f2d1aed49ff277857e65a303ef1b2e770f [file] [log] [blame]
#!/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 os
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.LIBAPPS_DIR / "fonts.tar.xz"
libdot.pack(tar, ["fonts"], exclude=["fonts/.hash"], cwd=nassh.DIR)
new_hash = libdot.sha256(tar)
final_tar = nassh.LIBAPPS_DIR / f"fonts-{new_hash}.tar.xz"
os.rename(tar, final_tar)
logging.info(
"To update the hash, run:\n"
"sed -i \"/^FONTS_HASH *=/s:=.*:= '%s':\" '%s/fonts'",
new_hash,
nassh.BIN_DIR,
)
logging.info(
"To upload the new fonts:\ngsutil cp -a public-read %s %s/",
final_tar,
nassh.fonts.FONTS_GS_URI,
)
if __name__ == "__main__":
sys.exit(main(sys.argv[1:]))