blob: 40f9bc9846b9bb7bcfa3c47054a63fc2b2fcfec9 [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 = "3748287ffbb41be7041287f69a9e41362c4580cab75891db190901e53ce7f3ea"
# pylint: enable=line-too-long
# Bucket maintained by us.
PLUGIN_VERSION = "0.66"
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:]))