pck-update (-a6): code cleanups

Signed-off-by: Davide Madrisan <davide.madrisan@gmail.com>
This commit is contained in:
Davide Madrisan 2012-01-31 00:54:51 +01:00
parent bc66419a27
commit 062ef27deb

View File

@ -2367,11 +2367,11 @@ $pck-$pck_rpmversion-$pck_rpmrelease$DISTRO_rpm.$target_cpu.rpm"
# display all the build requirements # display all the build requirements
( rpm -p -q --requires ${pcks_list[*]} | sort -u | \ ( rpm -p -q --requires ${pcks_list[*]} | sort -u | \
while read line; do while read line; do
buildreq= buildreq=""
req=${line// /} req=${line// /}
if [ -n "$(for p in ${pcks_provides[*]}; do if [ -n "$(for p in ${pcks_provides[*]}; do
# self-provided requirement # self-provided requirement
[ "$p" = "${req}" ] && echo "$p"; done)" ]; then [ "$p" = "${req}" ] && echo "$p"; done)" ]; then
: :
elif [ "${req:0:1}" = "/" ]; then elif [ "${req:0:1}" = "/" ]; then
# file requirement; ignore # file requirement; ignore
@ -2394,32 +2394,42 @@ $pck-$pck_rpmversion-$pck_rpmrelease$DISTRO_rpm.$target_cpu.rpm"
[ "$buildreq" ] || [ "$buildreq" ] ||
echo "# $req: perl requirement not resolved" echo "# $req: perl requirement not resolved"
elif [ "${req}" = "python(abi)" ]; then elif [ "${req}" = "python(abi)" ]; then
# FIXME: libpython-devel should be defined in autospec.conf # FIXME: libpython-devel should be defined in autospec.conf
# python requirement # python requirement
buildreq=libpython-devel buildreq="libpython-devel"
elif [ "${req/.so*/}" != "$req" ]; then elif [[ "$req" =~ .*\.so\.[0-9]* ]]; then
# requirement is a shared library solibpath_catch=""
req=${req/(*)/} # is a shared library
lib=${req/.*/}.so # req="libGL.so.1(libc6)" => /usr/lib/libGL.so
libpath=`$path_ldconfig -p | grep $req` solibpath=$($path_ldconfig -Np | \
libpath=${libpath/\(*\)/} sed -n "s, ,,g;/${req/(*)/}/{
if [ "$libpath" ]; then s,.*=>,,;s,\.so\..*,.so,p}")
libpath=${libpath/* => /} notify.debug "req=\"$req\" => solibpath=\"$solibpath\""
solibpath="${libpath/.so*/}.so" if [ "$solibpath" ]; then
if [ ! -e $solibpath \ if [ -e $solibpath ]; then
-a "${solibpath:0:5}" = "/lib/" ]; then solibpath_catch="$solibpath"
solibpath="/usr$solibpath" else
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 # let's try removing version extension in libname
# (eg. liblber-2.2.so => liblber.so) # (eg. liblber-2.2.so => liblber.so)
solibpath=`echo $solibpath | sed "s|-[0-9.]*\.so|.so|"` solibpath_alternate="\
eval buildreq=`rpm -qf $solibpath 2>/dev/null | \ $(echo $solibpath | sed "s|-[0-9.]*\.so|.so|")"
sed "s|\(.*\)-[^-]*-[^-]*|\1|"` 2>/dev/null if [ -e $solibpath_alternate ]; then
[ ! "$buildreq" -o $? -ne 0 ] && solibpath_catch="$solibpath_alternate"
echo "#$req: .so link not found" else
if [ "${solibpath:0:5}" = "/lib/" -o \
"${solibpath:0:7}" = "/lib64/" ]; then
[ -e "/usr${solibpath}" ] &&
solibpath_catch="/usr${solibpath}"
fi
fi
fi
if [ "$solibpath_catch" ]; then
eval buildreq="\
$(rpm --qf %{name} -qf $solibpath_catch 2>/dev/null)" 2>/dev/null
[ -z "$buildreq" -o $? -ne 0 ] && echo "\
#$req: $solibpath_catch: file not owned by any package"
else
echo "#$req: .so link not found"
fi fi
else else
echo "\ echo "\
@ -2427,16 +2437,16 @@ $pck-$pck_rpmversion-$pck_rpmrelease$DISTRO_rpm.$target_cpu.rpm"
fi fi
else else
# unidentified requirement # unidentified requirement
buildreq=`rpm -q --whatprovides $req 2>/dev/null | \ eval buildreq="$(\
sed "s|\(.*\)-[^-]*-[^-]*|\1|"` rpm -q --qf %{name} --whatprovides $req 2>/dev/null)"
[ "$buildreq" ] || \ [ -z "$buildreq" -o $? -ne 0 ] &&
echo "#$req: not found; what is this?" echo "#$req: not found; what is this?"
fi fi
if [ "${buildreq}" \ if [ -n "$buildreq" \
-a "${buildreq/%-devel/}" = "${buildreq}" ]; then -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` && rpm -q ${buildreq}-devel &>/dev/null &&
buildreq=`echo $develpkg | sed "s|\(.*\)-[^-]*-[^-]*|\1|"` buildreq="$(rpm -q --qf %{name} ${buildreq}-devel)"
fi fi
# finally print buildrequires block # finally print buildrequires block
[ "$buildreq" ] && echo "BuildRequires: $buildreq" [ "$buildreq" ] && echo "BuildRequires: $buildreq"