[build]: allow single src file to build multiple independent debian p… (#349)

add_derived_package setup dependency between the main deb and derived deb.
The derived deb depends on the main deb and need to install the main deb.

add_extra_package does not setup dependency between the main deb and peer deb,
does not require to install the main deb.

* rename add_peer_packages to add_extra_packages
This commit is contained in:
lguohan 2017-03-01 08:32:58 -08:00 committed by GitHub
parent e097440f58
commit 73fb59c52c
3 changed files with 33 additions and 12 deletions

View File

@ -10,10 +10,8 @@ DELL_Z9100_PLATFORM_MODULE = platform-modules-z9100_$(DELL_Z9100_PLATFORM_MODULE
$(DELL_Z9100_PLATFORM_MODULE)_SRC_PATH = $(PLATFORM_PATH)/sonic-platform-modules-dell $(DELL_Z9100_PLATFORM_MODULE)_SRC_PATH = $(PLATFORM_PATH)/sonic-platform-modules-dell
$(DELL_Z9100_PLATFORM_MODULE)_DEPENDS += $(LINUX_HEADERS) $(LINUX_HEADERS_COMMON) $(DELL_Z9100_PLATFORM_MODULE)_DEPENDS += $(LINUX_HEADERS) $(LINUX_HEADERS_COMMON)
$(DELL_Z9100_PLATFORM_MODULE)_PLATFORM = x86_64-dell_z9100_c2538-r0 $(DELL_Z9100_PLATFORM_MODULE)_PLATFORM = x86_64-dell_z9100_c2538-r0
SONIC_DPKG_DEBS += $(DELL_Z9100_PLATFORM_MODULE)
DELL_S6100_PLATFORM_MODULE = platform-modules-s6100_$(DELL_S6100_PLATFORM_MODULE_VERSION)_amd64.deb DELL_S6100_PLATFORM_MODULE = platform-modules-s6100_$(DELL_S6100_PLATFORM_MODULE_VERSION)_amd64.deb
$(DELL_S6100_PLATFORM_MODULE)_SRC_PATH = $(PLATFORM_PATH)/sonic-platform-modules-dell
$(DELL_S6100_PLATFORM_MODULE)_DEPENDS += $(LINUX_HEADERS) $(LINUX_HEADERS_COMMON)
$(DELL_S6100_PLATFORM_MODULE)_PLATFORM = x86_64-dell_s6100_c2538-r0 $(DELL_S6100_PLATFORM_MODULE)_PLATFORM = x86_64-dell_s6100_c2538-r0
$(eval $(call add_extra_package,$(DELL_Z9100_PLATFORM_MODULE),$(DELL_S6100_PLATFORM_MODULE)))
SONIC_DPKG_DEBS += $(DELL_Z9100_PLATFORM_MODULE) $(DELL_S6100_PLATFORM_MODULE)

View File

@ -89,13 +89,21 @@ endef
define add_derived_package define add_derived_package
$(2)_DEPENDS += $(1) $(2)_DEPENDS += $(1)
$(2)_RDEPENDS += $($(1)_RDEPENDS) $(2)_RDEPENDS += $($(1)_RDEPENDS)
$(2)_DERIVED_FROM = $(1) $(2)_MAIN_DEB = $(1)
$(1)_DERIVED_DEBS += $(2) $(1)_DERIVED_DEBS += $(2)
$(2)_URL = $($(1)_URL) $(2)_URL = $($(1)_URL)
$(2)_SRC_PATH = $($(1)_SRC_PATH) $(2)_SRC_PATH = $($(1)_SRC_PATH)
SONIC_DERIVED_DEBS += $(2) SONIC_DERIVED_DEBS += $(2)
endef endef
# 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
############################################################################### ###############################################################################
## Utility functions ## Utility functions
############################################################################### ###############################################################################

View File

@ -140,7 +140,7 @@ $(addprefix $(DEBS_PATH)/, $(SONIC_ONLINE_FILES)) : $(DEBS_PATH)/% : .platform
$(addprefix $(DEBS_PATH)/, $(SONIC_MAKE_DEBS)) : $(DEBS_PATH)/% : .platform $$(addsuffix -install,$$(addprefix $(DEBS_PATH)/,$$($$*_DEPENDS))) $(addprefix $(DEBS_PATH)/, $(SONIC_MAKE_DEBS)) : $(DEBS_PATH)/% : .platform $$(addsuffix -install,$$(addprefix $(DEBS_PATH)/,$$($$*_DEPENDS)))
$(HEADER) $(HEADER)
# remove target to force rebuild # remove target to force rebuild
rm -f $(addprefix $(DEBS_PATH)/, $* $($*_DERIVED_DEBS)) rm -f $(addprefix $(DEBS_PATH)/, $* $($*_DERIVED_DEBS) $($*_EXTRA_DEBS))
# build project and take package # build project and take package
make DEST=$(shell pwd)/$(DEBS_PATH) -C $($*_SRC_PATH) $(shell pwd)/$(DEBS_PATH)/$* $(LOG) make DEST=$(shell pwd)/$(DEBS_PATH) -C $($*_SRC_PATH) $(shell pwd)/$(DEBS_PATH)/$* $(LOG)
$(FOOTER) $(FOOTER)
@ -159,7 +159,7 @@ $(addprefix $(DEBS_PATH)/, $(SONIC_DPKG_DEBS)) : $(DEBS_PATH)/% : .platform $$(a
[ ! -f ./autogen.sh ] || ./autogen.sh $(LOG) [ ! -f ./autogen.sh ] || ./autogen.sh $(LOG)
dpkg-buildpackage -rfakeroot -b -us -uc $(LOG) dpkg-buildpackage -rfakeroot -b -us -uc $(LOG)
popd $(LOG) popd $(LOG)
mv $(addprefix $($*_SRC_PATH)/../, $* $($*_DERIVED_DEBS)) $(DEBS_PATH) $(LOG) mv $(addprefix $($*_SRC_PATH)/../, $* $($*_DERIVED_DEBS) $($*_EXTRA_DEBS)) $(DEBS_PATH) $(LOG)
$(FOOTER) $(FOOTER)
# Build project with python setup.py --command-packages=stdeb.command # Build project with python setup.py --command-packages=stdeb.command
@ -190,6 +190,19 @@ $(addprefix $(DEBS_PATH)/, $(SONIC_DERIVED_DEBS)) : $(DEBS_PATH)/% : .platform $
[ -f $@ ] && touch $@ [ -f $@ ] && touch $@
$(FOOTER) $(FOOTER)
# Rules for extra debian packages
# All noise takes place in main deb recipe, so we are just telling that
# we need to build the main deb and move our deb to other targets
# Add new dev package:
# $(eval $(call add_extra_package,$(ORIGINAL_DEB),extra_deb_file.deb))
$(addprefix $(DEBS_PATH)/, $(SONIC_EXTRA_DEBS)) : $(DEBS_PATH)/% : .platform $$(addprefix $(DEBS_PATH)/,$$($$*_MAIN_DEB))
$(HEADER)
# All noise takes place in main deb recipe, so we are just telling that
# we depend on it
# Put newer timestamp
[ -f $@ ] && touch $@
$(FOOTER)
# Targets for installing debian packages prior to build one that depends on them # Targets for installing debian packages prior to build one that depends on them
SONIC_INSTALL_TARGETS = $(addsuffix -install,$(addprefix $(DEBS_PATH)/, \ SONIC_INSTALL_TARGETS = $(addsuffix -install,$(addprefix $(DEBS_PATH)/, \
$(SONIC_ONLINE_DEBS) \ $(SONIC_ONLINE_DEBS) \
@ -197,7 +210,8 @@ SONIC_INSTALL_TARGETS = $(addsuffix -install,$(addprefix $(DEBS_PATH)/, \
$(SONIC_MAKE_DEBS) \ $(SONIC_MAKE_DEBS) \
$(SONIC_DPKG_DEBS) \ $(SONIC_DPKG_DEBS) \
$(SONIC_PYTHON_STDEB_DEBS) \ $(SONIC_PYTHON_STDEB_DEBS) \
$(SONIC_DERIVED_DEBS))) $(SONIC_DERIVED_DEBS) \
$(SONIC_EXTRA_DEBS)))
$(SONIC_INSTALL_TARGETS) : $(DEBS_PATH)/%-install : .platform $$(addsuffix -install,$$(addprefix $(DEBS_PATH)/,$$($$*_DEPENDS))) $(DEBS_PATH)/$$* $(SONIC_INSTALL_TARGETS) : $(DEBS_PATH)/%-install : .platform $$(addsuffix -install,$$(addprefix $(DEBS_PATH)/,$$($$*_DEPENDS))) $(DEBS_PATH)/$$*
$(HEADER) $(HEADER)
[ -f $(DEBS_PATH)/$* ] || { echo $(DEBS_PATH)/$* does not exist $(LOG) && exit 1; } [ -f $(DEBS_PATH)/$* ] || { echo $(DEBS_PATH)/$* does not exist $(LOG) && exit 1; }
@ -351,11 +365,12 @@ SONIC_CLEAN_DEBS = $(addsuffix -clean,$(addprefix $(DEBS_PATH)/, \
$(SONIC_MAKE_DEBS) \ $(SONIC_MAKE_DEBS) \
$(SONIC_DPKG_DEBS) \ $(SONIC_DPKG_DEBS) \
$(SONIC_PYTHON_STDEB_DEBS) \ $(SONIC_PYTHON_STDEB_DEBS) \
$(SONIC_DERIVED_DEBS))) $(SONIC_DERIVED_DEBS) \
$(SONIC_CLEAN_DEBS) : $(DEBS_PATH)/%-clean : .platform $$(addsuffix -clean,$$(addprefix $(DEBS_PATH)/,$$($$*_DERIVED_FROM))) $(SONIC_EXTRA_DEBS)))
@# remove derived targets if main one is removed, because we treat them $(SONIC_CLEAN_DEBS) : $(DEBS_PATH)/%-clean : .platform $$(addsuffix -clean,$$(addprefix $(DEBS_PATH)/,$$($$*_MAIN_DEB)))
@# remove derived or extra targets if main one is removed, because we treat them
@# as part of one package @# as part of one package
@rm -f $(addprefix $(DEBS_PATH)/, $* $($*_DERIVED_DEBS)) @rm -f $(addprefix $(DEBS_PATH)/, $* $($*_DERIVED_DEBS) $($*_EXTRA_DEBS))
SONIC_CLEAN_TARGETS += $(addsuffix -clean,$(addprefix $(TARGET_PATH)/, \ SONIC_CLEAN_TARGETS += $(addsuffix -clean,$(addprefix $(TARGET_PATH)/, \
$(SONIC_DOCKER_IMAGES) \ $(SONIC_DOCKER_IMAGES) \