From owner-freebsd-ports-bugs@FreeBSD.ORG Tue Apr 27 17:20:04 2010 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EACDF1065670 for ; Tue, 27 Apr 2010 17:20:04 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id A56398FC0A for ; Tue, 27 Apr 2010 17:20:04 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id o3RHK467046122 for ; Tue, 27 Apr 2010 17:20:04 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id o3RHK4x5046119; Tue, 27 Apr 2010 17:20:04 GMT (envelope-from gnats) Date: Tue, 27 Apr 2010 17:20:04 GMT Message-Id: <201004271720.o3RHK4x5046119@freefall.freebsd.org> To: freebsd-ports-bugs@FreeBSD.org From: "Matthias Andree" Cc: Subject: Re: ports/145984: [PATCH] ports-mgmt/portmaster: Fix abort with --index and local port not yet in ports X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Matthias Andree List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Apr 2010 17:20:05 -0000 The following reply was made to PR ports/145984; it has been noted by GNATS. From: "Matthias Andree" To: bug-followup@freebsd.org, "Doug Barton" Cc: Subject: Re: ports/145984: [PATCH] ports-mgmt/portmaster: Fix abort with --index and local port not yet in ports Date: Tue, 27 Apr 2010 19:15:41 +0200 ------------HAkDBBQl0dXpeSekg5q5g0 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes Content-Transfer-Encoding: 8bit I spoke too soon, and can in fact pinpoint the bug and propose a new patch. This only affects ports that have no matching INDEX lines for their origin, for instance, if they got removed (at least if the MOVED entry is missing - not sure if that is checked before or after the version), or for local ports that aren't reflected in /usr/ports and the INDEX. In that situation, check_for_updates() calls parse_index() with the origin, prints nothing (for lack of a matched INDEX lines), check_for_updates gets called with one argument. pkg_version -t then complains as seen below, because you don't quote strings on the assumption that they are neither empty nor contain characters from IFS, or shell meta characters. For debugging, I added one statement before line 1170 that reads: echo > &2 "DEBUG: argv=$# args=$@", and also encapsulated PM_INDEX/parse_index stuff in check_for_updates in set -x...set +x to actually see what I described above. I am proposing the attached new patch. Inlined here for easier perusal: Index: files/portmaster.sh.in =================================================================== RCS file: /home/pcvs/ports/ports-mgmt/portmaster/files/portmaster.sh.in,v retrieving revision 2.22 diff -u -r2.22 portmaster.sh.in --- files/portmaster.sh.in 11 Apr 2010 22:41:21 -0000 2.22 +++ files/portmaster.sh.in 27 Apr 2010 17:07:28 -0000 @@ -1211,7 +1211,11 @@ if [ -n "$PM_INDEX" ]; then port_ver=`parse_index $origin name` - check_pkg_version $iport $port_ver || { do_update=update_index ; } + if [ -z "$port_ver" ] ; then + echo " ===>>> Warning: No INDEX entry for $origin" + else + check_pkg_version $iport $port_ver || { do_update=update_index ; } + fi fi if [ -d "$pd/$origin" -a -z "$do_update" -a -z "$PM_INDEX_ONLY" ]; then To reproduce, install a port that isn't in INDEX, or just modify the origin of one port so that it doesn't match the origin of any port, for instance, modify the ORIGIN of the db50 port read databases/db55 (which doesn't exist). Remember to clean that up after testing. :) HTH Debug output: + set +x + [ -n /tmp/INDEX-8 ] + parse_index databases/db50 name + local pd line + [ -z /usr/ports -a -n '' ] + grep -m1 '.*|/usr/ports/databases/db50|.*' /tmp/INDEX-8 + line='db50-5.0.21.0|/usr/ports/databases/db50|/usr/local|The Oracle Berkeley DB, revision 5.0|/usr/ports/databases/db50/pkg-descr|mandree@FreeBSD.org|databases java|gettext-0.17_1 gmake-3.81_3 libiconv-1.13.1_1||http://www.oracle.com/database/berkeley-db/index.html|||' + echo db50-5.0.21.0 + port_ver=db50-5.0.21.0 + check_pkg_version db50-5.0.21.0 db50-5.0.21.0 + local iport port_ver udf + iport=db50-5.0.21.0 + port_ver=db50-5.0.21.0 + udf='' + echo 'DEBUG: argv=2 args=db50-5.0.21.0' db50-5.0.21.0 DEBUG: argv=2 args=db50-5.0.21.0 db50-5.0.21.0 + pkg_version -t db50-5.0.21.0 db50-5.0.21.0 + return + set +x + [ -n /tmp/INDEX-8 ] + parse_index databases/db51 name + local pd line + [ -z /usr/ports -a -n '' ] + grep -m1 '.*|/usr/ports/databases/db51|.*' /tmp/INDEX-8 + line='' + echo + port_ver='' + check_pkg_version db51-5.1.21.0 + local iport port_ver udf + iport=db51-5.1.21.0 + port_ver='' + udf='' + echo 'DEBUG: argv=1 args=db51-5.1.21.0' DEBUG: argv=1 args=db51-5.1.21.0 + pkg_version -t db51-5.1.21.0 pkg_version: Invalid -t usage. + do_update=update_index + set +x ===>>> Launching child to update db51-5.1.21.0 ===>>> No /usr/ports/databases/db51 exists, and no information ===>>> about databases/db51 can be found in /usr/ports/MOVED ===>>> No valid installed port, or port directory given ===>>> Try portmaster --help ===>>> Update for db51-5.1.21.0 failed ===>>> Aborting update Terminated Terminated -- Matthias Andree ------------HAkDBBQl0dXpeSekg5q5g0 Content-Disposition: attachment; filename=portmaster.diff Content-Type: application/octet-stream; name=portmaster.diff Content-Transfer-Encoding: Base64 SW5kZXg6IGZpbGVzL3BvcnRtYXN0ZXIuc2guaW4KPT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PQpSQ1MgZmlsZTogL2hvbWUvcGN2cy9wb3J0cy9wb3J0cy1tZ210L3BvcnRtYXN0 ZXIvZmlsZXMvcG9ydG1hc3Rlci5zaC5pbix2CnJldHJpZXZpbmcgcmV2aXNpb24g Mi4yMgpkaWZmIC11IC1yMi4yMiBwb3J0bWFzdGVyLnNoLmluCi0tLSBmaWxlcy9w b3J0bWFzdGVyLnNoLmluCTExIEFwciAyMDEwIDIyOjQxOjIxIC0wMDAwCTIuMjIK KysrIGZpbGVzL3BvcnRtYXN0ZXIuc2guaW4JMjcgQXByIDIwMTAgMTc6MDc6Mjgg LTAwMDAKQEAgLTEyMTEsNyArMTIxMSwxMSBAQAogCiAJaWYgWyAtbiAiJFBNX0lO REVYIiBdOyB0aGVuCiAJCXBvcnRfdmVyPWBwYXJzZV9pbmRleCAkb3JpZ2luIG5h bWVgCi0JCWNoZWNrX3BrZ192ZXJzaW9uICRpcG9ydCAkcG9ydF92ZXIgfHwgeyBk b191cGRhdGU9dXBkYXRlX2luZGV4IDsgfQorCQlpZiBbIC16ICIkcG9ydF92ZXIi IF0gOyB0aGVuCisJCQllY2hvICIJPT09Pj4+IFdhcm5pbmc6IE5vIElOREVYIGVu dHJ5IGZvciAkb3JpZ2luIgorCQllbHNlCisJCQljaGVja19wa2dfdmVyc2lvbiAk aXBvcnQgJHBvcnRfdmVyIHx8IHsgZG9fdXBkYXRlPXVwZGF0ZV9pbmRleCA7IH0K KwkJZmkKIAlmaQogCiAJaWYgWyAtZCAiJHBkLyRvcmlnaW4iIC1hIC16ICIkZG9f dXBkYXRlIiAtYSAteiAiJFBNX0lOREVYX09OTFkiIF07IHRoZW4K ------------HAkDBBQl0dXpeSekg5q5g0--