Date: Sat, 30 Jun 2007 14:24:49 -0400 (EDT) From: "Mikhail T." <mi@aldan.algebra.com> To: FreeBSD-gnats-submit@FreeBSD.org Subject: ports/114167: ignoring major numbers in LIB_DEPENDS (patch) Message-ID: <200706301824.l5UIOnW6052023@aldan.algebra.com> Resent-Message-ID: <200706301830.l5UIU2nK061477@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 114167 >Category: ports >Synopsis: ignoring major numbers in LIB_DEPENDS (patch) >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sat Jun 30 18:30:02 GMT 2007 >Closed-Date: >Last-Modified: >Originator: Mikhail T. >Release: FreeBSD 6.2-STABLE amd64 >Organization: Virtual Estates, Inc. >Environment: System: FreeBSD aldan.algebra.com 6.2-STABLE FreeBSD 6.2-STABLE #1: Thu Jun 7 22:11:33 EDT 2007 mi@aldan.algebra.com:/meow/obj/var/src/sys/SILVER-SMP amd64 >Description: Although specifying the major number of the shared library in a port's LIB_DEPENDS is neither mandatory nor needed in most circumstances, the practice is wide-spread. It is very rare, that a particular version is required. When a dependency-installed shlib changes, all dependants simply update their LIB_DEPENDS lines in a flurry of "chasing libfoo's major number" commits. A more important problem is one faced by people with already built/configured computers. Consider, for example, somebody, who has just built the entire KDE desktop. Three days later they may decide to add the Firefox browser, so they update their ports tree as advised (to get the latest version and security patches) and proceed. If, however, any of the ports used by both Firefox and KDE (such as the entire glib, JPEG, PNG, etc.) were updated during these few days, building firefox will fail, because firefox will require the new version of JPEG's (or PNG's, etc.) shared library, which will conflict with the one already installed. The person will then be faced with two rather poor options. Either rebuild the entire KDE, or use portupgrade to push the older version of libjpeg in the /usr/local/lib/compat/pkg. If neither the Firefox nor the already present KDE require whatever feature, that caused the JPEG (or PNG, etc.) library bump, the BEST solution is to make the new port (Firefox in this example) use the already present version of libjpeg, whatever it might be. The patch below makes it possible to tell bsd.port.mk to IGNORE the explicit major library numbers in all LIB_DEPENDS lines by defining a special IGNORE_SHLIB_NUMBERS knob to anything other than "no". The patch also changes bsd.port.mk to be stricter in its parsing the available inventory of shared library and to report the exact locations of the matching libraries. Adding the patch will not affect clean installs and it has no effect, unles the IGNORE_SHLIB_NUMBERS knob is set. Once the change is committed, make.conf(4) manual page can be updated to document the knob explaining its usual benefits and the occasional danger in those few cases, where the major number is, actually, important. >How-To-Repeat: >Fix: Index: bsd.port.mk =================================================================== RCS file: /home/pcvs/ports/Mk/bsd.port.mk,v retrieving revision 1.572 diff -U4 -r1.572 bsd.port.mk --- bsd.port.mk 28 Jun 2007 16:06:02 -0000 1.572 +++ bsd.port.mk 30 Jun 2007 01:02:44 -0000 @@ -5125,13 +5134,17 @@ lib-depends: .if defined(LIB_DEPENDS) && !defined(NO_DEPENDS) @for i in ${LIB_DEPENDS}; do \ lib=$${i%%:*}; \ - case $$lib in \ - *.*.*) pattern="`${ECHO_CMD} $$lib | ${SED} -e 's/\./\\\\./g'`" ;;\ - *.*) pattern="$${lib%%.*}\.$${lib#*.}" ;;\ - *) pattern="$$lib" ;;\ - esac; \ + if [ -n "${IGNORE_SHLIB_NUMBERS}" -a "${IGNORE_SHLIB_NUMBERS:L}" != "no" ]; then \ + pattern="$${lib%%.*}\."; \ + else \ + case $$lib in \ + *.*.*) pattern="`${ECHO_CMD} $$lib | ${SED} -e 's/\./\\\\./g'`$$" ;;\ + *.*) pattern="$${lib%%.*}\.$${lib#*.}$$" ;;\ + *) pattern="$$lib\." ;;\ + esac; \ + fi; \ dir=$${i#*:}; \ target=$${i##*:}; \ if ${TEST} $$dir = $$target; then \ target="${DEPENDS_TARGET}"; \ @@ -5140,10 +5153,12 @@ dir=$${dir%%:*}; \ fi; \ if [ -z "${DESTDIR}" ] ; then \ ${ECHO_MSG} -n "===> ${PKGNAME} depends on shared library: $$lib"; \ - if ${LDCONFIG} -r | ${GREP} -vwF -e "${PKGCOMPATDIR}" | ${GREP} -qwE -e "-l$$pattern"; then \ - ${ECHO_MSG} " - found"; \ + found=`${LDCONFIG} -r | ${AWK} -v skip="^${PKGCOMPATDIR:C,/+$,,}/" -v pat=":-l$$pattern" \ + '$$NF ~ skip {next} $$1 ~ pat { print $$NF; exit }'`; \ + if [ -n "$$found" ] ; then \ + ${ECHO_MSG} " - found ($$found)"; \ if [ ${_DEPEND_ALWAYS} = 1 ]; then \ ${ECHO_MSG} " (but building it anyway)"; \ notfound=1; \ else \ @@ -5173,11 +5188,15 @@ if [ ! -d "$$dir" ]; then \ ${ECHO_MSG} " => No directory for $$lib. Skipping.."; \ else \ ${_INSTALL_DEPENDS} \ - if ! ${LDCONFIG} -r | ${GREP} -vwF -e "${PKGCOMPATDIR}" | ${GREP} -qwE -e "-l$$pattern"; then \ - ${ECHO_MSG} "Error: shared library \"$$lib\" does not exist"; \ - ${FALSE}; \ + found=`${LDCONFIG} -r | ${AWK} -v skip="^${PKGCOMPATDIR:C,/+$,,}/" -v pat=":-l$$pattern" \ + '$$NF ~ skip {next} $$1 ~ pat { print $$NF; exit }'`; \ + if [ -z "$$found" ] ; then \ + ${ECHO_MSG} "Error: shared library \"$$lib\" was not installed"; \ + exit 1; \ + else \ + ${ECHO_MSG} "Shared library \"$$lib\" duly installed ($$found)"; \ fi; \ fi; \ fi; \ done >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200706301824.l5UIOnW6052023>