#! /bin/bash set -ex repos=$1 shift mock="mock -v -r fedora-rawhide-x86_64 --uniqueext=mass$$ --no-bootstrap-chroot --disable-plugin=yum_cache" mkdir -p build cd build for pkg in "$@";do #dnf --disablerepo='*' --enablerepo=$repos repoquery --requires "$pkg"|egrep '^(gcc|clang)' || continue srcrpm="$pkg.src.rpm" if [ -e "$srcrpm" ];then continue fi rm -rf $srcrpm* exec >>$srcrpm.log 2>&1 dnf --disablerepo='*' --enablerepo=$repos download --source "$pkg" if [ ! -e $srcrpm ];then touch $srcrpm.downloadfail continue fi #rpm -q --requires -p $srcrpm|egrep '^(gcc|clang)' || continue rpm2archive $srcrpm rm -rf $srcrpm.d mkdir $srcrpm.d cd $srcrpm.d tar xzf ../$srcrpm.tgz rm -f ../$srcrpm.tgz name=$(echo "$pkg"|sed 's/-[^-]*-[^-]*$//') if [ ! -e $name.spec ];then touch ../$srcrpm.specfail continue fi (echo '%global _find_debuginfo_dwz_opts %{nil}' echo '%global optflags %(echo %{optflags}|sed "s/ -g / -g -fdebug-types-section /")' sed 's/^%\(\(define\|global\) *_find_debuginfo_dwz_opts\)/\1/' ) <$name.spec >$name.spec.new cp -p $name.spec ../$srcrpm.spec cp -p $name.spec.new ../$srcrpm.spec.new diff -u $name.spec $name.spec.new || : mv -f $name.spec.new $name.spec if ! $mock --resultdir=$PWD/resultdir --buildsrpm --spec $name.spec --sources $PWD;then touch ../$srcrpm.bsmockfail continue fi if [ $[$(find resultdir -name "*.src.rpm"|wc -l)] -ne 1 ];then touch ../$srcrpm.bsmockefail continue fi # if not pkg.endswith('.rpm'): log.error("%s doesn't appear to be an rpm - skipping", pkg) mv -f resultdir/*.src.rpm ../$srcrpm.dt.rpm cd .. test -e $srcrpm.dt.rpm rm -rf $srcrpm.d for ext in "" ".dt.rpm";do resultdir=$PWD/$srcrpm$ext.resultdir test ! -e $resultdir set +e # --chain instead of --rebuild as otherwise -a does not work $mock --resultdir=$resultdir --nocheck $(: -a https://people.redhat.com/jkratoch/dwzrepo/ ) --chain $srcrpm$ext &>$srcrpm$ext.mocklog rc=$? set -e test -e $resultdir #rm -f $srcrpm$ext if [ $rc -ne 0 ];then touch $srcrpm$ext.mockfail break fi # --chain ignores --resultdir resultdirsrc="$(sed -n 's/^INFO: Results out to: //p' $srcrpm$ext.mocklog)" if [ ! -e $resultdirsrc/*/root.log ];then touch $srcrpm$ext.mockrfail break fi # With --chain $resultdir contains just some small *.log files. rm -rf $resultdir mv `dirname $resultdirsrc/*/root.log` $resultdir echo >$srcrpm$ext.rpmsize $(du -sbc /dev/null $resultdir/*-debuginfo*.rpm|tail -n1|awk '{print $1}') size=0 for i in $resultdir/*-debuginfo*.rpm;do if [ -e "$i" ];then sizethis="$(rpm -q --qf '%{longsize}' -p $i)" [[ "$sizethis" =~ ^[0-9]+$ ]] size=$[$size+$sizethis] fi done echo >$srcrpm$ext.filesize $size mkdir $srcrpm$ext.rpms mv -f $resultdir/*-debuginfo*.rpm $srcrpm$ext.rpms || : rm -rf $resultdir done touch $srcrpm.done done