diff --git a/rules/functions b/rules/functions index 1416372487de..774d3df5f5e2 100644 --- a/rules/functions +++ b/rules/functions @@ -120,3 +120,15 @@ $(foreach deb,$(1), \ fi; \ done; } ) endef + +############################################################################### +## 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 diff --git a/slave.mk b/slave.mk index a96639277680..d69e42875799 100644 --- a/slave.mk +++ b/slave.mk @@ -30,6 +30,7 @@ PYTHON_WHEELS_PATH = $(TARGET_PATH)/python-wheels PROJECT_ROOT = $(shell pwd) DBG_IMAGE_MARK = dbg DBG_SRC_ARCHIVE_FILE = $(TARGET_PATH)/sonic_src.tar.gz +DPKG_ADMINDIR_PATH = /sonic/dpkg CONFIGURED_PLATFORM := $(shell [ -f .platform ] && cat .platform || echo generic) PLATFORM_PATH = platform/$(CONFIGURED_PLATFORM) @@ -52,6 +53,7 @@ configure : @mkdir -p target/debs @mkdir -p target/files @mkdir -p target/python-wheels + @mkdir -p $(DPKG_ADMINDIR_PATH) @echo $(PLATFORM) > .platform distclean : .platform clean @@ -280,6 +282,7 @@ $(addprefix $(DEBS_PATH)/, $(SONIC_MAKE_DEBS)) : $(DEBS_PATH)/% : .platform $$(a rm -f $(addprefix $(DEBS_PATH)/, $* $($*_DERIVED_DEBS) $($*_EXTRA_DEBS)) # Apply series of patches if exist if [ -f $($*_SRC_PATH).patch/series ]; then pushd $($*_SRC_PATH) && QUILT_PATCHES=../$(notdir $($*_SRC_PATH)).patch quilt push -a; popd; fi + $(SETUP_OVERLAYFS_FOR_DPKG_ADMINDIR) # Build project and take package DEB_BUILD_OPTIONS="${DEB_BUILD_OPTIONS_GENERIC}" make DEST=$(shell pwd)/$(DEBS_PATH) -C $($*_SRC_PATH) $(shell pwd)/$(DEBS_PATH)/$* $(LOG) # Clean up @@ -307,9 +310,10 @@ $(addprefix $(DEBS_PATH)/, $(SONIC_DPKG_DEBS)) : $(DEBS_PATH)/% : .platform $$(a # Build project pushd $($*_SRC_PATH) $(LOG) [ ! -f ./autogen.sh ] || ./autogen.sh $(LOG) + $(SETUP_OVERLAYFS_FOR_DPKG_ADMINDIR) $(if $($*_DPKG_TARGET), - DEB_BUILD_OPTIONS="${DEB_BUILD_OPTIONS_GENERIC} ${$*_DEB_BUILD_OPTIONS}" dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --as-root -T$($*_DPKG_TARGET) $(LOG), - DEB_BUILD_OPTIONS="${DEB_BUILD_OPTIONS_GENERIC} ${$*_DEB_BUILD_OPTIONS}" dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) $(LOG) + DEB_BUILD_OPTIONS="${DEB_BUILD_OPTIONS_GENERIC} ${$*_DEB_BUILD_OPTIONS}" dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --as-root -T$($*_DPKG_TARGET) --admindir $$mergedir $(LOG), + DEB_BUILD_OPTIONS="${DEB_BUILD_OPTIONS_GENERIC} ${$*_DEB_BUILD_OPTIONS}" dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $$mergedir $(LOG) ) popd $(LOG) # Clean up diff --git a/src/bash/Makefile b/src/bash/Makefile index 2e9f093aedb4..ec888d47c658 100644 --- a/src/bash/Makefile +++ b/src/bash/Makefile @@ -10,7 +10,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : dget -u https://launchpad.net/debian/+archive/primary/+sourcefiles/bash/$(BASH_VERSION_FULL)/bash_$(BASH_VERSION_FULL).dsc pushd bash-$(BASH_VERSION_MAJOR) - DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -us -uc -b -j$(SONIC_CONFIG_MAKE_JOBS) + DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -us -uc -b -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) popd mv $* $(DEST)/ diff --git a/src/hiredis/Makefile b/src/hiredis/Makefile index d302b327d312..cb7f6316d03e 100644 --- a/src/hiredis/Makefile +++ b/src/hiredis/Makefile @@ -14,7 +14,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : dpkg-source -x hiredis_$(HIREDIS_VERSION_FULL).dsc pushd hiredis-$(HIREDIS_VERSION) - fakeroot debian/rules -j$(SONIC_CONFIG_MAKE_JOBS) binary + dpkg-buildpackage -rfakeroot -d -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) popd mv $* $(DERIVED_TARGETS) $(DEST)/ diff --git a/src/initramfs-tools/Makefile b/src/initramfs-tools/Makefile index 0b08e4aa431e..b412dee54bd7 100644 --- a/src/initramfs-tools/Makefile +++ b/src/initramfs-tools/Makefile @@ -19,7 +19,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : # Build the package rm -f debian/*.debhelper.log - dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) + dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) popd mv $(DERIVED_TARGETS) $* $(DEST)/ diff --git a/src/iproute2/Makefile b/src/iproute2/Makefile index 0181c9ca6d31..eaddbd304757 100644 --- a/src/iproute2/Makefile +++ b/src/iproute2/Makefile @@ -14,7 +14,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : dpkg-source -x iproute2_$(IPROUTE2_VERSION_FULL).dsc pushd iproute2-$(IPROUTE2_VERSION) - dpkg-buildpackage -us -uc -b -j$(SONIC_CONFIG_MAKE_JOBS) + dpkg-buildpackage -us -uc -b -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) popd mv $* $(DEST)/ diff --git a/src/isc-dhcp/Makefile b/src/isc-dhcp/Makefile index 4117b7f75665..aaa2353dbafe 100644 --- a/src/isc-dhcp/Makefile +++ b/src/isc-dhcp/Makefile @@ -24,7 +24,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : stg import -s ../patch/series # Build source and Debian packages - dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) + dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) popd # Move the newly-built .deb packages to the destination directory diff --git a/src/libnl3/Makefile b/src/libnl3/Makefile index bf5ba60ab91d..591fc952b6be 100644 --- a/src/libnl3/Makefile +++ b/src/libnl3/Makefile @@ -22,7 +22,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : dpkg-source -x libnl3_$(LIBNL3_VERSION).dsc pushd ./libnl3-$(LIBNL3_VERSION_BASE) - dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) + dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) popd mv $(DERIVED_TARGETS) $* $(DEST)/ diff --git a/src/libteam/Makefile b/src/libteam/Makefile index dade8f949aaa..b5dece4eaaff 100644 --- a/src/libteam/Makefile +++ b/src/libteam/Makefile @@ -30,7 +30,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : mv tmp/debian libteam/ rm -rf tmp pushd ./libteam - dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) + dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) popd mv $(DERIVED_TARGETS) $* $(DEST)/ diff --git a/src/lldpd/Makefile b/src/lldpd/Makefile index 5f502b86863c..387733d2d68a 100644 --- a/src/lldpd/Makefile +++ b/src/lldpd/Makefile @@ -23,7 +23,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : stg import -s ../patch/series # Build source and Debian packages - env "with_netlink_receive_bufsize=1024*1024" dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) + env "with_netlink_receive_bufsize=1024*1024" dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) popd # Move the newly-built .deb packages to the destination directory diff --git a/src/monit/Makefile b/src/monit/Makefile index 8c9817e52731..35e35e2ef63d 100644 --- a/src/monit/Makefile +++ b/src/monit/Makefile @@ -24,7 +24,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : stg import -s ../patch/series # Build source and Debian packages - dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) + dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) popd # Move the newly-built .deb packages to the destination directory diff --git a/src/mpdecimal/Makefile b/src/mpdecimal/Makefile index 5603c44b445f..dc5d8a0add12 100644 --- a/src/mpdecimal/Makefile +++ b/src/mpdecimal/Makefile @@ -14,7 +14,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : dpkg-source -x mpdecimal_$(MPDECIMAL_VERSION_FULL).dsc pushd mpdecimal-$(MPDECIMAL_VERSION) - dpkg-buildpackage -us -uc -b -j$(SONIC_CONFIG_MAKE_JOBS) + dpkg-buildpackage -us -uc -b -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) popd mv $* $(DERIVED_TARGETS) $(DEST)/ diff --git a/src/python-click/Makefile b/src/python-click/Makefile index 4deb27257fd2..31716e03616f 100644 --- a/src/python-click/Makefile +++ b/src/python-click/Makefile @@ -19,7 +19,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : git reset --hard debian/$(PYTHON_CLICK_VERSION) # Build source and Debian packages - dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) + dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) popd # Move the newly-built .deb package to the destination directory diff --git a/src/python3/Makefile b/src/python3/Makefile index d7718cbeccf6..2d7efeb4b1f9 100644 --- a/src/python3/Makefile +++ b/src/python3/Makefile @@ -32,7 +32,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : fi done - dpkg-buildpackage -rfakeroot -us -uc -b -j$(SONIC_CONFIG_MAKE_JOBS) + dpkg-buildpackage -rfakeroot -us -uc -b -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) popd cp $(DERIVED_TARGETS) $* $(DEST)/ diff --git a/src/radvd/Makefile b/src/radvd/Makefile index 9064a43c25c1..148a53aa002d 100644 --- a/src/radvd/Makefile +++ b/src/radvd/Makefile @@ -23,7 +23,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : stg import -s ../patch/series # Build source and Debian packages - dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) + dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) popd # Move the newly-built .deb packages to the destination directory diff --git a/src/redis/Makefile b/src/redis/Makefile index f229d321a11f..6685a389ed4b 100644 --- a/src/redis/Makefile +++ b/src/redis/Makefile @@ -16,7 +16,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : dpkg-source -x redis_$(REDIS_VERSION_FULL).dsc pushd redis-$(REDIS_VERSION) - DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -us -uc -b -j$(SONIC_CONFIG_MAKE_JOBS) + DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -us -uc -b -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) popd mv $(DERIVED_TARGETS) $* $(DEST)/ diff --git a/src/snmpd/Makefile b/src/snmpd/Makefile index e9645b93b686..a774db8ac38e 100644 --- a/src/snmpd/Makefile +++ b/src/snmpd/Makefile @@ -31,7 +31,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : stg init stg import -s ../patch-$(SNMPD_VERSION)/series - fakeroot debian/rules -j$(SONIC_CONFIG_MAKE_JOBS) binary + dpkg-buildpackage -rfakeroot -b -d -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) popd mv $(DERIVED_TARGETS) $* $(DEST)/ diff --git a/src/socat/Makefile b/src/socat/Makefile index e82208946ac1..08fc5883590d 100644 --- a/src/socat/Makefile +++ b/src/socat/Makefile @@ -18,7 +18,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : # Build source and Debian packages pushd socat-1.7.3.1 patch -p0 < ../enable_readline.patch - dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) + dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) popd # Move the newly-built .deb packages to the destination directory diff --git a/src/sonic-device-data/Makefile b/src/sonic-device-data/Makefile index ecac92b00e0e..ea4ca75d5b5f 100644 --- a/src/sonic-device-data/Makefile +++ b/src/sonic-device-data/Makefile @@ -22,7 +22,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : done; # Build the package - dpkg-buildpackage -rfakeroot -b -us -uc + dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) popd diff --git a/src/sonic-frr/Makefile b/src/sonic-frr/Makefile index 1b087a78185e..9b7d8b65fb2a 100644 --- a/src/sonic-frr/Makefile +++ b/src/sonic-frr/Makefile @@ -25,7 +25,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : cp -a debianpkg debian make -f debian/rules backports - # new directory to build the package + # new directory to build the package rm -rf frrpkg mkdir frrpkg cd frrpkg @@ -34,7 +34,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : tar xf ../../frr_*sonic.debian8*.debian.tar.xz # build package - dpkg-buildpackage -rfakeroot -b -us -uc + dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) cd .. mv $(DERIVED_TARGET) $* $(DEST)/ diff --git a/src/tacacs/nss/Makefile b/src/tacacs/nss/Makefile index 63abfcf2a3c9..9665faf58cc9 100644 --- a/src/tacacs/nss/Makefile +++ b/src/tacacs/nss/Makefile @@ -18,7 +18,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : git am ../0004-Skip-accessing-tacacs-servers-for-local-non-tacacs-u.patch git am ../0005-libnss-Modify-parsing-of-IP-addr-and-port-number-str.patch - dpkg-buildpackage -rfakeroot -b -us -uc + dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) popd mv $(DERIVED_TARGETS) $* $(DEST)/ diff --git a/src/tacacs/pam/Makefile b/src/tacacs/pam/Makefile index 627242af5a71..a726f523e357 100644 --- a/src/tacacs/pam/Makefile +++ b/src/tacacs/pam/Makefile @@ -9,7 +9,7 @@ DERIVED_TARGETS = libtac2_$(PAM_TACPLUS_VERSION)_amd64.deb \ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : # Obtain pam_tacplus rm -rf ./pam_tacplus - git clone https://github.com/jeroennijhof/pam_tacplus.git + git clone https://github.com/jeroennijhof/pam_tacplus.git pushd ./pam_tacplus git checkout -f v1.4.1 @@ -20,7 +20,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : git apply ../0004-management-vrf-support.patch git apply ../0005-pam-Modify-parsing-of-IP-address-and-port-number-to-.patch - dpkg-buildpackage -rfakeroot -b -us -uc + dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) popd mv $(DERIVED_TARGETS) $* $(DEST)/ diff --git a/src/thrift/Makefile b/src/thrift/Makefile index 077b7fb308bd..5ca4b77bfff6 100644 --- a/src/thrift/Makefile +++ b/src/thrift/Makefile @@ -23,7 +23,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : dpkg-source -x thrift_$(THRIFT_VERSION_FULL).dsc pushd thrift-$(THRIFT_VERSION) patch -p1 < ../patch/THRIFT-3577-assertion-failed.patch - DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -d -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) + DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -d -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) popd mv $(DERIVED_TARGETS) $* $(DEST)/