Skip to contentSkip to conversation

rpm: Allow setting platform macro settings externally

PATCH Superseded Zoltán Böszörményi 3 participants 4 messages Jul 31, 2023 – Aug 1, 2023

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH v5 1/1 rpm: Allow setting platform macro settings externally

Feed platform settings to installplatform externally. Based on the patch submitted under https://github.com/rpm-software-management/rpm/pull/2585

Patch against INSTALL was backported for rpm 4.18.1

---
 ...atform-macro-settings-externally-258.patch | 118 ++++++++++++++++++
 meta/recipes-devtools/rpm/rpm_4.18.1.bb       |  20 +++
 2 files changed, 138 insertions(+)
 create mode 100644 meta/recipes-devtools/rpm/files/0001-Allow-setting-platform-macro-settings-externally-258.patch
meta/recipes-devtools/rpm/files/0001-Allow-setting-platform-macro-settings-externally-258.patch new file +118 -0
new file mode 100644
index 0000000000..f4c3630b8c
@@ -0,0 +1,118 @@
+From e58c607dcdb303ff3ba1b22fd23eb20e374b6ed3 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?=
+ <[email protected]>
+Date: Fri, 28 Jul 2023 12:16:56 +0200
+Subject: [PATCH] Allow setting platform macro settings externally (#2585)
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+* Allow setting platform macro settings externally
+
+By default, rpm installs a series of default platforms based on
+the CPU architecture names in subdirectories called
+
+    /usr/lib/platform/<arch>-<os>
+
+This is enough for regular Linux distributions. However, some
+distributions may use more specific platform names that refer to
+particular computer systems, like SBCs or specific CPU tuning when
+compiling.
+
+If the platform subdirectory does not exist in /usr/lib/platform
+then rpmbuild does not work.
+
+Allow creating such custom platform subdirectory with feeding
+the necessary data using external variables: RPM_CUSTOM_ARCH,
+RPM_CUSTOM_ISANAME, RPM_CUSTOM_ISABITS, RPM_CUSTOM_CANONARCH
+and RPM_CUSTOM_CANONCOLOR
+
+Signed-off-by: Zoltán Böszörményi <[email protected]>
+
+---------
+
+Signed-off-by: Zoltán Böszörményi <[email protected]>
+Co-authored-by: Florian Festi <[email protected]>
+---
+ INSTALL         | 37 +++++++++++++++++++++++++++++++++++++
+ installplatform |  9 ++++++++-
+ 2 files changed, 45 insertions(+), 1 deletion(-)
+
+diff --git a/INSTALL b/INSTALL
+index 13d0d8a83..5e035cf6a 100644
+--- a/INSTALL
++++ b/INSTALL
+@@ -148,6 +148,43 @@ and then install with:
+ 
+     make install
+ 
++
++By default, rpm installs a series of default platforms based on the CPU
++architecture names in subdirectories called
++
++    /usr/lib/platform/<arch>-<os>
++
++This is enough for many distributions. However, some distributions
++may use more specific platform names that refer to particular computer
++systems, like SBCs or specific CPU tuning when compiling. Examples of such
++platform names are: "genericx86_64", "intel_skylake_64", "raspberrypi_armv7",
++"raspberrypi_armv8", etc.
++
++If the platform name is put into /etc/rpm/platform, then rpmbuild uses it
++and the only macros file rpmbuild looks for is
++
++    /usr/lib/platform/`cat /etc/rpm/platform`-<os>/macros
++
++If this file does not exist, many rpm macros will not have their expected
++values set and e.g. %configure will fail when trying to run rpmbuild.
++
++To allow creating the macros file for such a custom platform, the shell
++variables listed below must be set. If RPM_CUSTOM_ARCH is not set, the rest
++is ignored.
++
++    export RPM_CUSTOM_ARCH=genericx86_64
++    export RPM_CUSTOM_ISANAME=x86
++    export RPM_CUSTOM_ISABITS=64
++    export RPM_CUSTOM_CANONARCH=x86_64
++    export RPM_CUSTOM_CANONCOLOR=0 # to use /usr/lib for %_libdir
++    export RPM_CUSTOM_CANONCOLOR=3 # to use /usr/lib64 for %_libdir
++
++    make install 
++
++This also creates and installs the new platform file e.g.
++/usr/lib/platform/genericx86_64-linux/macros
++
++
+ Rpm comes with an automated self-test suite. The test-suite relies heavily
+ on fakechroot (https://github.com/dex4er/fakechroot/) and cannot be executed
+ without it. Provided that fakechroot was found during configure,
+diff --git a/installplatform b/installplatform
+index a5ad7c5b8..59f57697b 100755
+--- a/installplatform
++++ b/installplatform
+@@ -11,7 +11,7 @@ VENDOR="${4}"
+ OS="${5}"
+ RPMRC_GNU="${6}"
+ 
+-for ARCH in noarch `grep ^arch_canon $RPMRC | cut -d: -f2`; do
++for ARCH in noarch `grep ^arch_canon $RPMRC | cut -d: -f2` ${RPM_CUSTOM_ARCH:+custom}; do
+   RPMRC_OPTFLAGS="`sed -n 's/^optflags: '$ARCH' //p' $RPMRC`"
+   RPMRC_OPTFLAGS="`echo $RPMRC_OPTFLAGS | sed -e 's, ,\ ,g'`"
+   case $RPMRC_OPTFLAGS in
+@@ -30,6 +30,13 @@ for ARCH in noarch `grep ^arch_canon $RPMRC | cut -d: -f2`; do
+   CANONCOLOR=
+   FILTER=cat
+   case "${ARCH}" in
++    custom)
++	ARCH=$RPM_CUSTOM_ARCH
++	ISANAME=$RPM_CUSTOM_ISANAME
++	ISABITS=$RPM_CUSTOM_ISABITS
++	CANONARCH=$RPM_CUSTOM_CANONARCH
++	CANONCOLOR=$RPM_CUSTOM_CANONCOLOR
++    ;;
+     sparc64*) 
+ 	ISANAME=sparc
+ 	ISABITS=64
+-- 
+2.41.0
+
meta/recipes-devtools/rpm/rpm_4.18.1.bb +20 -0
index 95a9e92f96..0b8ebebb51 100644
@@ -40,6 +40,7 @@ SRC_URI = "git://github.com/rpm-software-management/rpm;branch=rpm-4.18.x;protoc
            file://0001-python-Use-Py_hash_t-instead-of-long-in-hdr_hash.patch \
            file://fix-declaration.patch \
            file://ea3187cfcf9cac87e5bc5e7db79b0338da9e355e.patch \
