(not subscribed to rpm-list@, please CC on replies)
Hi all,
Attached are two patches for rpm 4.4.2 (one against the package itself, one against its spec file) which slightly extend rpm's arm support, on which I would love to get some feedback, as I'm not entirely sure whether I Did The Right Thing in every place.
Any comments? Should these patches be discussed on the 'upstream' (i.e. @rpm.org) rpm mailing lists instead?
If they look OK, can they make it into F8? (Please don't apply this version as-is yet, though..)
Thanks in advance for your time.
thanks, Lennert
=== rpm-4.4.2-arm.diff
Index: rpm-4.4.2/Makefile.am
--- rpm-4.4.2.orig/Makefile.am +++ rpm-4.4.2/Makefile.am @@ -165,6 +165,12 @@ install-data-local: $(mkinstalldirs) $(DESTDIR)$(pkgsrcdir)/RPMS/athlon ;;\ alpha*) $(mkinstalldirs) $(DESTDIR)$(pkgsrcdir)/RPMS/alpha ;\ $(mkinstalldirs) $(DESTDIR)$(pkgsrcdir)/RPMS/alphaev6 ;;\
- arm*) $(mkinstalldirs) $(DESTDIR)$(pkgsrcdir)/RPMS/armv3l ;\
$(mkinstalldirs) $(DESTDIR)$(pkgsrcdir)/RPMS/armv4l ;\
$(mkinstalldirs) $(DESTDIR)$(pkgsrcdir)/RPMS/armv4tl ;\
$(mkinstalldirs) $(DESTDIR)$(pkgsrcdir)/RPMS/armv5tel ;\
$(mkinstalldirs) $(DESTDIR)$(pkgsrcdir)/RPMS/armv5tejl ;\
$(mkinstalldirs) $(DESTDIR)$(pkgsrcdir)/RPMS/armv6l ;;\
Add creation of RPMS dirs for the various ARM sub-archs. This seems pretty straightforward.
Index: rpm-4.4.2/config.guess
--- rpm-4.4.2.orig/config.guess +++ rpm-4.4.2/config.guess @@ -809,7 +809,14 @@ EOF echo ${UNAME_MACHINE}-pc-minix exit 0 ;; arm*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- eval $set_cc_for_build
- if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
| grep __ARM_EABI__ >/dev/null
- then
echo ${UNAME_MACHINE}-${VENDOR:-unknown}-linux-gnu
- else
echo ${UNAME_MACHINE}-${VENDOR:-unknown}-linux-gnueabi
- fi
There are two different ABIs for ARM systems, the 'legacy' ABI (old-ABI) and the newer-and-preferred ABI, EABI. EABI is selected by configuring using a target triple ending in *-gnueabi (this is a slightly odd convention, but it's an upstream-imposed convention, and followed by binutils, gcc, glibc, etc.) There isn't an easier way of detecting EABI than to check whether gcc defines __ARM_EABI__, as far as I know.
Index: rpm-4.4.2/configure.ac
--- rpm-4.4.2.orig/configure.ac +++ rpm-4.4.2/configure.ac @@ -1206,6 +1206,9 @@ fi if echo "$build_os" | grep '.*-gnulibc1' > /dev/null ; then build_os=`echo "${build_os}" | sed 's/-gnulibc1$//'` fi +if echo "$build_os" | grep '.*-gnueabi' > /dev/null ; then
- build_os=`echo "${build_os}" | sed 's/-gnueabi$//'`
+fi if echo "$build_os" | grep '.*-gnu' > /dev/null ; then build_os=`echo "${build_os}" | sed 's/-gnu$//'` fi
Strip -gnueabi off the target triple like we do with -gnulibc1 and -gnu.
@@ -1277,10 +1280,7 @@ s390x*) RPMCANONCOLOR=3; RPMCANONARCH=s s390*) RPMCANONCOLOR=0; RPMCANONARCH=s390 ;; powerpc64*|ppc64*) RPMCANONCOLOR=3; RPMCANONARCH=ppc64 ;; powerpc*|ppc*) RPMCANONCOLOR=0; RPMCANONARCH=ppc ;; -armv3l*) RPMCANONCOLOR=0; RPMCANONARCH=armv3l ;; -armv4l*) RPMCANONCOLOR=0; RPMCANONARCH=armv4l ;; -armv4b*) RPMCANONCOLOR=0; RPMCANONARCH=armv4b ;; -arm*) RPMCANONCOLOR=0; RPMCANONARCH="${build_cpu}" ;; +arm*) RPMCANONCOLOR=0; RPMCANONARCH=arm ;;
Make 'arm' the canon arch for all possible sub-archs.
Index: rpm-4.4.2/installplatform
--- rpm-4.4.2.orig/installplatform +++ rpm-4.4.2/installplatform @@ -21,17 +21,18 @@ E_O_F
RPM="./rpm --rcfile $TEMPRC"
-canonarch_sed='s_i.86_i386_;s_pentium[34]_i386_;s_athlon_i386_;s_sparc[^-]*_sparc_;s_alpha[^-]*_alpha_;s_(powerpc|ppc)[^-]*_ppc_' +canonarch_sed='s_i.86_i386_;s_pentium[34]_i386_;s_athlon_i386_;s_sparc[^-]*_sparc_;s_alpha[^-]*_alpha_;s_arm[^-]*_arm_;s_(powerpc|ppc)[^-]*_ppc_'
Idem.
-target_platform="`$RPM --eval '%{?_gnu:%undefine _gnu}%{_target_platform}'|sed -e "$canonarch_sed"`" +target_platform="`$RPM --eval '%{?_gnu:%undefine _gnu}%{?_gnu:%undefine _gnu}%{_target_platform}'|sed -e "$canonarch_sed"`"
(Note that this isn't ARM-specific.) For some reason, it seems necessary to undefine _gnu twice here to really undefine it. (Same thing happens on my x86 boxes.) Not exactly sure what's happening here.
- arm*) SUBSTS='s_arm_armv3l_ s_arm_arm4l_ s_arm_armv4tl_ s_arm_armv5tel_ s_arm_armv5tejl_ s_arm_armv6l_' ;;
Create /u/s/r/RPMS/$foo dirs for all possible sub-archs.
Index: rpm-4.4.2/lib/rpmts.c
--- rpm-4.4.2.orig/lib/rpmts.c +++ rpm-4.4.2/lib/rpmts.c @@ -236,7 +236,7 @@ static int isArch(const char * arch) "m68k", "rs6000", "ia64",
- "armv3l", "armv4b", "armv4l",
- "armv3l", "armv4b", "armv4l", "armv4tl", "armv5tel", "armv5tejl", "armv6l",
Include all sub-archs.
Index: rpm-4.4.2/macros.in
--- rpm-4.4.2.orig/macros.in +++ rpm-4.4.2/macros.in @@ -1260,6 +1260,10 @@ done \ # %ix86 i386 i486 i586 i686 pentium3 pentium4 athlon
+#------------------------------------------------------------------------------ +# arch macro for all supported ARM processors +%arm armv3l armv4b armv4l armv4tl armv5tel armv5tejl armv6l
Add %arm macro so that we can check whether we are building for an ARM box by checking %ifarch %{arm}, to make it easier to add sub-archs without having to patch every single spec file that has some ARM- dependent logic in it.
Index: rpm-4.4.2/rpm.spec.in
--- rpm-4.4.2.orig/rpm.spec.in +++ rpm-4.4.2/rpm.spec.in @@ -331,8 +331,8 @@ exit 0 %ifarch s390 s390x %attr(-, @RPMUSER@, @RPMGROUP@) %{__prefix}/lib/rpm/s390* %endif -%ifarch armv3l armv4l -%attr(-, @RPMUSER@, @RPMGROUP@) %{__prefix}/lib/rpm/armv[34][lb]* +%ifarch %{arm} +%attr(-, @RPMUSER@, @RPMGROUP@) %{__prefix}/lib/rpm/arm*
Check for ARM archs by checking against %{arm}, and just include all arm* dirs in /u/l/rpm in the package.
Index: rpm-4.4.2/rpmrc.in
--- rpm-4.4.2.orig/rpmrc.in +++ rpm-4.4.2/rpmrc.in @@ -61,6 +61,10 @@ optflags: mipsel -O2 -g optflags: armv3l -O2 -g -fsigned-char -fomit-frame-pointer -march=armv3 optflags: armv4b -O2 -g -fsigned-char -fomit-frame-pointer -march=armv4 optflags: armv4l -O2 -g -fsigned-char -fomit-frame-pointer -march=armv4 +optflags: armv4tl -O2 -g -march=armv4t +optflags: armv5tel -O2 -g -march=armv5te +optflags: armv5tejl -O2 -g -march=armv5te +optflags: armv6l -O2 -g -march=armv6
Add optflags for the newer ARM sub-archs.
I don't think we need -fsigned-char anymore, and maybe we should remove it from the other sub-archs as well.
(chars are unsigned on ARM by default, and I think that doing -fsigned-char by default was meant to work around buggy userland software that assumes that chars are always signed. I don't think this should be needed anymore.)
@@ -124,6 +128,9 @@ arch_canon: mipsel: mipsel 11 arch_canon: armv3l: armv3l 12 arch_canon: armv4b: armv4b 12 arch_canon: armv4l: armv4l 12 +arch_canon: armv5tel: armv5tel 12 +arch_canon: armv5tejl: armv5tejl 12 +arch_canon: armv6l: armv6l 12
Add more sub-archs..
=== rpm-4.4.2-spec-arm.diff
Index: SPECS/rpm.spec
--- SPECS.orig/rpm.spec +++ SPECS/rpm.spec @@ -68,6 +68,7 @@ Patch41: rpm-4.4.2-cdiff.patch Patch42: rpm-4.4.2-docflags.patch Patch43: rpm-debugedit-incremental-fix.patch Patch44: rpm-4.4.2-prefer-elf32.patch +Patch45: rpm-4.4.2-arm.diff License: GPL Requires: patch > 2.5 Prereq: shadow-utils @@ -214,6 +215,8 @@ shell-like rules. %patch42 -p1 -b .docflags %patch43 -p1 -b .debugcan2 %patch44 -p1 -b .elfprefer +%patch45 -p1 -b .arm
Add ARM patch.
+perl -pi -e "s/-gnu$/%{_gnu}/" macros.in
This is a hack to make sure that %{_gnu} ends up as -gnueabi on EABI targets. Ideally this should perhaps be hacked into the macros.in -> macros generation step itself. Ideas?
# rebuild configure for ipv6 autoconf @@ -410,8 +413,8 @@ exit 0 %ifarch s390 s390x %attr(-, rpm, rpm) %{__prefix}/lib/rpm/s390* %endif -%ifarch armv3l armv4l -%attr(-, rpm, rpm) %{__prefix}/lib/rpm/armv[34][lb]* +%ifarch %{arm} +%attr(-, rpm, rpm) %{__prefix}/lib/rpm/arm*
Same modification as to rpm.spec.in -- check %{arm} instead of a hardcoded list of sub-archs, and pick up all /u/l/rpm/arm* dirs.
Thanks!