blob: 981e467d510c07ea6f6d6755b989700bc2d179ce [file] [log] [blame]
#!/usr/bin/env python3
# Copyright 2021 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Download plugin to bundle with nassh/crosh."""
import os
import sys
import nassh # pylint: disable=wrong-import-order
import libdot
# The sha256sum hash of the plugin archive that we maintain.
# Allow a long line for easy automated updating.
# pylint: disable=line-too-long
PLUGIN_HASH = "0388d6e1ad38fd37bc9e022b214b140b54dcfb0aefe387bdccf17621d7888242"
# pylint: enable=line-too-long
# Bucket maintained by us.
PLUGIN_VERSION = "0.52"
PLUGIN_GS_FRAGMENT = "chromeos-localmirror/secureshell/releases"
PLUGIN_BASE_URI = f"https://storage.googleapis.com/{PLUGIN_GS_FRAGMENT}"
# The nassh plugin path.
PLUGIN_DIR = nassh.DIR / "plugin"
def plugin_update():
"""Download our copy of plugin if it doesn't exist."""
# TODO(joelhockey): It would be nicer if plugin files had a prefix such as
# plugin-0.47.tar.xz rather than just the version 0.47.tar.xz.
if not os.path.exists(PLUGIN_DIR):
libdot.download_tarball(
f"{PLUGIN_VERSION}.tar.xz", PLUGIN_BASE_URI, PLUGIN_DIR, PLUGIN_HASH
)
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)
plugin_update()
if __name__ == "__main__":
sys.exit(main(sys.argv[1:]))