diff options
author | Daniil Baturin <daniil@vyos.io> | 2024-03-23 20:50:36 +0000 |
---|---|---|
committer | Christian Breunig <christian@breunig.cc> | 2024-05-05 15:07:54 +0200 |
commit | df058a250f3845e9126ec0d684fafc4d302b0afe (patch) | |
tree | 7d4af40739dc1c64b6234d4380f4c7a5f9fa5f19 /scripts/vyos_build_utils.py | |
parent | 0f54ee83e570105a3e01ea6130219009271e3917 (diff) | |
download | vyos-build-df058a250f3845e9126ec0d684fafc4d302b0afe.tar.gz vyos-build-df058a250f3845e9126ec0d684fafc4d302b0afe.zip |
build scripts: T3664: move image build scripts to a dedicated directory
to avoid a mix of image build scripts and ancilliary scripts in the same directory
(cherry picked from commit 750819bfec5335566dfc48de1ab6dbbc869068a3)
Diffstat (limited to 'scripts/vyos_build_utils.py')
-rw-r--r-- | scripts/vyos_build_utils.py | 77 |
1 files changed, 0 insertions, 77 deletions
diff --git a/scripts/vyos_build_utils.py b/scripts/vyos_build_utils.py deleted file mode 100644 index ed358848..00000000 --- a/scripts/vyos_build_utils.py +++ /dev/null @@ -1,77 +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 vyos_build_defaults as 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 format_missing_dependencies(self): - msg = "E: There are missing system dependencies!\n" - if self.__missing['packages']: - msg += "E: Missing packages: " + " ".join(self.__missing['packages']) - if self.__missing['binaries']: - msg += "E: Missing binaries: " + " ".join(self.__missing['binaries']) - return msg - -def check_system_dependencies(deps): - checker = DependencyChecker(deps) - missing = checker.get_missing_dependencies() - if missing: - raise OSError(checker.format_missing_dependencies()) - else: - pass |