+           file://0001-Allow-setting-platform-macro-settings-externally-258.patch \
            "
 
 PE = "1"
@@ -128,10 +129,29 @@ do_install:append:class-nativesdk() {
 	EOF
 }
 
+def rpm_isaname(d):
+    import re
+    arch = d.getVar('TARGET_ARCH')
+    if re.match("^i.86$", arch) or re.match("^x86.*64$", arch):
+        return "x86"
+    # Add more platform tweaks for ISANAME as needed
+    return arch
+
+# Add the custom BSP platform "macros" file
+do_install:prepend:class-target() {
+    export RPM_CUSTOM_ARCH="${MACHINE_ARCH}"
+    export RPM_CUSTOM_ISANAME="${@rpm_isaname(d)}"
+    export RPM_CUSTOM_ISABITS="${SITEINFO_BITS}"
+    export RPM_CUSTOM_CANONARCH="${TARGET_ARCH}"
+    # CANONCOLOR determines whether /usr/lib or /usr/lib64 is used for a 64-bit platform
+    export RPM_CUSTOM_CANONCOLOR="${@bb.utils.contains('DISTRO_FEATURES', 'multilib', '3', '0', d)}"
+}
+
 # Rpm's make install creates var/tmp which clashes with base-files packaging
 do_install:append:class-target() {
     rm -rf ${D}/var
 }
