Packages requiring nonstandard rpmbuild Makefile

bind
bind:
	## jsoncpp-devel (EPEL) conflicts with build
	-sudo rpm -ev jsoncpp-devel
	:
	## need PKCS11, else et al will be orphand
	./rpmbuild --target=i586 -v -bb \
	-D 'dist .el8' \
	--with PKCS11 --without SDB \
	--without UNITTEST --without GEOIP2 \
	SPECS/$@.spec 2>&1 | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done | \
	tee log

src:
	./rpmbuild --target=i586 -v -bs \
	-D 'dist .el8' \
	--with PKCS11 --without SDB \
	--without UNITTEST --without GEOIP2 \
	SPECS/bind.spec
gpgme
PKG=gpgme
DIST=.el8
binary:
	./rpmbuild --target=i586 -v -bb \
	--with python2 \
	-D 'dist $(DIST)' \
	SPECS/$(PKG).spec 2>&1 | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done | \
	tee log
kernel
all:
	echo 'Use "make kernel-i686" or "make kernel-i586" .'
	false

kernel-i686:
	#--without perf \
	# RHEL8.3 made %define with_perf 0 on %{with_baseonly};
	# needs omitting --with baseonly to build python3-perf package
	#
	./rpmbuild --target=i686 -v -bb \
	--without debug --without debuginfo \
	--without kabidupchk --without kabidwchk --without kabidw_base \
	SPECS/kernel.spec 2>&1 | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done | \
	tee log.i686

kernel-i586:
	# --without perf \
	# --with baseonly \
	#
	./rpmbuild --target=i586 -v -bb \
	--without debug --without debuginfo \
	--without kabidupchk --without kabidwchk --without kabidw_base \
	SPECS/kernel.spec 2>&1 | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done | \
	tee log.i586

src:
	./rpmbuild -v -bs \
	--without debug --without debuginfo \
	--without kabidupchk --without kabidwchk --without kabidw_base \
	SPECS/kernel.spec

librepo
PKG=librepo
DIST=.el8
binary:
	# test fails with permission denied without sudo
	sudo \
	./rpmbuild --target=i586 -v -bb \
	-D 'dist $(DIST)' \
	SPECS/$(PKG).spec 2>&1 | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done | \
	tee log
	sudo chown -R `id -u`:`id -g` RPMS
libtalloc
PKG=libtalloc
binary:
	## uninstall libbsd(EPEL) beforehand
	-sudo rpm -ev --nodeps libbsd libbsd-devel
	:
	./rpmbuild --target=i586 -v -bb \
	-D 'dist .el8' \
	SPECS/$(PKG).spec 2>&1 | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done | \
	tee log
metacity
PKG=metacity
DIST=.el8
binary:
	# vulkan is not a dependency. configure --disable-vulkan
	env enable_vulkan=no \
	./rpmbuild --target=i586 -v -bb \
	-D 'dist $(DIST)' \
	SPECS/$(PKG).spec 2>&1 | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done | \
	tee log
mingw-gcc
PKG=mingw-gcc
DIST=.el8
binary:
	./rpmbuild --target=i586 -v -bb \
	-D 'dist $(DIST)' \
	--without winpthreads \
	SPECS/$(PKG).spec 2>&1 | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done | \
	tee log
newt
PKG=newt
binary:
	./rpmbuild --target=i586 -v -bb \
	-D 'dist .el8' \
	-D 'with_python2 1' \
	SPECS/$(PKG).spec 2>&1 | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done | \
	tee log
patchutils
patchutils:
	## do not let it use /bin/perl; use /usr/bin/perl
	## otherwise dnf cannot derive perl-interpreter package
	env PATH=/usr/bin:/usr/sbin:/bin:/sbin \
	./rpmbuild --target=i586 -v -bb SPECS/$@.spec
perl
PKG=perl
DIST=.el8

#test fails
#2020-01-08 11:27:37 #   Failed test 'timelocal year for 1970 1 2 0 0 0'
#2020-01-08 11:27:37 #   at t/Local.t line 109.
#2020-01-08 11:27:37 #          got: '170'
#2020-01-08 11:27:37 #     expected: '70'

