diff --git a/setup.py b/setup.py index 42928e3..1ca9151 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ from setuptools import setup, find_packages PACKAGE_NAME = 'tlscanary' -PACKAGE_VERSION = '3.1.0' +PACKAGE_VERSION = '3.1.1' INSTALL_REQUIRES = [ 'coloredlogs', diff --git a/tlscanary/modes/basemode.py b/tlscanary/modes/basemode.py index 76da9e3..52f9422 100644 --- a/tlscanary/modes/basemode.py +++ b/tlscanary/modes/basemode.py @@ -68,6 +68,10 @@ def setup_args(cls, parser): choices=["production", "stage", "custom"], action="store", default="production") + group.add_argument("--onecrlpin", + help="OneCRL-Tools git commit to use (default: 244e704)", + action="store", + default="244e704") group.add_argument("-p", "--prefs", help="Prefs to apply to all builds", type=str, @@ -228,7 +232,7 @@ def make_profile(self, profile_name, one_crl_env='production'): logger.info("Updating OneCRL revocation data") if one_crl_env == "production" or one_crl_env == "stage": # overwrite revocations file in test profile with live OneCRL entries from requested environment - revocations_file = one_crl.get_list(one_crl_env, self.args.workdir) + revocations_file = one_crl.get_list(one_crl_env, self.args.workdir, self.args.onecrlpin) profile_file = os.path.join(new_profile_dir, "revocations.txt") logger.debug("Writing OneCRL revocations data to `%s`" % profile_file) shutil.copyfile(revocations_file, profile_file) diff --git a/tlscanary/modes/performance.py b/tlscanary/modes/performance.py index ff9099a..974437f 100644 --- a/tlscanary/modes/performance.py +++ b/tlscanary/modes/performance.py @@ -9,7 +9,6 @@ from regression import RegressionMode import tlscanary.runlog as rl -import tlscanary.report as report logger = logging.getLogger(__name__) diff --git a/tlscanary/one_crl_downloader.py b/tlscanary/one_crl_downloader.py index c227d7c..493e1a6 100644 --- a/tlscanary/one_crl_downloader.py +++ b/tlscanary/one_crl_downloader.py @@ -14,7 +14,7 @@ logger = logging.getLogger(__name__) -def get_list(onecrl_env, workdir, use_cache=True, cache_timeout=60*60): +def get_list(onecrl_env, workdir, commit, use_cache=True, cache_timeout=60*60): global logger dc = cache.DiskCache(os.path.join(workdir, "cache"), cache_timeout, purge=True) @@ -41,10 +41,24 @@ def get_list(onecrl_env, workdir, use_cache=True, cache_timeout=60*60): # Install / update oneCRL2RevocationsTxt package package = "github.com/mozmark/OneCRL-Tools/oneCRL2RevocationsTxt" + repo_dir = os.path.join(go_path, "src", "github.com", "mozmark", "OneCRL-Tools") + # If the packaga has already been downloaded, checkout master, else `go get` will fail + if os.path.isdir(os.path.join(repo_dir, ".git")): + logger.debug("Checking out commit `master` in `%s` for update" % repo_dir) + if subprocess.call(["git", "checkout", "-q", "master"], cwd=repo_dir) != 0: + logger.critical("Cannot checkout OneCRL-Tools git commit `master`") + sys.exit(5) + # `go get` internally uses `git pull`. `-d` prevents installation logger.debug("Installing / updating Go package `%s`" % package) - if subprocess.call([go_bin, "get", "-u", package], env=go_env) != 0: + if subprocess.call([go_bin, "get", "-u", "-d", package], env=go_env) != 0: logger.critical("Cannot get Go package `%s`" % package) sys.exit(5) + # Checkout a known-working commit before installation + logger.debug("Checking out commit `%s` in `%s`" % (commit, repo_dir)) + if subprocess.call(["git", "checkout", "-q", commit], cwd=repo_dir) != 0: + logger.critical("Cannot checkout OneCRL-Tools git commit `%s`" % commit) + sys.exit(5) + # Install package if subprocess.call([go_bin, "install", package], env=go_env) != 0: logger.critical("Cannot install Go package `%s`" % package) sys.exit(5)