pck-update (-a6): another bunch of code cleanups

Signed-off-by: Davide Madrisan <davide.madrisan@gmail.com>
This commit is contained in:
Davide Madrisan 2012-01-29 17:34:11 +01:00
parent 877e3d5a37
commit 3ce36517c5

View File

@ -2334,10 +2334,7 @@ build the list of the build requirements""${NORM}"
notify.debug "pck_rpmversion = $pck_rpmversion" notify.debug "pck_rpmversion = $pck_rpmversion"
notify.debug "pck_rpmrelease = $pck_rpmrelease" notify.debug "pck_rpmrelease = $pck_rpmrelease"
notify.debug "SPEC_TARGET = [${SPEC_TARGET[*]}]" local pcks_list
local perl_prefixes=`perl -V | grep "^[[:space:]]\+/usr/lib/perl5"`
unset provides
for pck in ${SPEC_TARGET[*]}; do for pck in ${SPEC_TARGET[*]}; do
# FIXME : we should check and complain if the package has # FIXME : we should check and complain if the package has
# been built for a different architecture # been built for a different architecture
@ -2348,108 +2345,108 @@ $pck-$pck_rpmversion-$pck_rpmrelease$DISTRO_rpm.noarch.rpm"
filename="$rpms_dir/$target_cpu/\ filename="$rpms_dir/$target_cpu/\
$pck-$pck_rpmversion-$pck_rpmrelease$DISTRO_rpm.$target_cpu.rpm" $pck-$pck_rpmversion-$pck_rpmrelease$DISTRO_rpm.$target_cpu.rpm"
fi fi
[ -e $filename ] || [ -e $filename ] ||
notify.error $"package not found"": \`$filename'" notify.error $"package not found"": \`$filename'"
notify.note " * $filename"
# look for RPMs provides pcks_list=( ${pcks_list[*]} "$filename" )
provides="$provides `rpm -p -q $filename --provides | \
while read line; do echo -n "${line/ */} "; done`"
done done
notify.debug "SPEC_TARGET = [ ${SPEC_TARGET[*]} ]"
notify.debug "pcks_list = [ ${pcks_list[*]} ]"
local frequires=$(mktemp -q -t frequires.XXXXXXXX) || local frequires=$(mktemp -q -t frequires.XXXXXXXX) ||
notify.error $"can't create temporary files" notify.error $"can't create temporary files"
# FIXME: "/usr/lib/perl5" should be defined in autospec.conf
local perl_prefixes=$(perl -V | grep "^[[:space:]]\+/usr/lib/perl5")
for pck in ${SPEC_TARGET[*]}; do # look for RPMs provides
if [ "${SPEC_BUILDARCH:-$BUILD_ARCH}" == "noarch" ]; then local pcks_provides=(
filename="$rpms_dir/noarch/\ $(rpm -p -q --provides ${pcks_list[*]} 2>/dev/null | sort -u | \
$pck-$pck_rpmversion-$pck_rpmrelease$DISTRO_rpm.noarch.rpm" while read line; do echo "${line// /}"; done) )
else notify.debug "pcks_provides = [${pcks_provides[*]}]"
filename="$rpms_dir/$target_cpu/\
$pck-$pck_rpmversion-$pck_rpmrelease$DISTRO_rpm.$target_cpu.rpm"
fi
notify.note " * $filename"
# display all the build requirements # display all the build requirements
( rpm -p -q $filename --requires | \ ( rpm -p -q --requires ${pcks_list[*]} | sort -u | \
while read line; do while read line; do
buildreq="" buildreq=
req=${line/ */} req=${line// /}
if [ "`echo \"$provides\" | grep ${req}`" ]; then if [ -n "$(for p in ${pcks_provides[*]}; do
# self-provided requirement # self-provided requirement
: [ "$p" = "${req}" ] && echo "$p"; done)" ]; then
elif [ "${req:0:1}" = "/" ]; then :
# file requirement; ignore elif [ "${req:0:1}" = "/" ]; then
: # file requirement; ignore
elif [ "${req:0:7}" = "rpmlib(" -o \ :
"${req:0:7}" = "config(" -o \ elif [ "${req:0:7}" = "rpmlib(" -o \
"${req:0:11}" = "executable(" ]; then "${req:0:7}" = "config(" -o \
# not a build requirement "${req:0:11}" = "executable(" ]; then
: # not a build requirement
elif [ "${req:0:5}" = "perl(" ]; then :
# a perl requirement elif [ "${req:0:5}" = "perl(" ]; then
preq="`echo $req | \ # a perl requirement
sed -e 's|perl(\(.*\))|\1|g' -e 's|::|/|g'`"".pm" preq="$(echo $req | \
for pp in $perl_prefixes; do sed -e 's|perl(\(.*\))|\1|g' -e 's|::|/|g')"".pm"
[ -e $pp/$preq ] && buildreq=`\ for pp in $perl_prefixes; do
rpm -qf $pp/${preq} 2>/dev/null | \ [ -e $pp/$preq ] && buildreq=$(\
sed "s|\(.*\)-[^-]*-[^-]*|\1|"` rpm -qf $pp/${preq} 2>/dev/null | \
[ "$buildreq" ] && break sed "s|\(.*\)-[^-]*-[^-]*|\1|")
done [ "$buildreq" ] && break
[ "$buildreq" ] || done
echo "# $req: perl requirement not resolved" [ "$buildreq" ] ||
elif [ "${req}" = "python(abi)" ]; then echo "# $req: perl requirement not resolved"
# python requirement elif [ "${req}" = "python(abi)" ]; then
buildreq=libpython-devel # FIXME: libpython-devel should be defined in autospec.conf
elif [ "${req/.so*/}" != "$req" ]; then # python requirement
# requirement is a shared library buildreq=libpython-devel
req=${req/(*)/} elif [ "${req/.so*/}" != "$req" ]; then
lib=${req/.*/}.so # requirement is a shared library
libpath=`$path_ldconfig -p | grep $req` req=${req/(*)/}
libpath=${libpath/\(*\)/} lib=${req/.*/}.so
if [ "$libpath" ]; then libpath=`$path_ldconfig -p | grep $req`
libpath=${libpath/* => /} libpath=${libpath/\(*\)/}
solibpath="${libpath/.so*/}.so" if [ "$libpath" ]; then
if [ ! -e $solibpath \ libpath=${libpath/* => /}
-a "${solibpath:0:5}" = "/lib/" ]; then solibpath="${libpath/.so*/}.so"
solibpath="/usr$solibpath" if [ ! -e $solibpath \
fi -a "${solibpath:0:5}" = "/lib/" ]; then
solibpath="/usr$solibpath"
fi
eval buildreq=`rpm -qf $solibpath 2>/dev/null | \
sed "s|\(.*\)-[^-]*-[^-]*|\1|"` 2>/dev/null
if [ ! "$buildreq" -o $? -ne 0 ]; then
# let's try removing version extension in libname
# (eg. liblber-2.2.so => liblber.so)
solibpath=`echo $solibpath | sed "s|-[0-9.]*\.so|.so|"`
eval buildreq=`rpm -qf $solibpath 2>/dev/null | \ eval buildreq=`rpm -qf $solibpath 2>/dev/null | \
sed "s|\(.*\)-[^-]*-[^-]*|\1|"` 2>/dev/null sed "s|\(.*\)-[^-]*-[^-]*|\1|"` 2>/dev/null
if [ ! "$buildreq" -o $? -ne 0 ]; then [ ! "$buildreq" -o $? -ne 0 ] &&
# let's try removing version extension in libname echo "#$req: .so link not found"
# (eg. liblber-2.2.so => liblber.so)
solibpath=`echo $solibpath | sed "s|-[0-9.]*\.so|.so|"`
eval buildreq=`rpm -qf $solibpath 2>/dev/null | \
sed "s|\(.*\)-[^-]*-[^-]*|\1|"` 2>/dev/null
[ ! "$buildreq" -o $? -ne 0 ] &&
echo "#$req: .so link not found"
fi
else
echo "\
#$req: library not reported by ldconfig; run \`ldconfig' and try again"
fi fi
else else
# unidentified requirement echo "\
buildreq=`rpm -q --whatprovides $req 2>/dev/null | \ #$req: library not reported by ldconfig; run \`ldconfig' and try again"
sed "s|\(.*\)-[^-]*-[^-]*|\1|"`
[ "$buildreq" ] || \
echo "#$req: not found; what is this?"
fi fi
if [ "${buildreq}" \ else
-a "${buildreq/%-devel/}" = "${buildreq}" ]; then # unidentified requirement
buildreq=`rpm -q --whatprovides $req 2>/dev/null | \
sed "s|\(.*\)-[^-]*-[^-]*|\1|"`
[ "$buildreq" ] || \
echo "#$req: not found; what is this?"
fi
if [ "${buildreq}" \
-a "${buildreq/%-devel/}" = "${buildreq}" ]; then
# if a -devel exists for this package, use it # if a -devel exists for this package, use it
develpkg=`rpm -q ${buildreq}-devel 2>/dev/null` && develpkg=`rpm -q ${buildreq}-devel 2>/dev/null` &&
buildreq=`echo $develpkg | sed "s|\(.*\)-[^-]*-[^-]*|\1|"` buildreq=`echo $develpkg | sed "s|\(.*\)-[^-]*-[^-]*|\1|"`
fi fi
# finally print buildrequires block # finally print buildrequires block
[ "$buildreq" ] && echo "BuildRequires: $buildreq" [ "$buildreq" ] && echo "BuildRequires: $buildreq"
done ) >> $frequires done ) >> $frequires
done
notify.note "## AUTOBUILDREQ-BEGIN" notify.note "
cat $frequires | sort -u ## AUTOBUILDREQ-BEGIN"
notify.note "## AUTOBUILDREQ-END" sort -u $frequires
notify.note "## AUTOBUILDREQ-END
"
rm -f $frequires rm -f $frequires
;; ;;
7) notify.note "[${NOTE}step $step${NORM}] -- ${NOTE}"$"\ 7) notify.note "[${NOTE}step $step${NORM}] -- ${NOTE}"$"\