From e3cb2175d54fe984374898e878aa208685f31b4b Mon Sep 17 00:00:00 2001 From: Yijing Yan Date: Mon, 15 Jun 2026 12:34:15 +1000 Subject: [PATCH] use locally built scapy for p4lang Signed-off-by: Yijing Yan --- rules/p4lang.mk | 1 + sonic-slave-trixie/Dockerfile.j2 | 1 - src/p4lang/Makefile | 1 + .../remove-scapy-from-debian-dependency.patch | 26 +++++++++++++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/p4lang/p4lang-p4c.patch/remove-scapy-from-debian-dependency.patch diff --git a/rules/p4lang.mk b/rules/p4lang.mk index 471d871307e..17dfe7c35f2 100644 --- a/rules/p4lang.mk +++ b/rules/p4lang.mk @@ -38,5 +38,6 @@ export P4LANG_P4C_VERSION_FULL P4LANG_P4C = p4lang-p4c_$(P4LANG_P4C_VERSION_FULL)_$(CONFIGURED_ARCH).deb $(P4LANG_P4C)_SRC_PATH = $($(P4LANG_PI)_SRC_PATH) $(P4LANG_P4C)_DEPENDS = $(P4LANG_BMV2) +$(P4LANG_P4C)_WHEEL_DEPENDS = $(SCAPY) $(P4LANG_P4C)_RDEPENDS = $(P4LANG_BMV2) SONIC_MAKE_DEBS += $(P4LANG_P4C) diff --git a/sonic-slave-trixie/Dockerfile.j2 b/sonic-slave-trixie/Dockerfile.j2 index 72f49705ec2..e55d746446b 100644 --- a/sonic-slave-trixie/Dockerfile.j2 +++ b/sonic-slave-trixie/Dockerfile.j2 @@ -535,7 +535,6 @@ RUN eatmydata apt-get install -y \ net-tools \ python3-pyroute2 \ python3-ply \ - python3-scapy \ python3-thrift {%- endif %} diff --git a/src/p4lang/Makefile b/src/p4lang/Makefile index 2e5173745bb..d9dd8da3f5d 100644 --- a/src/p4lang/Makefile +++ b/src/p4lang/Makefile @@ -47,6 +47,7 @@ $(addprefix $(DEST)/, $(P4LANG_P4C_TARGET)): $(DEST)/% : patch -p1 -i ../p4lang-p4c.patch/fix-build-for-boost-1.83.patch patch -p1 -i ../p4lang-p4c.patch/update-thrift-dependency.patch patch -p1 -i ../p4lang-p4c.patch/remove-protobuf-from-debian-dependency.patch + patch -p1 -i ../p4lang-p4c.patch/remove-scapy-from-debian-dependency.patch 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 diff --git a/src/p4lang/p4lang-p4c.patch/remove-scapy-from-debian-dependency.patch b/src/p4lang/p4lang-p4c.patch/remove-scapy-from-debian-dependency.patch new file mode 100644 index 00000000000..b32a255dd94 --- /dev/null +++ b/src/p4lang/p4lang-p4c.patch/remove-scapy-from-debian-dependency.patch @@ -0,0 +1,26 @@ +Don't depend on Debian's python3-scapy. SONiC builds scapy locally as a +Python wheel and installs it with pip, so the distro python3-scapy package +is not present in the build slave. Remove it from both Build-Depends (so +dpkg-checkbuilddeps passes) and Depends (so installing the built deb into +the slave to satisfy downstream build dependencies does not fail). This +mirrors how python3-protobuf/python3-grpcio are already handled. Runtime +containers that ship p4lang-p4c (e.g. docker-ptf) install scapy on their +own, so dropping the runtime dependency is safe. +Index: p4lang-p4c-1.2.4.2/debian/control +=================================================================== +--- p4lang-p4c-1.2.4.2.orig/debian/control ++++ p4lang-p4c-1.2.4.2/debian/control +@@ -25,6 +25,5 @@ Build-Depends: + python3-all, + python3-pyroute2, + python3-ply, +- python3-scapy, + python3-setuptools, + python3-thrift, +@@ -64,6 +63,5 @@ Depends: + net-tools, + python3-pyroute2, + python3-ply, +- python3-scapy, + python3-setuptools, + python3-thrift, \ No newline at end of file