summaryrefslogtreecommitdiff
path: root/scripts/check-build-env
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2016-03-04 15:05:03 -0500
committerDaniil Baturin <daniil@baturin.org>2016-03-04 15:05:03 -0500
commit08a6856b3c8f3146343647f996fca9c48fb4e960 (patch)
tree1166dee4b9cee8884b3bdf3fb02d5297cac3877a /scripts/check-build-env
parentc6bca34587458c1abee07ff7af7d618ea2f40b9c (diff)
downloadvyos-build-08a6856b3c8f3146343647f996fca9c48fb4e960.tar.gz
vyos-build-08a6856b3c8f3146343647f996fca9c48fb4e960.zip
Factor out dependency checking functions to its own class (ref T9).
Diffstat (limited to 'scripts/check-build-env')
-rwxr-xr-xscripts/check-build-env49
1 files changed, 23 insertions, 26 deletions
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)
+