summaryrefslogtreecommitdiff
path: root/scripts/util.py
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@vyos.io>2022-10-06 12:08:40 -0400
committerDaniil Baturin <daniil@vyos.io>2022-10-06 17:55:01 -0400
commit3979b25dcf137600b6ba7ccd361ae78515c012e8 (patch)
tree2480bb35911dbb09557be01869d71c782e882e5e /scripts/util.py
parent7149a2aa2e51abe6ffb2d81db4ff58da825f0da8 (diff)
downloadvyos-build-3979b25dcf137600b6ba7ccd361ae78515c012e8.tar.gz
vyos-build-3979b25dcf137600b6ba7ccd361ae78515c012e8.zip
T3664: initial implementation of the build flavor system
Diffstat (limited to 'scripts/util.py')
-rw-r--r--scripts/util.py65
1 files changed, 0 insertions, 65 deletions
diff --git a/scripts/util.py b/scripts/util.py
deleted file mode 100644
index 7cc33364..00000000
--- a/scripts/util.py
+++ /dev/null
@@ -1,65 +0,0 @@
-# Copyright (C) 2015 VyOS maintainers and contributors
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 2 or later as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-# File: util.py
-# Purpose:
-# Various common functions for use in build scripts.
-
-
-import sys
-import os
-from distutils.spawn import find_executable
-
-import defaults
-
-def check_build_config():
- if not os.path.exists(defaults.BUILD_CONFIG):
- print("Build config file ({file}) does not exist".format(file=defaults.BUILD_CONFIG))
- print("If you are running this script by hand, you should better not. Run 'make iso' instead.")
- sys.exit(1)
-
-
-class DependencyChecker(object):
- def __init__(self, spec):
- missing_packages = self._get_missing_packages(spec['packages'])
- missing_binaries = self._get_missing_binaries(spec['binaries'])
- self.__missing = {'packages': missing_packages, 'binaries': missing_binaries}
-
-
- def _package_installed(self, 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
-
- def _get_missing_packages(self, packages):
- missing_packages = []
- for p in packages:
- if not self._package_installed(p):
- missing_packages.append(p)
- return missing_packages
-
- def _get_missing_binaries(self, binaries):
- missing_binaries = []
- for b in binaries:
- if not find_executable(b):
- missing_binaries.append(b)
- return missing_binaries
-
- def get_missing_dependencies(self):
- if self.__missing['packages'] or self.__missing['binaries']:
- return self.__missing
- return None
-
- def print_missing_deps(self):
- print("Missing packages: " + " ".join(self.__missing['packages']))
- print("Missing binaries: " + " ".join(self.__missing['binaries']))