Use perl lib depends checker, that parses the full gamut of libspecs.

This commit is contained in:
espie 2001-11-17 10:39:19 +00:00
parent 59593ab40b
commit 47692f4664
2 changed files with 166 additions and 41 deletions

View File

@ -0,0 +1,128 @@
#!/usr/bin/perl
# $OpenBSD: resolve-lib,v 1.1 2001/11/17 10:39:19 espie Exp $
#
# Copyright (c) 2001
# Marc Espie. All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Neither the name of OpenBSD 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 ITS AUTHOR AND THE OpenBSD project ``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 REGENTS 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.
use strict;
my $noshared;
my $sharedonly;
my $strict;
my $reqmajor;
my $reqminor;
# Grab arguments
$_=shift;
if ($_ eq '-noshared') {
$noshared = 1;
$_ = shift;
}
s/\.$//;
# Parse spec
if (m/\.a$/) {
$_ = $`;
$noshared = 1;
} else {
if (m/\.(\d+)\.(\d+)$/) {
$reqmajor = $1;
$reqminor = $2;
$_ = $`;
} elsif (m/\.\=(\d+)\.(\d+)$/) {
$reqmajor = $1;
$reqminor = $2;
$_ = $`;
$strict = 1;
} elsif (m/\.(\d+)$/) {
$reqmajor = $1;
$reqminor = 0;
$_ = $`;
} elsif (m/\.\=(\d+)$/) {
$reqmajor = $1;
$reqminor = 0;
$strict = 1;
$_ = $`;
}
if (m/\.so$/) {
$_ = $`;
$sharedonly = 1;
}
}
{
my $libname=$_;
my $bestmajor=-1;
my $bestminor=-1;
my $found_shared;
my $found_unshared;
while(<>) {
chomp;
if (!$noshared && m/^lib$libname\.so\.(\d+)\.(\d+)$/) {
my $major = $1;
my $minor = $2;
if ($strict) {
if ($major > $reqmajor) {
print "Error: strict library too high\n";
exit(0);
}
if ($major < $reqmajor) {
next;
}
if ($minor < $reqminor) {
next;
}
$found_shared = 1;
$bestmajor = $major;
if ($minor >= $bestminor) {
$bestminor = $minor;
}
} else {
if ($major < $reqmajor || ($major == $reqmajor &&
$minor < $reqminor)) {
next;
}
$found_shared = 1;
if ($major > $bestmajor || ($major == $bestmajor &&
$minor > $bestminor)) {
$bestmajor = $major;
$bestminor = $minor;
}
}
} elsif (!$sharedonly && m/^lib$libname.a$/) {
$found_unshared = 1;
}
}
if ($found_shared) {
print "$libname.$bestmajor.$bestminor\n";
} elsif ($found_unshared) {
print "$libname.a\n";
} else {
print "Missing library\n";
}
}

View File

