2016-12-05 13:12:19 -06:00
|
|
|
###############################################################################
|
|
|
|
## FUNCTIONS
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
## Colored output
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
# Enable colored output
|
|
|
|
ifeq ($(SONIC_CONFIG_ENABLE_COLORS),y)
|
|
|
|
ifeq ($(MAKE_TERMOUT),)
|
|
|
|
RED=\033[1;31m
|
|
|
|
PURPLE=\033[1;35m
|
|
|
|
CYAN=\033[1;36m
|
|
|
|
GREEN=\033[1;32m
|
|
|
|
GRAY=\033[0m
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Print red colored output
|
|
|
|
# call:
|
|
|
|
# log_red message
|
|
|
|
log_red = echo -e "$(RED)$(1)$(GRAY)"
|
|
|
|
|
|
|
|
# Print purple colored output
|
|
|
|
# call:
|
|
|
|
# log_purple message
|
|
|
|
log_purple = echo -e "$(PURPLE)$(1)$(GRAY)"
|
|
|
|
|
|
|
|
# Print blue colored output
|
|
|
|
# call:
|
|
|
|
# log_blue message
|
|
|
|
log_blue = echo -e "$(CYAN)$(1)$(GRAY)"
|
|
|
|
|
|
|
|
# Print green colored output
|
|
|
|
# call:
|
|
|
|
# log_green message
|
|
|
|
log_green = echo -e "$(GREEN)$(1)$(GRAY)"
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
## Logging
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
FLUSH_LOG = rm -f $@.log
|
|
|
|
|
2017-07-25 01:49:39 -05:00
|
|
|
LOG = &>> $(PROJECT_ROOT)/$@.log || { [ $$? -eq 0 ] || pushd $(PROJECT_ROOT) > /dev/null ; ./update_screen.sh -e $@ ; popd > /dev/null ; false ; }
|
2016-12-05 13:12:19 -06:00
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
## Header and footer for each target
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
# Dump targets taht current depends on
|
|
|
|
ifeq ($(SONIC_CONFIG_PRINT_DEPENDENCIES),y)
|
2017-07-25 01:49:39 -05:00
|
|
|
PRINT_DEPENDENCIES = echo Dependencies for $@ are $^ $(LOG)
|
2016-12-05 13:12:19 -06:00
|
|
|
endif
|
|
|
|
|
|
|
|
# header for each rule
|
|
|
|
define HEADER
|
2017-07-25 01:49:39 -05:00
|
|
|
@
|
2016-12-05 13:12:19 -06:00
|
|
|
$(PRINT_DEPENDENCIES)
|
|
|
|
$(FLUSH_LOG)
|
2017-07-25 01:49:39 -05:00
|
|
|
./update_screen.sh -a $@
|
2016-12-05 13:12:19 -06:00
|
|
|
endef
|
|
|
|
|
|
|
|
# footer for each rule
|
|
|
|
define FOOTER
|
2017-07-25 01:49:39 -05:00
|
|
|
./update_screen.sh -d $@
|
2016-12-05 13:12:19 -06:00
|
|
|
endef
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
## Definition of derived target
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
# call:
|
|
|
|
# add_derived_package some_deb.deb, some_derived_deb
|
|
|
|
define add_derived_package
|
|
|
|
$(2)_DEPENDS += $(1)
|
|
|
|
$(2)_RDEPENDS += $($(1)_RDEPENDS)
|
2017-03-01 10:32:58 -06:00
|
|
|
$(2)_MAIN_DEB = $(1)
|
2016-12-05 13:12:19 -06:00
|
|
|
$(1)_DERIVED_DEBS += $(2)
|
|
|
|
$(2)_URL = $($(1)_URL)
|
|
|
|
$(2)_SRC_PATH = $($(1)_SRC_PATH)
|
|
|
|
SONIC_DERIVED_DEBS += $(2)
|
|
|
|
endef
|
|
|
|
|
2017-03-01 10:32:58 -06:00
|
|
|
# call:
|
|
|
|
# add_extra_package some_deb.deb, some_extra_deb
|
|
|
|
define add_extra_package
|
|
|
|
$(2)_MAIN_DEB = $(1)
|
|
|
|
$(1)_EXTRA_DEBS += $(2)
|
|
|
|
SONIC_EXTRA_DEBS += $(2)
|
|
|
|
endef
|
|
|
|
|
[build]: wait for conflicts package to be uninstalled (#5039)
when parallel build is enabled, both docker-fpm-frr and docker-syncd-brcm
is built at the same time, docker-fpm-frr requires swss which requires to
install libsaivs-dev. docker-syncd-brcm requires syncd package which requires
to install libsaibcm-dev.
since libsaivs-dev and libsaibcm-dev install the sai header in the same
location, these two packages cannot be installed at the same time. Therefore,
we need to serialize the build between these two packages. Simply uninstall
the conflict package is not enough to solve this issue. The correct solution
is to have one package wait for another package to be uninstalled.
For example, if syncd is built first, then it will install libsaibcm-dev.
Meanwhile, if the swss build job starts and tries to install libsaivs-dev,
it will first try to query if libsaibcm-dev is installed or not. if it is
installed, then it will wait until libsaibcm-dev is uninstalled. After syncd
job is finished, it will uninstall libsaibcm-dev and swss build job will be
unblocked.
To solve this issue, _UNINSTALLS is introduced to uninstall a package that
is no longer needed and to allow blocked job to continue.
Signed-off-by: Guohan Lu <lguohan@gmail.com>
2020-07-27 12:46:20 -05:00
|
|
|
###############################################################################
|
|
|
|
## Definition of conflict packages
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
# call:
|
|
|
|
# add_conflict_package some_deb.deb, conflict_deb
|
|
|
|
define add_conflict_package
|
|
|
|
$(1)_CONFLICT_DEBS += $(2)
|
|
|
|
$(2)_CONFLICT_DEBS += $(1)
|
|
|
|
endef
|
|
|
|
|
2016-12-05 13:12:19 -06:00
|
|
|
###############################################################################
|
|
|
|
## Utility functions
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
expand = $(foreach d,$(1),$(call expand,$($(d)_$(2)),$(2))) $(1)
|
2021-01-12 08:03:12 -06:00
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
## Setup overlay fs for dpkg admin directory /var/lib/dpkg
|
|
|
|
###############################################################################
|
|
|
|
define SETUP_OVERLAYFS_FOR_DPKG_ADMINDIR
|
|
|
|
upperdir=$(shell mktemp -d -p $(DPKG_ADMINDIR_PATH))
|
|
|
|
workdir=$(shell mktemp -d -p $(DPKG_ADMINDIR_PATH))
|
|
|
|
mergedir=$(shell mktemp -d -p $(DPKG_ADMINDIR_PATH))
|
|
|
|
sudo mount -t overlay overlay -olowerdir=/var/lib/dpkg,upperdir=$$upperdir,workdir=$$workdir $$mergedir
|
|
|
|
export SONIC_DPKG_ADMINDIR=$$mergedir
|
|
|
|
trap "sudo umount $$mergedir && rm -rf $$mergedir $$upperdir $$workdir" EXIT
|
|
|
|
endef
|
[build]: wait for conflicts package to be uninstalled (#5039)
when parallel build is enabled, both docker-fpm-frr and docker-syncd-brcm
is built at the same time, docker-fpm-frr requires swss which requires to
install libsaivs-dev. docker-syncd-brcm requires syncd package which requires
to install libsaibcm-dev.
since libsaivs-dev and libsaibcm-dev install the sai header in the same
location, these two packages cannot be installed at the same time. Therefore,
we need to serialize the build between these two packages. Simply uninstall
the conflict package is not enough to solve this issue. The correct solution
is to have one package wait for another package to be uninstalled.
For example, if syncd is built first, then it will install libsaibcm-dev.
Meanwhile, if the swss build job starts and tries to install libsaivs-dev,
it will first try to query if libsaibcm-dev is installed or not. if it is
installed, then it will wait until libsaibcm-dev is uninstalled. After syncd
job is finished, it will uninstall libsaibcm-dev and swss build job will be
unblocked.
To solve this issue, _UNINSTALLS is introduced to uninstall a package that
is no longer needed and to allow blocked job to continue.
Signed-off-by: Guohan Lu <lguohan@gmail.com>
2020-07-27 12:46:20 -05:00
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
## Uninstall debs
|
|
|
|
###############################################################################
|
|
|
|
define UNINSTALL_DEBS
|
2021-01-01 03:00:47 -06:00
|
|
|
if [ -n "$(1)" ]; then \
|
|
|
|
while true; do \
|
|
|
|
if mkdir $(DEBS_PATH)/dpkg_lock &> /dev/null; then \
|
|
|
|
{ sudo DEBIAN_FRONTEND=noninteractive dpkg -P $(foreach deb,$(1),$(firstword $(subst _, ,$(basename $(deb))))) $(LOG) && rm -d $(DEBS_PATH)/dpkg_lock && break; } || { rm -d $(DEBS_PATH)/dpkg_lock && exit 1 ; } \
|
|
|
|
fi; \
|
|
|
|
done; \
|
|
|
|
fi
|
[build]: wait for conflicts package to be uninstalled (#5039)
when parallel build is enabled, both docker-fpm-frr and docker-syncd-brcm
is built at the same time, docker-fpm-frr requires swss which requires to
install libsaivs-dev. docker-syncd-brcm requires syncd package which requires
to install libsaibcm-dev.
since libsaivs-dev and libsaibcm-dev install the sai header in the same
location, these two packages cannot be installed at the same time. Therefore,
we need to serialize the build between these two packages. Simply uninstall
the conflict package is not enough to solve this issue. The correct solution
is to have one package wait for another package to be uninstalled.
For example, if syncd is built first, then it will install libsaibcm-dev.
Meanwhile, if the swss build job starts and tries to install libsaivs-dev,
it will first try to query if libsaibcm-dev is installed or not. if it is
installed, then it will wait until libsaibcm-dev is uninstalled. After syncd
job is finished, it will uninstall libsaibcm-dev and swss build job will be
unblocked.
To solve this issue, _UNINSTALLS is introduced to uninstall a package that
is no longer needed and to allow blocked job to continue.
Signed-off-by: Guohan Lu <lguohan@gmail.com>
2020-07-27 12:46:20 -05:00
|
|
|
endef
|