From bfd7db3136e71531fb1dc972f835705f494bb032 Mon Sep 17 00:00:00 2001 From: ngn Date: Mon, 19 Aug 2024 00:50:31 +0300 Subject: [PATCH] update: make sure mp-build checks build-essential as a depend --- README.md | 1 - matter-iso/main.sh | 4 +-- mp-build/scripts/mp-build.sh | 57 ++++++++++++++++++++++++------------ 3 files changed, 41 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 5e0ebf9..8e3d739 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,6 @@ Following dependencies are required for these scripts and tools: - bash - coreutils -- gcc - make - GRUB (please see matter-iso warning) - gnupg diff --git a/matter-iso/main.sh b/matter-iso/main.sh index 73894db..7aa654a 100755 --- a/matter-iso/main.sh +++ b/matter-iso/main.sh @@ -78,8 +78,8 @@ check_iso_vars() { if ! type "grub-mkrescue" > /dev/null; then error "You need to install GRUB to create ISO files with grub-mkrescue" set_indent - info "If you want to create UEFI ISO files make sure you install x64 GRUB or grub-efi" - info "If you want to create BIOS ISO files make sure you install x86 GRUB or grub-bios" + warn "If you want to create UEFI ISO files make sure you install x64 GRUB or grub-efi" + warn "If you want to create BIOS ISO files make sure you install x86 GRUB or grub-bios" exit 1 fi diff --git a/mp-build/scripts/mp-build.sh b/mp-build/scripts/mp-build.sh index c976fac..89ea74d 100755 --- a/mp-build/scripts/mp-build.sh +++ b/mp-build/scripts/mp-build.sh @@ -105,25 +105,31 @@ clean_dist() { rm -f "${distpath}/files.tar.gz" } -# checks/installs a list of depends -check_depends() { - local list=("$@") - - if [ "${#list[@]}" == "0" ]; then - info "Got zero depends, skipping depend check" - return 0 - fi - +# install a list of packages with matt +matt_install(){ if [ "$EUID" -ne 0 ]; then if type doas > /dev/null; then DOAS="doas" elif type sudo > /dev/null; then DOAS="sudo" else - error "Failed to find doas or sudo, skipping depend check" - return 0 + error "Failed to find doas or sudo, cannot run the install command" + return 1 fi fi + + $DOAS matt install --yes --skip --ignore-none $@ + return $? +} + +# checks and installs a list of depends +check_depends() { + local list=("$@") + + if [ "${#list[@]}" == "0" ]; then + info "Got zero depends, skipping depend check" + return 0 + fi for dep in "${list[@]}"; do if [ -z "${depends_str}" ]; then @@ -133,12 +139,12 @@ check_depends() { fi done - depends_uniq=$(echo "${depends_str}" | tr ' ' '\n' | sort | uniq) - depends_count=$(echo "${depends_uniq}" | wc -l) - depends_uniq=$(echo "${depends_uniq}" | tr '\n' ' ') + depends_uniq="$(echo "${depends_str}" | tr ' ' '\n' | sort | uniq)" + depends_count="$(echo "${depends_uniq}" | wc -l)" + depends_uniq="$(echo "${depends_uniq}" | tr '\n' ' ')" info "Installing ${depends_count} depends" - $DOAS matt install --yes --skip --ignore-none $depends_uniq + matt_install $depends_uniq return $? } @@ -202,10 +208,12 @@ if [ ! -d "${TARGET}" ]; then fi if [ $OPT_NO_DEPEND -eq 0 ] && ! command -v matt &> /dev/null; then - error "!!! BUILD ON MATTERLINUX !!!" - error "matt is not installed, please build on a MatterLinux system" - error "Do NOT create bug reports if build fails on non-MatterLinux systems" + error "BUILD ON MATTERLINUX!" + set_indent + warn "matt is not installed, please build on a MatterLinux system" + warn "Do NOT create bug reports if build fails on non-MatterLinux systems" info "Auto enabling NO_DEPEND as depend check will fail without matt" + unset_indent OPT_NO_DEPEND=1 fi @@ -277,8 +285,21 @@ all_depends+=("${DEPENDS[@]}") all_depends+=("${BUILD[@]}") if [ $OPT_NO_DEPEND -eq 0 ]; then + info "Checking all the dependencies" + set_indent + + is_essential_installed="$(matt info build-essential --grep | grep INSTALLED)" + is_essential_installed="$(echo "${is_essential_installed}" | cut -d: -f2)" + + if [ "${is_essential_installed}" == "0" ]; then + info "Installing build-essential (required for every build)" + matt_install build-essential + check_ret "Failed to install build-essential package" + fi + check_depends "${all_depends[@]}" check_ret "Failed to check all the dependencies" + unset_indent fi # make sure file count and the hash count is the same