#!/bin/bash -ex

rpmbuild --rebuild https://distrib-coffee.ipsl.jussieu.fr/pub/linux/Mageia/distrib/cauldron/SRPMS/core/release/tcl-8.6.16-2.mga10.src.rpm --define "mkrel %nil" \
 && sudo rpm -Uvh ${HOME}/rpmbuild/RPMS/*/{tcl,lib64tcl{8.6,-devel}}-8.6*.rpm

rpm -ivh http://distrib-coffee.ipsl.jussieu.fr/pub/linux/Mageia/distrib/9/SRPMS/core/release/rdesktop-1.9.0-6.mga9.src.rpm \
 && sed -i ${HOME}/rpmbuild/SPECS/rdesktop.spec -e "s|%{_rpmconfigdir}/%{_real_vendor}|/usr/share/libtool/config|" \
 && rpmbuild -bb ${HOME}/rpmbuild/SPECS/rdesktop.spec --define "mkrel %nil" \
 && sudo rpm -Uvh ${HOME}/rpmbuild/RPMS/*/rdesktop-1*.rpm

rpm -ivh https://distrib-coffee.ipsl.jussieu.fr/pub/linux/Mageia/distrib/9/SRPMS/core/release/sword-1.9.0-9.mga9.src.rpm \
 && rpmbuild -bb ${HOME}/rpmbuild/SPECS/sword.spec --define "cmake_build %__make %{?_smp_mflags}" --define "cmake_install %__make -C build install DESTDIR=%{?buildroot}" --define "__cc /usr/bin/gcc" --define "__cxx /usr/bin/g++" --define "_disable_ld_no_undefined 1" --define "mkrel %nil" --define "python3_ext_suffix .cpython-311-x86_64-linux-gnu.so" --nodeps \
 && sudo rpm -Uvh ${HOME}/rpmbuild/RPMS/*/{lib64sword{1.9,-devel},sword}-1.9.0-*.rpm

rpmbuild --rebuild http://distrib-coffee.ipsl.jussieu.fr/pub/linux/Mageia/distrib/cauldron/SRPMS/core/release/yaz-5.34.4-2.mga10.src.rpm --define "mkrel %nil" --nodeps \
 && sudo rpm -Uvh ${HOME}/rpmbuild/RPMS/*/{lib64yaz{5,-devel},yaz}-5*.rpm

rpm -ivh http://distrib-coffee.ipsl.jussieu.fr/pub/linux/Mageia/distrib/9/SRPMS/core/release/rdiff-backup-2.2.2-1.mga9.src.rpm \
 && rpmbuild -bb ${HOME}/rpmbuild/SPECS/rdiff-backup.spec --define "mkrel %nil" \
 && sudo rpm -Uvh ${HOME}/rpmbuild/RPMS/*/rdiff-backup-2*.rpm

rpmbuild --rebuild http://distrib-coffee.ipsl.jussieu.fr/pub/linux/Mageia/distrib/9/SRPMS/core/release/cscope-15.9-3.mga9.src.rpm --define "mkrel %nil" \
 && sudo rpm -Uvh ${HOME}/rpmbuild/RPMS/*/cscope-15*.rpm

rpm -ivh http://distrib-coffee.ipsl.jussieu.fr/pub/linux/Mageia/distrib/9/SRPMS/core/release/perl-Getopt-ArgvFile-1.110.0-10.mga9.src.rpm \
 && rpmbuild -bb ${HOME}/rpmbuild/SPECS/perl-Getopt-ArgvFile.spec --define "mkrel %nil" \
 && sudo rpm -Uvh ${HOME}/rpmbuild/RPMS/*/perl-Getopt-ArgvFile-1*.rpm

rpm -ivh http://distrib-coffee.ipsl.jussieu.fr/pub/linux/Mageia/distrib/9/SRPMS/core/release/perl-PAR-1.18.0-1.mga9.src.rpm \
 && sed -i ${HOME}/rpmbuild/SPECS/perl-PAR.spec -e "s/MYMETA.yml//" \
 && rpmbuild -bb ${HOME}/rpmbuild/SPECS/perl-PAR.spec --define "mkrel %nil" --nodeps \
 && sudo rpm -Uvh ${HOME}/rpmbuild/RPMS/*/perl-PAR-1*.rpm

rpm -ivh http://distrib-coffee.ipsl.jussieu.fr/pub/linux/Mageia/distrib/9/SRPMS/core/release/perl-PAR-Packer-1.57.0-1.mga9.src.rpm \
 && sed -i ${HOME}/rpmbuild/SPECS/perl-PAR-Packer.spec -e "s/MYMETA.yml//" \
 && rpmbuild -bb ${HOME}/rpmbuild/SPECS/perl-PAR-Packer.spec --define "mkrel %nil" --nodeps \
 && sudo rpm -Uvh ${HOME}/rpmbuild/RPMS/*/perl-PAR-Packer-1*.rpm

rpm -ivh http://distrib-coffee.ipsl.jussieu.fr/pub/linux/Mageia/distrib/9/SRPMS/core/release/wireless-tools-30-0.pre9.14.mga9.src.rpm \
 && sed -i ${HOME}/rpmbuild/SPECS/wireless-tools.spec -e "s/%patch/%patch -P /" \
 && rpmbuild -bb ${HOME}/rpmbuild/SPECS/wireless-tools.spec --define "mkrel %nil" \
 && sudo rpm -Uvh ${HOME}/rpmbuild/RPMS/*/lib64iw{30,-devel}-30*.rpm