+
 do_install:append:class-nativesdk() {
     rm -rf ${D}${SDKPATHNATIVE}/var
     # Ensure find-debuginfo is located correctly inside SDK
Signature · 1 line
2.41.0
#1 lore raw

Hello,

Quoted 43 lines · Zoltan Boszormenyi

Feed platform settings to installplatform externally. Based on the patch submitted under https://github.com/rpm-software-management/rpm/pull/2585

Patch against INSTALL was backported for rpm 4.18.1

---
 ...atform-macro-settings-externally-258.patch | 118 ++++++++++++++++++
 meta/recipes-devtools/rpm/rpm_4.18.1.bb       |  20 +++
 2 files changed, 138 insertions(+)
 create mode 100644 meta/recipes-devtools/rpm/files/0001-Allow-setting-platform-macro-settings-externally-258.patch
meta/recipes-devtools/rpm/files/0001-Allow-setting-platform-macro-settings-externally-258.patch new file +25 -0
new file mode 100644
index 0000000000..f4c3630b8c
@@ -0,0 +1,118 @@
+From e58c607dcdb303ff3ba1b22fd23eb20e374b6ed3 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?=
+ <[email protected]>
+Date: Fri, 28 Jul 2023 12:16:56 +0200
+Subject: [PATCH] Allow setting platform macro settings externally (#2585)
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+* Allow setting platform macro settings externally
+
+By default, rpm installs a series of default platforms based on
+the CPU architecture names in subdirectories called
+
+    /usr/lib/platform/<arch>-<os>
+
+This is enough for regular Linux distributions. However, some
+distributions may use more specific platform names that refer to
+particular computer systems, like SBCs or specific CPU tuning when
+compiling.
+
+If the platform subdirectory does not exist in /usr/lib/platform
+then rpmbuild does not work.
+
+Allow creating such custom platform subdirectory with feeding

meta/recipes-devtools/rpm/files/0001-Allow-setting-platform-macro-settings-externally-258.patch line 35

Quoted 10 lines
meta/recipes-devtools/rpm/files/0001-Allow-setting-platform-macro-settings-externally-258.patch new file +10 -0
+the necessary data using external variables: RPM_CUSTOM_ARCH,
+RPM_CUSTOM_ISANAME, RPM_CUSTOM_ISABITS, RPM_CUSTOM_CANONARCH
+and RPM_CUSTOM_CANONCOLOR
+
+Signed-off-by: Zolt�n B�sz�rm�nyi <[email protected]>
+
+---------
+
+Signed-off-by: Zolt�n B�sz�rm�nyi <[email protected]>
+Co-authored-by: Florian Festi <[email protected]>

This is missing the Upstream-Status tag.

Quoted 138 lines
meta/recipes-devtools/rpm/files/0001-Allow-setting-platform-macro-settings-externally-258.patch new file +83 -0
+---
+ INSTALL         | 37 +++++++++++++++++++++++++++++++++++++
+ installplatform |  9 ++++++++-
+ 2 files changed, 45 insertions(+), 1 deletion(-)
+
+diff --git a/INSTALL b/INSTALL
+index 13d0d8a83..5e035cf6a 100644
+--- a/INSTALL
++++ b/INSTALL
+@@ -148,6 +148,43 @@ and then install with:
+ 
+     make install
+ 
++
++By default, rpm installs a series of default platforms based on the CPU
++architecture names in subdirectories called
++
++    /usr/lib/platform/<arch>-<os>
++
++This is enough for many distributions. However, some distributions
++may use more specific platform names that refer to particular computer
++systems, like SBCs or specific CPU tuning when compiling. Examples of such
++platform names are: "genericx86_64", "intel_skylake_64", "raspberrypi_armv7",
++"raspberrypi_armv8", etc.
++
++If the platform name is put into /etc/rpm/platform, then rpmbuild uses it
++and the only macros file rpmbuild looks for is
++
++    /usr/lib/platform/`cat /etc/rpm/platform`-<os>/macros
++
++If this file does not exist, many rpm macros will not have their expected
++values set and e.g. %configure will fail when trying to run rpmbuild.
++
++To allow creating the macros file for such a custom platform, the shell
++variables listed below must be set. If RPM_CUSTOM_ARCH is not set, the rest
++is ignored.
++
++    export RPM_CUSTOM_ARCH=genericx86_64
++    export RPM_CUSTOM_ISANAME=x86
++    export RPM_CUSTOM_ISABITS=64
++    export RPM_CUSTOM_CANONARCH=x86_64
++    export RPM_CUSTOM_CANONCOLOR=0 # to use /usr/lib for %_libdir
++    export RPM_CUSTOM_CANONCOLOR=3 # to use /usr/lib64 for %_libdir
++
++    make install 
++
++This also creates and installs the new platform file e.g.
++/usr/lib/platform/genericx86_64-linux/macros
++
++
+ Rpm comes with an automated self-test suite. The test-suite relies heavily
+ on fakechroot (https://github.com/dex4er/fakechroot/) and cannot be executed
+ without it. Provided that fakechroot was found during configure,
+diff --git a/installplatform b/installplatform
+index a5ad7c5b8..59f57697b 100755
+--- a/installplatform
++++ b/installplatform
+@@ -11,7 +11,7 @@ VENDOR="${4}"
+ OS="${5}"
+ RPMRC_GNU="${6}"
+ 
+-for ARCH in noarch `grep ^arch_canon $RPMRC | cut -d: -f2`; do
++for ARCH in noarch `grep ^arch_canon $RPMRC | cut -d: -f2` ${RPM_CUSTOM_ARCH:+custom}; do
+   RPMRC_OPTFLAGS="`sed -n 's/^optflags: '$ARCH' //p' $RPMRC`"
+   RPMRC_OPTFLAGS="`echo $RPMRC_OPTFLAGS | sed -e 's, ,\ ,g'`"
+   case $RPMRC_OPTFLAGS in
+@@ -30,6 +30,13 @@ for ARCH in noarch `grep ^arch_canon $RPMRC | cut -d: -f2`; do
+   CANONCOLOR=
+   FILTER=cat
+   case "${ARCH}" in
++    custom)
++	ARCH=$RPM_CUSTOM_ARCH
++	ISANAME=$RPM_CUSTOM_ISANAME
++	ISABITS=$RPM_CUSTOM_ISABITS
++	CANONARCH=$RPM_CUSTOM_CANONARCH
++	CANONCOLOR=$RPM_CUSTOM_CANONCOLOR
++    ;;
+     sparc64*) 
+ 	ISANAME=sparc
+ 	ISABITS=64
+-- 
+2.41.0
+
meta/recipes-devtools/rpm/rpm_4.18.1.bb +20 -0
index 95a9e92f96..0b8ebebb51 100644
@@ -40,6 +40,7 @@ SRC_URI = "git://github.com/rpm-software-management/rpm;branch=rpm-4.18.x;protoc
            file://0001-python-Use-Py_hash_t-instead-of-long-in-hdr_hash.patch \
            file://fix-declaration.patch \
            file://ea3187cfcf9cac87e5bc5e7db79b0338da9e355e.patch \
+           file://0001-Allow-setting-platform-macro-settings-externally-258.patch \
            "
 
 PE = "1"
@@ -128,10 +129,29 @@ do_install:append:class-nativesdk() {
 	EOF
 }
 
+def rpm_isaname(d):
+    import re
+    arch = d.getVar('TARGET_ARCH')
+    if re.match("^i.86$", arch) or re.match("^x86.*64$", arch):
+        return "x86"
+    # Add more platform tweaks for ISANAME as needed
+    return arch
+
+# Add the custom BSP platform "macros" file
+do_install:prepend:class-target() {
+    export RPM_CUSTOM_ARCH="${MACHINE_ARCH}"
+    export RPM_CUSTOM_ISANAME="${@rpm_isaname(d)}"
+    export RPM_CUSTOM_ISABITS="${SITEINFO_BITS}"
+    export RPM_CUSTOM_CANONARCH="${TARGET_ARCH}"
+    # CANONCOLOR determines whether /usr/lib or /usr/lib64 is used for a 64-bit platform
+    export RPM_CUSTOM_CANONCOLOR="${@bb.utils.contains('DISTRO_FEATURES', 'multilib', '3', '0', d)}"
+}
+
 # Rpm's make install creates var/tmp which clashes with base-files packaging
 do_install:append:class-target() {
     rm -rf ${D}/var
 }
+
 do_install:append:class-nativesdk() {
     rm -rf ${D}${SDKPATHNATIVE}/var
     # Ensure find-debuginfo is located correctly inside SDK
Signature · 11 lines
2.41.0



-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#185126): https://lists.openembedded.org/g/openembedded-core/message/185126
Mute This Topic: https://lists.openembedded.org/mt/100457649/3617179
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#2 lore raw

2023. 07. 31. 19:11 keltezéssel, Alexandre Belloni írta:

Quoted 49 lines

Hello,

Quoted 46 lines · Zoltan Boszormenyi

Feed platform settings to installplatform externally. Based on the patch submitted under https://github.com/rpm-software-management/rpm/pull/2585

Patch against INSTALL was backported for rpm 4.18.1

---
  ...atform-macro-settings-externally-258.patch | 118 ++++++++++++++++++
  meta/recipes-devtools/rpm/rpm_4.18.1.bb       |  20 +++
  2 files changed, 138 insertions(+)

create mode 100644 meta/recipes-devtools/rpm/files/0001-Allow-setting-platform-macro-settings-externally-258.patch

meta/recipes-devtools/rpm/files/0001-Allow-setting-platform-macro-settings-externally-258.patch new file +28 -0
new file mode 100644
index 0000000000..f4c3630b8c
@@ -0,0 +1,118 @@
+From e58c607dcdb303ff3ba1b22fd23eb20e374b6ed3 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?=
+ <[email protected]>
+Date: Fri, 28 Jul 2023 12:16:56 +0200
+Subject: [PATCH] Allow setting platform macro settings externally (#2585)
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+* Allow setting platform macro settings externally
+
+By default, rpm installs a series of default platforms based on
+the CPU architecture names in subdirectories called
+
+    /usr/lib/platform/<arch>-<os>
+
+This is enough for regular Linux distributions. However, some
+distributions may use more specific platform names that refer to
+particular computer systems, like SBCs or specific CPU tuning when
+compiling.
+
+If the platform subdirectory does not exist in /usr/lib/platform
+then rpmbuild does not work.
+
+Allow creating such custom platform subdirectory with feeding
+the necessary data using external variables: RPM_CUSTOM_ARCH,
+RPM_CUSTOM_ISANAME, RPM_CUSTOM_ISABITS, RPM_CUSTOM_CANONARCH
+and RPM_CUSTOM_CANONCOLOR
Quoted 8 lines

meta/recipes-devtools/rpm/files/0001-Allow-setting-platform-macro-settings-externally-258.patch line 35

Quoted 7 lines
meta/recipes-devtools/rpm/files/0001-Allow-setting-platform-macro-settings-externally-258.patch new file +7 -0
+
+Signed-off-by: Zoltán Böszörményi <[email protected]>
+
+---------
+
+Signed-off-by: Zoltán Böszörményi <[email protected]>
+Co-authored-by: Florian Festi <[email protected]>

This is missing the Upstream-Status tag.

"Upstream-Status: Backport" ?

#3 lore raw

Zoltan Boszormenyi <[email protected]> escreveu no dia terça, 1/08/2023 à(s) 06:26:

Quoted 65 lines

2023. 07. 31. 19:11 keltezéssel, Alexandre Belloni írta:

Quoted 5 lines

Hello,

Quoted 2 lines · Zoltan Boszormenyi

Feed platform settings to installplatform externally. Based on the patch submitted under

https://github.com/rpm-software-management/rpm/pull/2585

Quoted 9 lines
Quoted 9 lines

Patch against INSTALL was backported for rpm 4.18.1

---
  ...atform-macro-settings-externally-258.patch | 118 ++++++++++++++++++
  meta/recipes-devtools/rpm/rpm_4.18.1.bb       |  20 +++
  2 files changed, 138 insertions(+)

create mode 100644

meta/recipes-devtools/rpm/files/0001-Allow-setting-platform-macro-settings-externally-258.patch

Quoted 2 lines
Quoted 2 lines

diff --git

a/meta/recipes-devtools/rpm/files/0001-Allow-setting-platform-macro-settings-externally-258.patch b/meta/recipes-devtools/rpm/files/0001-Allow-setting-platform-macro-settings-externally-258.patch

Quoted 4 lines
Quoted 4 lines

new file mode 100644
index 0000000000..f4c3630b8c
--- /dev/null
+++

b/meta/recipes-devtools/rpm/files/0001-Allow-setting-platform-macro-settings-externally-258.patch

Quoted 6 lines

meta/recipes-devtools/rpm/files/0001-Allow-setting-platform-macro-settings-externally-258.patch line 5

Quoted 6 lines
meta/recipes-devtools/rpm/files/0001-Allow-setting-platform-macro-settings-externally-258.patch new file +5 -0
@@ -0,0 +1,118 @@
+From e58c607dcdb303ff3ba1b22fd23eb20e374b6ed3 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?=
+ <[email protected]>
+Date: Fri, 28 Jul 2023 12:16:56 +0200
+Subject: [PATCH] Allow setting platform macro settings externally

(#2585)

Quoted 23 lines
Quoted 23 lines
meta/recipes-devtools/rpm/files/0001-Allow-setting-platform-macro-settings-externally-258.patch new file +23 -0
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+* Allow setting platform macro settings externally
+
+By default, rpm installs a series of default platforms based on
+the CPU architecture names in subdirectories called
+
+    /usr/lib/platform/<arch>-<os>
+
+This is enough for regular Linux distributions. However, some
+distributions may use more specific platform names that refer to
+particular computer systems, like SBCs or specific CPU tuning when
+compiling.
+
+If the platform subdirectory does not exist in /usr/lib/platform
+then rpmbuild does not work.
+
+Allow creating such custom platform subdirectory with feeding
+the necessary data using external variables: RPM_CUSTOM_ARCH,
+RPM_CUSTOM_ISANAME, RPM_CUSTOM_ISABITS, RPM_CUSTOM_CANONARCH
+and RPM_CUSTOM_CANONCOLOR
Quoted 8 lines

meta/recipes-devtools/rpm/files/0001-Allow-setting-platform-macro-settings-externally-258.patch line 35

Quoted 7 lines
meta/recipes-devtools/rpm/files/0001-Allow-setting-platform-macro-settings-externally-258.patch new file +7 -0
+
+Signed-off-by: Zoltán Böszörményi <[email protected]>
+
+---------
+
+Signed-off-by: Zoltán Böszörményi <[email protected]>
+Co-authored-by: Florian Festi <[email protected]>

This is missing the Upstream-Status tag.

Quoted 2 lines

"Upstream-Status: Backport" ?

Yes as it is already merged on master.

Upstream-Status: Backport [
https://github.com/rpm-software-management/rpm/commit/fde03ae33d55b160a31a6c54946880dcdf8fd0d6
]

Jose

Quoted 13 lines

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#185191):
https://lists.openembedded.org/g/openembedded-core/message/185191
Mute This Topic: https://lists.openembedded.org/mt/100457649/5052612
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Signature · 3 lines
Best regards,

José Quaresma