diff options
author | jmmv <jmmv@pkgsrc.org> | 2005-10-01 12:56:51 +0000 |
---|---|---|
committer | jmmv <jmmv@pkgsrc.org> | 2005-10-01 12:56:51 +0000 |
commit | 3f46f297cd33cb958f5052b8a1c1f8373669d086 (patch) | |
tree | 1ef909bd61573555d37e0297ac06fd7f4371dfa3 /pkgtools | |
parent | 9484d4d5ebd936f4de474a74337828fa6c3d336d (diff) | |
download | pkgsrc-3f46f297cd33cb958f5052b8a1c1f8373669d086.tar.gz |
Initial import of verifypc, version 1.0:
verifypc is a tool that sanity checks the dependencies of a package based on
the results of a successful build, assuming the package uses pkg-config to
detect dependencies.
verifypc will warn you if the configuration script requests an uninstalled
or unavailable package (not specified as a direct dependency) or if the
requested package does not match the version specification in the packages'
dependencies.
Diffstat (limited to 'pkgtools')
-rw-r--r-- | pkgtools/verifypc/DESCR | 8 | ||||
-rw-r--r-- | pkgtools/verifypc/Makefile | 37 | ||||
-rw-r--r-- | pkgtools/verifypc/PLIST | 3 | ||||
-rw-r--r-- | pkgtools/verifypc/files/verifypc.1 | 94 | ||||
-rw-r--r-- | pkgtools/verifypc/files/verifypc.sh | 157 |
5 files changed, 299 insertions, 0 deletions
diff --git a/pkgtools/verifypc/DESCR b/pkgtools/verifypc/DESCR new file mode 100644 index 00000000000..3c4b4aa44a7 --- /dev/null +++ b/pkgtools/verifypc/DESCR @@ -0,0 +1,8 @@ +verifypc is a tool that sanity checks the dependencies of a package based on +the results of a successful build, assuming the package uses pkg-config to +detect dependencies. + +verifypc will warn you if the configuration script requests an uninstalled +or unavailable package (not specified as a direct dependency) or if the +requested package does not match the version specification in the packages' +dependencies. diff --git a/pkgtools/verifypc/Makefile b/pkgtools/verifypc/Makefile new file mode 100644 index 00000000000..34e1d89e4e1 --- /dev/null +++ b/pkgtools/verifypc/Makefile @@ -0,0 +1,37 @@ +# $NetBSD: Makefile,v 1.1.1.1 2005/10/01 12:56:51 jmmv Exp $ +# + +DISTNAME= verifypc-1.0 +CATEGORIES= pkgtools +MASTER_SITES= # empty +DISTFILES= # empty + +MAINTAINER= jmmv@NetBSD.org +COMMENT= Sanity check package dependencies according to pkg-config + +PKG_INSTALLATION_TYPES= overwrite pkgviews + +EXTRACT_ONLY= # empty +NO_CHECKSUM= YES +NO_BUILD= YES +WRKSRC= ${WRKDIR} + +SUBST_CLASSES+= vars +SUBST_STAGE.vars= do-configure +SUBST_MESSAGE.vars= "Configuring sources." +SUBST_FILES.vars= * +SUBST_SED.vars= -e 's|@MAKE@|${MAKE}|g' +SUBST_SED.vars+= -e 's|@SH@|${SH}|g' + +INSTALLATION_DIRS= man/man1 bin + +do-extract: + ${CP} ${FILESDIR}/verifypc.sh ${WRKSRC} + ${CP} ${FILESDIR}/verifypc.1 ${WRKSRC} + +do-install: + ${INSTALL_SCRIPT} ${WRKSRC}/verifypc.sh \ + ${PREFIX}/bin/verifypc + ${INSTALL_MAN} ${WRKSRC}/verifypc.1 ${PREFIX}/man/man1/ + +.include "../../mk/bsd.pkg.mk" diff --git a/pkgtools/verifypc/PLIST b/pkgtools/verifypc/PLIST new file mode 100644 index 00000000000..0ca188f5683 --- /dev/null +++ b/pkgtools/verifypc/PLIST @@ -0,0 +1,3 @@ +@comment $NetBSD: PLIST,v 1.1.1.1 2005/10/01 12:56:51 jmmv Exp $ +bin/verifypc +man/man1/verifypc.1 diff --git a/pkgtools/verifypc/files/verifypc.1 b/pkgtools/verifypc/files/verifypc.1 new file mode 100644 index 00000000000..67f668822bd --- /dev/null +++ b/pkgtools/verifypc/files/verifypc.1 @@ -0,0 +1,94 @@ +.\" $NetBSD: verifypc.1,v 1.1.1.1 2005/10/01 12:56:51 jmmv Exp $ +.\" +.\" verifypc - Sanity check package dependencies according to pkg-config +.\" Copyright (c) 2005 Julio M. Merino Vidal <jmmv@NetBSD.org> +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Neither the name of The NetBSD Foundation nor the names of its +.\" contributors may be used to endorse or promote products derived +.\" from this software without specific prior written permission. +.\" 3. Neither the name of author nor the names of its contributors may +.\" be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS +.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS +.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +.\" POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd October 1, 2005 +.Dt VERIFYPC 1 +.Os +.Sh NAME +.Nm verifypc +.Nd sanity check package dependencies according to pkg-config +.Sh SYNOPSIS +.Nm +.Sh DESCRIPTION +.Nm +is a tool that sanity checks the dependencies of a package based on the +results of a successful build, assuming the package uses +.Xr pkg-config 1 +to detect its dependencies. +It will warn you if the configuration script requests an uninstalled or +unavailable package (not specified as a direct dependency) or if the +requested package does not match the version specification in the +packages' dependencies. +.Pp +.Nm +has to be run within a package directory after that package has +been successfully built. +Usually, a +.Sq make configure +is enough, but it is recommended to run a full build to also catch calls to +.Xr pkg-config 1 +in the build phase. +.Pp +In order to do its checks, +.Nm +relies on a log file generated by +.Xr pkg-config 1 ; +this log is stored inside the work directory and is automatically generated +by pkgsrc assuming that your installed +.Xr pkg-config 1 +binary is newer than 0.19nb1. +The tool will return an error if the log file does not exist. +.Sh RETURN VALUES +.Nm +exits 0 if all dependencies are correctly satisfied by the package or 1 if +there were any errors. +.Sh ENVIRONMENT +The following environment variables are honored: +.Bl -tag +.It Ev MAKE +Path to the +.Xr make 1 +utility used to parse package make files. +Defaults to +.Pa @MAKE@ . +.It Ev VERIFYPC_IGNORE +White-space separated list of pkg-config package names that this tool +will ignore if they were not found. +Useful to shut up warnings for packages that are not yet in pkgsrc, such as +X11 pkg-config files. +Defaults to nothing. +.El +.Sh SEE ALSO +.Xr pkg-config 1 +.Sh HISTORY +The +.Nm +utility first appeared in pkgsrc-2005Q4. +.Sh AUTHORS +.An Julio M. Merino Vidal Aq jmmv@NetBSD.org diff --git a/pkgtools/verifypc/files/verifypc.sh b/pkgtools/verifypc/files/verifypc.sh new file mode 100644 index 00000000000..a380b8621b1 --- /dev/null +++ b/pkgtools/verifypc/files/verifypc.sh @@ -0,0 +1,157 @@ +#!@SH@ +# +# $NetBSD: verifypc.sh,v 1.1.1.1 2005/10/01 12:56:51 jmmv Exp $ +# +# verifypc - Sanity check package dependencies according to pkg-config +# Copyright (c) 2005 Julio M. Merino Vidal <jmmv@NetBSD.org> +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name of author nor the names of its contributors may +# be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS +# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +: ${MAKE:=@MAKE@} + +: ${VERIFYPC_IGNORE:=} + +SORTED_DEPS= + +# ------------------------------------------------------------------------- + +# +# Show an error message on stderr and exit. +# +err() { + echo "verifypc: ${@}" 1>&2 + exit 1 +} + +# ------------------------------------------------------------------------- + +# +# Show a warning message on stderr. +# +warn() { + echo "verifypc: ${@}" 1>&2 +} + +# ------------------------------------------------------------------------- + +# +# Checks if the file passed as an argument belongs to any of our direct +# dependencies. +# +search_file_in_depends() { + local file="${1}" + local dep dir file + + for dep in ${SORTED_DEPS}; do + dir=$(echo ${dep} | cut -d : -f 2) + if [ -d ${dir} ] && grep ${file} ${dir}/PLIST* >/dev/null; then + echo ${dep} + return + fi + done +} + +# ------------------------------------------------------------------------- + +# +# Checks if the pkg-config dependency specification is satisfied by +# the 'dep' package dependency. +# +check_match() { + local dep="${1}" pcname="${2}" pcop="${3}" pcver="${4}" + local pkgdep pkgname + + if [ ${pcop} != ">" -a ${pcop} != ">=" -a ${pcop} != "-" ]; then + warn "unsupported operator ${pcop} in ${pcname} dependency" + return 1 + fi + + pkgdep=$(echo ${dep} | cut -d : -f 1 | sed 's|>=|-|;s|>|-|') + pkgname=$(echo ${pkgdep} | cut -d - -f 1) + + if ! pkg_admin pmatch "${pkgname}${pcop}${pcver}" "${pkgdep}"; then + warn "${pcname} not correct; '${pcop} ${pcver}' needed" + return 1 + fi + return 0 +} + +# ------------------------------------------------------------------------- + +# +# Main program. +# +main() { + local dep error lines log pcname pcop pcver + + [ -f Makefile -a -f ../../mk/bsd.pkg.mk ] || + err "must be run within a package directory" + + log=$(${MAKE} show-var VARNAME=_PKG_CONFIG_LOG) + + [ -f ${log} ] || + err "pkg-config log not found; must run '${MAKE} configure' first" + + # Construct a list of dependency specifications for the current package. + SORTED_DEPS=$(${MAKE} show-vars VARNAMES="BUILD_DEPENDS DEPENDS" | tr ' ' ' +' | sort -r | uniq) + + error=0 + lines=$(cat ${log} | sort | uniq | tr ' ' '¬') + for l in ${lines}; do + pcname=$(echo ${l} | cut -d '¬' -f 1) + pcop=$(echo ${l} | cut -d '¬' -f 2) + pcver=$(echo ${l} | cut -d '¬' -f 3) + + dep=$(search_file_in_depends pkgconfig/${pcname}.pc) + if [ -n "${dep}" -a "${pcop}" != "NOT-FOUND" ]; then + # The package passed to pkg-config is correct, as we have it + # among our dependencies. If we are requiring an specific + # version of it, let's check if it is correct. + if [ ${pcop} != "(any)" ]; then + check_match ${dep} ${pcname} ${pcop} ${pcver} + [ $? -eq 0 ] || error=1 + fi + else + # The package passed to pkg-config cannot be found among our + # dependencies or it does not exist; tell the user. + if echo ${VERIFYPC_IGNORE} | \ + egrep "^${pcname}$|^${pcname} | ${pcname} | ${pcname}$" \ + >/dev/null + then + : # Package explicitly ignored by the user, so shut up. + else + warn "${pcname} not a direct dependency" + error=1 + fi + fi + done + + return ${error} +} + +main "${@}" |