diff --git a/Makefile.work b/Makefile.work index c9db8b00f81a..3db1f03ab98f 100644 --- a/Makefile.work +++ b/Makefile.work @@ -139,13 +139,21 @@ endif ifeq ($(CONFIGURED_ARCH),amd64) SLAVE_BASE_IMAGE = $(SLAVE_DIR) MULTIARCH_QEMU_ENVIRON = n +CROSS_BUILD_ENVIRON = n else ifeq ($(CONFIGURED_ARCH), $(COMPILE_HOST_ARCH)) SLAVE_BASE_IMAGE = $(SLAVE_DIR) MULTIARCH_QEMU_ENVIRON = n +CROSS_BUILD_ENVIRON = n else ifneq ($(CONFIGURED_ARCH),) SLAVE_BASE_IMAGE = $(SLAVE_DIR)-march-$(CONFIGURED_ARCH) +ifneq ($(CROSS_BLDENV),) +MULTIARCH_QEMU_ENVIRON = n +CROSS_BUILD_ENVIRON = y +else MULTIARCH_QEMU_ENVIRON = y +CROSS_BUILD_ENVIRON = n +endif endif endif SLAVE_IMAGE = $(SLAVE_BASE_IMAGE)-$(USER_LC) @@ -169,8 +177,8 @@ $(shell SONIC_VERSION_CONTROL_COMPONENTS=$(SONIC_VERSION_CONTROL_COMPONENTS) \ scripts/generate_buildinfo_config.sh) # Generate the slave Dockerfile, and prepare build info for it -$(shell CONFIGURED_ARCH=$(CONFIGURED_ARCH) MULTIARCH_QEMU_ENVIRON=$(MULTIARCH_QEMU_ENVIRON) ENABLE_FIPS_FEATURE=$(ENABLE_FIPS_FEATURE) DOCKER_EXTRA_OPTS=$(DOCKER_EXTRA_OPTS) DEFAULT_CONTAINER_REGISTRY=$(DEFAULT_CONTAINER_REGISTRY) j2 $(SLAVE_DIR)/Dockerfile.j2 > $(SLAVE_DIR)/Dockerfile) -$(shell CONFIGURED_ARCH=$(CONFIGURED_ARCH) MULTIARCH_QEMU_ENVIRON=$(MULTIARCH_QEMU_ENVIRON) j2 $(SLAVE_DIR)/Dockerfile.user.j2 > $(SLAVE_DIR)/Dockerfile.user) +$(shell CONFIGURED_ARCH=$(CONFIGURED_ARCH) MULTIARCH_QEMU_ENVIRON=$(MULTIARCH_QEMU_ENVIRON) CROSS_BUILD_ENVIRON=$(CROSS_BUILD_ENVIRON) ENABLE_FIPS_FEATURE=$(ENABLE_FIPS_FEATURE) DOCKER_EXTRA_OPTS=$(DOCKER_EXTRA_OPTS) DEFAULT_CONTAINER_REGISTRY=$(DEFAULT_CONTAINER_REGISTRY) j2 $(SLAVE_DIR)/Dockerfile.j2 > $(SLAVE_DIR)/Dockerfile) +$(shell CONFIGURED_ARCH=$(CONFIGURED_ARCH) MULTIARCH_QEMU_ENVIRON=$(MULTIARCH_QEMU_ENVIRON) CROSS_BUILD_ENVIRON=$(CROSS_BUILD_ENVIRON) j2 $(SLAVE_DIR)/Dockerfile.user.j2 > $(SLAVE_DIR)/Dockerfile.user) $(shell BUILD_SLAVE=y DEFAULT_CONTAINER_REGISTRY=$(DEFAULT_CONTAINER_REGISTRY) scripts/prepare_docker_buildinfo.sh $(SLAVE_BASE_IMAGE) $(SLAVE_DIR)/Dockerfile $(CONFIGURED_ARCH) "" $(BLDENV)) # Add the versions in the tag, if the version change, need to rebuild the slave @@ -272,7 +280,7 @@ ifneq ($(MULTIARCH_QEMU_ENVIRON), y) endif endif -ifeq ($(MULTIARCH_QEMU_ENVIRON), y) +ifneq ($(filter y, $(MULTIARCH_QEMU_ENVIRON) $(CROSS_BUILD_ENVIRON)),) ifeq ($(DOCKER_DATA_ROOT_FOR_MULTIARCH),) DOCKER_DATA_ROOT_FOR_MULTIARCH := /var/lib/march/docker endif @@ -344,6 +352,7 @@ SONIC_BUILD_INSTRUCTION := make \ PLATFORM=$(PLATFORM) \ PLATFORM_ARCH=$(PLATFORM_ARCH) \ MULTIARCH_QEMU_ENVIRON=$(MULTIARCH_QEMU_ENVIRON) \ + CROSS_BUILD_ENVIRON=$(CROSS_BUILD_ENVIRON) \ BUILD_NUMBER=$(BUILD_NUMBER) \ BUILD_TIMESTAMP=$(BUILD_TIMESTAMP) \ SONIC_IMAGE_VERSION=$(SONIC_IMAGE_VERSION) \ @@ -405,7 +414,7 @@ SONIC_BUILD_INSTRUCTION := make \ .DEFAULT_GOAL := all %:: -ifeq ($(MULTIARCH_QEMU_ENVIRON), y) +ifneq ($(filter y, $(MULTIARCH_QEMU_ENVIRON) $(CROSS_BUILD_ENVIRON)),) @$(DOCKER_MULTIARCH_CHECK) ifneq ($(BLDENV), ) @$(DOCKER_SERVICE_MULTIARCH_CHECK) diff --git a/README.md b/README.md index 5334bbe18dbd..a3ca0cdb4e30 100644 --- a/README.md +++ b/README.md @@ -173,6 +173,17 @@ To build Arm32 bit for (ARMHF) platform make target/sonic-marvell-armhf.bin +To build Arm32 bit for (ARMHF) Marvell platform on amd64 host for debian buster using cross-compilation run the following commands: + + # Execute make configure once to configure ASIC and ARCH for cross-compilation build + + NOJESSIE=1 NOSTRETCH=1 BLDENV=buster CROSS_BLDENV=1 make configure PLATFORM=marvell-armhf PLATFORM_ARCH=armhf + + # Execute Arm32 build using cross-compilation environment + + NOJESSIE=1 NOSTRETCH=1 BLDENV=buster CROSS_BLDENV=1 make target/sonic-marvell-armhf.bin + +Running the above Arm32 build using cross-compilation instead of qemu emulator drastically reduces the build time. To build Arm64 bit for platform diff --git a/build_debian.sh b/build_debian.sh index 92ecb7ac1653..1dd77f3bee6e 100755 --- a/build_debian.sh +++ b/build_debian.sh @@ -123,6 +123,10 @@ echo 'Dir::Bin::dpkg "/usr/local/bin/dpkg";' | sudo tee $FILESYSTEM_ROOT/etc/apt echo '[INFO] Install packages for building image' sudo LANG=C chroot $FILESYSTEM_ROOT apt-get -y install makedev psmisc +if [[ $CROSS_BUILD_ENVIRON == y ]]; then + sudo LANG=C chroot $FILESYSTEM_ROOT dpkg --add-architecture $CONFIGURED_ARCH +fi + ## Create device files echo '[INFO] MAKEDEV' if [[ $CONFIGURED_ARCH == armhf || $CONFIGURED_ARCH == arm64 ]]; then @@ -643,7 +647,7 @@ fi # ALERT: This bit of logic tears down the qemu based build environment used to # perform builds for the ARM architecture. This must be the last step in this # script before creating the Sonic installer payload zip file. -if [ $MULTIARCH_QEMU_ENVIRON == y ]; then +if [[ $MULTIARCH_QEMU_ENVIRON == y || $CROSS_BUILD_ENVIRON == y ]]; then # Remove qemu arm bin executable used for cross-building sudo rm -f $FILESYSTEM_ROOT/usr/bin/qemu*static || true DOCKERFS_PATH=../dockerfs/ diff --git a/dockers/docker-base-bullseye/Dockerfile.j2 b/dockers/docker-base-bullseye/Dockerfile.j2 index f47d56468102..d488c5f1f0ce 100644 --- a/dockers/docker-base-bullseye/Dockerfile.j2 +++ b/dockers/docker-base-bullseye/Dockerfile.j2 @@ -1,8 +1,8 @@ {% set prefix = DEFAULT_CONTAINER_REGISTRY %} {% from "dockers/dockerfile-macros.j2" import install_debian_packages, install_python_wheels, copy_files %} -{% if CONFIGURED_ARCH == "armhf" and MULTIARCH_QEMU_ENVIRON == "y" %} +{% if CONFIGURED_ARCH == "armhf" and (MULTIARCH_QEMU_ENVIRON == "y" or CROSS_BUILD_ENVIRON == "y") %} FROM {{ prefix }}multiarch/debian-debootstrap:armhf-bullseye -{% elif CONFIGURED_ARCH == "arm64" and MULTIARCH_QEMU_ENVIRON == "y" %} +{% elif CONFIGURED_ARCH == "arm64" and (MULTIARCH_QEMU_ENVIRON == "y" or CROSS_BUILD_ENVIRON == "y") %} FROM {{ prefix }}multiarch/debian-debootstrap:arm64-bullseye {% else %} FROM {{ prefix }}{{DOCKER_BASE_ARCH}}/debian:bullseye diff --git a/dockers/docker-base-buster/Dockerfile.j2 b/dockers/docker-base-buster/Dockerfile.j2 index 52c784e9a7fe..9118287cac39 100644 --- a/dockers/docker-base-buster/Dockerfile.j2 +++ b/dockers/docker-base-buster/Dockerfile.j2 @@ -1,8 +1,8 @@ {% set prefix = DEFAULT_CONTAINER_REGISTRY %} {% from "dockers/dockerfile-macros.j2" import install_debian_packages, install_python_wheels, copy_files %} -{% if CONFIGURED_ARCH == "armhf" and MULTIARCH_QEMU_ENVIRON == "y" %} +{% if CONFIGURED_ARCH == "armhf" and (MULTIARCH_QEMU_ENVIRON == "y" or CROSS_BUILD_ENVIRON == "y") %} FROM {{ prefix }}multiarch/debian-debootstrap:armhf-buster -{% elif CONFIGURED_ARCH == "arm64" and MULTIARCH_QEMU_ENVIRON == "y" %} +{% elif CONFIGURED_ARCH == "arm64" and (MULTIARCH_QEMU_ENVIRON == "y" or CROSS_BUILD_ENVIRON == "y") %} FROM {{ prefix }}multiarch/debian-debootstrap:arm64-buster {% else %} FROM {{ prefix }}{{DOCKER_BASE_ARCH}}/debian:buster diff --git a/files/build_templates/sonic_debian_extension.j2 b/files/build_templates/sonic_debian_extension.j2 index 57449e655c2d..a15822046b61 100644 --- a/files/build_templates/sonic_debian_extension.j2 +++ b/files/build_templates/sonic_debian_extension.j2 @@ -68,7 +68,7 @@ sudo bash -c "echo \"DOCKER_OPTS=\"--storage-driver=overlay2\"\" >> $FILESYSTEM_ # Copy docker start script to be able to start docker in chroot sudo mkdir -p "$FILESYSTEM_ROOT/$DOCKER_CTL_DIR" sudo cp $DOCKER_SCRIPTS_DIR/docker "$FILESYSTEM_ROOT/$DOCKER_CTL_SCRIPT" -if [ $MULTIARCH_QEMU_ENVIRON == y ]; then +if [[ $MULTIARCH_QEMU_ENVIRON == y || $CROSS_BUILD_ENVIRON == y ]]; then DOCKER_HOST="unix:///dockerfs/var/run/docker.sock" SONIC_NATIVE_DOCKERD_FOR_DOCKERFS_PID="cat `pwd`/dockerfs/var/run/docker.pid" else @@ -670,7 +670,7 @@ EOF {% endif %} ## Bind docker path -if [ $MULTIARCH_QEMU_ENVIRON == y ]; then +if [[ $MULTIARCH_QEMU_ENVIRON == y || $CROSS_BUILD_ENVIRON == y ]]; then sudo mkdir -p $FILESYSTEM_ROOT/dockerfs sudo mount --bind dockerfs $FILESYSTEM_ROOT/dockerfs fi @@ -755,7 +755,7 @@ sudo LANG=C DOCKER_HOST="$DOCKER_HOST" chroot $FILESYSTEM_ROOT sonic-package-man sudo umount $FILESYSTEM_ROOT/target sudo rm -r $FILESYSTEM_ROOT/target -if [ $MULTIARCH_QEMU_ENVIRON == y ]; then +if [[ $MULTIARCH_QEMU_ENVIRON == y || $CROSS_BUILD_ENVIRON == y ]]; then sudo umount $FILESYSTEM_ROOT/dockerfs sudo rm -fr $FILESYSTEM_ROOT/dockerfs sudo kill -9 `sudo $SONIC_NATIVE_DOCKERD_FOR_DOCKERFS_PID` || true diff --git a/platform/marvell-armhf/prestera/debian/rules b/platform/marvell-armhf/prestera/debian/rules index d3895c2f769a..069ff0a11916 100755 --- a/platform/marvell-armhf/prestera/debian/rules +++ b/platform/marvell-armhf/prestera/debian/rules @@ -3,7 +3,9 @@ include /usr/share/dpkg/pkg-info.mk PACKAGE_PRE_NAME := mrvlprestera +ifneq ($(CROSS_BUILD_ENVIRON), y) KVERSION ?= $(shell uname -r) +endif KERNEL_SRC := /lib/modules/$(KVERSION) MOD_SRC_DIR:= $(shell pwd) MODULE_DIR := mrvl-prestera/cpssEnabler/linuxNoKernelModule/drivers diff --git a/rules/libyang.mk b/rules/libyang.mk index b361c9796b92..a8e6734459ea 100644 --- a/rules/libyang.mk +++ b/rules/libyang.mk @@ -18,8 +18,8 @@ SONIC_MAKE_DEBS += $(LIBYANG) LIBYANG_DEV = libyang-dev_$(LIBYANG_VERSION)_$(CONFIGURED_ARCH).deb $(eval $(call add_derived_package,$(LIBYANG),$(LIBYANG_DEV))) -LIBYANG_DBG = libyang-dbg_$(LIBYANG_VERSION)_$(CONFIGURED_ARCH).deb -$(eval $(call add_derived_package,$(LIBYANG),$(LIBYANG_DBG))) +LIBYANG_DBGSYM = libyang-dbgsym_$(LIBYANG_VERSION)_$(CONFIGURED_ARCH).deb +$(eval $(call add_derived_package,$(LIBYANG),$(LIBYANG_DBGSYM))) LIBYANG_CPP = libyang-cpp_$(LIBYANG_VERSION)_$(CONFIGURED_ARCH).deb $(LIBYANG_CPP)_DEPENDS += $(LIBYANG) @@ -32,4 +32,4 @@ $(eval $(call add_derived_package,$(LIBYANG),$(LIBYANG_PY3))) $(eval $(call add_conflict_package,$(LIBYANG),$(LIBYANG1),$(LIBYANG2))) $(eval $(call add_conflict_package,$(LIBYANG_DEV),$(LIBYANG1_DEV),$(LIBYANG2_DEV))) -export LIBYANG LIBYANG_DBG LIBYANG_DEV LIBYANG_CPP LIBYANG_PY3 +export LIBYANG LIBYANG_DBGSYM LIBYANG_DEV LIBYANG_CPP LIBYANG_PY3 diff --git a/rules/systemd-sonic-generator.mk b/rules/systemd-sonic-generator.mk index cea08099177f..80d9b65f5e00 100644 --- a/rules/systemd-sonic-generator.mk +++ b/rules/systemd-sonic-generator.mk @@ -1,3 +1,3 @@ SYSTEMD_SONIC_GENERATOR = systemd-sonic-generator_1.0.0_$(CONFIGURED_ARCH).deb $(SYSTEMD_SONIC_GENERATOR)_SRC_PATH = $(SRC_PATH)/systemd-sonic-generator -SONIC_MAKE_DEBS += $(SYSTEMD_SONIC_GENERATOR) +SONIC_DPKG_DEBS += $(SYSTEMD_SONIC_GENERATOR) diff --git a/scripts/build_debian_base_system.sh b/scripts/build_debian_base_system.sh index a403791e5242..1532befdbe58 100755 --- a/scripts/build_debian_base_system.sh +++ b/scripts/build_debian_base_system.sh @@ -23,7 +23,7 @@ generate_version_file() if [ "$ENABLE_VERSION_CONTROL_DEB" != "y" ] || [ ! -d files/build/versions/host-base-image ]; then if [[ $CONFIGURED_ARCH == armhf || $CONFIGURED_ARCH == arm64 ]]; then - if [ $MULTIARCH_QEMU_ENVIRON == "y" ]; then + if [[ $MULTIARCH_QEMU_ENVIRON == y || $CROSS_BUILD_ENVIRON == y ]]; then # qemu arm bin executable for cross-building sudo mkdir -p $FILESYSTEM_ROOT/usr/bin sudo cp /usr/bin/qemu*static $FILESYSTEM_ROOT/usr/bin || true diff --git a/slave.mk b/slave.mk index 8a400a8c88c4..2e648b37f4c8 100644 --- a/slave.mk +++ b/slave.mk @@ -59,6 +59,7 @@ ifeq ($(CONFIGURED_ARCH),arm64) override DOCKER_BASE_ARCH = arm64v8 endif endif + IMAGE_DISTRO := bullseye IMAGE_DISTRO_DEBS_PATH = $(TARGET_PATH)/debs/$(IMAGE_DISTRO) IMAGE_DISTRO_FILES_PATH = $(TARGET_PATH)/files/$(IMAGE_DISTRO) @@ -81,6 +82,7 @@ export IMAGE_DISTRO export IMAGE_DISTRO_DEBS_PATH export MULTIARCH_QEMU_ENVIRON export DOCKER_BASE_ARCH +export CROSS_BUILD_ENVIRON export BLDENV ############################################################################### @@ -274,6 +276,46 @@ ifeq ($(CONFIGURED_PLATFORM),vs) export BUILD_MULTIASIC_KVM endif +ifeq ($(CROSS_BUILD_ENVIRON),y) +DEB_BUILD_OPTIONS_GENERIC += nocheck +export $(dpkg-architecture -a$(CONFIGURED_ARCH)) +ifeq ($(ENABLE_PY2_MODULES),n) +ANT_DEB_CROSS_PROFILES=nopython2 +endif +ANT_DEB_CROSS_OPT := -a$(CONFIGURED_ARCH) -Pcross,nocheck,$(ANT_DEB_CROSS_PROFILES) +ANT_DEB_CONFIG := CONFIG_SITE=/etc/dpkg-cross/cross-config.$(CONFIGURED_ARCH) + +VIRTENV_BASE_CROSS_PYTHON2 = /python_virtualenv/env2/ +VIRTENV_BASE_CROSS_PYTHON3 = /python_virtualenv/env3/ +VIRTENV_BIN_CROSS_PYTHON2 = $(VIRTENV_BASE_CROSS_PYTHON2)/bin/ +VIRTENV_BIN_CROSS_PYTHON3 = $(VIRTENV_BASE_CROSS_PYTHON3)/bin/ +VIRTENV_LIB_CROSS_PYTHON2 = $(VIRTENV_BASE_CROSS_PYTHON2)/lib/ +VIRTENV_LIB_CROSS_PYTHON3 = $(VIRTENV_BASE_CROSS_PYTHON3)/lib/ + +CROSS_HOST_TYPE = $(shell dpkg-architecture -a $(CONFIGURED_ARCH) -q DEB_HOST_MULTIARCH) + +ifeq ($(CONFIGURED_ARCH),armhf) +GOARCH=arm +else ifeq ($(CONFIGURED_ARCH),arm64) +GOARCH=arm64 +endif + +CROSS_COMPILE = $(CROSS_HOST_TYPE)- +CC = $(CROSS_COMPILE)gcc +CXX = $(CROSS_COMPILE)g++ +AR = $(CROSS_COMPILE)ar +LD = $(CROSS_COMPILE)ld +CROSS_LIB_PATH = /usr/$(CROSS_HOST_TYPE)/lib/ +CROSS_BIN_PATH = /usr/$(CROSS_HOST_TYPE)/bin/ +CROSS_PKGS_LIB_PATH = /usr/lib/$(CROSS_HOST_TYPE) + +CROSS_LIBPERL_VERSION = $(shell dpkg -s libperl-dev:$(CONFIGURED_ARCH)|grep Version|awk '{split($$2,v,"-"); print v[1];}') +CROSS_PERL_CORE_PATH = $(CROSS_PKGS_LIB_PATH)/perl/$(CROSS_LIBPERL_VERSION)/CORE/ + +CROSS_COMPILE_FLAGS := CGO_ENABLED=1 GOOS=linux GOARCH=$(GOARCH) CROSS_COMPILE=$(CROSS_COMPILE) OVERRIDE_HOST_TYPE=$(CROSS_HOST_TYPE) CROSS_LIB_PATH=$(CROSS_LIB_PATH) CROSS_BIN_PATH=$(CROSS_BIN_PATH) CROSS_HOST_TYPE=$(CROSS_HOST_TYPE) CROSS_PKGS_LIB_PATH=$(CROSS_PKGS_LIB_PATH) CROSS_PERL_CORE_PATH=$(CROSS_PERL_CORE_PATH) CC=$(CC) CXX=$(CXX) AR=$(AR) LD=$(LD) + +endif + ############################################################################### ## Routing stack related exports ############################################################################### @@ -358,6 +400,7 @@ $(info "DEFAULT_CONTAINER_REGISTRY" : "$(SONIC_DEFAULT_CONTAINER_REGISTRY)" ifeq ($(CONFIGURED_PLATFORM),vs) $(info "BUILD_MULTIASIC_KVM" : "$(BUILD_MULTIASIC_KVM)") endif +$(info "CROSS_BUILD_ENVIRON" : "$(CROSS_BUILD_ENVIRON)") $(info ) else $(info SONiC Build System for $(CONFIGURED_PLATFORM):$(CONFIGURED_ARCH)) @@ -580,7 +623,7 @@ $(addprefix $(DEBS_PATH)/, $(SONIC_MAKE_DEBS)) : $(DEBS_PATH)/% : .platform $$(a if [ -f $($*_SRC_PATH).patch/series ]; then pushd $($*_SRC_PATH) && QUILT_PATCHES=../$(notdir $($*_SRC_PATH)).patch quilt push -a; popd; fi # Build project and take package $(SETUP_OVERLAYFS_FOR_DPKG_ADMINDIR) - DEB_BUILD_OPTIONS="${DEB_BUILD_OPTIONS_GENERIC}" make -j$(SONIC_CONFIG_MAKE_JOBS) DEST=$(shell pwd)/$(DEBS_PATH) -C $($*_SRC_PATH) $(shell pwd)/$(DEBS_PATH)/$* $(LOG) + DEB_BUILD_OPTIONS="${DEB_BUILD_OPTIONS_GENERIC}" $(ANT_DEB_CONFIG) $(CROSS_COMPILE_FLAGS) make -j$(SONIC_CONFIG_MAKE_JOBS) DEST=$(shell pwd)/$(DEBS_PATH) -C $($*_SRC_PATH) $(shell pwd)/$(DEBS_PATH)/$* $(LOG) # Clean up if [ -f $($*_SRC_PATH).patch/series ]; then pushd $($*_SRC_PATH) && quilt pop -a -f; [ -d .pc ] && rm -rf .pc; popd; fi @@ -623,8 +666,8 @@ $(addprefix $(DEBS_PATH)/, $(SONIC_DPKG_DEBS)) : $(DEBS_PATH)/% : .platform $$(a if [ -f ./autogen.sh ]; then ./autogen.sh $(LOG); fi $(SETUP_OVERLAYFS_FOR_DPKG_ADMINDIR) $(if $($*_DPKG_TARGET), - ${$*_BUILD_ENV} DEB_BUILD_OPTIONS="${DEB_BUILD_OPTIONS_GENERIC} ${$*_DEB_BUILD_OPTIONS}" dpkg-buildpackage -rfakeroot -b -us -uc -tc -j$(SONIC_CONFIG_MAKE_JOBS) --as-root -T$($*_DPKG_TARGET) --admindir $$mergedir $(LOG), - ${$*_BUILD_ENV} DEB_BUILD_OPTIONS="${DEB_BUILD_OPTIONS_GENERIC} ${$*_DEB_BUILD_OPTIONS}" dpkg-buildpackage -rfakeroot -b -us -uc -tc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $$mergedir $(LOG) + ${$*_BUILD_ENV} DEB_BUILD_OPTIONS="${DEB_BUILD_OPTIONS_GENERIC} ${$*_DEB_BUILD_OPTIONS}" $(ANT_DEB_CONFIG) $(CROSS_COMPILE_FLAGS) dpkg-buildpackage -rfakeroot -b $(ANT_DEB_CROSS_OPT) -us -uc -tc -j$(SONIC_CONFIG_MAKE_JOBS) --as-root -T$($*_DPKG_TARGET) --admindir $$mergedir $(LOG), + ${$*_BUILD_ENV} DEB_BUILD_OPTIONS="${DEB_BUILD_OPTIONS_GENERIC} ${$*_DEB_BUILD_OPTIONS}" $(ANT_DEB_CONFIG) $(CROSS_COMPILE_FLAGS) dpkg-buildpackage -rfakeroot -b $(ANT_DEB_CROSS_OPT) -us -uc -tc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $$mergedir $(LOG) ) popd $(LOG_SIMPLE) # Clean up @@ -691,7 +734,15 @@ $(SONIC_INSTALL_DEBS) : $(DEBS_PATH)/%-install : .platform $$(addsuffix -install { while dpkg -s $(firstword $(subst _, ,$(basename $(deb)))) | grep "^Version: $(word 2, $(subst _, ,$(basename $(deb))))" &> /dev/null; do echo "waiting for $(deb) to be uninstalled" $(LOG); sleep 1; done } ) # put a lock here because dpkg does not allow installing packages in parallel if mkdir $(DEBS_PATH)/dpkg_lock &> /dev/null; then +ifneq ($(CROSS_BUILD_ENVIRON),y) { sudo DEBIAN_FRONTEND=noninteractive dpkg -i $(DEBS_PATH)/$* $(LOG) && rm -d $(DEBS_PATH)/dpkg_lock && break; } || { rm -d $(DEBS_PATH)/dpkg_lock && sudo lsof /var/lib/dpkg/lock-frontend && ps aux && exit 1 ; } +else + # Relocate debian packages python libraries to the cross python virtual env location + { sudo DEBIAN_FRONTEND=noninteractive dpkg -i $(if $(findstring $(LINUX_HEADERS),$*),--force-depends) $(DEBS_PATH)/$* $(LOG) && \ + rm -rf tmp && mkdir tmp && dpkg -x $(DEBS_PATH)/$* tmp && (sudo cp -rf tmp/usr/lib/python2*/dist-packages/* $(VIRTENV_LIB_CROSS_PYTHON2)/python2*/site-packages/ 2>/dev/null || true) && \ + (sudo cp -rf tmp/usr/lib/python3/dist-packages/* $(VIRTENV_LIB_CROSS_PYTHON3)/python3.*/site-packages/ 2>/dev/null || true) && \ + rm -d $(DEBS_PATH)/dpkg_lock && break; } || { rm -d $(DEBS_PATH)/dpkg_lock && sudo lsof /var/lib/dpkg/lock-frontend && ps aux && exit 1 ; } +endif fi sleep 10 done @@ -764,10 +815,19 @@ $(addprefix $(PYTHON_WHEELS_PATH)/, $(SONIC_PYTHON_WHEELS)) : $(PYTHON_WHEELS_PA pushd $($*_SRC_PATH) $(LOG_SIMPLE) # apply series of patches if exist if [ -f ../$(notdir $($*_SRC_PATH)).patch/series ]; then QUILT_PATCHES=../$(notdir $($*_SRC_PATH)).patch quilt push -a; fi +ifneq ($(CROSS_BUILD_ENVIRON),y) # Use pip instead of later setup.py to install dependencies into user home, but uninstall self pip$($*_PYTHON_VERSION) install . && pip$($*_PYTHON_VERSION) uninstall --yes `python$($*_PYTHON_VERSION) setup.py --name` if [ ! "$($*_TEST)" = "n" ]; then python$($*_PYTHON_VERSION) setup.py test $(LOG); fi python$($*_PYTHON_VERSION) setup.py bdist_wheel $(LOG) +else + { + export PATH=$(VIRTENV_BIN_CROSS_PYTHON$($*_PYTHON_VERSION)):${PATH} + python$($*_PYTHON_VERSION) setup.py build $(LOG) + if [ ! "$($*_TEST)" = "n" ]; then python$($*_PYTHON_VERSION) setup.py test $(LOG); fi + python$($*_PYTHON_VERSION) setup.py bdist_wheel $(LOG) + } +endif # clean up if [ -f ../$(notdir $($*_SRC_PATH)).patch/series ]; then quilt pop -a -f; [ -d .pc ] && rm -rf .pc; fi popd $(LOG_SIMPLE) @@ -793,7 +853,12 @@ $(SONIC_INSTALL_WHEELS) : $(PYTHON_WHEELS_PATH)/%-install : .platform $$(addsuff # put a lock here to avoid race conditions while true; do if mkdir $(PYTHON_WHEELS_PATH)/pip_lock &> /dev/null; then +ifneq ($(CROSS_BUILD_ENVIRON),y) { sudo -E pip$($*_PYTHON_VERSION) install $(PYTHON_WHEELS_PATH)/$* $(LOG) && rm -d $(PYTHON_WHEELS_PATH)/pip_lock && break; } || { rm -d $(PYTHON_WHEELS_PATH)/pip_lock && exit 1 ; } +else + # Link python script and data expected location to the cross python virtual env istallation locations + { PATH=$(VIRTENV_BIN_CROSS_PYTHON$($*_PYTHON_VERSION)):${PATH} sudo -E $(VIRTENV_BIN_CROSS_PYTHON$($*_PYTHON_VERSION))/pip$($*_PYTHON_VERSION) install $(PYTHON_WHEELS_PATH)/$* $(LOG) && $(if $(findstring $(SONIC_CONFIG_ENGINE_PY3),$*),(sudo ln -s $(VIRTENV_BIN_CROSS_PYTHON$($*_PYTHON_VERSION))/sonic-cfggen /usr/local/bin/sonic-cfggen 2>/dev/null || true), true ) && $(if $(findstring $(SONIC_YANG_MODELS_PY3),$*),(sudo ln -s $(VIRTENV_BASE_CROSS_PYTHON3)/yang-models /usr/local/yang-models 2>/dev/null || true), true ) && rm -d $(PYTHON_WHEELS_PATH)/pip_lock && break; } || { rm -d $(PYTHON_WHEELS_PATH)/pip_lock && exit 1 ; } +endif fi done $(FOOTER) @@ -918,7 +983,7 @@ $(addprefix $(TARGET_PATH)/, $(DOCKER_IMAGES)) : $(TARGET_PATH)/%.gz : .platform $(eval export $(subst -,_,$(notdir $($*.gz_PATH)))_whls=$(shell printf "$(subst $(SPACE),\n,$(call expand,$($*.gz_PYTHON_WHEELS)))\n" | awk '!a[$$0]++')) $(eval export $(subst -,_,$(notdir $($*.gz_PATH)))_dbgs=$(shell printf "$(subst $(SPACE),\n,$(call expand,$($*.gz_DBG_PACKAGES)))\n" | awk '!a[$$0]++')) $(eval export $(subst -,_,$(notdir $($*.gz_PATH)))_pkgs=$(shell printf "$(subst $(SPACE),\n,$(call expand,$($*.gz_APT_PACKAGES)))\n" | awk '!a[$$0]++')) - if [ -d $($*.gz_PATH)/cli-plugin-tests/ ]; then pushd $($*.gz_PATH)/cli-plugin-tests; pytest-$($(SONIC_UTILITIES_PY3)_PYTHON_VERSION) -v $(LOG); popd; fi + if [ -d $($*.gz_PATH)/cli-plugin-tests/ ]; then pushd $($*.gz_PATH)/cli-plugin-tests; PATH=$(VIRTENV_BIN_CROSS_PYTHON$($(SONIC_UTILITIES_PY3)_PYTHON_VERSION)):${PATH} pytest-$($(SONIC_UTILITIES_PY3)_PYTHON_VERSION) -v $(LOG); popd; fi # Label docker image with componenets versions $(eval export $(subst -,_,$(notdir $($*.gz_PATH)))_labels=$(foreach component,\ $(call expand,$($*.gz_DEPENDS),RDEPENDS) \ @@ -1227,7 +1292,6 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \ ) ) - # Exported variables are used by sonic_debian_extension.sh export installer_start_scripts="$(foreach docker, $($*_DOCKERS),$(addsuffix .sh, $($(docker:-dbg.gz=.gz)_CONTAINER_NAME)))" export feature_vs_image_names="$(foreach docker, $($*_DOCKERS), $(addsuffix :, $($(docker:-dbg.gz=.gz)_CONTAINER_NAME):$(docker:-dbg.gz=.gz)))" @@ -1293,6 +1357,7 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \ SIGNING_CERT="$(SIGNING_CERT)" \ PACKAGE_URL_PREFIX=$(PACKAGE_URL_PREFIX) \ MULTIARCH_QEMU_ENVIRON=$(MULTIARCH_QEMU_ENVIRON) \ + CROSS_BUILD_ENVIRON=$(CROSS_BUILD_ENVIRON) \ ./build_debian.sh $(LOG) USERNAME="$(USERNAME)" \ diff --git a/sonic-slave-bullseye/Dockerfile.j2 b/sonic-slave-bullseye/Dockerfile.j2 index edac99af113e..2258946c781d 100644 --- a/sonic-slave-bullseye/Dockerfile.j2 +++ b/sonic-slave-bullseye/Dockerfile.j2 @@ -7,6 +7,14 @@ COPY --from=qemu /usr/bin/qemu-arm-static /usr/bin FROM {{ prefix }}multiarch/qemu-user-static:x86_64-aarch64-6.1.0-8 as qemu FROM {{ prefix }}multiarch/debian-debootstrap:arm64-bullseye COPY --from=qemu /usr/bin/qemu-aarch64-static /usr/bin +{%- elif CONFIGURED_ARCH == "armhf" and CROSS_BUILD_ENVIRON == "y" %} +FROM {{ prefix }}multiarch/qemu-user-static:x86_64-arm-6.1.0-8 as qemu +FROM {{ prefix }}debian:bullseye +COPY --from=qemu /usr/bin/qemu-arm-static /usr/bin +{%- elif CONFIGURED_ARCH == "arm64" and CROSS_BUILD_ENVIRON == "y" %} +FROM {{ prefix }}multiarch/qemu-user-static:x86_64-aarch64-6.1.0-8 as qemu +FROM {{ prefix }}debian:bullseye +COPY --from=qemu /usr/bin/qemu-aarch64-static /usr/bin {%- else -%} FROM {{ prefix }}debian:bullseye {%- endif %} @@ -25,7 +33,7 @@ RUN echo "deb [arch=amd64] http://debian-archive.trafficmanager.net/debian/ bull echo "deb [arch=amd64] http://packages.trafficmanager.net/debian/debian bullseye main contrib non-free" >> /etc/apt/sources.list && \ echo "deb [arch=amd64] http://packages.trafficmanager.net/debian/debian bullseye-updates main contrib non-free" >> /etc/apt/sources.list -{%- if CONFIGURED_ARCH == "armhf" %} +{%- if CONFIGURED_ARCH == "armhf" and CROSS_BUILD_ENVIRON != "y" %} RUN echo "deb [arch=armhf] http://deb.debian.org/debian bullseye main contrib non-free" > /etc/apt/sources.list && \ echo "deb-src [arch=armhf] http://deb.debian.org/debian bullseye main contrib non-free" >> /etc/apt/sources.list && \ echo "deb [arch=armhf] http://deb.debian.org/debian bullseye-updates main contrib non-free" >> /etc/apt/sources.list && \ @@ -36,7 +44,7 @@ RUN echo "deb [arch=armhf] http://deb.debian.org/debian bullseye main contrib no echo "deb [arch=armhf] http://packages.trafficmanager.net/debian/debian-security bullseye-security main contrib non-free" >> /etc/apt/sources.list && \ echo "deb [arch=armhf] http://packages.trafficmanager.net/debian/debian bullseye main contrib non-free" >> /etc/apt/sources.list && \ echo "deb [arch=armhf] http://packages.trafficmanager.net/debian/debian bullseye-updates main contrib non-free" >> /etc/apt/sources.list -{%- elif CONFIGURED_ARCH == "arm64" %} +{%- elif CONFIGURED_ARCH == "arm64" and CROSS_BUILD_ENVIRON != "y" %} RUN echo "deb [arch=arm64] http://deb.debian.org/debian bullseye main contrib non-free" > /etc/apt/sources.list && \ echo "deb-src [arch=arm64] http://deb.debian.org/debian bullseye main contrib non-free" >> /etc/apt/sources.list && \ echo "deb [arch=arm64] http://deb.debian.org/debian bullseye-updates main contrib non-free" >> /etc/apt/sources.list && \ @@ -47,11 +55,59 @@ RUN echo "deb [arch=arm64] http://deb.debian.org/debian bullseye main contrib no echo 'deb [arch=arm64] http://ftp.debian.org/debian bullseye-backports main' >> /etc/apt/sources.list && \ echo "deb [arch=arm64] http://packages.trafficmanager.net/debian/debian bullseye main contrib non-free" >> /etc/apt/sources.list && \ echo "deb [arch=arm64] http://packages.trafficmanager.net/debian/debian bullseye-updates main contrib non-free" >> /etc/apt/sources.list +{%- elif CROSS_BUILD_ENVIRON == "y" %} +{%- if CONFIGURED_ARCH == "armhf" %} +ARG arch=armhf +ARG gcc_arch=arm-linux-gnueabihf +ARG PYTHON_CROSS_PLATFORM=linux_armv7l +{%- elif CONFIGURED_ARCH == "arm64" %} +ARG arch=arm64 +ARG gcc_arch=aarch64-linux-gnu +ARG PYTHON_CROSS_PLATFORM=linux_aarch64 +{%- endif %} + +RUN dpkg --add-architecture $arch +RUN apt-get update +RUN apt-get install -y crossbuild-essential-$arch +RUN apt-get install -y gcc-$gcc_arch + +RUN apt-mark hold g++-$gcc_arch +RUN apt-mark hold g++-10-$gcc_arch +RUN apt-mark hold gcc-$gcc_arch +RUN apt-mark hold gcc-10-$gcc_arch + +ARG CROSS_CC=${gcc_arch}-gcc +ARG CROSS_CXX=${gcc_arch}-g++ {%- endif %} ## Make apt-get non-interactive ENV DEBIAN_FRONTEND=noninteractive +{%- if CROSS_BUILD_ENVIRON == "y" %} +RUN apt-get install -y python3 python3-pip +RUN apt-get install -y python3-minimal:$arch python3.9:$arch python3:$arch python3-dev:$arch python3-setuptools:$arch +RUN apt-get download python3-distutils && dpkg --force-all -i python3-distutils* +RUN apt-get download python3-pip && dpkg --force-all -i python3-pip* +RUN which pip3 && pip3 install enum34 +RUN pip3 install virtualenv + +# Create target arm python3 virtual environments with all required packages installed +RUN mkdir /python_virtualenv +RUN cd /python_virtualenv && python3 -m virtualenv --copies -p /usr/bin/python3 env3 + +RUN PATH=/python_virtualenv/env3/bin/:$PATH pip3 install setuptools==49.6.00 wheel==0.35.1 fastentrypoints pytest pytest-cov pytest-runner==5.2 nose==1.3.7 mockredispy==2.9.3 mock==3.0.5 PyYAML==5.4.1 redis==3.5.3 pexpect==4.8.0 Pympler==0.8 parameterized natsort==6.2.1 MarkupSafe==2.0.1 Jinja2==3.0.3 click tabulate netaddr netifaces pyroute2 pyfakefs sphinx && ln -s /python_virtualenv/env3/bin/pytest /python_virtualenv/env3/bin/pytest-3 + +RUN apt-get --fix-broken install -y +RUN LIBPYTHON3_DEPS="`apt-cache depends libpython3-dev:$arch |grep Depends|awk {'print \$2;'}|tr "\n" " "`" && apt-get install -y libpython2.7-dev:$arch $LIBPYTHON3_DEPS libxml2-dev:$arch libxslt-dev:$arch libssl-dev:$arch libz-dev:$arch + +RUN apt-get install -y swig libssl-dev + +RUN PATH=/python_virtualenv/env3/bin/:$PATH python3 -m pip install pyang==2.4.0 +RUN PATH=/python_virtualenv/env3/bin/:$PATH python3 -m pip install pyangbind==0.8.1 +RUN PATH=/python_virtualenv/env3/bin/:$PATH python3 -m pip uninstall -y enum34 +RUN PATH=/python_virtualenv/env3/bin/:$PATH pip3 install --force-reinstall --no-cache-dir coverage +{%- endif %} + RUN apt-get update && apt-get install -y \ apt-utils \ default-jre-headless \ @@ -107,8 +163,10 @@ RUN apt-get update && apt-get install -y \ libsystemd-dev \ python3-ipaddr \ libcmocka-dev \ +#{%- if CROSS_BUILD_ENVIRON != "y" %} python3-all-dev \ python3-all-dbg \ +#{%- endif %} install-info \ logrotate \ # For libnl3 (local) build @@ -131,7 +189,9 @@ RUN apt-get update && apt-get install -y \ gem2deb \ libevent-dev \ libglib2.0-dev \ +#{%- if CROSS_BUILD_ENVIRON != "y" %} python3-all-dev \ +#{%- endif %} python3-twisted \ phpunit \ libbit-vector-perl \ @@ -174,7 +234,7 @@ RUN apt-get update && apt-get install -y \ {%- if CONFIGURED_ARCH == "amd64" %} linux-compiler-gcc-10-x86 \ {%- endif %} -{%- if CONFIGURED_ARCH == "armhf" %} +{%- if CONFIGURED_ARCH == "armhf" and CROSS_BUILD_ENVIRON != "y" %} linux-compiler-gcc-10-arm \ {%- endif %} linux-kbuild-5.10 \ @@ -240,7 +300,9 @@ RUN apt-get update && apt-get install -y \ sphinx-common \ python3-sphinx \ # For sonic config engine testing +{%- if CROSS_BUILD_ENVIRON != "y" %} python3-dev \ +{%- endif %} {%- if CONFIGURED_ARCH == "armhf" or CONFIGURED_ARCH == "arm64" %} libxslt-dev \ {%- endif %} @@ -361,15 +423,21 @@ RUN apt-get update && apt-get install -y \ libauparse-dev \ auditd +{%- if CROSS_BUILD_ENVIRON == "y" %} +# Arm vs. amd64 versions conflict - remove amd64 packages +RUN apt-get remove -y libnl-3-200 +RUN apt-get install -y libpcre3:$arch +{%- endif %} + RUN apt-get -y build-dep openssh # Build fix for ARM64 and ARMHF /etc/debian_version {%- if CONFIGURED_ARCH == "armhf" or CONFIGURED_ARCH == "arm64" %} -RUN apt upgrade -y base-files +RUN apt upgrade -y base-files libc-bin=$(dpkg-query -W -f '${Version}' libc-bin) {%- endif %} # Build fix for ARMHF bullseye libsairedis -{%- if CONFIGURED_ARCH == "armhf" %} +{%- if CONFIGURED_ARCH == "armhf" and MULTIARCH_QEMU_ENVIRON == "y" %} # Install doxygen build dependency packages RUN apt install -y libxapian-dev yui-compressor texlive-extra-utils \ texlive-font-utils rdfind llvm-11-dev libclang-11-dev sassc faketime mat2 @@ -400,8 +468,12 @@ RUN sudo augtool --autosave "set /files/etc/dpkg/dpkg.cfg/force-confdef" ## do not modify the current configuration file, the new version is installed with a .dpkg-dist suffix RUN sudo augtool --autosave "set /files/etc/dpkg/dpkg.cfg/force-confold" +{%- if CROSS_BUILD_ENVIRON != "y" %} # For linux build RUN apt-get -y build-dep linux +{%- else %} +RUN apt-get install -y kernel-wedge +{%- endif %} # For gobgp and telemetry build RUN apt-get install -y golang-1.15 && ln -s /usr/lib/go-1.15 /usr/local/go @@ -420,6 +492,16 @@ RUN apt-get purge -y python3-pip python3-yaml RUN pip3 install setuptools==49.6.00 RUN pip3 install wheel==0.35.1 +{%- if CONFIGURED_ARCH == "armhf" %} +# Allow only manylinux wheels on armhf, to ensure that binaries/libraries work correctly on armhf +COPY ["disable-non-manylinux.patch", "/"] +{%- if CROSS_BUILD_ENVIRON == "y" %} +RUN patch -p1 -i /disable-non-manylinux.patch /python_virtualenv/env3/lib/python3.9/site-packages/pip/_vendor/packaging/tags.py +{%- else %} +RUN patch -p1 -i /disable-non-manylinux.patch /usr/local/lib/python3.9/dist-packages/pip/_vendor/packaging/tags.py +{%- endif %} +{%- endif %} + # For building sonic-utilities RUN pip3 install fastentrypoints mock @@ -445,7 +527,9 @@ RUN pip3 install j2cli==0.3.10 # For sonic-mgmt-framework RUN pip3 install "PyYAML==5.4.1" +{%- if CROSS_BUILD_ENVIRON != "y" %} RUN pip3 install "lxml==4.6.2" +{%- endif %} # For sonic-platform-common testing RUN pip3 install redis @@ -475,7 +559,11 @@ RUN apt-get install -y vim # Install rsyslog RUN apt-get install -y rsyslog +{%- if CROSS_BUILD_ENVIRON == "y" %} +RUN cd /usr/src/gtest && CXX=$CROSS_CXX CC=$CROSS_CC cmake . && make -C /usr/src/gtest +{%- else %} RUN cd /usr/src/gtest && cmake . && make -C /usr/src/gtest +{%- endif %} RUN mkdir /var/run/sshd EXPOSE 22 @@ -501,7 +589,11 @@ RUN apt-get install -y \ {%- endif %} RUN curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add - RUN add-apt-repository \ +{%- if CROSS_BUILD_ENVIRON == "y" %} + "deb https://download.docker.com/linux/debian \ +{%- else %} "deb [arch={{ CONFIGURED_ARCH }}] https://download.docker.com/linux/debian \ +{%- endif %} $(lsb_release -cs) \ stable" RUN apt-get update @@ -520,6 +612,20 @@ RUN pip3 install git+https://github.com/aristanetworks/swi-tools.git@bead66bf261 RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - RUN apt-get install -y nodejs +{%- if CROSS_BUILD_ENVIRON == "y" %} +RUN apt-get install -y rsync dh-python + +RUN apt-get install -y libelf-dev:$arch libdw-dev:$arch libbz2-dev:$arch liblzo2-dev:$arch libedit-dev:$arch libevent-dev:$arch libopts25-dev:$arch libssl-dev:$arch pps-tools:$arch libpam-cap:$arch libcap-dev:$arch libpam0g-dev:$arch libaudit-dev:$arch libgtk-3-dev:$arch libkrb5-dev:$arch libsystemd-dev:$arch libwrap0-dev:$arch libkrb5-dev:$arch libboost1.74-dev:$arch libboost-dev:$arch libzmq5:$arch libzmq3-dev:$arch libdaemon-dev:$arch libjansson-dev:$arch libmnl-dev:$arch libsensors5:$arch libsensors4-dev:$arch libperl-dev:$arch libmariadb-dev:$arch libmariadb-dev-compat:$arch libpci-dev:$arch libjson-c-dev:$arch libreadline-dev:$arch librtr-dev:$arch librrd-dev:$arch libnetfilter-conntrack-dev:$arch libnetfilter-conntrack3:$arch libnfnetlink-dev:$arch libnftnl-dev:$arch libldap2-dev:$arch libbind-export-dev:$arch check:$arch libboost-atomic-dev:$arch libboost-test-dev:$arch libglib2.0-dev:$arch libexplain-dev:$arch libc-ares-dev:$arch libiptc0:$arch libxtables12:$arch libatm1-dev:$arch libdb-dev:$arch pkg-config:$arch libnghttp2-14:$arch librtmp1:$arch libssh2-1:$arch libcjson1:$arch libcjson-dev:$arch libcurl3-gnutls:$arch libcurl3-nss-dev:$arch libboost-thread1.74-dev:$arch libboost-thread-dev:$arch libboost-system1.74-dev:$arch libboost-system-dev:$arch libgtest-dev:$arch libgmock-dev:$arch libfido2-dev:$arch libcunit1:$arch libcunit1-dev:$arch libauparse-dev:$arch libnetsnmptrapd40:$arch qtbase5-dev:$arch libboost-log-dev:$arch libboost-filesystem-dev:$arch libboost-program-options-dev:$arch + +RUN apt-get download libgirepository1.0-dev:$arch && dpkg --force-all -i libgirepository1.0-dev* +RUN PATH=/python_virtualenv/env3/bin/:$PATH pip3 install pycairo + +# Install libpcsclite-dev for wpasupplicant using download because regular install removes amd64 python package +RUN apt-get download libpcsclite1:$arch && dpkg --force-all -i libpcsclite1* && apt-get download libpcsclite-dev:$arch && dpkg --force-all -i libpcsclite-dev* +# Install python3-dev for frr (/usr/bin/python3-config for $arch) using download because regular install removes amd64 python package +RUN apt-get download python3.9-dev:$arch && apt-get download python3-dev:$arch && dpkg --force-all -i python3*-dev* +{% endif %} + # Tell azure pipeline to use node.js in the docker LABEL "com.azure.dev.pipelines.agent.handler.node.path"="/usr/bin/node" {% endif -%} diff --git a/sonic-slave-bullseye/Dockerfile.user.j2 b/sonic-slave-bullseye/Dockerfile.user.j2 index 5bc747beb2fc..2eb7ef18b6cd 100644 --- a/sonic-slave-bullseye/Dockerfile.user.j2 +++ b/sonic-slave-bullseye/Dockerfile.user.j2 @@ -1,5 +1,5 @@ ARG slave_base_tag_ref=latest -{%- if MULTIARCH_QEMU_ENVIRON != "y" %} +{%- if MULTIARCH_QEMU_ENVIRON != "y" and CROSS_BUILD_ENVIRON != "y" %} FROM sonic-slave-bullseye:${slave_base_tag_ref} {%- else %} FROM sonic-slave-bullseye-march-{{ CONFIGURED_ARCH }}:${slave_base_tag_ref} diff --git a/sonic-slave-bullseye/disable-non-manylinux.patch b/sonic-slave-bullseye/disable-non-manylinux.patch new file mode 100644 index 000000000000..67e81c4e9116 --- /dev/null +++ b/sonic-slave-bullseye/disable-non-manylinux.patch @@ -0,0 +1,10 @@ +--- a/tags.py 2022-07-12 00:07:22.710207780 +0000 ++++ b/tags.py 2022-07-12 00:07:13.185890659 +0000 +@@ -424,7 +424,6 @@ + _, arch = linux.split("_", 1) + yield from _manylinux.platform_tags(linux, arch) + yield from _musllinux.platform_tags(arch) +- yield linux + + + def _generic_platforms() -> Iterator[str]: diff --git a/sonic-slave-buster/Dockerfile.j2 b/sonic-slave-buster/Dockerfile.j2 index 2f3cadf0a4b4..b89d44656d3a 100644 --- a/sonic-slave-buster/Dockerfile.j2 +++ b/sonic-slave-buster/Dockerfile.j2 @@ -1,10 +1,19 @@ {% set prefix = DEFAULT_CONTAINER_REGISTRY %} {%- if CONFIGURED_ARCH == "armhf" and MULTIARCH_QEMU_ENVIRON == "y" %} -FROM {{ prefix }}multiarch/qemu-user-static:x86_64-arm-5.0.0-2 as qemu +FROM {{ prefix }}multiarch/qemu-user-static:x86_64-arm as qemu FROM {{ prefix }}multiarch/debian-debootstrap:armhf-buster COPY --from=qemu /usr/bin/qemu-arm-static /usr/bin {%- elif CONFIGURED_ARCH == "arm64" and MULTIARCH_QEMU_ENVIRON == "y" %} +FROM {{ prefix }}multiarch/qemu-user-static:x86_64-aarch64 as qemu FROM {{ prefix }}multiarch/debian-debootstrap:arm64-buster +{%- elif CONFIGURED_ARCH == "armhf" and CROSS_BUILD_ENVIRON == "y" %} +FROM {{ prefix }}multiarch/qemu-user-static:x86_64-arm as qemu +FROM {{ prefix }}debian:buster +COPY --from=qemu /usr/bin/qemu-arm-static /usr/bin +{%- elif CONFIGURED_ARCH == "arm64" and CROSS_BUILD_ENVIRON == "y" %} +FROM {{ prefix }}multiarch/qemu-user-static:x86_64-aarch64 as qemu +FROM {{ prefix }}debian:buster +COPY --from=qemu /usr/bin/qemu-aarch64-static /usr/bin {%- else -%} FROM {{ prefix }}debian:buster {%- endif %} @@ -22,7 +31,7 @@ RUN echo "deb [arch=amd64] http://debian-archive.trafficmanager.net/debian/ bust echo "deb [arch=amd64] http://packages.trafficmanager.net/debian/debian buster-updates main contrib non-free" >> /etc/apt/sources.list && \ echo "deb [arch=amd64] http://packages.trafficmanager.net/debian/debian-security buster_updates main contrib non-free" >> /etc/apt/sources.list -{%- if CONFIGURED_ARCH == "armhf" %} +{%- if CONFIGURED_ARCH == "armhf" and CROSS_BUILD_ENVIRON != "y" %} RUN echo "deb [arch=armhf] http://deb.debian.org/debian buster main contrib non-free" > /etc/apt/sources.list && \ echo "deb-src [arch=armhf] http://deb.debian.org/debian buster main contrib non-free" >> /etc/apt/sources.list && \ echo "deb [arch=armhf] http://deb.debian.org/debian buster-updates main contrib non-free" >> /etc/apt/sources.list && \ @@ -33,7 +42,7 @@ RUN echo "deb [arch=armhf] http://deb.debian.org/debian buster main contrib non- echo "deb [arch=armhf] http://packages.trafficmanager.net/debian/debian buster main contrib non-free" >> /etc/apt/sources.list && \ echo "deb [arch=armhf] http://packages.trafficmanager.net/debian/debian buster-updates main contrib non-free" >> /etc/apt/sources.list && \ echo "deb [arch=arm64] http://packages.trafficmanager.net/debian/debian-security buster_updates main contrib non-free" >> /etc/apt/sources.list -{%- elif CONFIGURED_ARCH == "arm64" %} +{%- elif CONFIGURED_ARCH == "arm64" and CROSS_BUILD_ENVIRON != "y" %} RUN echo "deb [arch=arm64] http://deb.debian.org/debian buster main contrib non-free" > /etc/apt/sources.list && \ echo "deb-src [arch=arm64] http://deb.debian.org/debian buster main contrib non-free" >> /etc/apt/sources.list && \ echo "deb [arch=arm64] http://deb.debian.org/debian buster-updates main contrib non-free" >> /etc/apt/sources.list && \ @@ -44,11 +53,63 @@ RUN echo "deb [arch=arm64] http://deb.debian.org/debian buster main contrib non- echo "deb [arch=arm64] http://packages.trafficmanager.net/debian/debian buster main contrib non-free" >> /etc/apt/sources.list && \ echo "deb [arch=arm64] http://packages.trafficmanager.net/debian/debian buster-updates main contrib non-free" >> /etc/apt/sources.list && \ echo "deb [arch=arm64] http://packages.trafficmanager.net/debian/debian-security buster_updates main contrib non-free" >> /etc/apt/sources.list +{%- elif CROSS_BUILD_ENVIRON == "y" %} +{%- if CONFIGURED_ARCH == "armhf" %} +ARG arch=armhf +ARG gcc_arch=arm-linux-gnueabihf +ARG PYTHON_CROSS_PLATFORM=linux_armv7l +{%- elif CONFIGURED_ARCH == "arm64" %} +ARG arch=arm64 +ARG gcc_arch=aarch64-linux-gnu +ARG PYTHON_CROSS_PLATFORM=linux_aarch64 +{%- endif %} + +RUN echo "deb http://ftp.debian.org/debian buster-backports main" >> /etc/apt/sources.list + +RUN dpkg --add-architecture $arch +RUN apt-get update +RUN apt-get install -y crossbuild-essential-$arch +RUN apt-get install -y gcc-$gcc_arch + +RUN apt-mark hold g++-$gcc_arch +RUN apt-mark hold g++-8-$gcc_arch +RUN apt-mark hold gcc-$gcc_arch +RUN apt-mark hold gcc-8-$gcc_arch + +ARG CROSS_CC=${gcc_arch}-gcc +ARG CROSS_CXX=${gcc_arch}-g++ {%- endif %} ## Make apt-get non-interactive ENV DEBIAN_FRONTEND=noninteractive +{%- if CROSS_BUILD_ENVIRON == "y" %} +RUN apt-get install -y python3 python3-pip +RUN apt-get install -y python:$arch python3-minimal:$arch python3.7:$arch python3:$arch python-setuptools:$arch +RUN apt-get download python3-distutils && dpkg --force-all -i python3-distutils* +RUN apt-get download python3-pip && dpkg --force-all -i python3-pip* +RUN which pip3 && pip3 install enum34 +RUN pip3 install virtualenv + +# Create target arm python2/3 virtual environments with all required packages installed +RUN mkdir /python_virtualenv +RUN cd /python_virtualenv && python3 -m virtualenv -p /usr/bin/python env2 +RUN cd /python_virtualenv && python3 -m virtualenv --copies -p /usr/bin/python3 env3 + +RUN PATH=/python_virtualenv/env2/bin/:$PATH pip2 install setuptools==40.8.0 wheel==0.35.1 fastentrypoints pytest pytest-cov pytest-runner==4.4 nose==1.3.7 mockredispy==2.9.3 mock==3.0.5 j2cli==0.3.10 PyYAML==5.4.1 pexpect==4.6.0 Pympler==0.8 ctypesgen==1.0.2 natsort==6.2.1 redis==3.5.3 protobuf==3.17.3 +RUN PATH=/python_virtualenv/env3/bin/:$PATH pip3 install setuptools==49.6.00 wheel==0.35.1 fastentrypoints pytest pytest-cov pytest-runner==5.2 nose==1.3.7 mockredispy==2.9.3 mock==3.0.5 PyYAML==5.4.1 redis==3.5.3 pexpect==4.8.0 Pympler==0.8 parameterized natsort==6.2.1 MarkupSafe==2.0.1 Jinja2==3.0.3 sphinx && ln -s /python_virtualenv/env3/bin/pytest /python_virtualenv/env3/bin/pytest-3 + +RUN apt-get --fix-broken install -y +RUN LIBPYTHON3_DEPS="`apt-cache depends libpython3-dev:$arch |grep Depends|awk {'print \$2;'}|tr "\n" " "`" && apt-get install -y libpython2.7-dev:$arch $LIBPYTHON3_DEPS libxml2-dev:$arch libxslt-dev:$arch libssl-dev:$arch libz-dev:$arch + +RUN apt-get install -y swig libssl-dev + +RUN PATH=/python_virtualenv/env3/bin/:$PATH python3 -m pip install pyang==2.4.0 +RUN PATH=/python_virtualenv/env3/bin/:$PATH python3 -m pip install pyangbind==0.8.1 +RUN PATH=/python_virtualenv/env3/bin/:$PATH python3 -m pip uninstall -y enum34 +RUN PATH=/python_virtualenv/env3/bin/:$PATH pip3 install --force-reinstall --no-cache-dir coverage +{%- endif %} + RUN apt-get update && apt-get install -y \ apt-utils \ default-jre-headless \ @@ -104,8 +165,10 @@ RUN apt-get update && apt-get install -y \ libsystemd-dev \ python-ipaddr \ libcmocka-dev \ +{%- if CROSS_BUILD_ENVIRON != "y" %} python3-all-dev \ python3-all-dbg \ +{%- endif %} install-info \ logrotate \ # For libnl3 (local) build @@ -180,7 +243,7 @@ RUN apt-get update && apt-get install -y \ {%- if CONFIGURED_ARCH == "amd64" %} linux-compiler-gcc-8-x86 \ {%- endif %} -{%- if CONFIGURED_ARCH == "armhf" %} +{%- if CONFIGURED_ARCH == "armhf" and CROSS_BUILD_ENVIRON != "y" %} linux-compiler-gcc-8-arm \ {%- endif %} linux-kbuild-4.19 \ @@ -324,6 +387,9 @@ RUN apt-get update && apt-get install -y \ # For WPA supplication qtbase5-dev \ aspell-en \ +{%- if CROSS_BUILD_ENVIRON != "y" %} + libhiredis-dev \ +{%- endif %} swig3.0 \ libpython2.7-dev \ libssl-dev \ @@ -375,14 +441,19 @@ RUN apt-get install -y -t buster-backports \ dwz \ debhelper +{%- if CROSS_BUILD_ENVIRON == "y" %} +# Arm vs. amd64 versions conflict - remove amd64 packages +RUN apt-get remove -y libnl-3-200 libsnmp30 +RUN apt-get install -y libpcre2-dev:$arch libpcre3:$arch +{%- endif %} + RUN apt-get -y build-dep openssh # Build fix for ARMHF buster libsairedis -{%- if CONFIGURED_ARCH == "armhf" %} +{%- if CONFIGURED_ARCH == "armhf" and MULTIARCH_QEMU_ENVIRON == "y" %} # Install doxygen build dependency packages RUN apt install -y libxapian-dev yui-compressor libclang-3.9-dev texlive-extra-utils \ texlive-font-utils rdfind llvm-6.0-dev libclang-6.0-dev sassc - # Update doxygen with 64bit file offset patch RUN dget -u http://deb.debian.org/debian/pool/main/d/doxygen/doxygen_1.8.13-10.dsc && \ cd doxygen-1.8.13 && \ @@ -408,15 +479,19 @@ RUN sudo augtool --autosave "set /files/etc/dpkg/dpkg.cfg/force-confdef" ## do not modify the current configuration file, the new version is installed with a .dpkg-dist suffix RUN sudo augtool --autosave "set /files/etc/dpkg/dpkg.cfg/force-confold" +{%- if CROSS_BUILD_ENVIRON != "y" %} # For linux build RUN apt-get -y build-dep linux +{%- else %} +RUN apt-get install -y kernel-wedge +{%- endif %} # For gobgp and telemetry build RUN export VERSION=1.14.2 \ -{%- if CONFIGURED_ARCH == "armhf" %} +{%- if CONFIGURED_ARCH == "armhf" and CROSS_BUILD_ENVIRON != "y" %} && wget https://storage.googleapis.com/golang/go$VERSION.linux-armv6l.tar.gz \ && tar -C /usr/local -xzf go$VERSION.linux-armv6l.tar.gz \ -{%- elif CONFIGURED_ARCH == "arm64" %} +{%- elif CONFIGURED_ARCH == "arm64" and CROSS_BUILD_ENVIRON != "y" %} && wget https://storage.googleapis.com/golang/go$VERSION.linux-arm64.tar.gz \ && tar -C /usr/local -xzf go$VERSION.linux-arm64.tar.gz \ {%- else %} @@ -477,8 +552,11 @@ RUN pip3 install Jinja2==3.0.3 # For sonic-mgmt-framework RUN pip2 install "PyYAML==5.4.1" RUN pip3 install "PyYAML==5.4.1" + +{%- if CROSS_BUILD_ENVIRON != "y" %} RUN pip2 install "lxml==4.6.5" RUN pip3 install "lxml==4.6.5" +{%- endif %} # For sonic-platform-common testing RUN pip3 install redis @@ -509,7 +587,11 @@ RUN apt-get install -y vim # Install rsyslog RUN apt-get install -y rsyslog +{%- if CROSS_BUILD_ENVIRON == "y" %} +RUN cd /usr/src/gtest && CXX=$CROSS_CXX CC=$CROSS_CC cmake . && make -C /usr/src/gtest +{%- else %} RUN cd /usr/src/gtest && cmake . && make -C /usr/src/gtest +{%- endif %} RUN mkdir /var/run/sshd EXPOSE 22 @@ -535,7 +617,11 @@ RUN apt-get install -y \ {%- endif %} RUN curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add - RUN add-apt-repository \ +{%- if CROSS_BUILD_ENVIRON == "y" %} + "deb https://download.docker.com/linux/debian \ +{%- else %} "deb [arch={{ CONFIGURED_ARCH }}] https://download.docker.com/linux/debian \ +{%- endif %} $(lsb_release -cs) \ stable" RUN apt-get update @@ -554,6 +640,21 @@ RUN pip3 install git+https://github.com/aristanetworks/swi-tools.git@bead66bf261 RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - RUN apt-get install -y nodejs +{%- if CROSS_BUILD_ENVIRON == "y" %} +RUN apt-get install -y rsync dh-python + +RUN apt-get install -y libelf-dev:$arch libdw-dev:$arch libbz2-dev:$arch liblzo2-dev:$arch libedit-dev:$arch libevent-dev:$arch libopts25-dev:$arch libssl-dev:$arch pps-tools:$arch libpam-cap:$arch libcap-dev:$arch libpam0g-dev:$arch libaudit-dev:$arch libgtk-3-dev:$arch libkrb5-dev:$arch libsystemd-dev:$arch libwrap0-dev:$arch libkrb5-dev:$arch libboost1.67-dev:$arch libboost-dev:$arch libzmq5:$arch libzmq3-dev:$arch libdaemon-dev:$arch libjansson-dev:$arch libmnl-dev:$arch libsensors5:$arch libsensors4-dev:$arch libperl-dev:$arch libmariadb-dev:$arch libmariadb-dev-compat:$arch libpci-dev:$arch libjson-c3:$arch libjson-c-dev:$arch libreadline-dev:$arch librtr-dev:$arch librrd-dev:$arch libnetfilter-conntrack-dev:$arch libnetfilter-conntrack3:$arch libnfnetlink-dev:$arch libnftnl-dev:$arch libldap2-dev:$arch libbind-export-dev:$arch check:$arch libboost-atomic-dev:$arch libboost-test-dev:$arch libglib2.0-dev:$arch qt5-default:$arch libexplain-dev:$arch libc-ares-dev:$arch libip4tc0:$arch libip6tc0:$arch libiptc0:$arch libxtables12:$arch iptables-dev:$arch libatm1-dev:$arch libdb-dev:$arch pkg-config:$arch libnghttp2-14:$arch librtmp1:$arch libssh2-1:$arch libcjson1:$arch libcjson-dev:$arch libcurl3-gnutls:$arch libcurl3-nss-dev:$arch libboost-thread1.67-dev:$arch libboost-thread-dev:$arch libboost-system1.67-dev:$arch libboost-system-dev:$arch libgtest-dev:$arch libgmock-dev:$arch + +RUN apt-get install -y -t buster-backports \ + libbpf-dev:$arch + +RUN apt-get download libgirepository1.0-dev:$arch && dpkg --force-all -i libgirepository1.0-dev* +RUN PATH=/python_virtualenv/env3/bin/:$PATH pip3 install pycairo + +# Install libpcsclite-dev for wpasupplicant using download because regular install removes amd64 python package +RUN apt-get download libpcsclite1:$arch && dpkg --force-all -i libpcsclite1* && apt-get download libpcsclite-dev:$arch && dpkg --force-all -i libpcsclite-dev* +{% endif %} + # Tell azure pipeline to use node.js in the docker LABEL "com.azure.dev.pipelines.agent.handler.node.path"="/usr/bin/node" {% endif -%} diff --git a/sonic-slave-buster/Dockerfile.user.j2 b/sonic-slave-buster/Dockerfile.user.j2 index 8b17e482356c..377bf2c8322e 100644 --- a/sonic-slave-buster/Dockerfile.user.j2 +++ b/sonic-slave-buster/Dockerfile.user.j2 @@ -1,5 +1,5 @@ ARG slave_base_tag_ref=latest -{%- if MULTIARCH_QEMU_ENVIRON != "y" %} +{%- if MULTIARCH_QEMU_ENVIRON != "y" and CROSS_BUILD_ENVIRON != "y" %} FROM sonic-slave-buster:${slave_base_tag_ref} {%- else %} FROM sonic-slave-buster-march-{{ CONFIGURED_ARCH }}:${slave_base_tag_ref} diff --git a/src/bash/Makefile b/src/bash/Makefile index 0d1b3817134d..a72cbc170351 100644 --- a/src/bash/Makefile +++ b/src/bash/Makefile @@ -17,6 +17,9 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : pushd bash-$(BASH_VERSION_MAJOR) # build package +ifeq ($(CROSS_BUILD_ENVIRON), y) + dpkg-buildpackage -us -uc -b -a$(CONFIGURED_ARCH) -Pcross,nocheck -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +else DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -us -uc -b -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) # copy UT code. @@ -30,7 +33,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : # run UT after config.h ready. make -C unittest && make test -C unittest - +endif popd mv $* $(DEST)/ diff --git a/src/ethtool/Makefile b/src/ethtool/Makefile index 779a3b9e40ff..d122b6f4c8bd 100644 --- a/src/ethtool/Makefile +++ b/src/ethtool/Makefile @@ -14,6 +14,8 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : # Build package ifeq ($(MULTIARCH_QEMU_ENVIRON), y) DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +else ifeq ($(CROSS_BUILD_ENVIRON), y) + DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -rfakeroot -b -us -uc -a$(CONFIGURED_ARCH) -Pcross,nocheck -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) else dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) endif diff --git a/src/hiredis/Makefile b/src/hiredis/Makefile index 4935a039e0af..ab257e5e0845 100644 --- a/src/hiredis/Makefile +++ b/src/hiredis/Makefile @@ -14,7 +14,11 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : dpkg-source -x hiredis_$(HIREDIS_VERSION_FULL).dsc pushd hiredis-$(HIREDIS_VERSION) +ifeq ($(CROSS_BUILD_ENVIRON), y) + dpkg-buildpackage -rfakeroot -d -b -us -uc -a$(CONFIGURED_ARCH) -Pcross,nocheck -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +else dpkg-buildpackage -rfakeroot -d -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +endif popd mv $* $(DERIVED_TARGETS) $(DEST)/ diff --git a/src/ifupdown2/Makefile b/src/ifupdown2/Makefile index ed6f6b549992..77008afb9ac6 100644 --- a/src/ifupdown2/Makefile +++ b/src/ifupdown2/Makefile @@ -22,7 +22,11 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : stg import -s ../patch/series # Build source and Debian packages +ifeq ($(CROSS_BUILD_ENVIRON), y) + dpkg-buildpackage -rfakeroot -d -b -us -uc -a$(CONFIGURED_ARCH) -Pcross,nocheck -j$(SONIC_CONFIG_MAKE_JOBS) +else dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +endif popd # Move the newly-built .deb packages to the destination directory diff --git a/src/initramfs-tools/Makefile b/src/initramfs-tools/Makefile index 27832cabca32..4800c1616041 100644 --- a/src/initramfs-tools/Makefile +++ b/src/initramfs-tools/Makefile @@ -19,7 +19,11 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : # Build the package rm -f debian/*.debhelper.log +ifeq ($(CROSS_BUILD_ENVIRON), y) + dpkg-buildpackage -rfakeroot -b -us -uc -a$(CONFIGURED_ARCH) -Pcross,nocheck -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +else dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +endif popd mv $(DERIVED_TARGETS) $* $(DEST)/ diff --git a/src/iproute2/Makefile b/src/iproute2/Makefile index 93c680628acb..fe5cf17a292a 100644 --- a/src/iproute2/Makefile +++ b/src/iproute2/Makefile @@ -17,7 +17,12 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : patch -p1 < ../patch/0001-patch-macsec-xpn-support.patch +ifeq ($(CROSS_BUILD_ENVIRON), y) + patch -p1 < ../patch/cross-compile-changes.patch + dpkg-buildpackage -us -uc -b -a$(CONFIGURED_ARCH) -Pcross,nocheck -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +else dpkg-buildpackage -us -uc -b -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +endif popd mv $* $(DEST)/ diff --git a/src/iproute2/patch/cross-compile-changes.patch b/src/iproute2/patch/cross-compile-changes.patch new file mode 100644 index 000000000000..a38df0630686 --- /dev/null +++ b/src/iproute2/patch/cross-compile-changes.patch @@ -0,0 +1,12 @@ +Index: iproute2-5.10.0/tc/tc_core.c +=================================================================== +--- iproute2-5.10.0.orig/tc/tc_core.c ++++ iproute2-5.10.0/tc/tc_core.c +@@ -20,6 +20,7 @@ + #include + #include + #include ++#include + + #include "utils.h" + #include "tc_core.h" diff --git a/src/iptables/Makefile b/src/iptables/Makefile index 681ef5d2dcc3..07a8fea2265a 100644 --- a/src/iptables/Makefile +++ b/src/iptables/Makefile @@ -38,7 +38,11 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : stg import -s ../patch/series # Build source and Debian packages +ifeq ($(CROSS_BUILD_ENVIRON), y) + dpkg-buildpackage -rfakeroot -b -us -uc -a$(CONFIGURED_ARCH) -Pcross,nocheck -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +else dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +endif popd # Move the newly-built .deb packages to the destination directory diff --git a/src/isc-dhcp/Makefile b/src/isc-dhcp/Makefile index 63e82e5c49aa..c908ddeeed0a 100644 --- a/src/isc-dhcp/Makefile +++ b/src/isc-dhcp/Makefile @@ -23,7 +23,11 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : stg import -s ../patch/series # Build source and Debian packages +ifeq ($(CROSS_BUILD_ENVIRON), y) + dpkg-buildpackage -rfakeroot -b -us -uc -a$(CONFIGURED_ARCH) -Pcross,nocheck -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +else dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +endif popd # Move the newly-built .deb packages to the destination directory diff --git a/src/kdump-tools/Makefile b/src/kdump-tools/Makefile index 6c66c37c0843..aad9eb99ec71 100644 --- a/src/kdump-tools/Makefile +++ b/src/kdump-tools/Makefile @@ -21,7 +21,11 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : stg import -s ../patch/series # Build source and Debian packages +ifeq ($(CROSS_BUILD_ENVIRON), y) + dpkg-buildpackage -rfakeroot -b -us -uc -a$(CONFIGURED_ARCH) -Pcross,nocheck -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +else dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +endif popd # Move the newly-built .deb packages to the destination directory diff --git a/src/kdump-tools/patch/cross-compile-changes.patch b/src/kdump-tools/patch/cross-compile-changes.patch new file mode 100644 index 000000000000..87a8a4b81c44 --- /dev/null +++ b/src/kdump-tools/patch/cross-compile-changes.patch @@ -0,0 +1,14 @@ +Index: kdump-tools-1.6.8.4/debian/rules +=================================================================== +--- kdump-tools-1.6.8.4.orig/debian/rules ++++ kdump-tools-1.6.8.4/debian/rules +@@ -20,6 +20,9 @@ endif + %: + dh $@ + ++override_dh_auto_build: ++ dh_auto_build TARGET=$(CONFIGURED_ARCH) ++ + override_dh_gencontrol: + dh_gencontrol -- $(SUBSTVARS) + diff --git a/src/libnl3/Makefile b/src/libnl3/Makefile index b81f294c30c2..0d48ffc1e1aa 100644 --- a/src/libnl3/Makefile +++ b/src/libnl3/Makefile @@ -25,7 +25,12 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : stg import -s ../patch/series ln -s ../debian debian +ifeq ($(CROSS_BUILD_ENVIRON), y) + dpkg-buildpackage -rfakeroot -b -us -uc -a$(CONFIGURED_ARCH) -Pcross,nocheck -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +else dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +endif + popd mv $(DERIVED_TARGETS) $* $(DEST)/ diff --git a/src/libteam/Makefile b/src/libteam/Makefile index 47f9d1dd21bf..0c98c0ce4899 100644 --- a/src/libteam/Makefile +++ b/src/libteam/Makefile @@ -31,7 +31,11 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : mv tmp/debian libteam/ rm -rf tmp pushd ./libteam +ifeq ($(CROSS_BUILD_ENVIRON), y) + dpkg-buildpackage -rfakeroot -b -us -uc -a$(CONFIGURED_ARCH) -Pcross,nocheck -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +else dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +endif popd mv $(DERIVED_TARGETS) $* $(DEST)/ diff --git a/src/libyang/Makefile b/src/libyang/Makefile index 357908ebc370..53c4d59d1e1a 100644 --- a/src/libyang/Makefile +++ b/src/libyang/Makefile @@ -3,7 +3,7 @@ SHELL = /bin/bash .SHELLFLAGS += -e MAIN_TARGET = $(LIBYANG) -DERIVED_TARGETS = $(LIBYANG_DEV) $(LIBYANG_DBG) $(LIBYANG_PY3) $(LIBYANG_CPP) +DERIVED_TARGETS = $(LIBYANG_DEV) $(LIBYANG_DBGSYM) $(LIBYANG_PY3) $(LIBYANG_CPP) $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : # Obtaining the libyang @@ -14,15 +14,14 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : # Apply patch series stg init stg import -s ../patch/series - - mkdir build - pushd build - cmake .. - make build-deb - - pushd debs - mv $* $(DEST)/ - mv $(DERIVED_TARGETS) $(DEST)/ + +ifeq ($(CROSS_BUILD_ENVIRON), y) + dpkg-buildpackage -rfakeroot -b -us -uc -a$(CONFIGURED_ARCH) -Pcross,nocheck -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +else + dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +endif popd + mv $(DERIVED_TARGETS) $* $(DEST)/ + $(addprefix $(DEST)/, $(DERIVED_TARGETS)): $(DEST)/% : $(DEST)/$(MAIN_TARGET) diff --git a/src/libyang/patch/debian-packaging-files.patch b/src/libyang/patch/debian-packaging-files.patch new file mode 100644 index 000000000000..5370a94aa453 --- /dev/null +++ b/src/libyang/patch/debian-packaging-files.patch @@ -0,0 +1,233 @@ +From 99afc75d62942e1e4a4d576a880c697ecb0bab06 Mon Sep 17 00:00:00 2001 +From: Saikrishna Arcot +Date: Fri, 1 Jul 2022 10:30:48 -0700 +Subject: [PATCH] Add debian packaging files. + +Libyang does have a custom cmake target that can make these files, but +it breaks several things. Building for another architecture doesn't +cleanly work unless you happen to enable language bindings in your +initial CMake call (otherwise, it will use the default C++ compiler +instead of whatever is set in the environment variable). In addition, +objcopy at the end doesn't appear to use the target +architecture-specific version for whatever reason. + +Make things cleaner by just creating the debian files. In these files, +bump up the compat level, remove the hardcoded debug packages (dbgsym +packages are automatically generated), and rely on debhelper to do the +configure/build. + +Signed-off-by: Saikrishna Arcot +--- + debian/changelog | 23 +++++++++++++++++++++ + debian/compat | 1 + + debian/control | 37 ++++++++++++++++++++++++++++++++++ + debian/copyright | 28 +++++++++++++++++++++++++ + debian/libyang-cpp-dev.install | 3 +++ + debian/libyang-cpp.install | 1 + + debian/libyang-dev.install | 3 +++ + debian/libyang.install | 5 +++++ + debian/python3-yang.install | 1 + + debian/rules | 16 +++++++++++++++ + debian/source/format | 1 + + 11 files changed, 119 insertions(+) + create mode 100644 debian/changelog + create mode 100644 debian/compat + create mode 100644 debian/control + create mode 100644 debian/copyright + create mode 100644 debian/libyang-cpp-dev.install + create mode 100644 debian/libyang-cpp.install + create mode 100644 debian/libyang-dev.install + create mode 100644 debian/libyang.install + create mode 100644 debian/python3-yang.install + create mode 100755 debian/rules + create mode 100644 debian/source/format + +diff --git a/debian/changelog b/debian/changelog +new file mode 100644 +index 00000000..421609c7 +--- /dev/null ++++ b/debian/changelog +@@ -0,0 +1,23 @@ ++libyang (1.0.73) stable; urgency=low ++ ++ * VERSION bump to version 1.0.73 (Radek Krejci) ++ ++ * SOVERSION bump to version 1.2.2 (Radek Krejci) ++ ++ * JSON parser CHANGE respect STRICT flag and if not set, ignore unknown data (Radek Krejci) ++ ++ * VERSION bump to version 1.0.72 (Radek Krejci) ++ ++ * SOVERSION bump to version 1.2.1 (Radek Krejci) ++ ++ * schema parsers BUGFIX duplicating iffeature expression data (Radek Krejci) ++ ++ * VERSION bump to version 1.0.71 (Radek Krejci) ++ ++ * SOVERSION bump to version 1.2.0 (Radek Krejci) ++ ++ * schema parsers BUGFIX creating implicit cases when augmenting choice (Radek Krejci) ++ ++ * Merge pull request #891 from opensourcerouting/api_tracing (Michal Vasko) ++ ++ -- sarcot Fri, 1 Jul 2022 16:46:13 +0000 +diff --git a/debian/compat b/debian/compat +new file mode 100644 +index 00000000..f599e28b +--- /dev/null ++++ b/debian/compat +@@ -0,0 +1 @@ ++10 +diff --git a/debian/control b/debian/control +new file mode 100644 +index 00000000..cb182fa4 +--- /dev/null ++++ b/debian/control +@@ -0,0 +1,37 @@ ++Source: libyang ++Maintainer: CESNET ++Priority: extra ++Standards-Version: 3.8.2 ++Build-Depends: debhelper (>= 10) ++Homepage: https://github.com/CESNET/libyang ++ ++Package: libyang ++Depends: libpcre3, ${shlibs:Depends} ++Conflicts: libyang-experimental (= 1.0) ++Section: libs ++Architecture: any ++Description: Libyang is YANG data modelling language parser and toolkit written (and providing API) in C. ++ ++Package: libyang-dev ++Depends: libpcre3-dev, libyang (= ${binary:Version}) ++Section: libdevel ++Architecture: any ++Description: Headers of libyang library. ++ ++Package: libyang-cpp ++Depends: libyang (= ${binary:Version}) ++Section: libs ++Architecture: any ++Description: Bindings of libyang library to C++ language. ++ ++Package: libyang-cpp-dev ++Depends: libpcre3-dev, libyang-cpp (= ${binary:Version}) ++Section: libdevel ++Architecture: any ++Description: Headers of bindings to c++ language libyang library. ++ ++Package: python3-yang ++Depends: libyang (= ${binary:Version}), libyang-cpp (= ${binary:Version}) ++Section: libs ++Architecture: any ++Description: Bindings of libyang library to python3 language. +diff --git a/debian/copyright b/debian/copyright +new file mode 100644 +index 00000000..f7cafac5 +--- /dev/null ++++ b/debian/copyright +@@ -0,0 +1,28 @@ ++Copyright (c) 2015-2016, CESNET ++All rights reserved. ++ ++Redistribution and use in source and binary forms, with or without ++modification, are permitted provided that the following conditions are met: ++ ++* Redistributions of source code must retain the above copyright notice, this ++ list of conditions and the following disclaimer. ++ ++* Redistributions in binary form must reproduce the above copyright notice, ++ this list of conditions and the following disclaimer in the documentation ++ and/or other materials provided with the distribution. ++ ++* Neither the name of libyang nor the names of its ++ contributors may be used to endorse or promote products derived from ++ this software without specific prior written permission. ++ ++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ++AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ++IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE ++FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ++DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ++SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER ++CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, ++OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ++OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ +diff --git a/debian/libyang-cpp-dev.install b/debian/libyang-cpp-dev.install +new file mode 100644 +index 00000000..e56e41ed +--- /dev/null ++++ b/debian/libyang-cpp-dev.install +@@ -0,0 +1,3 @@ ++usr/lib/*/libyang-cpp.so ++usr/include/libyang/*.hpp ++usr/lib/*/pkgconfig/libyang-cpp.pc +diff --git a/debian/libyang-cpp.install b/debian/libyang-cpp.install +new file mode 100644 +index 00000000..2157465b +--- /dev/null ++++ b/debian/libyang-cpp.install +@@ -0,0 +1 @@ ++usr/lib/*/libyang-cpp.so.* +\ No newline at end of file +diff --git a/debian/libyang-dev.install b/debian/libyang-dev.install +new file mode 100644 +index 00000000..bb04ac28 +--- /dev/null ++++ b/debian/libyang-dev.install +@@ -0,0 +1,3 @@ ++usr/lib/*/libyang.so ++usr/lib/*/pkgconfig/libyang.pc ++usr/include/libyang/*.h +diff --git a/debian/libyang.install b/debian/libyang.install +new file mode 100644 +index 00000000..249a5291 +--- /dev/null ++++ b/debian/libyang.install +@@ -0,0 +1,5 @@ ++usr/bin/yanglint ++usr/bin/yangre ++usr/share/man/man1 ++usr/lib/*/libyang.so.* ++usr/lib/*/libyang/* +diff --git a/debian/python3-yang.install b/debian/python3-yang.install +new file mode 100644 +index 00000000..3272cd65 +--- /dev/null ++++ b/debian/python3-yang.install +@@ -0,0 +1 @@ ++usr/lib/python3/dist-packages/* +diff --git a/debian/rules b/debian/rules +new file mode 100755 +index 00000000..9308403e +--- /dev/null ++++ b/debian/rules +@@ -0,0 +1,16 @@ ++#!/usr/bin/make -f ++# -*- makefile -*- ++# Uncomment this to turn on verbose mode. ++export DH_VERBOSE=1 ++ ++%: ++ dh $@ ++ ++override_dh_auto_configure: ++ dh_auto_configure -- -DENABLE_LYD_PRIV=ON -DGEN_LANGUAGE_BINDINGS=ON -DGEN_PYTHON_VERSION=2 ++ ++override_dh_makeshlibs: ++ dh_makeshlibs -Xextensions -Xuser_types ++ ++override_dh_auto_test: ++ ctest --output-on-failure +diff --git a/debian/source/format b/debian/source/format +new file mode 100644 +index 00000000..163aaf8d +--- /dev/null ++++ b/debian/source/format +@@ -0,0 +1 @@ ++3.0 (quilt) +-- +2.25.1 + diff --git a/src/libyang/patch/series b/src/libyang/patch/series index 28352b9628e5..9796e28649c5 100644 --- a/src/libyang/patch/series +++ b/src/libyang/patch/series @@ -2,3 +2,4 @@ libyang.patch libyang_mgmt_framework.patch swig.patch large_file_support_arm32.patch +debian-packaging-files.patch diff --git a/src/libyang1/Makefile b/src/libyang1/Makefile index 834893eb0bbe..a87f03bf638c 100644 --- a/src/libyang1/Makefile +++ b/src/libyang1/Makefile @@ -31,7 +31,11 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : # Enable large file support for 32-bit arch echo 'add_definitions(-D_FILE_OFFSET_BITS=64)' >> CMakeLists.txt +ifeq ($(CROSS_BUILD_ENVIRON), y) + dpkg-buildpackage -rfakeroot -b -us -uc -a$(CONFIGURED_ARCH) -Pcross,nocheck -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +else dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +endif popd # Move the newly-built .deb packages to the destination directory diff --git a/src/libyang2/Makefile b/src/libyang2/Makefile index 621717521972..fab24590a340 100644 --- a/src/libyang2/Makefile +++ b/src/libyang2/Makefile @@ -31,7 +31,12 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : # Enable large file support for 32-bit arch echo 'add_definitions(-D_FILE_OFFSET_BITS=64)' >> CMakeLists.txt +ifeq ($(CROSS_BUILD_ENVIRON), y) + dpkg-buildpackage -rfakeroot -d -b -us -uc -a$(CONFIGURED_ARCH) -Pcross,nocheck -j$(SONIC_CONFIG_MAKE_JOBS) +else dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +endif + popd # Move the newly-built .deb packages to the destination directory diff --git a/src/lldpd/Makefile b/src/lldpd/Makefile index a336f1e989ae..349724d77ec1 100644 --- a/src/lldpd/Makefile +++ b/src/lldpd/Makefile @@ -35,7 +35,11 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : stg import -s ../patch/series # Build source and Debian packages +ifeq ($(CROSS_BUILD_ENVIRON), y) + env "with_netlink_receive_bufsize=1024*1024" CFLAGS="-I $$CROSS_PERL_CORE_PATH" dpkg-buildpackage -rfakeroot -b -us -uc -a$(CONFIGURED_ARCH) -Pcross,nocheck -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +else env "with_netlink_receive_bufsize=1024*1024" dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +endif popd # Move the newly-built .deb packages to the destination directory diff --git a/src/lm-sensors/Makefile b/src/lm-sensors/Makefile index a5aa3ba7d885..fbeee8c2610f 100644 --- a/src/lm-sensors/Makefile +++ b/src/lm-sensors/Makefile @@ -25,7 +25,11 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : stg init stg import -s ../patch/series +ifeq ($(CROSS_BUILD_ENVIRON), y) + PROG_EXTRA=sensord dpkg-buildpackage -us -uc -b -a$(CONFIGURED_ARCH) -Pcross,nocheck -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +else DEB_BUILD_OPTIONS=nocheck PROG_EXTRA=sensord dpkg-buildpackage -us -uc -b -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +endif popd mv $(DERIVED_TARGETS) $* $(DEST)/ diff --git a/src/monit/Makefile b/src/monit/Makefile index 570f30cf60f8..308daac8a2e3 100644 --- a/src/monit/Makefile +++ b/src/monit/Makefile @@ -23,8 +23,16 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : stg init stg import -s ../patch/series +ifeq ($(CROSS_BUILD_ENVIRON), y) + patch -p1 < ../patch/cross-compile-changes.patch +endif + # Build source and Debian packages +ifeq ($(CROSS_BUILD_ENVIRON), y) + dpkg-buildpackage -rfakeroot -b -us -uc --host-arch $(CONFIGURED_ARCH) -Pcross,nocheck -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +else dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +endif popd # Move the newly-built .deb packages to the destination directory diff --git a/src/monit/patch/cross-compile-changes.patch b/src/monit/patch/cross-compile-changes.patch new file mode 100644 index 000000000000..2affa602d48d --- /dev/null +++ b/src/monit/patch/cross-compile-changes.patch @@ -0,0 +1,13 @@ +Index: monit/debian/rules +=================================================================== +--- monit.orig/debian/rules ++++ monit/debian/rules +@@ -4,7 +4,7 @@ + dh $@ --with autoreconf + + override_dh_auto_configure: +- dh_auto_configure -- \ ++ dh_auto_configure -- libmonit_cv_setjmp_available=yes libmonit_cv_vsnprintf_c99_conformant=yes \ + --sysconfdir=/etc/monit + + override_dh_fixperms: diff --git a/src/mpdecimal/Makefile b/src/mpdecimal/Makefile index b7f82ba702e5..dbd0569e15e0 100644 --- a/src/mpdecimal/Makefile +++ b/src/mpdecimal/Makefile @@ -14,7 +14,11 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : dpkg-source -x mpdecimal_$(MPDECIMAL_VERSION_FULL).dsc pushd mpdecimal-$(MPDECIMAL_VERSION) +ifeq ($(CROSS_BUILD_ENVIRON), y) + dpkg-buildpackage -us -uc -b -a$(CONFIGURED_ARCH) -Pcross,nocheck -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +else dpkg-buildpackage -us -uc -b -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +endif popd mv $* $(DERIVED_TARGETS) $(DEST)/ diff --git a/src/ntp/Makefile b/src/ntp/Makefile index 0a821ad6ca52..c0103ba78107 100644 --- a/src/ntp/Makefile +++ b/src/ntp/Makefile @@ -38,8 +38,21 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : # and go into learning mode. sed -i 's/\/usr\/sbin\/ntpd {/\/usr\/sbin\/ntpd flags=(attach_disconnected complain) {/' debian/apparmor-profile +ifeq ($(CROSS_BUILD_ENVIRON), y) + sed -i 's/dh_auto_configure \--/dh_auto_configure -- --with-yielding-select=yes /g' debian/rules + echo ". $(CONFIG_SITE)" > fix.ntp.cross-config.$(CONFIGURED_ARCH) + echo "unset with_openssl_libdir" >> fix.ntp.cross-config.$(CONFIGURED_ARCH) + echo "unset with_openssl_incdir" >> fix.ntp.cross-config.$(CONFIGURED_ARCH) + rm -f cross-config.cache + ln -s /etc/dpkg-cross/cross-config.cache cross-config.cache +endif + # Build source and Debian packages with the symbols +ifeq ($(CROSS_BUILD_ENVIRON), y) + CONFIG_SITE=`pwd`/fix.ntp.cross-config.$(CONFIGURED_ARCH) dpkg-buildpackage -rfakeroot -b -us -uc -a$(CONFIGURED_ARCH) -Pcross,nocheck -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +else dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +endif popd diff --git a/src/openssh/Makefile b/src/openssh/Makefile index 91d4fd52bcf7..ec7942fe7e5e 100644 --- a/src/openssh/Makefile +++ b/src/openssh/Makefile @@ -19,7 +19,13 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : stg import -s ../patch/series # Build package +ifeq ($(CROSS_BUILD_ENVIRON), y) + patch -p1 < ../patch/cross-compile-changes.patch + dpkg-buildpackage -rfakeroot -b -us -uc -a$(CONFIGURED_ARCH) -Pcross,nocheck -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +else + sudo http_proxy=$(http_proxy) apt-get -y build-dep openssh dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +endif popd mv $(DERIVED_TARGETS) $* $(DEST)/ diff --git a/src/openssh/patch/cross-compile-changes.patch b/src/openssh/patch/cross-compile-changes.patch new file mode 100644 index 000000000000..511c8c684386 --- /dev/null +++ b/src/openssh/patch/cross-compile-changes.patch @@ -0,0 +1,13 @@ +Index: openssh-server/debian/rules +=================================================================== +--- openssh-server.orig/debian/rules ++++ openssh-server/debian/rules +@@ -77,7 +77,7 @@ confflags_udeb := $(confflags) + confflags += --with-tcp-wrappers + confflags += --with-pam + confflags += --with-libedit +-confflags += --with-kerberos5=/usr ++confflags += --with-kerberos5-libdir=$(CROSS_PKGS_LIB_PATH) + confflags += --with-ssl-engine + ifeq ($(DEB_HOST_ARCH_OS),linux) + confflags += --with-selinux diff --git a/src/radius/nss/Makefile b/src/radius/nss/Makefile index 09526a04961c..96389ed3cc20 100644 --- a/src/radius/nss/Makefile +++ b/src/radius/nss/Makefile @@ -15,7 +15,11 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : # Apply patch (if any) +ifeq ($(CROSS_BUILD_ENVIRON), y) + dpkg-buildpackage -rfakeroot -b -a$(CONFIGURED_ARCH) -Pcross,nocheck -us -uc +else dpkg-buildpackage -rfakeroot -b -us -uc +endif popd mv $(DERIVED_TARGETS) $* $(DEST)/ diff --git a/src/radius/pam/Makefile b/src/radius/pam/Makefile index 9e10773b9bf9..685516b5f82f 100644 --- a/src/radius/pam/Makefile +++ b/src/radius/pam/Makefile @@ -16,9 +16,14 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : patch -p1 < ../patches/freeradius_configure.patch patch -p1 < ../patches/freeradius_2007-04-06.patch patch -p1 < ../patches/freeradius_libeap_deprecated_openssl_1_0.patch + patch -p1 < ../patches/libltdl_config_sub.patch cp ../patches/config.sub . cp ../patches/config.guess . +ifeq ($(CROSS_BUILD_ENVIRON), y) + ./configure --disable-static --enable-libtool-lock --host=$(CROSS_HOST_TYPE) +else ./configure --disable-static --enable-libtool-lock +endif make popd @@ -31,7 +36,11 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : cp -r ../debian . +ifeq ($(CROSS_BUILD_ENVIRON), y) + dpkg-buildpackage -rfakeroot -b -a$(CONFIGURED_ARCH) -Pcross,nocheck -us -uc -nc +else dpkg-buildpackage -rfakeroot -b -us -uc -nc +endif popd mv $(DERIVED_TARGETS) $* $(DEST)/ diff --git a/src/radius/pam/freeradius/patches/libltdl_config_sub.patch b/src/radius/pam/freeradius/patches/libltdl_config_sub.patch new file mode 100644 index 000000000000..37ad68edb482 --- /dev/null +++ b/src/radius/pam/freeradius/patches/libltdl_config_sub.patch @@ -0,0 +1,20 @@ +diff --git a/libltdl/config.sub b/libltdl/config.sub +index 2851647..63c6366 100755 +--- a/libltdl/config.sub ++++ b/libltdl/config.sub +@@ -241,6 +241,7 @@ case $basic_machine in + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ + | am33_2.0 \ + | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ ++ | aarch64 \ + | bfin \ + | c4x | clipper \ + | d10v | d30v | dlx | dsp16xx \ +@@ -317,6 +318,7 @@ case $basic_machine in + | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ + | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ ++ | aarch64-* \ + | avr-* \ + | bfin-* | bs2000-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ diff --git a/src/redis/Makefile b/src/redis/Makefile index 3a4fe3f4844c..f7014d68a351 100644 --- a/src/redis/Makefile +++ b/src/redis/Makefile @@ -22,7 +22,11 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : pushd redis-$(REDIS_VERSION) export ARCH="" +ifeq ($(CROSS_BUILD_ENVIRON), y) + dpkg-buildpackage -us -uc -b -a$(CONFIGURED_ARCH) -Pcross,nocheck -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +else DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -us -uc -b -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +endif popd mv $(DERIVED_TARGETS) $* $(DEST)/ diff --git a/src/sflow/hsflowd/Makefile b/src/sflow/hsflowd/Makefile index d4312b30c267..35d17783f903 100644 --- a/src/sflow/hsflowd/Makefile +++ b/src/sflow/hsflowd/Makefile @@ -26,7 +26,11 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : chmod u+x debian/rules sed -i -e s/_VERSION_/$(HSFLOWD_VERSION)-$(HSFLOWD_SUBVERSION)/g debian/changelog +ifeq ($(CROSS_BUILD_ENVIRON), y) + dpkg-buildpackage -rfakeroot -b -us -uc -a$(CONFIGURED_ARCH) -Pcross,nocheck -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) --buildinfo-option=-u. --changes-option=-u. +else dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) --buildinfo-option=-u. --changes-option=-u. +endif mv $(DERIVED_TARGET) $* $(DEST)/ popd diff --git a/src/sflow/hsflowd/patch/0002-host_sflow_debian.patch b/src/sflow/hsflowd/patch/0002-host_sflow_debian.patch index 86ebab723351..f1977ccb00b2 100644 --- a/src/sflow/hsflowd/patch/0002-host_sflow_debian.patch +++ b/src/sflow/hsflowd/patch/0002-host_sflow_debian.patch @@ -68,7 +68,7 @@ diff -ruN a/DEBIAN_build/rules b/DEBIAN_build/rules + dpkg-deb --build debian/hsflowd hsflowd_$(HSFLOWD_VERSION)-$(HSFLOWD_SUBVERSION)_$(CONFIGURED_ARCH).deb + +override_dh_auto_build: -+ make sonic-deb FEATURES="SONIC" ++ make sonic-deb FEATURES="SONIC" CC=$(CC) CXX=$(CXX) LD=$(CC) + +override_dh_auto_configure: + diff --git a/src/sflow/psample/Makefile b/src/sflow/psample/Makefile index bbdefde2289b..12981d8ebff3 100644 --- a/src/sflow/psample/Makefile +++ b/src/sflow/psample/Makefile @@ -13,7 +13,11 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : pushd ./libpsample git checkout -b libpsample -f e48fad2 +ifeq ($(CROSS_BUILD_ENVIRON), y) + dpkg-buildpackage -rfakeroot -b -us -uc -a$(CONFIGURED_ARCH) -Pcross,nocheck -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +else dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +endif popd mv $* $(DEST)/ diff --git a/src/sflow/psample/debian/psample.install b/src/sflow/psample/debian/psample.install deleted file mode 100644 index 36d4eac1a85b..000000000000 --- a/src/sflow/psample/debian/psample.install +++ /dev/null @@ -1,4 +0,0 @@ -bin/psample usr/bin -lib/libpsample.so.1.0 lib/x86_64-linux-gnu -lib/libpsample.so.1 lib/x86_64-linux-gnu -lib/libpsample.so lib/x86_64-linux-gnu diff --git a/src/sflow/psample/debian/rules b/src/sflow/psample/debian/rules index 73f484d32581..eb7df4dda5c8 100755 --- a/src/sflow/psample/debian/rules +++ b/src/sflow/psample/debian/rules @@ -4,16 +4,9 @@ %: dh $@ -override_dh_auto_build: - cmake . && make - override_dh_auto_install: + dh_auto_install + rm -r debian/psample/usr/include override_dh_auto_test: -override_dh_auto_clean: - -override_dh_strip: - -override_dh_clean: - diff --git a/src/sflow/sflowtool/Makefile b/src/sflow/sflowtool/Makefile index 5f2ad995a585..ecb0a4bb2903 100644 --- a/src/sflow/sflowtool/Makefile +++ b/src/sflow/sflowtool/Makefile @@ -12,7 +12,11 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : pushd ./sflowtool git checkout -b sflowtool -f 6c2963b +ifeq ($(CROSS_BUILD_ENVIRON), y) + CC=$(CROSS_CC) dpkg-buildpackage -rfakeroot -b -us -uc -a$(CONFIGURED_ARCH) -Pcross,nocheck -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +else dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +endif popd mv $* $(DEST)/ diff --git a/src/snmpd/Makefile b/src/snmpd/Makefile index 35fc1d38ce9f..0445b1ed6bee 100644 --- a/src/snmpd/Makefile +++ b/src/snmpd/Makefile @@ -56,7 +56,11 @@ endif stg init stg import -s ../patch-$(SNMPD_VERSION)/series +ifneq ($(CROSS_BUILD_ENVIRON), y) dpkg-buildpackage -rfakeroot -b -d -us -uc -j1 --admindir $(SONIC_DPKG_ADMINDIR) +else + PYTHONPATH=/usr/lib/python2.7/plat-arm-linux-gnueabihf/ dpkg-buildpackage -rfakeroot -b -d -us -uc -a$(CONFIGURED_ARCH) -Pcross,nocheck -j1 --admindir $(SONIC_DPKG_ADMINDIR) +endif popd mv $(DERIVED_TARGETS) $* $(DEST)/ diff --git a/src/snmpd/patch-5.7.3+dfsg/cross-compile-changes.patch b/src/snmpd/patch-5.7.3+dfsg/cross-compile-changes.patch new file mode 100644 index 000000000000..47db1105a68a --- /dev/null +++ b/src/snmpd/patch-5.7.3+dfsg/cross-compile-changes.patch @@ -0,0 +1,17 @@ +diff --git a/debian/rules b/debian/rules +index 9274c17..d107454 100755 +--- a/debian/rules ++++ b/debian/rules +@@ -5,6 +5,12 @@ export DEB_BUILD_MAINT_OPTIONS := hardening=+all + DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) + DEB_BUILD_ARCH_OS ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH_OS) + ++DEB_BUILD_MULTIARCH ?= $(shell dpkg-architecture -qDEB_BUILD_MULTIARCH) ++ ++ifneq ($(DEB_BUILD_MULTIARCH),$(DEB_HOST_MULTIARCH)) ++export PERL5OPT := -I/usr/lib/$(DEB_HOST_MULTIARCH)/perl/cross-config-$(shell perl -MConfig -e 'print $$Config{version}') ++endif ++ + LIB_VERSION = 30 + PYTHON_VERSION = 1.0a1 + diff --git a/src/snmpd/patch-5.7.3+dfsg/series b/src/snmpd/patch-5.7.3+dfsg/series index 31b251845dea..769b2938d37a 100644 --- a/src/snmpd/patch-5.7.3+dfsg/series +++ b/src/snmpd/patch-5.7.3+dfsg/series @@ -3,3 +3,4 @@ 0006-From-Jiri-Cervenka-snmpd-Fixed-agentx-crashing-and-or-freezing-on-timeout.patch 0007-Linux-VRF-5.7.3-Support.patch 0008-Enable-macro-DEB_BUILD_ARCH_OS-in-order-to-build-ipv.patch +cross-compile-changes.patch diff --git a/src/snmpd/patch-5.9+dfsg/cross-compile-changes.patch b/src/snmpd/patch-5.9+dfsg/cross-compile-changes.patch new file mode 100644 index 000000000000..fedaeaa36bbf --- /dev/null +++ b/src/snmpd/patch-5.9+dfsg/cross-compile-changes.patch @@ -0,0 +1,17 @@ +diff --git a/debian/rules b/debian/rules +index b23b335..b8a79b9 100755 +--- a/debian/rules ++++ b/debian/rules +@@ -5,6 +5,12 @@ export DEB_BUILD_MAINT_OPTIONS := hardening=+all + DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) + DEB_BUILD_ARCH_OS ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH_OS) + ++DEB_BUILD_MULTIARCH ?= $(shell dpkg-architecture -qDEB_BUILD_MULTIARCH) ++ ++ifneq ($(DEB_BUILD_MULTIARCH),$(DEB_HOST_MULTIARCH)) ++export PERL5OPT := -I/usr/lib/$(DEB_HOST_MULTIARCH)/perl/cross-config ++endif ++ + LIB_VERSION = 40 + + MIB_MODULES = smux ucd-snmp/dlmod mibII/mta_sendmail disman/event-mib diff --git a/src/snmpd/patch-5.9+dfsg/series b/src/snmpd/patch-5.9+dfsg/series index cabee4060f9f..81a3ecc3f3e1 100644 --- a/src/snmpd/patch-5.9+dfsg/series +++ b/src/snmpd/patch-5.9+dfsg/series @@ -3,3 +3,4 @@ #0006-From-Jiri-Cervenka-snmpd-Fixed-agentx-crashing-and-or-freezing-on-timeout.patch #0007-Linux-VRF-5.7.3-Support.patch 0008-Enable-macro-DEB_BUILD_ARCH_OS-in-order-to-build-ipv.patch +cross-compile-changes.patch diff --git a/src/socat/Makefile b/src/socat/Makefile index 1d1a0b36695c..8df6c826007b 100644 --- a/src/socat/Makefile +++ b/src/socat/Makefile @@ -18,7 +18,11 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : # Build source and Debian packages pushd socat-1.7.4.1 patch -p0 < ../enable_readline.patch +ifeq ($(CROSS_BUILD_ENVIRON), y) + dpkg-buildpackage -rfakeroot -b -us -uc -a$(CONFIGURED_ARCH) -Pcross,nocheck -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +else DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -rfakeroot -Pnocheck -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +endif 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 2077e98f3e98..7993564ea309 100644 --- a/src/sonic-device-data/Makefile +++ b/src/sonic-device-data/Makefile @@ -26,7 +26,11 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : done; # Build the package +ifeq ($(CROSS_BUILD_ENVIRON), y) + dpkg-buildpackage -rfakeroot -b -us -uc -a$(CONFIGURED_ARCH) -Pcross,nocheck -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +else dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +endif popd diff --git a/src/sonic-frr/Makefile b/src/sonic-frr/Makefile index a2e2c12885db..289c3de6bc74 100644 --- a/src/sonic-frr/Makefile +++ b/src/sonic-frr/Makefile @@ -11,15 +11,26 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : # Build the package pushd ./frr git checkout -b $(FRR_BRANCH) origin/$(FRR_BRANCH) || git checkout $(FRR_BRANCH) +ifeq ($(CROSS_BUILD_ENVIRON), y) + git reset --hard +endif stg branch --create $(STG_BRANCH) $(FRR_TAG) stg import -s ../patch/series - gbp dch --ignore-branch --new-version=$(FRR_VERSION)-sonic-$(FRR_SUBVERSION) --dch-opt="--force-bad-version" --commit --git-author + gbp dch --ignore-branch --new-version=$(FRR_VERSION)-sonic-$(FRR_SUBVERSION) --dch-opt="--force-bad-version" --commit --git-author + +ifeq ($(CROSS_BUILD_ENVIRON), y) + CFLAGS="-I $$CROSS_PERL_CORE_PATH" dpkg-buildpackage -rfakeroot -b -d -us -uc -Ppkg.frr.nortrlib -a$(CONFIGURED_ARCH) -Pcross,nocheck -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +else dpkg-buildpackage -rfakeroot -b -us -uc -Ppkg.frr.nortrlib -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +endif stg undo || true git clean -xfdf git checkout $(FRR_BRANCH) - stg branch --delete $(STG_BRANCH) + stg branch --delete --force $(STG_BRANCH) git rev-parse --short HEAD | xargs git checkout +ifeq ($(CROSS_BUILD_ENVIRON), y) + git reset --hard +endif git checkout master git branch -D $(FRR_BRANCH) popd diff --git a/src/sonic-frr/patch/cross-compile-changes.patch b/src/sonic-frr/patch/cross-compile-changes.patch new file mode 100644 index 000000000000..621a8a66985d --- /dev/null +++ b/src/sonic-frr/patch/cross-compile-changes.patch @@ -0,0 +1,86 @@ +From ece218405fe4c086017f2a4f2b2b4c86b9790db0 Mon Sep 17 00:00:00 2001 +From: Saikrishna Arcot +Date: Wed, 6 Jul 2022 11:28:16 -0700 +Subject: [PATCH] Make changes to support crosscompilation in SONiC + +Signed-off-by: Saikrishna Arcot +--- + debian/frr-doc.info | 1 - + debian/frr.manpages | 16 ---------------- + debian/rules | 17 ++++++++++++----- + 3 files changed, 12 insertions(+), 22 deletions(-) + delete mode 100644 debian/frr-doc.info + delete mode 100644 debian/frr.manpages + +diff --git a/debian/frr-doc.info b/debian/frr-doc.info +deleted file mode 100644 +index a83255a24..000000000 +--- a/debian/frr-doc.info ++++ /dev/null +@@ -1 +0,0 @@ +-doc/user/_build/texinfo/frr.info +diff --git a/debian/frr.manpages b/debian/frr.manpages +deleted file mode 100644 +index 5075fd763..000000000 +--- a/debian/frr.manpages ++++ /dev/null +@@ -1,16 +0,0 @@ +-doc/manpages/_build/man/frr-bgpd.8 +-doc/manpages/_build/man/frr-eigrpd.8 +-doc/manpages/_build/man/frr-fabricd.8 +-doc/manpages/_build/man/frr-isisd.8 +-doc/manpages/_build/man/frr-ldpd.8 +-doc/manpages/_build/man/frr-nhrpd.8 +-doc/manpages/_build/man/frr-ospf6d.8 +-doc/manpages/_build/man/frr-ospfd.8 +-doc/manpages/_build/man/frr-pimd.8 +-doc/manpages/_build/man/frr-ripd.8 +-doc/manpages/_build/man/frr-ripngd.8 +-doc/manpages/_build/man/frr-watchfrr.8 +-doc/manpages/_build/man/frr-zebra.8 +-doc/manpages/_build/man/frr.1 +-doc/manpages/_build/man/mtracebis.8 +-doc/manpages/_build/man/vtysh.1 +diff --git a/debian/rules b/debian/rules +index 0fa9c3a3b..6b005ea5f 100755 +--- a/debian/rules ++++ b/debian/rules +@@ -27,10 +27,17 @@ else + CONF_LUA=--enable-scripting + endif + ++DEB_BUILD_ARCH ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH) ++DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH) ++ ++ifneq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH)) ++export PYTHON=/python_virtualenv/env3/bin/python3 ++else + export PYTHON=python3 ++endif + + %: +- dh $@ ++ dh $@ --builddirectory=build + + override_dh_auto_configure: + $(shell dpkg-buildflags --export=sh); \ +@@ -67,12 +74,12 @@ override_dh_auto_configure: + override_dh_auto_install: + dh_auto_install + +- sed -e '1c #!/usr/bin/python3' -i debian/tmp/usr/lib/frr/frr-reload.py +- sed -e '1c #!/usr/bin/python3' -i debian/tmp/usr/lib/frr/generate_support_bundle.py ++ sed -e '1c #!$(shell which $PYTHON)' -i debian/tmp/usr/lib/frr/frr-reload.py ++ sed -e '1c #!$(shell which $PYTHON)' -i debian/tmp/usr/lib/frr/generate_support_bundle.py + + # let dh_systemd_* and dh_installinit do their thing automatically +- cp tools/frr.service debian/frr.service +- cp tools/frrinit.sh debian/frr.init ++ cp build/tools/frr.service debian/frr.service ++ cp build/tools/frrinit.sh debian/frr.init + -rm -f debian/tmp/usr/lib/frr/frr + + # install config files +-- +2.25.1 + diff --git a/src/sonic-frr/patch/series b/src/sonic-frr/patch/series index 43e407a3c952..3e8438bf6dd5 100644 --- a/src/sonic-frr/patch/series +++ b/src/sonic-frr/patch/series @@ -7,3 +7,4 @@ 0007-Add-support-of-bgp-l3vni-evpn.patch 0008-Link-local-scope-was-not-set-while-binding-socket-for-bgp-ipv6-link-local-neighbors.patch Disable-ipv6-src-address-test-in-pceplib.patch +cross-compile-changes.patch diff --git a/src/swig/Makefile b/src/swig/Makefile index 2d3388eba138..f00d86521806 100644 --- a/src/swig/Makefile +++ b/src/swig/Makefile @@ -13,7 +13,11 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : dpkg-source -x swig_$(SWIG_VERSION).dsc pushd ./swig-$(SWIG_VERSION) +ifeq ($(CROSS_BUILD_ENVIRON), y) + dpkg-buildpackage -rfakeroot -b -us -uc -a$(CONFIGURED_ARCH) -Pcross,nocheck -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +else dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +endif popd mv $(DERIVED_TARGETS) $* $(DEST)/ diff --git a/src/systemd-sonic-generator/Makefile b/src/systemd-sonic-generator/Makefile index 565fcb8030a7..0e6fb9095dce 100644 --- a/src/systemd-sonic-generator/Makefile +++ b/src/systemd-sonic-generator/Makefile @@ -1,17 +1,11 @@ CC=gcc -CFLAGS=-std=gnu99 -D_GNU_SOURCE +CFLAGS += -std=gnu99 -D_GNU_SOURCE -CPP=g++ -CPPFLAGS=-std=c++11 -D_GNU_SOURCE -LFLAGS=-lpthread -lboost_filesystem -lboost_system -lgtest +CXX=g++ +CXXFLAGS += -std=c++11 -D_GNU_SOURCE +LDFLAGS += -lpthread -lboost_filesystem -lboost_system -lgtest BINARY = systemd-sonic-generator -MAIN_TARGET = $(BINARY)_1.0.0_$(CONFIGURED_ARCH).deb - -$(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : - dpkg-buildpackage -us -uc -b -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) - mv ../$(MAIN_TARGET) $(DEST)/ - rm ../$(BINARY)-* ../$(BINARY)_* $(BINARY): systemd-sonic-generator.c rm -f ./systemd-sonic-generator @@ -30,7 +24,7 @@ test: ssg_test ./ssg_test ssg_test: ssg-test.cc systemd-sonic-generator.o - $(CPP) $(CPPFLAGS) -o $@ $^ $(LFLAGS) + $(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) systemd-sonic-generator.o: systemd-sonic-generator.c $(CC) $(CFLAGS) -D_SSG_UNITTEST -o $@ -c $^ diff --git a/src/systemd-sonic-generator/debian/control b/src/systemd-sonic-generator/debian/control index cbf8989e8dfb..1daa9bc0f71d 100644 --- a/src/systemd-sonic-generator/debian/control +++ b/src/systemd-sonic-generator/debian/control @@ -1,6 +1,11 @@ Source: systemd-sonic-generator +Section: devel +Priority: optional +Build-Depends: debhelper (>= 11.0.0) +Standards-Version: 3.9.3 Maintainer: Lawrence Lee Package: systemd-sonic-generator Architecture: any +Depends: ${shlibs:Depends} Description: Systemd generator for SONiC services diff --git a/src/systemd-sonic-generator/debian/rules b/src/systemd-sonic-generator/debian/rules index 212fdda16b1f..9e806e866501 100755 --- a/src/systemd-sonic-generator/debian/rules +++ b/src/systemd-sonic-generator/debian/rules @@ -1,21 +1,9 @@ #!/usr/bin/make -f - -DISTRIBUTION = $(shell sed -n "s/^VERSION_CODENAME=//p" /etc/os-release) -VERSION = 1.0.0 -PACKAGEVERSION = $(VERSION) +export DH_VERBOSE=1 %: dh $@ -override_dh_auto_clean: -override_dh_auto_build: -override_dh_auto_install: - make systemd-sonic-generator - make install DESTDIR=debian/systemd-sonic-generator - -override_dh_gencontrol: - dh_gencontrol -- -v$(PACKAGEVERSION) - override_dh_auto_test: ifneq "$(DEB_HOST_ARCH)" "armhf" make test diff --git a/src/tacacs/audisp/Makefile b/src/tacacs/audisp/Makefile index 6bf80cc67710..ecfd692779b7 100644 --- a/src/tacacs/audisp/Makefile +++ b/src/tacacs/audisp/Makefile @@ -21,10 +21,14 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : # fix aclocal depency issue by run auto.sh ./auto.sh +ifeq ($(CROSS_BUILD_ENVIRON), y) + dpkg-buildpackage -rfakeroot -b -us -uc -a$(CONFIGURED_ARCH) -Pcross,nocheck -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +else # build package dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +endif popd mv $(DERIVED_TARGETS) $* $(DEST)/ -$(addprefix $(DEST)/, $(DERIVED_TARGETS)): $(DEST)/% : $(DEST)/$(MAIN_TARGET) \ No newline at end of file +$(addprefix $(DEST)/, $(DERIVED_TARGETS)): $(DEST)/% : $(DEST)/$(MAIN_TARGET) diff --git a/src/tacacs/nss/Makefile b/src/tacacs/nss/Makefile index 0c8f25f44eac..f958e5625f00 100644 --- a/src/tacacs/nss/Makefile +++ b/src/tacacs/nss/Makefile @@ -15,7 +15,11 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : stg init stg import -s ../patch/series +ifeq ($(CROSS_BUILD_ENVIRON), y) + dpkg-buildpackage -rfakeroot -b -us -uc -a$(CONFIGURED_ARCH) -Pcross,nocheck -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +else dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +endif popd mv $(DERIVED_TARGETS) $* $(DEST)/ diff --git a/src/tacacs/pam/Makefile b/src/tacacs/pam/Makefile index eac4840b2afc..6c213d53dff1 100644 --- a/src/tacacs/pam/Makefile +++ b/src/tacacs/pam/Makefile @@ -25,7 +25,11 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : git apply ../0009-Add-setting-flag-for-authorization-and-accounting.patch git apply ../0010-handle-bad-password-set-by-sshd.patch +ifeq ($(CROSS_BUILD_ENVIRON), y) + dpkg-buildpackage -rfakeroot -b -us -uc -a$(CONFIGURED_ARCH) -Pcross,nocheck -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +else dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +endif popd mv $(DERIVED_TARGETS) $* $(DEST)/ diff --git a/src/thrift/Makefile b/src/thrift/Makefile index 2580002fd457..643cc61faf45 100644 --- a/src/thrift/Makefile +++ b/src/thrift/Makefile @@ -27,7 +27,11 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : # (https://jira.apache.org/jira/browse/THRIFT-3650) patch -p1 < ../patch/0001-Revert-THRIFT-3650-incorrect-union-serialization.patch patch -p1 < ../patch/0002-cve-2017-1000487.patch +ifeq ($(CROSS_BUILD_ENVIRON), y) + CC=$(CROSS_CC) LDSHARED=$(CROSS_CC) CXXFLAGS="-DFORCE_BOOST_SMART_PTR -DSIGNED_RIGHT_SHIFT_IS=1 -DARITHMETIC_RIGHT_SHIFT=1" CFLAGS="-DSIGNED_RIGHT_SHIFT_IS=1 -DARITHMETIC_RIGHT_SHIFT=1" dpkg-buildpackage -d -rfakeroot -b -us -uc -a$(CONFIGURED_ARCH) -Pcross,nocheck -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +else CXXFLAGS="-DFORCE_BOOST_SMART_PTR" DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -d -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +endif popd mv $(DERIVED_TARGETS) $* $(DEST)/ diff --git a/src/wpasupplicant/Makefile b/src/wpasupplicant/Makefile index 8d098bdc8b87..0ae72fef615e 100644 --- a/src/wpasupplicant/Makefile +++ b/src/wpasupplicant/Makefile @@ -8,7 +8,11 @@ DERIVED_TARGETS = wpasupplicant-dbgsym_$(WPASUPPLICANT_VERSION)_$(CONFIGURED_ARC $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : # Clone wpa repo pushd ./sonic-wpa-supplicant +ifeq ($(CROSS_BUILD_ENVIRON), y) + dpkg-buildpackage -rfakeroot -b -us -uc -a$(CONFIGURED_ARCH) -Pcross,nocheck -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +else dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +endif popd # Move the newly-built .deb packages to the destination directory