#test fails with perl-Net-SSLeay version mismatch
#2021-01-01 17:35:20 SSLeay.c: loadable library and perl binaries are mismatched (got handshake key 0x8200080, needed 0x80c0080)
#2021-01-01 17:35:20 # Failed test 1 - config information dumped with -d at ../lib/perlbug.t line 51
#2021-01-01 17:35:20 #      got ''
#2021-01-01 17:35:20 # expected /(?^:Site configuration information)/
#...
#2021-01-01 17:35:23 ../lib/perlbug.t ................................................... 
#2021-01-01 17:35:23 Failed 19/25 subtests 
#	--without test

binary:
	TZ=GMT+0 \
	./rpmbuild --target=i586 -v -bb \
	-D 'dist $(DIST)' \
	SPECS/$(PKG).spec 2>&1 | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done | \
	tee log
postfix
PKG=postfix
DIST=.el8
binary:
	./rpmbuild --target=i586 -v -bb \
	-D 'dist $(DIST)' \
	--without pgsql --without mysql --without cdb \
	SPECS/$(PKG).spec 2>&1 | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done | \
	tee log
python-cffi
python-cffi:
	## demands defining %{__python}
	./rpmbuild --target=i586 -v -bb \
	-D '__python /usr/bin/python3' \
	SPECS/$@.spec
python3
python3:
	## Needs to move out existing /usr/lib/python3.6/site-packages ,
	## otherwise test.test_site.StartupImportTests FAILs
	-sudo mv /usr/lib/python3.6/site-packages /usr/lib/python3.6/site-packages81
	env LANG=C \
	./rpmbuild --target=i586 -v -bb \
	-D 'dist .el8' \
	SPECS/$@.spec 2>&1 | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done| \
	tee log
	sudo mv /usr/lib/python3.6/site-packages81 /usr/lib/python3.6/site-packages
ruby
DIST=.module_el8.1.0+249+93480f15
ruby:
	## move out existing ones else TestOpenURI#test_200 freezes
	-sudo sh -c 'mv /usr/share/rubygems{,81}; mv /usr/share/ruby{,81}; mv /usr/lib/ruby{,81}'
	:
	# USER= needed to be reset to the running user, else euid tests fail
	# (i686env sets these to "root")
	# --without jit needed to circumvent "hardened" gcc 8.3
	# otherwise %check fails with
	# "error: one or more PCH files were found, but they were invalid";
	# needs patched SPECS/ruby.spec
	:
	USER=`whoami` USERNAME=`whoami` LOGNAME=`whoami` \
	./rpmbuild --target=i586 -v -bb \
	-D 'dist $(DIST)' \
	--without jit \
	SPECS/$@.spec </dev/null 2>&1 | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done| \
	tee log
	:
	sudo sh -c 'mv /usr/share/rubygems{81,}; mv /usr/share/ruby{81,}; mv /usr/lib/ruby{81,}'
rust

For rust.i586, bootstrap rust.i686 first by make rust-bootstrap, install the resulting rust.i686, then use make rust-i586 to make rust.i586.

You need rust to build librsvg2.i586 package, which otherwise extensively uses cmov and endbr32 in .i686 library code.

Note that you will need around 23GB of free disk space.

DIST=.module+el8.4.0+9446+1a463e08

## Run "make rust-bootstrap" to bootstrap from rust-lang.org provided
## https://static.rust-lang.org/dist/rust-1.48.0-i686-unknown-linux-gnu.tar.xz
## Install the resulting .i686 rust first.
## Then, run "make rust-i586" to "cross compile" rust.i586

rust-bootstrap:
	## from rust-1.41, 32bit /bin/ld.bfd barfs with
	## /bin/ld: failed to set dynamic section sizes: Memory exhausted
	## try using /bin/ld.gold
	sudo alternatives --set ld /usr/bin/ld.gold

	# test [debuginfo-lldb] debuginfo/constant-in-match-pattern.rs ... ok
	# test [debuginfo-lldb] debuginfo/cross-crate-spans.rs ... ignored
	# (freezing in cross-crate-type-uniquing.lldb)
	# try "uninstalling" /usr/bin/lldb beforehand
	# try --without lldb
	if [ ! -f /usr/bin/lldb- -a -f /usr/bin/lldb ]; then sudo mv -i /usr/bin/lldb{,-}; fi
	
	./rpmbuild --target=i686 -v -bb \
	-D 'channel stable' \
	-D 'dist $(DIST)' \
	-D 'bootstrap_arches i686' \
	--without lldb \
	SPECS/rust.spec 2>&1 | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done | \
	tee log.boot
	sudo alternatives --auto ld ## return to ld.bfd
	if [ -f /usr/bin/lldb- ]; then sudo mv -i /usr/bin/lldb{-,}; fi