@ -1,6 +1,6 @@
#-*- mode: Fundamental; tab-width: 4; -*-
# ex:ts=4 sw=4 filetype=make:
FULL_REVISION=$$OpenBSD: bsd.port.mk,v 1.498 2001/11/15 02:07:05 espie Exp $$
FULL_REVISION=$$OpenBSD: bsd.port.mk,v 1.499 2001/11/17 10:39:19 espie Exp $$
# $FreeBSD: bsd.port.mk,v 1.264 1996/12/25 02:27:44 imp Exp $
# $NetBSD: bsd.port.mk,v 1.62 1998/04/09 12:47:02 hubertf Exp $
#
@ -771,7 +771,7 @@ DESCR?= ${PKGDIR}/DESCR${SUBPACKAGE}
# And create the actual files from sources
${WRKPKG}/PLIST${SUBPACKAGE}: ${PLIST}
@echo "@comment subdir=${FULLPKGPATH} cdrom=${PERMIT_PACKAGE_CDROM:L} ftp=${PERMIT_PACKAGE_FTP:L}" >$@.tmp
@self=${FULLPKGNAME${SUBPACKAGE}} exec ${MAKE} new-depends|sort -u >>$@.tmp
@self=${FULLPKGNAME${SUBPACKAGE}} exec ${MAKE} _solve-package-depends|sort -u >>$@.tmp
.if defined(NO_SHARED_LIBS)
@sed -e '/^!%%SHARED%%$$/r${PKGDIR}/PFRAG.no-shared${SUBPACKAGE}' \
-e '/^%%!SHARED%%$$/r${PKGDIR}/PFRAG.no-shared${SUBPACKAGE}' \
@ -1237,14 +1237,10 @@ _build_depends_fragment=${_fetch_depends_fragment}
_run_depends_fragment=${_fetch_depends_fragment}
_regress_depends_fragment=${_fetch_depends_fragment}
.if !defined(NO_SHARED_LIBS)
_sharedlib_resolve_fragment = \
lib=`echo $$d | sed -e 's|\.$$||' -e 's|\([^\\]\)\.|\1\\\\.|g'`; \
check=`eval $$listlibs |grep '^lib.*\.so\.*'| \
sed -e 's,^lib,,' -e 's,$$,.,' -e 's,\.so\.,.,' | \
grep "^$$lib\."|sed -e 's,\.$$,,'` || true
.if defined(NO_SHARED_LIBS)
_no_shared=-noshared
.else
_sharedlib_resolve_fragment = :
_noshared=
.endif
_libresolve_fragment = \
@ -1253,11 +1249,9 @@ _libresolve_fragment = \
d=$${d\#\#*/};; \
*) shprefix="" shdir="${LOCALBASE}/lib";; \
esac; \
${_sharedlib_resolve_fragment}; \
case "X$$check" in "X") \
lib=`echo $$d | sed -e 's|\([^\\]\)[\\\.].*|\1|'`; \
check=`eval $$listlibs | grep "^lib$$lib\.a$$"` || true;; \
esac
check=`eval $$listlibs| perl \
${PORTSDIR}/infrastructure/build/resolve-lib ${_noshared} $$d` \
|| true
_lib_depends_fragment = \
@ -1265,7 +1259,10 @@ _lib_depends_fragment = \
IFS=,; bad=false; for d in $$dep; do \
listlibs='ls $$shdir 2>/dev/null'; \
${_libresolve_fragment}; \
case "X$$check" in "X") bad=true; msg="$$msg $$d missing...";; esac; \
case "$$check" in \
Missing\ library) bad=true; msg="$$msg $$d missing...";; \
Error:*) bad=true; msg="$$msg $$d unsolvable...";; \
esac; \
done; $$bad || found=true
@ -2283,6 +2280,7 @@ _RUN_DEP2=
_RUN_DEP=
.endif
.if defined(FETCH_DEPENDS) || defined(BUILD_DEPENDS)
_BUILD_DEP2 = ${FETCH_DEPENDS:C/^[^:]*:([^:]*:[^:]*).*$/\1/} \
${BUILD_DEPENDS:C/^[^:]*:([^:]*:[^:]*).*$/\1/}
@ -2292,6 +2290,10 @@ _BUILD_DEP2=
_BUILD_DEP=
.endif
_LIB_DEP2= ${LIB_DEPENDS}
_RUN_DEP2+= ${_ALWAYS_DEP3}
_BUILD_DEP2+=${_ALWAYS_DEP3}
.if !target(clean-depends)
clean-depends:
. if !empty(_ALWAYS_DEP) || !empty(_BUILD_DEP) || !empty(_RUN_DEP)
@ -2329,14 +2331,12 @@ describe:
echo -n "/dev/null|"; \
fi; \
echo -n "${MAINTAINER}|${CATEGORIES}|"
. if !empty(_ALWAYS_DEP3) || !empty(_BUILD_DEP2)
@cd ${.CURDIR} && _FINAL_ECHO=: _INITIAL_ECHO=: exec ${MAKE} build-depends-list
. endif
@echo -n "|"
. if !empty(_ALWAYS_DEP3) || !empty(_RUN_DEP2)
@cd ${.CURDIR} && _FINAL_ECHO=: _INITIAL_ECHO=: exec ${MAKE} run-depends-list
. endif
. for _d in LIB BUILD RUN
. if !empty(_${_d}_DEP2)
@cd ${.CURDIR} && _FINAL_ECHO=: _INITIAL_ECHO=: exec ${MAKE} ${_d:L}-depends-list
. endif
@echo -n "|"
. endfor
@case "${ONLY_FOR_ARCHS}" in \
"") case "${NOT_FOR_ARCHS}" in \
"") echo -n "any|";; \
@ -2556,21 +2556,18 @@ dir-depends:
@echo "${FULLPKGPATH} ${FULLPKGPATH}"
.endif
.for _i in RUN BUILD
.for _i in RUN BUILD LIB
${_i:L}-depends-list:
. if !empty(_ALWAYS_DEP2) || !empty(_${_i}_DEP2)
. if !empty(_${_i}_DEP2)
@unset FLAVOR SUBPACKAGE || true; \
: $${_INITIAL_ECHO:='echo -n "This port requires \""'}; \
: $${_ECHO='echo -n'}; \
: $${_FINAL_ECHO:='echo "\" to ${_i:L}."'}; space=''; \
: $${_FINAL_ECHO:='echo "\" for ${_i:L}."'}; space=''; \
eval $${_INITIAL_ECHO}; \
for spec in `echo '${_ALWAYS_DEP2} ${_${_i}_DEP2}' \
for spec in `echo '${_${_i}_DEP2}' \
| tr '\040' '\012' | sort -u`; do \
dir=$${spec#*:}; pkg=$${spec%:*}; \
case X"$$pkg" in \
X) $${_ECHO} "$$space$${dir}";; \
*) $${_ECHO} "$$space$${pkg}:$${dir}";; \
esac; space=' '; \
$${_ECHO} "$$space$${spec}"; \
space=' '; \
done; eval $${_FINAL_ECHO}
. endif
.endfor
@ -2611,11 +2608,11 @@ package-dir-depends:
@echo "${FULLPKGPATH} ${FULLPKGPATH}"
.endif
new-depends:
.if !empty(_ALWAYS_DEP3) || !empty(_RUN_DEP2)
_solve-package-depends:
.if !empty(_RUN_DEP2)
@unset FLAVOR SUBPACKAGE || true; \
: $${self:=self}; \
for spec in `echo '${_ALWAYS_DEP3} ${_RUN_DEP2}' \
for spec in `echo '${_RUN_DEP2}' \
| tr '\040' '\012' | sort -u`; do \
dir=$${spec#*:}; pkg=$${spec%:*}; \
${_flavor_fragment}; \
@ -2623,7 +2620,7 @@ new-depends:
: $${pkg:=$$default}; \
echo "@newdepend $$self:$$pkg:$$default"; \
toset="$$toset self=\"$$default\""; \
if ! eval $$toset ${MAKE} new-depends; then \
if ! eval $$toset ${MAKE} _solve-package-depends; then \
echo 1>&2 "*** Problem checking deps in \"$$dir\"." ; \
exit 1; \
fi; \
@ -2647,12 +2644,12 @@ new-depends:
fi; \
IFS=,; for d in $$dep; do \
${_libresolve_fragment}; \
case "X$$check" in \
Xlib*.a) continue;; \
X) \
case "$$check" in \
*.a) continue;; \
Missing\ library|Error:*) \
echo 1>&2 "Can't resolve libspec $$d"; \
exit 1;; \
X*) \
*) \
libspecs="$$libspecs$$comma$$shprefix$$check"; \
comma=',';; \
esac; \
@ -2662,7 +2659,7 @@ new-depends:
*) \
echo "@libdepend $$self:$$libspecs:$$pkg:$$default"; \
toset="$$toset self=\"$$default\""; \
if ! eval $$toset ${MAKE} new-depends; then \
if ! eval $$toset ${MAKE} _solve-package-depends; then \
echo 1>&2 "*** Problem checking deps in \"$$dir\"." ; \
exit 1; \
fi;; \
@ -2763,7 +2760,7 @@ unlink-categories:
repackage run-depends tags uninstall fetch-all print-depends \
recurse-build-depends recurse-package-depends \
distpatch real-distpatch do-distpatch post-distpatch show \
link-categories unlink-categories _package new-depends \
link-categories unlink-categories _package _solve-package-depends \
dir-depends _recurse-dir-depends package-dir-depends \
_package-recurse-dir-depends recursebuild-depends-list run-depends-list \
bulk-packages bulk-do _recurse-lib-depends lib-depends-check