From 08a6856b3c8f3146343647f996fca9c48fb4e960 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Fri, 4 Mar 2016 15:05:03 -0500 Subject: Factor out dependency checking functions to its own class (ref T9). --- scripts/check-build-env | 49 +++++++++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 26 deletions(-) (limited to 'scripts/check-build-env') diff --git a/scripts/check-build-env b/scripts/check-build-env index 6f08847f..6dcf885b 100755 --- a/scripts/check-build-env +++ b/scripts/check-build-env @@ -23,34 +23,31 @@ import os import sys -required_packages = [ - 'sudo', - 'make', - 'live-build', - 'pbuilder', - 'devscripts', - 'python-pystache' -] - - -def is_installed(name): - result = os.system("dpkg-query -W --showformat='${{Status}}\n' {name} 2>&1 | grep 'install ok installed' >/dev/null".format(name=name)) - return True if result == 0 else False - - -missing_packages = [] +import util + +deps = { + 'packages': [ + 'sudo', + 'make', + 'live-build', + 'pbuilder', + 'devscripts', + 'python-pystache' + ], + 'binaries': [] +} print("Checking if packages required for VyOS image build are installed") -for p in required_packages: - if not is_installed(p): - missing_packages.append(p) +checker = util.DependencyChecker(deps) -if missing_packages: - print("Your system does not have some of the required packages installed.") - print("Please install the following packages:") - print(" ".join(missing_packages)) - sys.exit(1) -else: - print("All required packages are installed") +missing = checker.get_missing_dependencies() +if not missing: + print("All dependencies are installed") sys.exit(0) +else: + checker.print_missing_deps() + sys.exit(1) + +sys.exit(0) + -- cgit v1.2.3