diff --git a/backport-pylibfdt-libfdt.i-fix-backwards-compatibility-of-return-values.patch b/backport-pylibfdt-libfdt.i-fix-backwards-compatibility-of-return-values.patch new file mode 100644 index 0000000000000000000000000000000000000000..48317b826358b084ff51eb6a2258ebbe38ece9b7 --- /dev/null +++ b/backport-pylibfdt-libfdt.i-fix-backwards-compatibility-of-return-values.patch @@ -0,0 +1,88 @@ +From 9a969f3b70b07bbf1c9df44a38d7f8d1d3a6e2a5 Mon Sep 17 00:00:00 2001 +From: Brandon Maier +Date: Sun, 24 Nov 2024 15:48:04 -0600 +Subject: pylibfdt/libfdt.i: fix backwards compatibility of return values + +When our Python functions wrap `fdt_getprop()` they return a list +containing `[*data, length]`. + +In SWIG v4.2 and earlier SWIG would discard `*data` if it is NULL/None. +Causing the return value to just be `length`. + +But starting in SWIG v4.3 it no longer discards `*data`. So the return +value is now `[None, length]`. + +Handle this compatibility issue in libfdt.i by checking if the return +value looks like the older 4.2 return value, and casting it to the newer +style. + +See https://github.com/swig/swig/pull/2907 + +Signed-off-by: Brandon Maier +Signed-off-by: David Gibson +--- + pylibfdt/libfdt.i | 25 ++++++++++++++----------- + 1 file changed, 14 insertions(+), 11 deletions(-) + +diff --git a/pylibfdt/libfdt.i b/pylibfdt/libfdt.i +index 9f5b6a9..bb9985c 100644 +--- a/pylibfdt/libfdt.i ++++ b/pylibfdt/libfdt.i +@@ -114,11 +114,14 @@ def check_err_null(val, quiet=()): + FdtException if val indicates an error was reported and the error + is not in @quiet. + """ +- # Normally a list is returned which contains the data and its length. +- # If we get just an integer error code, it means the function failed. ++ # Compatibility for SWIG v4.2 and earlier. SWIG 4.2 would drop the first ++ # item from the list if it was None, returning only the second item. + if not isinstance(val, list): +- if -val not in quiet: +- raise FdtException(val) ++ val = [None, val] ++ ++ if val[0] is None: ++ if -val[1] not in quiet: ++ raise FdtException(val[1]) + return val + + class FdtRo(object): +@@ -395,8 +398,8 @@ class FdtRo(object): + """ + pdata = check_err_null( + fdt_get_property_by_offset(self._fdt, prop_offset), quiet) +- if isinstance(pdata, (int)): +- return pdata ++ if pdata[0] is None: ++ return pdata[1] + return Property(pdata[0], pdata[1]) + + def getprop(self, nodeoffset, prop_name, quiet=()): +@@ -417,8 +420,8 @@ class FdtRo(object): + """ + pdata = check_err_null(fdt_getprop(self._fdt, nodeoffset, prop_name), + quiet) +- if isinstance(pdata, (int)): +- return pdata ++ if pdata[0] is None: ++ return pdata[1] + return Property(prop_name, bytearray(pdata[0])) + + def hasprop(self, nodeoffset, prop_name, quiet=()): +@@ -444,10 +447,10 @@ class FdtRo(object): + """ + pdata = check_err_null(fdt_getprop(self._fdt, nodeoffset, prop_name), + quiet + (NOTFOUND,)) +- if isinstance(pdata, (int)): +- if pdata == -NOTFOUND: ++ if pdata[0] is None: ++ if pdata[1] == -NOTFOUND: + return False +- return pdata ++ return pdata[1] + return True + + def get_phandle(self, nodeoffset): +-- +cgit 1.2.3-korg + diff --git a/dtc-1.7.0.tar.xz b/dtc-1.7.0.tar.xz deleted file mode 100644 index c974b08e6bdbff54f5ae4b3452eb112b875cae8e..0000000000000000000000000000000000000000 Binary files a/dtc-1.7.0.tar.xz and /dev/null differ diff --git a/dtc-1.7.2.tar.xz b/dtc-1.7.2.tar.xz new file mode 100644 index 0000000000000000000000000000000000000000..2fc0b01c91d6960b6a53754a118435a67f30e813 Binary files /dev/null and b/dtc-1.7.2.tar.xz differ diff --git a/dtc.spec b/dtc.spec index 28f7ef949be63df89e39fac6dc949612a4e2be82..956a56808891d3f9d2d3419627e625cafc7a9a57 100644 --- a/dtc.spec +++ b/dtc.spec @@ -1,24 +1,17 @@ -%define _wrong_version_format_terminate_build 0 - Name: dtc -Version: 1.7.0 -Release: 4 +Version: 1.7.2 +Release: 3 Summary: Device tree compiler -License: GPLv2+ +License: GPL-2.0-or-later URL: https://devicetree.org/ Source0: https://www.kernel.org/pub/software/utils/%{name}/%{name}-%{version}.tar.xz - +Patch6001: backport-pylibfdt-libfdt.i-fix-backwards-compatibility-of-return-values.patch BuildRequires: gcc make flex bison swig -BuildRequires: python3-devel python3-setuptools python3-setuptools_scm python3-pip python3-wheel -Provides: libfdt -Obsoletes: libfdt - -Patch1: openEuler-add-secure-compile-option-in-Makefile.patch -Patch2: remove-ldflags-in-cflags.patch - -%ifarch ppc64le -Patch3: fix-secure-compile-option-error-in-Makefile.patch -%endif +BuildRequires: meson >= 0.57.0 +BuildRequires: pkgconfig(yaml-0.1) >= 0.2.3 +BuildRequires: python3-devel python3-setuptools python3-setuptools_scm python3-pip python3-wheel +Provides: libfdt = %{version}-%{release} +Obsoletes: libfdt < %{version}-%{release} %description The devicetree is a data structure for describing hardware. Rather than hard coding @@ -31,8 +24,10 @@ Tree (FDT) form. %package devel Summary: Development headers for device tree library Requires: libfdt = %{version}-%{release} -Provides: libfdt-static libfdt-devel -Obsoletes: libfdt-static libfdt-devel +Provides: libfdt-static = %{version}-%{release} +Provides: libfdt-devel = %{version}-%{release} +Obsoletes: libfdt-static < %{version}-%{release} +Obsoletes: libfdt-devel < %{version}-%{release} %description devel This package provides development files for dtc. @@ -52,42 +47,27 @@ This package provides python3 bindings for libfdt %build export SETUPTOOLS_SCM_PRETEND_VERSION=%{version} -%if "%toolchain" == "clang" - CFLAGS="$CFLAGS -Wno-error=cast-qual -Wno-error=missing-prototypes -Wno-error=unused-command-line-argument" -%endif -%make_build - +%meson -Dvalgrind=disabled +%meson_build %install export SETUPTOOLS_SCM_PRETEND_VERSION=%{version} -%if "%toolchain" == "clang" - CFLAGS="$CFLAGS -Wno-error=cast-qual -Wno-error=missing-prototypes -Wno-error=unused-command-line-argument" -%endif -make install DESTDIR=$RPM_BUILD_ROOT PREFIX=$RPM_BUILD_ROOT/usr \ - LIBDIR=%{_libdir} BINDIR=%{_bindir} INCLUDEDIR=%{_includedir} V=1 +%meson_install %check export SETUPTOOLS_SCM_PRETEND_VERSION=%{version} -%make_build check - -%pre - -%preun - -%post - -%postun +%meson_test %files %license GPL README.license %{_bindir}/* -%{_libdir}/libfdt-%{version}.so %{_libdir}/libfdt.so.* %files devel %{_libdir}/libfdt.so %{_includedir}/* %{_libdir}/libfdt.a +%{_libdir}/pkgconfig/*.pc %files -n python3-libfdt %{python3_sitearch}/* @@ -96,6 +76,10 @@ export SETUPTOOLS_SCM_PRETEND_VERSION=%{version} %doc Documentation/manual.txt %changelog +* Thu Aug 28 2025 Funda Wang - 1.7.2-3 +- build with meson +- update to 1.7.2 + * Mon Aug 25 2025 wangjiang - 1.7.0-4 - fix changelog diff --git a/dtc.yaml b/dtc.yaml index 410836efb4084f629f57e4e3fb34ef82606e251d..098d9f14afd2fc02fcf607dd8ec9e138d052c1e7 100644 --- a/dtc.yaml +++ b/dtc.yaml @@ -1,4 +1,4 @@ version_control: git src_repo: https://git.kernel.org/pub/scm/utils/dtc/dtc.git tag_prefix: ^v -seperator: "." +separator: "." diff --git a/fix-secure-compile-option-error-in-Makefile.patch b/fix-secure-compile-option-error-in-Makefile.patch deleted file mode 100644 index 7a093defa03ee4b5294778fd0405a4980fef3369..0000000000000000000000000000000000000000 --- a/fix-secure-compile-option-error-in-Makefile.patch +++ /dev/null @@ -1,29 +0,0 @@ -From de1f376fd21c7a8f46d67597fca57cfd2be66cd8 Mon Sep 17 00:00:00 2001 -From: Yingjun Ni -Date: Thu, 18 Jul 2024 10:40:34 +0800 -Subject: [PATCH] Fix secure compile option error in Makefile. -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -dtc rpm包会生成dtc bin和libfdt.so,-fPIE不作用于libfdt.so,其他应用(如qemu)调用libfdt.so时会出现段错误,使用-fPIC代替-fPIE。 ---- - Makefile | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/Makefile b/Makefile -index 5ef6edd..d2124da 100644 ---- a/Makefile -+++ b/Makefile -@@ -20,7 +20,7 @@ CONFIG_LOCALVERSION = - # See libfdt_internal.h for details - ASSUME_MASK ?= 0 - --EXTRA_CFLAGS += -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fPIE -+EXTRA_CFLAGS += -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fPIC - LDFLAGS += -Wl,-z,now -pie - CPPFLAGS = -I libfdt -I . -DFDT_ASSUME_MASK=$(ASSUME_MASK) - WARNINGS = -Wall -Wpointer-arith -Wcast-qual -Wnested-externs -Wsign-compare \ --- -2.43.0 - diff --git a/openEuler-add-secure-compile-option-in-Makefile.patch b/openEuler-add-secure-compile-option-in-Makefile.patch deleted file mode 100644 index 8806902151aba075c12334b76289ecc2bd3f0e09..0000000000000000000000000000000000000000 --- a/openEuler-add-secure-compile-option-in-Makefile.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 1c3f9fea2f808ae9eb481bc344ff589b42a106a7 Mon Sep 17 00:00:00 2001 -From: Yangyang Shen -Date: Sat, 20 Mar 2021 16:40:13 +0800 -Subject: [PATCH] openEuler add secure compile option in Makefile - ---- - Makefile | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/Makefile b/Makefile -index f02aa19..a37a2db 100644 ---- a/Makefile -+++ b/Makefile -@@ -20,6 +20,8 @@ CONFIG_LOCALVERSION = - # See libfdt_internal.h for details - ASSUME_MASK ?= 0 - -+EXTRA_CFLAGS += -D_FORTIFY_SOURCE=2 -fstack-protector-strong -Wl,-z,now -fPIE -+LDFLAGS += -Wl,-z,now -pie - CPPFLAGS = -I libfdt -I . -DFDT_ASSUME_MASK=$(ASSUME_MASK) - WARNINGS = -Wall -Wpointer-arith -Wcast-qual -Wnested-externs -Wsign-compare \ - -Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls -Wshadow --- -2.23.0 - diff --git a/remove-ldflags-in-cflags.patch b/remove-ldflags-in-cflags.patch deleted file mode 100644 index d5baa1967f8442fef1fb2cd60f85962aa4321fe2..0000000000000000000000000000000000000000 --- a/remove-ldflags-in-cflags.patch +++ /dev/null @@ -1,19 +0,0 @@ -diff -up dtc-1.7.0/Makefile.orig2 dtc-1.7.0/Makefile ---- dtc-1.7.0/Makefile.orig2 2023-04-21 18:28:46.693701292 +0800 -+++ dtc-1.7.0/Makefile 2023-04-21 18:28:58.425735633 +0800 -@@ -20,12 +20,12 @@ CONFIG_LOCALVERSION = - # See libfdt_internal.h for details - ASSUME_MASK ?= 0 - --EXTRA_CFLAGS += -D_FORTIFY_SOURCE=2 -fstack-protector-strong -Wl,-z,now -fPIE -+EXTRA_CFLAGS += -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fPIE - LDFLAGS += -Wl,-z,now -pie - CPPFLAGS = -I libfdt -I . -DFDT_ASSUME_MASK=$(ASSUME_MASK) - WARNINGS = -Wall -Wpointer-arith -Wcast-qual -Wnested-externs -Wsign-compare \ - -Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls -Wshadow --CFLAGS = -g -Os $(SHAREDLIB_CFLAGS) -Werror $(WARNINGS) $(EXTRA_CFLAGS) -+CFLAGS += -g -Os $(SHAREDLIB_CFLAGS) -Werror $(WARNINGS) $(EXTRA_CFLAGS) - - BISON = bison - LEX = flex -