#! /bin/bash set -e # build/znc-1.8.1-2.fc33.src.rpm.rpms which readelf >/dev/null for rpms in "$@";do srcrpm="${rpms%.rpms}" if [ "$rpms" = "$srcrpm" ];then echo >&2 "$rpms is not *.rpms" exit 1 fi if [ "$srcrpm" != "${srcrpm%.dt5.rpm}" ];then # The non-.dt5.rpm run will handle both. exit 0 fi test -e $srcrpm.rpms test -e $srcrpm.dt5.rpm.rpms test ! -e $srcrpm.dtneeded test ! -e $srcrpm.rpms.d t=/tmp/dtneededsizerpms.$$ rm -f $t mkdir $srcrpm.rpms.d pushd $srcrpm.rpms.d >/dev/null rpmsbase=../../`basename $srcrpm` dwzrpms=$rpmsbase.rpms dtrpms=$rpmsbase.dt5.rpm.rpms mkdir empty cd empty if [ -z "$(find $dwzrpms $dtrpms -maxdepth 1 -type f)" ];then popd >/dev/null rm -rf $srcrpm.rpms.d exit 0 fi cd .. function extract { for i in $1/*-debuginfo*.rpm;do test ! -e $i.tgz rpm2archive $i test -e $i.tgz tar xzf $i.tgz rm -f $i.tgz done } mkdir dwz;(cd dwz;extract $dwzrpms) mkdir dt;(cd dt;extract $dtrpms) dwzcommonname="$(find dwz/usr/lib/debug/.dwz/ -type f 2>/dev/null || :)" if [ -z "$dwzcommonname" ];then dwzcommonname="nodwzcommon" dwzcommon=0 else dwzcommon="$(find "$dwzcommonname" -maxdepth 0 -printf "%s")" echo >>$t "$dwzcommonname isdwzcommon $dwzcommon NA" fi pushd dwz >/dev/null for i in `find -type f -name "*.debug*"`;do dwz=$(find $i -maxdepth 0 -printf "%s") dt=$(find ../dt/$i -maxdepth 0 -printf "%s") if readelf -WS $i 2>/dev/null|fgrep -q .gnu_debugaltlink;then if [ $dwzcommon -eq 0 ];then echo >&2 Excessive .gnu_debugaltlink: $i exit 1 fi fi echo >>$t "$(echo "$i"|sed 's/\.debug$//') $dwzcommonname $dwz $dt" done popd >/dev/null popd >/dev/null rm -rf $srcrpm.rpms.d mv $t $srcrpm.dtneeded done