From bb9db70c97359fed8f24d0b9640cb310a89aca8c Mon Sep 17 00:00:00 2001 From: Geoffroy Van Cutsem Date: Tue, 15 Feb 2022 12:07:57 +0100 Subject: [PATCH] Makefile: detect if 'dpkg' is available The 'dpkg' utility is required in order to build Debian packages. If it is not installed and available on the build system, the 'make' instructions will fail with a Python traceback. Fix this by detecting its availability and doing a graceful exit if not (or simply skip the step). Tracked-On: #7109 Signed-off-by: Geoffroy Van Cutsem Co-authored-by: David Kinder --- Makefile | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 1e09956d4..13b734193 100644 --- a/Makefile +++ b/Makefile @@ -79,13 +79,16 @@ BUILD_TAG ?= HV_CFG_LOG = $(HV_OUT)/cfg.log VM_CONFIGS_DIR = $(T)/misc/config_tools ASL_COMPILER ?= $(shell which iasl) +DPKG_BIN ?= $(shell which dpkg) .PHONY: all hypervisor devicemodel tools life_mngr doc all: hypervisor devicemodel tools @cat $(HV_CFG_LOG) - @DEB_BOARD=$$(grep "BOARD" $(HV_CFG_LOG) | awk -F '= ' '{print $$2 }'); \ - DEB_SCENARIO=$$(grep "SCENARIO" $(HV_CFG_LOG) | awk -F '= ' '{print $$2 }'); \ - python3 misc/packaging/gen_acrn_deb.py acrn_all $(ROOT_OUT) --version=$(FULL_VERSION) --board_name="$$DEB_BOARD" --scenario="$$DEB_SCENARIO" + @if [ -x "$(DPKG_BIN)" ]; then \ + DEB_BOARD=$$(grep "BOARD" $(HV_CFG_LOG) | awk -F '= ' '{print $$2 }'); \ + DEB_SCENARIO=$$(grep "SCENARIO" $(HV_CFG_LOG) | awk -F '= ' '{print $$2 }'); \ + python3 misc/packaging/gen_acrn_deb.py acrn_all $(ROOT_OUT) --version=$(FULL_VERSION) --board_name="$$DEB_BOARD" --scenario="$$DEB_SCENARIO"; \ + fi #help functions to build acrn and install acrn/acrn symbols define build_acrn @@ -102,8 +105,13 @@ define install_acrn_debug endef HV_MAKEOPTS := -C $(T)/hypervisor BOARD=$(BOARD) SCENARIO=$(SCENARIO) HV_OBJDIR=$(HV_OUT) RELEASE=$(RELEASE) + board_inspector: - @python3 misc/packaging/gen_acrn_deb.py board_inspector $(ROOT_OUT) --version=$(FULL_VERSION) + @if [ -x "$(DPKG_BIN)" ]; then \ + python3 misc/packaging/gen_acrn_deb.py board_inspector $(ROOT_OUT) --version=$(FULL_VERSION); \ + else \ + echo -e "The 'dpkg' utility is not available. Unable to create Debian package for board_inspector."; \ + fi hypervisor: hvdefconfig $(MAKE) $(HV_MAKEOPTS)