#!/bin/bash -ex 

# Build supplementary development tools

# heimdal
# run "make libheimdal" first
sudo rpm -Uvh --force /home/trinity/rpmbuild/RPMS.tde-14.1.6/x86_64/*-7.8.0-1.oss160.x86_64.rpm

# nmap
wget -nv \
  https://rpmfind.net/linux/opensuse/distribution/leap/15.6/repo/oss/x86_64/liblua5_3-5-5.3.6-3.6.1.x86_64.rpm \
  https://rpmfind.net/linux/opensuse/distribution/leap/15.6/repo/oss/x86_64/nmap-7.92-150600.7.3.x86_64.rpm \
&& sudo rpm -Uvh liblua5_3-5-5.3.6-3.6.1.x86_64.rpm nmap-7.92-150600.7.3.x86_64.rpm

# perl-Getopt-ArgvFile
rpmbuild --rebuild https://ftp.lysator.liu.se/pub/opensuse/opensuse/source/distribution/leap/15.6/repo/oss/src/perl-Getopt-ArgvFile-1.11-bp156.3.1.src.rpm --define "perl_requires %nil"\
 && sudo rpm -Uvh "${HOME}/rpmbuild/RPMS/"*"/perl-Getopt-ArgvFile-"*".rpm"

# perl-PAR-Packer
rpm -Uvh http://download.opensuse.org/source/distribution/leap/15.5/repo/oss/src/perl-PAR-Packer-1.057-bp155.1.4.src.rpm \
 && rpmbuild -bb ${HOME}/rpmbuild/SPECS/perl-PAR-Packer.spec \
 && sudo rpm -Uvh "${HOME}/rpmbuild/RPMS/"*"/perl-PAR-Packer"*".rpm"

# sword
rpm -ivh https://ftp.lysator.liu.se/pub/opensuse/opensuse/source/distribution/leap/15.6/repo/oss/src/sword-1.8.1-bp156.3.7.src.rpm \
 && sed -i "${HOME}/rpmbuild/SPECS/sword.spec"  -e "s|^%patch|%patch -P |" \
 && rpmbuild -ba "${HOME}/rpmbuild/SPECS/sword.spec" \
 && sudo rpm -Uvh "${HOME}/rpmbuild/RPMS/"*"/"{libsword,sword,sword-devel}"-"*".rpm"

# torsocks
rpmbuild --rebuild https://ftp.lysator.liu.se/pub/opensuse/source/distribution/leap/15.6/repo/oss/src/torsocks-2.4.0-bp156.2.4.src.rpm

#
zypper ar --no-gpgcheck trinity.noarch https://repo/rpmbuild/RPMS/RPMS.oss160.tde-14.1.6/noarch/
zypper ar --no-gpgcheck trinity.x86_64 https://repo/rpmbuild/RPMS/RPMS.oss160.tde-14.1.6/x86_64/
