github.com/swiftstack/ProxyFS@v0.0.0-20210203235616-4017c267d62f/ci/ansible/check_pinned_packages (about) 1 #!/usr/bin/env python 2 3 # Copyright (c) 2015-2021, NVIDIA CORPORATION. 4 # SPDX-License-Identifier: Apache-2.0 5 6 import json 7 import os 8 import subprocess 9 import sys 10 11 12 script_dir = os.path.abspath(os.path.dirname(__file__)) 13 json_path = os.path.join(script_dir, "chef_files", "packages", "rhel_ss.json") 14 15 with open(json_path, "r") as json_file: 16 versions_data = json.load(json_file) 17 18 everything_ok = True 19 for section, packages in versions_data.items(): 20 for package_info in packages: 21 if len(package_info) == 1: 22 continue 23 package, pinned_version = package_info 24 try: 25 yum_versions = subprocess.check_output( 26 "repoquery {} --queryformat '%{{vr}}'".format(package), 27 shell=True, stderr=subprocess.STDOUT) 28 except subprocess.CalledProcessError as e: 29 print("! Error checking {}: {}".format( 30 package, e.output.strip())) 31 everything_ok = False 32 continue 33 yum_versions = yum_versions.strip().split("\n") 34 if pinned_version not in yum_versions: 35 print("{} not ok! pinned: {} | found in yum: {}".format( 36 package, pinned_version, ", ".join(yum_versions))) 37 everything_ok = False 38 39 if everything_ok: 40 print("All pinned packages are installable") 41 else: 42 print("\nFinished with errors") 43 sys.exit(1)