From 1c32f4e810e1f63a009975dd3c401fd4bba5ee69 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 9 Aug 2016 14:19:34 +0100 Subject: [PATCH] Add RPM / rpmbuild to the stage3 chroot. --- .gitignore | 2 ++ Makefile | 76 +++++++++++++++++++++++++++++++++++++++- beecrypt-disable-cplusplus.patch | 14 ++++++++ rpm-hacks.patch | 53 ++++++++++++++++++++++++++++ 4 files changed, 144 insertions(+), 1 deletion(-) create mode 100644 beecrypt-disable-cplusplus.patch create mode 100644 rpm-hacks.patch diff --git a/.gitignore b/.gitignore index ba3ce2f..39e4989 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ stamp-* /stage3-disk.img.xz /bash-4.3/ +/beecrypt-4.2.1/ /coreutils-8.25/ /file-5.25/ /gmp-6.1.1/ @@ -27,6 +28,7 @@ stamp-* /popt-1.16/ /riscv-binutils-gdb-riscv-binutils-2.26/ /riscv-gcc-riscv-gcc-6.1.0/ +/rpm-9571218/ /tar-1.29/ /util-linux-2.28/ /zlib-1.2.8/ diff --git a/Makefile b/Makefile index 3a9a1fb..f6447c1 100644 --- a/Makefile +++ b/Makefile @@ -36,7 +36,8 @@ LOCAL_LINUX_GIT_COPY = $(HOME)/d/linux # The root packages (plus their dependencies) that we want to # cross-compile into the stage 3 chroot. -STAGE3_PACKAGES = gcc rpm-build +# beecrypt-devel is required to build RPM. +STAGE3_PACKAGES = gcc rpm-build beecrypt-devel # Versions of cross-compiled packages. NCURSES_VERSION = 6.0-20160730 @@ -55,6 +56,10 @@ ZLIB_VERSION = 1.2.8 # "Cannot use the installed version of file (xx) to cross-compile file yy" FILE_VERSION = 5.25 POPT_VERSION = 1.16 +BEECRYPT_VERSION = 4.2.1 +RPM_COMMIT = 95712183458748ea6cafebac1bdd5daa097d9bee +RPM_SHORT_COMMIT = 9571218 +BDB_VERSION = 4.5.20 all: stage1 stage2 stage3 stage4 @@ -268,6 +273,8 @@ stage3: stage3-kernel/linux-$(KERNEL_VERSION)/vmlinux \ stage3-chroot/usr/lib64/libz.so \ stage3-chroot/usr/bin/file \ stage3-chroot/usr/lib64/libpopt.so \ + stage3-chroot/usr/lib64/libbeecrypt.so \ + stage3-chroot/usr/bin/rpm \ stage3-chroot/init \ stage3-disk.img @@ -597,6 +604,73 @@ popt-$(POPT_VERSION).tar.gz: wget -O $@-t http://rpm5.org/files/popt/popt-$(POPT_VERSION).tar.gz mv $@-t $@ +# Cross-compile beecrypt. +stage3-chroot/usr/lib64/libbeecrypt.so: beecrypt-$(BEECRYPT_VERSION).tar.gz + rm -rf beecrypt-$(BEECRYPT_VERSION) + tar -zxf $^ + cd beecrypt-$(BEECRYPT_VERSION) && patch -p0 < ../beecrypt-disable-cplusplus.patch + cd beecrypt-$(BEECRYPT_VERSION) && autoreconf -i + cd beecrypt-$(BEECRYPT_VERSION) && \ + PATH=$(ROOT)/fixed-gcc:$$PATH \ + LDFLAGS=-L$(ROOT)/stage3-chroot/usr/lib64 \ + ./configure \ + --host=riscv64-unknown-linux-gnu \ + --prefix=/usr --libdir=/usr/lib64 \ + --without-cplusplus \ + --without-java \ + --disable-openmp \ + --disable-static \ + --enable-shared + cd beecrypt-$(BEECRYPT_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make V=1 + cd beecrypt-$(BEECRYPT_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make install DESTDIR=$(ROOT)/stage3-chroot V=1 + chrpath -d stage3-chroot/usr/lib64/libbeecrypt.so.* + rm -f stage3-chroot/usr/lib64/*.la + +beecrypt-$(BEECRYPT_VERSION).tar.gz: + rm -f $@ $@-t + wget -O $@-t http://downloads.sourceforge.net/sourceforge/beecrypt/beecrypt-$(BEECRYPT_VERSION).tar.gz + mv $@-t $@ + +# Cross-compile RPM / rpmbuild. +# We build this from a git commit, with a few hacks to the configure +# script. +stage3-chroot/usr/bin/rpm: rpm-$(RPM_SHORT_COMMIT).tar.gz db-$(BDB_VERSION).tar.gz + rm -rf rpm-$(RPM_SHORT_COMMIT) + tar -zxf rpm-$(RPM_SHORT_COMMIT).tar.gz + tar -zxf db-$(BDB_VERSION).tar.gz -C rpm-$(RPM_SHORT_COMMIT) + cd rpm-$(RPM_SHORT_COMMIT) && ln -s db-$(BDB_VERSION) db + cd rpm-$(RPM_SHORT_COMMIT) && patch -p1 < ../rpm-hacks.patch + cd rpm-$(RPM_SHORT_COMMIT) && autoreconf -i + cd rpm-$(RPM_SHORT_COMMIT) && \ + PATH=$(ROOT)/fixed-gcc:$$PATH \ + LDFLAGS=-L$(ROOT)/stage3-chroot/usr/lib64 \ + ./configure \ + --host=riscv64-unknown-linux-gnu \ + --prefix=/usr --libdir=/usr/lib64 \ + --disable-rpath \ + --without-libarchive \ + --without-lua \ + --with-beecrypt \ + --without-archive \ + --without-external-db \ + --enable-ndb \ + --disable-plugins + cd rpm-$(RPM_SHORT_COMMIT) && \ + sed -i 's|^sys_lib_dlsearch_path_spec="/lib64|sys_lib_dlsearch_path_spec="$(ROOT)/stage3-chroot/usr/lib64 /lib64|g' libtool + cd rpm-$(RPM_SHORT_COMMIT) && PATH=$(ROOT)/fixed-gcc:$$PATH make V=1 + cd rpm-$(RPM_SHORT_COMMIT) && PATH=$(ROOT)/fixed-gcc:$$PATH make install DESTDIR=$(ROOT)/stage3-chroot + rm -f stage3-chroot/usr/lib64/*.la + +rpm-$(RPM_SHORT_COMMIT).tar.gz: + rm -f $@ $@-t + wget -O $@-t 'http://rpm.org/gitweb?p=rpm.git;a=snapshot;h=$(RPM_COMMIT);sf=tgz' + mv $@-t $@ + +db-$(BDB_VERSION).tar.gz: + rm -f $@ $@-t + wget -O $@-t http://download.oracle.com/berkeley-db/db-$(BDB_VERSION).tar.gz + mv $@-t $@ + # Create an /init script. stage3-chroot/init: init.sh install -m 0755 $^ $@ diff --git a/beecrypt-disable-cplusplus.patch b/beecrypt-disable-cplusplus.patch new file mode 100644 index 0000000..d32958b --- /dev/null +++ b/beecrypt-disable-cplusplus.patch @@ -0,0 +1,14 @@ +The act of linking to any C++ file causes libbeecrypt to be linked to +libstdc++ etc. We don't need any of that so kill it. + +--- Makefile.am~ 2009-07-08 19:56:18.000000000 +0100 ++++ Makefile.am 2016-08-09 15:31:40.039891644 +0100 +@@ -62,7 +62,7 @@ + + lib_LTLIBRARIES = libbeecrypt.la + +-libbeecrypt_la_SOURCES = aes.c base64.c beecrypt.c blockmode.c blockpad.c blowfish.c dhies.c dldp.c dlkp.c dlpk.c dlsvdp-dh.c dsa.c elgamal.c endianness.c entropy.c fips186.c hmac.c hmacmd5.c hmacsha1.c hmacsha224.c hmacsha256.c md4.c md5.c hmacsha384.c hmacsha512.c memchunk.c mp.c mpbarrett.c mpnumber.c mpprime.c mtprng.c pkcs1.c pkcs12.c ripemd128.c ripemd160.c ripemd256.c ripemd320.c rsa.c rsakp.c rsapk.c sha1.c sha224.c sha256.c sha384.c sha512.c sha2k32.c sha2k64.c timestamp.c cppglue.cxx ++libbeecrypt_la_SOURCES = aes.c base64.c beecrypt.c blockmode.c blockpad.c blowfish.c dhies.c dldp.c dlkp.c dlpk.c dlsvdp-dh.c dsa.c elgamal.c endianness.c entropy.c fips186.c hmac.c hmacmd5.c hmacsha1.c hmacsha224.c hmacsha256.c md4.c md5.c hmacsha384.c hmacsha512.c memchunk.c mp.c mpbarrett.c mpnumber.c mpprime.c mtprng.c pkcs1.c pkcs12.c ripemd128.c ripemd160.c ripemd256.c ripemd320.c rsa.c rsakp.c rsapk.c sha1.c sha224.c sha256.c sha384.c sha512.c sha2k32.c sha2k64.c timestamp.c + libbeecrypt_la_DEPENDENCIES = $(BEECRYPT_OBJECTS) + libbeecrypt_la_LIBADD = blowfishopt.lo mpopt.lo sha1opt.lo $(OPENMP_LIBS) + libbeecrypt_la_LDFLAGS = -no-undefined -version-info $(LIBBEECRYPT_LT_CURRENT):$(LIBBEECRYPT_LT_REVISION):$(LIBBEECRYPT_LT_AGE) diff --git a/rpm-hacks.patch b/rpm-hacks.patch new file mode 100644 index 0000000..d4921d2 --- /dev/null +++ b/rpm-hacks.patch @@ -0,0 +1,53 @@ +diff --git a/configure.ac b/configure.ac +index e2d5ec3..3f94742 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -309,6 +309,8 @@ AC_SUBST(WITH_NSS_LIB) + WITH_MAGIC_INCLUDE= + WITH_MAGIC_LIB= + ++old_LIBS="$LIBS" ++LIBS="-lz" + AC_CHECK_HEADER([magic.h], [ + AC_CHECK_LIB(magic, magic_open, [ + WITH_MAGIC_INCLUDE= +@@ -319,6 +321,7 @@ AC_CHECK_HEADER([magic.h], [ + ],[ + AC_MSG_ERROR([missing required header magic.h]) + ]) ++LIBS="$old_LIBS" + + AC_SUBST(WITH_MAGIC_INCLUDE) + AC_SUBST(WITH_MAGIC_LIB) +@@ -369,18 +372,19 @@ AM_CONDITIONAL(WITH_ARCHIVE,[test "$with_archive" = yes]) + + #================= + # Check for elfutils libdw library with dwelf_elf_gnu_build_id. +-AS_IF([test "$WITH_LIBELF" = yes],[ +- AC_CHECK_HEADERS([elfutils/libdwelf.h],[ +- AC_CHECK_LIB(dw, dwelf_elf_gnu_build_id, [ +- AC_DEFINE(HAVE_LIBDW, 1, +- [Define to 1 if you have elfutils libdw library]) +- WITH_LIBDW_LIB="-ldw" +- WITH_LIBDW=yes +- ]) +- ]) +- AC_SUBST(WITH_LIBDW_LIB) +- AM_CONDITIONAL(LIBDW,[test "$WITH_LIBDW" = yes]) +-]) ++dnl AS_IF([test "$WITH_LIBELF" = yes],[ ++dnl AC_CHECK_HEADERS([elfutils/libdwelf.h],[ ++dnl AC_CHECK_LIB(dw, dwelf_elf_gnu_build_id, [ ++dnl AC_DEFINE(HAVE_LIBDW, 1, ++dnl [Define to 1 if you have elfutils libdw library]) ++dnl WITH_LIBDW_LIB="-ldw" ++dnl WITH_LIBDW=yes ++dnl ]) ++dnl ]) ++dnl AC_SUBST(WITH_LIBDW_LIB) ++dnl AM_CONDITIONAL(LIBDW,[test "$WITH_LIBDW" = yes]) ++dnl ]) ++AM_CONDITIONAL(LIBDW,[false]) + + #================= + # Process --with/without-external-db -- 1.8.3.1