#!/bin/bash -ex

# Build supplementary development tools

#rpmbuild --rebuild https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/36/Everything/source/tree/Packages/g/gnuchess-6.2.9-3.fc36.src.rpm \
# && sudo rpm -Uvh ${HOME}/rpmbuild/RPMS/*/gnuchess-6*.rpm

rpmbuild --rebuild https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/36/Everything/source/tree/Packages/p/pilot-link-0.12.5-50.fc36.src.rpm \
 && sudo rpm -Uvh ${HOME}/rpmbuild/RPMS/*/pilot-link-{devel,libs}-0*.rpm

wget -nv -P ${HOME}/rpmbuild/RPMS/x86_64 \
  http://rpms.remirepo.net/enterprise/9/remi/x86_64/libicu69-69.1-4.el9.remi.x86_64.rpm \
  http://rpms.remirepo.net/enterprise/9/remi/x86_64/libyaz{,-devel}-5.32.0-1.el9.remi.x86_64.rpm \
 && sudo rpm -Uvh ${HOME}/rpmbuild/RPMS/*/lib{icu69,yaz}-*.rpm

rpmbuild --rebuild https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/35/Everything/source/tree/Packages/w/wireless-tools-29-28.fc35.src.rpm \
 && sudo rpm -Uvh ${HOME}/rpmbuild/RPMS/*/wireless-tools{,-devel}-29*.rpm

rpmbuild --rebuild https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/36/Everything/source/tree/Packages/s/sword-1.9.0-9.fc36.src.rpm --undefine "__cmake_in_source_build" \
 && sudo rpm -Uvh ${HOME}/rpmbuild/RPMS/*/sword{,-devel}-1*.rpm

rpmbuild --rebuild https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/36/Everything/source/tree/Packages/c/chmlib-0.40-26.fc36.src.rpm \
 && sudo rpm -Uvh ${HOME}/rpmbuild/RPMS/*/chmlib{,-devel}-0*.rpm

#rpmbuild --rebuild https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/36/Everything/source/tree/Packages/g/GeoIP-GeoLite-data-2018.06-9.fc36.src.rpm \
# && sudo rpm -Uvh ${HOME}/rpmbuild/RPMS/*/GeoIP-GeoLite-data-2*.rpm 

#rpmbuild --rebuild https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/36/Everything/source/tree/Packages/g/GeoIP-1.6.12-11.fc36.src.rpm \
# && sudo rpm -Uvh ${HOME}/rpmbuild/RPMS/*/GeoIP{,-devel}-1*.rpm 

#rpmbuild --rebuild https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/36/Everything/source/tree/Packages/l/liblo-0.31-5.fc36.src.rpm \
# && sudo rpm -Uvh ${HOME}/rpmbuild/RPMS/*/liblo{,-devel}-0*.rpm 

rpm -ivh https://dl.fedoraproject.org/pub/epel/10/Everything/source/tree/Packages/l/libunibreak-6.1-2.el10_0.src.rpm \
 && sed -i ${HOME}/rpmbuild/SPECS/libunibreak.spec -e "/^Patch:.*offline_files.patch/ s/^Patch:/Patch1:/" -e "/^Patch:.*remove_unused_var.patch/ s/^Patch:/Patch2:/" \
 && rpmbuild -ba ${HOME}/rpmbuild/SPECS/libunibreak.spec \
 && sudo rpm -Uvh ${HOME}/rpmbuild/RPMS/*/libunibreak-{6,devel}*.rpm