rust-i586:
	## from rust-1.41, 32bit /bin/ld.bfd barfs with
	## /bin/ld: failed to set dynamic section sizes: Memory exhausted
	## try using /bin/ld.gold
	sudo alternatives --set ld /usr/bin/ld.gold

	# freeze (no load) during test: try --without lldb
	# test [debuginfo-lldb] debuginfo/constant-in-match-pattern.rs ... ok
	# test [debuginfo-lldb] debuginfo/cross-crate-spans.rs ... ignored
	# (freezing in cross-crate-type-uniquing.lldb)
	# try "uninstalling" /usr/bin/lldb beforehand
	if [ ! -f /usr/bin/lldb- -a -f /usr/bin/lldb ]; then sudo mv -i /usr/bin/lldb{,-}; fi

	./rpmbuild --target=i586 -v -bb \
	-D 'channel stable' \
	-D 'dist $(DIST)' \
	--without bundled_llvm \
	--without lldb \
	SPECS/rust.spec 2>&1 | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done | \
	tee log.i586
	sudo alternatives --auto ld ## return to ld.bfd
	if [ -f /usr/bin/lldb- ]; then sudo mv -i /usr/bin/lldb{-,}; fi

src:
	./rpmbuild --target=noarch -v -bs \
	-D 'channel stable' \
	-D 'dist $(DIST)' \
	-D 'srcrpm 1' \
	SPECS/rust.spec
samba
samba:
	if rpm -q libbsd; then \
		echo '*** STRONGLY RECOMMENDED: uninstall EPEL libbsd package beforehand to prevent dependency'; \
	fi
	./rpmbuild --target=i586 -v -bb \
	-D 'dist .el8' \
	SPECS/$@.spec 2>&1 | \
	(IFS=""; while read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done)| \
	tee log
sssd
sssd:
	# With po4a enabled, it tries to rebuild translated manpages
	# and discards files below 80% translation rate.
	# Squelch such behavior by pretending po4a is not installed,
	# just like koji.
	env ac_cv_prog_PO4A="no" \
	./rpmbuild --target=i586 -v -bb \
	-D 'dist .el8' \
	SPECS/$@.spec 2>&1 | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done| \
	tee log
subversion
PKG=subversion
binary:
	./rpmbuild --target=i586 -v -bb \
	--without kwallet \
	--without python2 --without pyswig --with python3 \
	-D 'dist .module_el8.0.0+45+75bba4f4' \
	SPECS/$(PKG).spec 2>&1 | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done | \
	tee log
systemd
DIST=.el8_4
systemd:
	# needed for "meson test test-cgroup-util":
	# parent: mount -o bind /sys/fs/cgroup/systemd /chroot/i686/sys/fs/cgroup/systemd
	# -D 'debug_package %{nil}' 
	:
	LOGNAME=`whoami` USER=`whoami` USERNAME=`whoami` \
	./rpmbuild --target=i586 -v -bb \
	-D 'dist $(DIST)' \
	SPECS/$@.spec 2>&1 | \
	(IFS=""; while read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done)| \
	tee log

src:
	./rpmbuild --target=i586 -v -bs \
	-D 'dist $(DIST)' \
	SPECS/systemd.spec
systemtap
PKG=systemtap
DIST=.el8_4
binary:
	./rpmbuild --target=i586 -v -bb \
	-D 'dist $(DIST)' \
	--without virthost -D 'with_virthost 0' \
	SPECS/$(PKG).spec 2>&1 | \
	while IFS="" read line; do echo `date '+%Y-%m-%d %T'` "$$line"; done | \
	tee log
webkit2gtk3
Needs to fix /lib/openjpeg-2.3/OpenJPEGConfig.cmake (provided by openjpeg2-devel package):
get_filename_component(OPENJPEG_INCLUDE_ROOT "${SELF_DIR}/../../include/openjpeg-2.3" ABSOLUTE)
to
get_filename_component(OPENJPEG_INCLUDE_ROOT "${SELF_DIR}/../../usr/include/openjpeg-2.3" ABSOLUTE)