From owner-freebsd-ports@FreeBSD.ORG Sun May 20 04:53:07 2007 Return-Path: X-Original-To: freebsd-ports@freebsd.org Delivered-To: freebsd-ports@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id CFB2916A468 for ; Sun, 20 May 2007 04:53:07 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from mail2.fluidhosting.com (mx24.fluidhosting.com [204.14.89.7]) by mx1.freebsd.org (Postfix) with SMTP id 8914213C468 for ; Sun, 20 May 2007 04:53:07 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: (qmail 18727 invoked by uid 399); 20 May 2007 04:53:07 -0000 Received: from localhost (HELO lap.dougb.net) (dougb@dougbarton.us@127.0.0.1) by localhost with SMTP; 20 May 2007 04:53:07 -0000 X-Originating-IP: 127.0.0.1 Message-ID: <464FD431.50104@FreeBSD.org> Date: Sat, 19 May 2007 21:53:05 -0700 From: Doug Barton Organization: http://www.FreeBSD.org/ User-Agent: Thunderbird 2.0b2 (X11/20070116) MIME-Version: 1.0 To: Peter Jeremy References: <20070518140441.GA17685@lpthe.jussieu.fr> <464F868D.7020601@FreeBSD.org> <20070520002136.GJ1164@turion.vk2pj.dyndns.org> In-Reply-To: <20070520002136.GJ1164@turion.vk2pj.dyndns.org> Content-Type: multipart/mixed; boundary="------------060603030503070305080307" Cc: freebsd-ports@freebsd.org Subject: Re: Specs for saving old shared libs X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 May 2007 04:53:08 -0000 This is a multi-part message in MIME format. --------------060603030503070305080307 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Peter Jeremy wrote: > On 2007-May-19 16:21:49 -0700, Doug Barton wrote: >> I still feel that the only safe way to do this is to find the union of >> 'ldconfig -r' and 'pkg_info -L' and save those files, and those files only. > > That should be intersection, not union. Yeah, that's what I meant, sorry. Too much going on around at home today. I was visualizing the intersection, and thinking "where the two things come together," which came out "union" somehow. > I think this makes sense - > there is no point in backing up private .so files because these should > only be referenced by the port in question (and therefore the old .so > files should be unnecessary once the old port version is deleted). Ok, I've attached the patch that implements this feature for review. A full version of portmaster with this, and the other new features is at http://dougbarton.us/portmaster FYI, the bit of this patch that moves 'make clean' to after 'make package' is an unrelated bug fix, but it's needed here to make sure everything is happening in the right order for delete and install. Thanks to all those who weighed in, Doug -- This .signature sanitized for your protection --------------060603030503070305080307 Content-Type: text/plain; name="pm-shared-libs.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="pm-shared-libs.diff" --- portmaster 2007/05/19 22:02:44 1.167 +++ portmaster 2007/05/20 04:35:34 1.168 @@ -2,7 +2,7 @@ # Local version: 1.153 # $FreeBSD$ -# $Id: portmaster,v 1.167 2007/05/19 22:02:44 doug Exp $ +# $Id: portmaster,v 1.168 2007/05/20 04:35:34 doug Exp $ # Copyright (c) 2005-2007 Douglas Barton, All rights reserved # Please see detailed copyright below @@ -32,7 +32,7 @@ echo "portmaster version `grep "[$]FreeBSD:" $0 | cut -d ' ' -f 4`" echo '' echo 'Usage:' - echo "Common flags: [--force-config] [-CGgntv B|b uf|i D|d] [-m ]" + echo "Common flags: [--force-config] [-CGgntvx B|b uf|i D|d] [-m ]" echo "${0##*/} [Common flags] " echo "${0##*/} [Common flags] " echo "${0##*/} [Common flags] Multiple full names/paths from $pdb|$pd" @@ -67,6 +67,7 @@ echo '-n do not actually make or install any ports' echo '-t recurse dependencies thoroughly, using all-depends-list' echo '-v verbose output' + echo '-x save old shared libraries before deinstall' echo "-u unattended mode -- accept defaults for all but 'make config'" echo '-f always rebuild ports (overrides -i)' echo '-i interactive update mode' @@ -923,7 +924,7 @@ fi # Save switches for potential child processes -while getopts 'BCDGLRabde:fghilm:nop:r:stuv' COMMAND_LINE_ARGUMENT ; do +while getopts 'BCDGLRabde:fghilm:nop:r:stuvx' COMMAND_LINE_ARGUMENT ; do case "${COMMAND_LINE_ARGUMENT}" in B) NO_BACKUP=yes; ARGS="-B $ARGS" ;; C) DONT_PRE_CLEAN=yes; ARGS="-C $ARGS" ;; @@ -955,6 +956,7 @@ t) RECURSE_THOROUGH=yes; ARGS="-t $ARGS" ;; u) UNATTENDED=yes; ARGS="-u $ARGS" ;; v) VERBOSE=yes; ARGS="-v $ARGS" ;; + x) SAVE_SHARED=yes; ARGS="-x $ARGS" ;; *) usage ;; esac done @@ -1128,6 +1130,9 @@ IPC_SAVE=`mktemp -t ipc_save-$PARENT_PID` export CURRENT_DEPS_O CURRENT_DEPS_I IGNOREME_YES DISPLAY_LIST IPC_SAVE + PORTS_PREFIX=`make $PM_MAKE_ARGS -f$pd/Mk/bsd.port.mk -VPREFIX` + export PORTS_PREFIX + if [ -n "$INTERACTIVE_UPDATE" ]; then INTERACTIVE_YES=':' INTERACTIVE_NO=':' @@ -1580,6 +1585,21 @@ if [ -z "$NO_BACKUP" ]; then backup_package $upg_port fi + + if [ -n "$SAVE_SHARED" ]; then + ldconfig_out=`mktemp -t f-${PARENT_PID}-ldconfig` + ldconfig -r | sed 's#.* ##' | + grep -v ^${PORTS_PREFIX}/lib/compat > $ldconfig_out + + mkdir -p ${PORTS_PREFIX}/lib/compat/pkg + + for file in `pkg_info -q -L $upg_port | sort - $ldconfig_out | \ + uniq -d`; do + cp -p $file ${PORTS_PREFIX}/lib/compat/pkg/ + done + ldconfig -m ${PORTS_PREFIX}/lib/compat/pkg + fi + pkg_delete -f $upg_port || fail 'pkg_delete failed' if [ -n "$REPLACE_ORIGIN" ]; then @@ -1590,13 +1610,21 @@ fi fi -make $PM_MAKE_ARGS install clean NOCLEANDEPENDS=yes || { +make $PM_MAKE_ARGS install || { if [ -z "$NO_BACKUP" -a -n "$upg_port" ]; then echo '' echo "===>>> A backup package for $portdir should be located in $pkgrep" fi fail "Installation of new port failed";} +# Remove saved libs that match newly installed files +pkg_info -q -L $new_port | while read file; do + if [ -e "${PORTS_PREFIX}/lib/compat/pkg/${file##*/}" ]; then + unlink ${PORTS_PREFIX}/lib/compat/pkg/${file##*/} + fi +done +ldconfig -m ${PORTS_PREFIX}/lib/compat/pkg + # Implement storage of distfile information in the +CONTENTS file in the # same way that it will (hopefully, soon?) be implemented in bsd.port.mk # See http://www.freebsd.org/cgi/query-pr.cgi?pr=106483 @@ -1619,6 +1647,8 @@ make $PM_MAKE_ARGS package || fail 'Package creation of new port failed' echo " ===>>> Package can be found in $pkgrep" fi + +make $PM_MAKE_ARGS clean NOCLEANDEPENDS=yes # By now, if this file exists, it should be authoritative if [ -s "$req_deps" ]; then --------------060603030503070305080307--