#! /bin/bash # Check requires defined by pkgconfig .pc files. # # Copyright (C) 2005, 2007 Stanislav Brabec , SuSE Linux # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # See http://www.gnu.org/copyleft/lesser.html # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # Set default PKG_CONFIG_PATH. # Guess default path from existing directories. # FIXME: This guess does not work in live system. if test -d "$BUILD_ROOT/usr/lib64" ; then COMPLETE_PKG_CONFIG_PATH=/usr/lib64/pkgconfig else COMPLETE_PKG_CONFIG_PATH=/usr/lib/pkgconfig fi if test -d "$BUILD_ROOT/usr/share/pkgconfig" ; then COMPLETE_PKG_CONFIG_PATH=$COMPLETE_PKG_CONFIG_PATH:/usr/share/pkgconfig fi # locate package file. # locate_pc name_without_pc function locate_pc { local DIR for DIR in $COMPLETE_PKG_CONFIG_PATH ; do if test -f $BUILD_ROOT$DIR/$1.pc ; then LOCATED_PC=$DIR/$1.pc return fi done return 1 } # Check requirements of RPM package. # check_rpm_requires rpm declare -a RPMS declare -a UNKNOWNS IFS=$IFS":," PKGS=$(sed =][<>=]* [^ ]*//g' | tr ' ' '\n' | sort -u) for REQ in $PKGS ; do if test "$REQ" ; then if locate_pc $REQ ; then RPM=$(rpm --queryformat '%{NAME}\n' -qf $LOCATED_PC) # NOTE: Here is a place for plugins or version dependent corrections. RPMS[${#RPMS[@]}]=$RPM else UNKNOWNS[${#UNKNOWNS[@]}]=$REQ.pc fi fi done RPMLIST=$(echo ${RPMS[*]} | sort -u | tr '\n' ' ' | sed 's/ $//') SUM=$(echo "$RPMLIST" | md5sum | sed 's/ .*$//') if test ${#UNKNOWNS[@]} -gt 0 ; then UNKNOWNSUM=$(echo "${UNKNOWNS[*]}" | md5sum | sed 's/ .*$//') echo "#BEGIN pkg-buildrequires # Created by pkg-buildrequires. Do not edit by hand. BuildRequires: $RPMLIST %define pkg_buildrequires_checksum $SUM %define pkg_buildrequires_unknown_checksum $UNKNOWNSUM #END pkg-buildrequires" | tee pkg-buildrequires.log else echo "#BEGIN pkg-buildrequires # Created by pkg-buildrequires. Do not edit by hand. BuildRequires: $RPMLIST %define pkg_buildrequires_checksum $SUM #END pkg-buildrequires" | tee pkg-buildrequires.log fi if test ${#UNKNOWNS[@]} -gt 0 ; then echo >&2 "WARNING: These pkg-config files were not located: ${UNKNOWNS[*]}" fi if test "$SUM" != "$PKG_BUILDREQUIRES_CHECKSUM" ; then echo >&2 "Your BuildRequires are outdated. Please call: pkg-update-buildrequires [ $PWD or build_log_file ] [ spec_file ] If you are using build root, you may have to install pkg-buildrequires-wrap and prepend root path it to the path." exit 1 fi if test "$SUM" != "$PKG_BUILDREQUIRES_CHECKSUM" ; then echo >&2 "Your BuildRequires may be outdated. Please call pkg-update-buildrequires $PWD [ spec_file ] or update requirements manually. Please see above and fix or confirm its correctness by calling: pkg-update-buildrequires $PWD [ spec_file ] If you are using build root, you may have to install pkg-buildrequires-wrap and prepend root path it to the path." exit 1 fi