#!/bin/bash

# Build supplementary development tools
rpm -i http://distrib-coffee.ipsl.jussieu.fr/pub/linux/Mageia/distrib/8/SRPMS/core/release/torsocks-2.3.0-2.mga8.src.rpm \
 && sed -i ${HOME}/rpmbuild/SPECS/torsocks.spec -e "s|%license|%doc|" \
 && rpmbuild -ba ${HOME}/rpmbuild/SPECS/torsocks.spec \
 && sudo rpm -Uvh /home/trinity/rpmbuild/RPMS/*/torsocks-2*.rpm

rpm -ivh http://distrib-coffee.ipsl.jussieu.fr/pub/linux/Mageia/distrib/8/SRPMS/core/release/cscope-15.9-2.mga8.src.rpm \
 && rpmbuild -ba ${HOME}/rpmbuild/SPECS/cscope.spec \
 && sudo rpm -Uvh /home/trinity/rpmbuild/RPMS/*/cscope-15*.rpm

rpm -i http://distrib-coffee.ipsl.jussieu.fr/pub/linux/Mageia/distrib/8/SRPMS/core/release/rpcsvc-proto-1.4-1.mga8.src.rpm \
 && sed -i ${HOME}/rpmbuild/SPECS/rpcsvc-proto.spec -e "s|%autosetup .*|%setup -q|" -e "s|%configure|%configure2_5x|" -e "s|%license|%doc|" \
 && rpmbuild -ba ${HOME}/rpmbuild/SPECS/rpcsvc-proto.spec \
 && sudo rpm -Uvh /home/trinity/rpmbuild/RPMS/*/rpcgen-1*.rpm

rpm -ivh http://distrib-coffee.ipsl.jussieu.fr/pub/linux/Mageia/distrib/8/SRPMS/core/release/html2ps-2.0-3.b7.8.mga8.src.rpm \
 && sed -i ${HOME}/rpmbuild/SPECS/html2ps.spec -e "s|%patch|%patch -P |" \
 && rpmbuild -ba ${HOME}/rpmbuild/SPECS/html2ps.spec \
 && sudo rpm -Uvh /home/trinity/rpmbuild/RPMS/*/html2ps-2*.rpm

rpm -ivh http://distrib-coffee.ipsl.jussieu.fr/pub/linux/Mageia/distrib/9/SRPMS/core/release/heimdal-7.8.0-2.mga9.src.rpm \
 && sed -i ${HOME}/rpmbuild/SPECS/heimdal.spec -e "s|%patch|%patch -P |" -e "/Conflicts:  krb5-devel/ s|^|#|" -e "s|%mkrel 2|1%{?dist}|" \
 && LDFLAGS="-lcrypt -Wl,--allow-shlib-undefined" rpmbuild -ba ${HOME}/rpmbuild/SPECS/heimdal.spec \
 && sudo rpm -Uvh --force /home/trinity/rpmbuild/RPMS/*/heimdal-{devel,libs}-7*.rpm
