Last active
May 5, 2021 00:45
-
-
Save unxmaal/d57926d243dcec93b24ece1c6d1e715f to your computer and use it in GitHub Desktop.
This variant of autobuilder works with randombuilder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/sgug/bin/bash -e | |
set -o pipefail | |
_list=list.txt | |
_repodir=/usr/people/edodd/sgug-rse.git | |
_builddir=/usr/people/edodd/rpmbuild | |
_rpmlist=logs/rpmlist.txt | |
_buildlog=logs/build.log | |
_installed=logs/install.log | |
#_fcurl="https://download-ib01.fedoraproject.org/pub/fedora/linux/releases/31/Everything/SRPMS/Packages/" | |
_fcurl="https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/31/Everything/source/tree/Packages/" | |
#_fcupdates_url="https://download-ib01.fedoraproject.org/pub/fedora/linux/updates/31/Everything/SRPMS/Packages/" | |
_fcupdates_url="https://archives.fedoraproject.org/pub/archive/fedora/linux/updates/31/Everything/SRPMS/Packages/" | |
# this must check in Updates first | |
# and it could be deprecated if we'd share our srpms | |
getsrpm(){ | |
if [[ -e "${_repodir}/packages/$i/SPECS/$i.spec" ]] ; then | |
local _version=$(grep 'Version:' "${_repodir}/packages/$i/SPECS/$i.spec" | awk '{print $2}') | |
local _srpmname="${i}-${_version}" | |
else | |
local _srpmname="${i}-" | |
fi | |
if ! grep "$_srpmname" "$_rpmlist" ; then | |
echo "not found" | |
#get first letter | |
local _fl=${i:0:1} | |
# test if the srpm is in updates | |
unset _un | |
if [[ -f un.txt ]] ; then rm un.txt ; fi | |
wget "${_fcupdates_url}${_fl}/" -O un.txt | |
local _un=$( grep "$_srpmname" un.txt | grep src.rpm | cut -d '=' -f4| cut -d\" -f2) | |
if [[ -n $_un ]] ; then | |
#get the url for the rpm | |
local _ul="$_fcupdates_url/$_fl/$_un" | |
#fetch the rpm | |
curl -o "SRPMS/$_un" "$_ul" | |
#install the rpm | |
rpm -Uvh "SRPMS/$_un" | |
else | |
#get the name of the rpm | |
if [[ -f rn.txt ]] ; then rm rn.txt ; fi | |
wget "${_fcurl}${_fl}/" -O rn.txt | |
local _rn=$(grep "$_srpmname" rn.txt | grep src.rpm | cut -d '=' -f4| cut -d\" -f2) | |
#local _rn=$(curl "${_fcurl}${_fl}/" | grep "$_srpmname" | grep src.rpm | cut -d '=' -f4| cut -d\" -f2) | |
if [[ -z "$_rn" ]] ; then | |
fail "SRPM for $_rn not found!" | |
exit 1 | |
fi | |
#get the url for the rpm | |
local _rl="$_fcurl/$_fl/$_rn" | |
#fetch the rpm | |
curl -o "SRPMS/$_rn" "$_rl" | |
#install the rpm | |
rpm -Uvh "SRPMS/$_rn" | |
fi | |
fi | |
} | |
fail(){ | |
local _msg="${1}" | |
echo "${_msg}" | |
exit 1 | |
} | |
newspecs(){ | |
local _pkg=${1} | |
_bpath="${_repodir}/packages/${_pkg}" | |
_spec="${_bpath}/SPECS" | |
_src="${_bpath}/SOURCES" | |
_tpath="${_builddir}" | |
_tspecs="${_tpath}/SPECS" | |
_tsrc="${_tpath}/SOURCES" | |
if [[ -d "${_repodir}/packages/$_pkg" ]] ; then | |
cp ${_spec}/* ${_tspecs}/. | |
if [[ -e "${_src}" ]] ; then | |
cp ${_src}/* ${_tsrc}/. | |
fi | |
fi | |
} | |
build(){ | |
local _pkg=${1} | |
rpmbuild -ba --undefine=_disable_source_fetch -ba "SPECS/$_pkg.spec" --nocheck | tee "logs/$_pkg.build.log" | |
local _buildval="${PIPESTATUS[0]}" | |
if [[ $_buildval -ne 0 ]] ; then | |
cp $_buildlog "logs/$_pkg.buildfailed" | |
fail "ERROR: build for "$_pkg" failed." | |
fi | |
local _built=$(grep Wrote "logs/$_pkg.build.log" | cut -d' ' -f2 | grep -v SRPM) | |
for _b in $_built ; do | |
sudo rpm -Uvh --reinstall $_b | |
local _rv=$? | |
if [[ $_rv -eq 0 ]] ; then | |
echo $_b >> "$_installed" | |
else | |
echo $_b >> "logs/install_failed.log" | |
fail "ERROR: install for $_pkg failed." | |
fi | |
done | |
} | |
setup(){ | |
mkdir -p logs | |
#rpm -qa | sort > logs/rpmlist.txt | |
rm -rf "${_builddir:?}/BUILD/"* | |
rm -rf "${_builddir:?}/BUILDROOT/"* | |
} | |
main(){ | |
setup | |
for i in $(cat $_list) ; do | |
#getsrpm | |
newspecs $i | |
build $i | |
done | |
} | |
main | |
exit $? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment