From nobody@FreeBSD.org  Sun Oct 17 19:08:34 2010
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 985F31065672
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 17 Oct 2010 19:08:34 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 8583F8FC12
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 17 Oct 2010 19:08:34 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o9HJ8XZn073754
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 17 Oct 2010 19:08:33 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id o9HJ8WMq073753;
	Sun, 17 Oct 2010 19:08:32 GMT
	(envelope-from nobody)
Message-Id: <201010171908.o9HJ8WMq073753@www.freebsd.org>
Date: Sun, 17 Oct 2010 19:08:32 GMT
From: Philip Christian <subs@christiantena.net>
To: freebsd-gnats-submit@FreeBSD.org
Subject: pkg_upgrade (sysutils/bsdadminscripts) not working if /usr/ports not present
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         151521
>Category:       ports
>Synopsis:       pkg_upgrade (sysutils/bsdadminscripts) not working if /usr/ports not present
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Oct 17 19:10:08 UTC 2010
>Closed-Date:    Thu Nov 04 05:29:16 UTC 2010
>Last-Modified:  Mon Feb  6 03:30:07 UTC 2012
>Originator:     Philip Christian
>Release:        8.0
>Organization:
None
>Environment:
FreeBSD mail 8.0-RELEASE FreeBSD 8.0-RELEASE #2: Mon Mar 15 12:13:05 GMT 2010     root@freebsd:/usr/obj/usr/src/sys/NET5501  i386
>Description:
pkg_upgrade from bsdadminscripts-6.1.1 does not work if /usr/ports is not present on the system.

# ./usr/local/sbin/pkg_upgrade -an
cd: can't cd to /usr/ports
cd: can't cd to /usr/ports
fetch: ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-8-release/INDEX: File unavailable (e.g., file not found, no access)

In my opinion it would be more user friendly if the script creates any directories that it needs (maybe prompt user for permission?) rather than just failing.
>How-To-Repeat:
Build FreeBSD system but don't install ports collection
pkg_add -r bsdadminscripts
./usr/local/sbin/pkg_upgrade -an
>Fix:
modify script to check if directories that it needs are present and create them if not.

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-ports-bugs 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Sat Oct 23 07:46:10 UTC 2010 
Responsible-Changed-Why:  
ports PR. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=151521 

From: Dominic Fandrey <kamikaze@bsdforen.de>
To: bug-followup@FreeBSD.org, subs@christiantena.net
Cc:  
Subject: Re: ports/151521: pkg_upgrade (sysutils/bsdadminscripts) not working
 if /usr/ports not present
Date: Mon, 25 Oct 2010 14:38:31 +0200

 This is fixed upstream. There'll be a CFT by the end of the week,
 should my health allow it.
 
 Thank you for the report!
 
 Regards
State-Changed-From-To: open->closed 
State-Changed-By: miwi 
State-Changed-When: Thu Nov 4 05:29:15 UTC 2010 
State-Changed-Why:  
duplicate, and both is fixed in upstream. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=151521 

From: Alvin Poon <aspoon@gmail.com>
To: bug-followup@FreeBSD.org, subs@christiantena.net
Cc:  
Subject: Re: ports/151521: pkg_upgrade (sysutils/bsdadminscripts) not working
 if /usr/ports not present
Date: Mon, 6 Feb 2012 11:01:29 +0800

 The problem resurfaces as 9-RELEASE is available:
 
 # pkg_upgrade -aC
 fetch: ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-9-release/INDEX:
 File unavailable (e.g., file not found, no access)
 #
 
 It appears to be a problem with the name "packages-9-release", as the
 folder available on FTP is actually "packages-9.0-release".  (note the
 .0 in the version)  Once the system switches to stable releases such
 as "packages-9-stable" it should work fine. (as packages-9-stable is
 available on FTP)
 
 The problem is found in /usr/local/sbin/uma, line 76 onwards:
 
      71 # Logic from src/usr.sbin/pkg_install/add/main.c, plus the
 possibility to
      72 # override the architecture with ARCH.
      73 : ${PACKAGEROOT="ftp://ftp.freebsd.org"}
      74 : ${ARCH="$(uname -m)"}
      75 branch="$(uname -r | tr '[:upper:]' '[:lower:]')"
      76 number="${branch%%.*}"
      77 branch="${branch##*-}"
      78 case "$branch" in
      79         release)
      80                 branch=$number-$branch
      81         ;;
      82         stable|current)
      83                 branch=${number%%.*}-$branch
      84         ;;
      85         *)
      86                 # Fallback to stable for prerelease and the like.
      87                 branch=${number%%.*}-stable
      88         ;;
      89 esac
 
 It arbitrarily removed the .x minor version from the number.  It
 should have been "number=${branch%%-*}", since the minor version is
 further stripped off in the following case statements depending on the
 release.
>Unformatted:
