From 5d838aa8a216e0c474294302a2f805df9655d813 Mon Sep 17 00:00:00 2001 From: Richard Chen Zheng <58443436+rchenzheng@users.noreply.github.com> Date: Thu, 22 Apr 2021 11:51:50 -0400 Subject: T3485: Add macos support - add binary dependency checks - add os check - automate image building - use rsync to solely transfer image to local - allow custom builds --- build-tools/macos-build/check-macos-build-env | 84 +++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100755 build-tools/macos-build/check-macos-build-env (limited to 'build-tools/macos-build/check-macos-build-env') diff --git a/build-tools/macos-build/check-macos-build-env b/build-tools/macos-build/check-macos-build-env new file mode 100755 index 0000000..3cf2d2b --- /dev/null +++ b/build-tools/macos-build/check-macos-build-env @@ -0,0 +1,84 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2016 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 . +# +# File: check-macos-build-env +# Purpose: +# Checks if binaries for macOS image building are installed. + + +import os +import sys +from distutils.spawn import find_executable + +import platform + +class DependencyChecker(object): + def __init__(self, spec): + missing_binaries = self._get_missing_binaries(spec['binaries']) + self.__missing = {'binaries': missing_binaries} + + 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['binaries']: + return self.__missing + return None + + def print_missing_deps(self): + print("Missing binaries: " + " ".join(self.__missing['binaries'])) + +platform = platform.system() +if platform != 'Darwin': + print("Your system is not macOS.") + sys.exit(1) + +deps = { + 'binaries': [ + 'vagrant', + 'virtualbox', + 'rsync' + ] +} + +print("Checking if packages required for VyOS image build are installed") + +checker = DependencyChecker(deps) + +missing = checker.get_missing_dependencies() +print(missing) +if not missing: + print("All dependencies are installed") + sys.exit(0) +else: + checker.print_missing_deps() + if 'vagrant' in missing['binaries']: + print("Your system does not have Vagrant.") + print("Please install Vagrant from https://www.vagrantup.com/downloads.") + sys.exit(1) + elif 'virtualbox' in missing['binaries']: + print("Your system does not have Virtualbox.") + print("Please install Virtualbox from https://www.virtualbox.org/wiki/Downloads.") + sys.exit(1) + elif 'rsync' in missing['binaries']: + print("Your system does not have Rsync.") + print("Please install Rsync from https://formulae.brew.sh/formula/rsync.") + sys.exit(1) +sys.exit(0) -- cgit v1.2.3