# Problem with Updating by portupgrade -PP Option



## Hydrogen (Dec 27, 2008)

Hi all 

I have problem with updating a package (for example `nano') using portupgrade -PP option (using packages instead of ports), while no problem using ports only (I mean using portupgrade without -PP).

The following is the output of some utilities to clear the problem:


```
$ cd /usr/ports

$ portsnap update
Ports tree is already up to date.

$ pkg_version -v | grep -v =
bash-3.2.25                         <   needs updating (port has 3.2.39_1)
bison-2.3_3,1                       <   needs updating (port has 2.3_4,1)
...
nano-2.0.6                          <   needs updating (port has 2.0.9)
...
```


```
$ portupgrade -v -R -PP nano                                                  
--->  Session started at: Fri, 26 Dec 2008 15:41:13 +0000                                                             
** No need to upgrade 'libiconv-1.11_1' (>= libiconv-1.11_1). (specify -f to force)                                   
--->  ** Upgrade tasks 3: 0 done, 1 ignored, 0 skipped and 0 failed                                                   
** No need to upgrade 'gettext-0.17_1' (>= gettext-0.17_1). (specify -f to force)                                     
--->  ** Upgrade tasks 3: 0 done, 2 ignored, 0 skipped and 0 failed                                                   
--->  Checking for the latest package of 'editors/nano'                                                               
--->  Found a package of 'editors/nano': /usr/ports/packages/All/nano-2.0.6.tbz (nano-2.0.6)                          
--->  Fetching the package(s) for 'nano-2.0.9' (editors/nano)                                                         
--->  Fetching nano-2.0.9                                                                                             
++ Will try the following sites in the order named:
        ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/i386/packages-7.0-release/
--->  Invoking a command: /usr/bin/fetch -o '/var/tmp/portupgradeq6C9KJuN/nano-2.0.9.tbz' 'ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/i386/packages-7.0-release/All/nano-2.0.9.tbz'
fetch: ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/i386/packages-7.0-release/All/nano-2.0.9.tbz: File unavailable (e.g., file not found, no access)
** The command returned a non-zero exit status: 1
** Failed to fetch ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/i386/packages-7.0-release/All/nano-2.0.9.tbz
--->  Invoking a command: /usr/bin/fetch -o '/var/tmp/portupgradeq6C9KJuN/nano-2.0.9.tgz' 'ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/i386/packages-7.0-release/All/nano-2.0.9.tgz'
fetch: ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/i386/packages-7.0-release/All/nano-2.0.9.tgz: File unavailable (e.g., file not found, no access)
** The command returned a non-zero exit status: 1
** Failed to fetch ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/i386/packages-7.0-release/All/nano-2.0.9.tgz
** Failed to fetch nano-2.0.9
--->  Listing the results (+:done / -:ignored / *:skipped / !:failed)
        ! nano-2.0.9    (fetch error)
--->  Packages processed: 0 done, 0 ignored, 0 skipped and 1 failed
--->  Fetching the latest package(s) for 'nano' (editors/nano)
--->  Fetching nano
++ Will try the following sites in the order named:
        ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/i386/packages-7.0-release/
--->  Invoking a command: /usr/bin/fetch -o '/var/tmp/portupgradeWGg5o17Z/nano.tbz' 'ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/i386/packages-7.0-release/Latest/nano.tbz'
/var/tmp/portupgradeWGg5o17Z/nano.tbz         100% of  275 kB   35 kBps
--->  Downloaded as nano.tbz
--->  Identifying the package /var/tmp/portupgradeWGg5o17Z/nano.tbz
--->  Saved as /usr/ports/packages/All/nano-2.0.6.tbz
--->  Skipping libiconv-1.11_1 (already installed)
--->  Identifying the package /usr/ports/packages/All/gettext-0.16.1_3.tbz
--->  Listing the results (+:done / -:ignored / *:skipped / !:failed)
        + nano@
        - libiconv-1.11_1
        - gettext-0.16.1_3
--->  Packages processed: 1 done, 2 ignored, 0 skipped and 0 failed
--->  Found a package of 'editors/nano': /usr/ports/packages/All/nano-2.0.6.tbz (nano-2.0.6)
--->  Located a package version 2.0.6 (/usr/ports/packages/All/nano-2.0.6.tbz)
** Ignoring the package, which is the same version as is installed (2.0.6)
** No package available: editors/nano
--->  ** Upgrade tasks 3: 0 done, 2 ignored, 0 skipped and 1 failed
--->  Listing the results (+:done / -:ignored / *:skipped / !:failed)
        - converters/libiconv (libiconv-1.11_1)
        - devel/gettext (gettext-0.17_1)
        ! editors/nano (nano-2.0.6)     (package not found)
--->  Packages processed: 0 done, 2 ignored, 0 skipped and 1 failed
--->  Session ended at: Fri, 26 Dec 2008 15:42:55 +0000 (consumed 00:01:41)
```
It failed:

```
$ pkg_version -v | grep -i nano
$ nano-2.0.6                          <   needs updating (port has 2.0.9)
```

Executing without -PP :


```
$ portupgrade -v  nano
--->  Session started at: Fri, 26 Dec 2008 15:53:00 +0000
--->  Upgrade of editors/nano started at: Fri, 26 Dec 2008 15:53:01 +0000
--->  Upgrading 'nano-2.0.6' to 'nano-2.0.9' (editors/nano)              
--->  Build of editors/nano started at: Fri, 26 Dec 2008 15:53:01 +0000  
--->  Building '/usr/ports/editors/nano'                                 
===>  Cleaning for nano-2.0.9                                            
===>  Extracting for nano-2.0.9                                          
=> MD5 Checksum mismatch for nano-2.0.9.tar.gz.                          
=> SHA256 Checksum mismatch for nano-2.0.9.tar.gz.                       
===>  Refetch for 1 more times files: nano-2.0.9.tar.gz nano-2.0.9.tar.gz 
=> nano-2.0.9.tar.gz doesn't seem to exist in /usr/ports/distfiles/.      
=> Attempting to fetch from http://www.nano-editor.org/dist/v2.0/.        
nano-2.0.9.tar.gz                             100% of 1370 kB 8054  Bps 00m00s
=> MD5 Checksum OK for nano-2.0.9.tar.gz.                                     
=> SHA256 Checksum OK for nano-2.0.9.tar.gz.                                  
===>  Patching for nano-2.0.9                                                 
===>  Applying FreeBSD patches for nano-2.0.9                                 
===>   nano-2.0.9 depends on shared library: intl - found                     
===>  Configuring for nano-2.0.9                                              
checking...
[much output comes here]
```
Now, I have nano updated:

```
[root@myfb /usr/ports]# pkg_version -v | grep -i nano
nano-2.0.9                          =   up-to-date with port
```

Thank you all, in advance.


----------



## danger@ (Dec 27, 2008)

please have a look at this post:
http://forums.freebsd.org/showpost.php?p=6912&postcount=1


----------



## Hydrogen (Dec 27, 2008)

Thanks, useful.


```
uname -a
FreeBSD myfb 7.0-RELEASE FreeBSD 7.0-RELEASE #0: Sun Feb 24 19:59:52 UTC 2008     root@logan.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386
```

Yes, I am using 7.0-RELEASE version, and the point was that. Because, portupgrade -PP goes to get packages from ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-7-release in its default manner. So, to change this, I used this: http://www.hydrus.org.uk/journal/portupgrade.html
Briefly, since the portupgrade utility uses uname to determine the FreeBSD version running, and one can hack uname output by setting UNAME_r variable (see man uname), so I did the work successfully by:


```
env UNAME_r="7.0-STABLE" portupgrade -v -R -PP m4                                                                     
--->  Session started at: Fri, 26 Dec 2008 18:30:23 +0000                                                                                     
--->  Checking for the latest package of 'devel/m4'                                                                                           
--->  Fetching the package(s) for 'm4-1.4.11,1' (devel/m4)                                                                                    
--->  Fetching m4-1.4.11,1                                                                                                                    
++ Will try the following sites in the order named:                                                                                           
        [B]ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/i386/packages-7-stable/[/B]                                                                       
--->  Invoking a command: /usr/bin/fetch -o '/var/tmp/portupgradekNUYFxJE/m4-1.4.11,1.tbz' 'ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/i386/packages-7-stable/All/m4-1.4.11,1.tbz'                                                                                                                                           
/var/tmp/portupgradekNUYFxJE/m4-1.4.11,1.tbz  100% of  172 kB   14 kBps 00m00s
```

However, I think it's somehow a dirty way! Is there a standard good way to do this? For example setting a related variable (like the PACKAGESITE one for pkg_add you had mentioned in that post.)...


----------



## danger@ (Dec 27, 2008)

No, the standard way is to add PACKAGESITE variable to /etc/make.conf:

`# echo PACKAGESITE=ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-7-stable/Latest/ >> /etc/make.conf`

This should work better


----------



## Hydrogen (Dec 27, 2008)

Thank you for your quick replies 

But, as far as I know, portupgrade does NOT use the PACKAGESITE variable. I set it in make.conf and also in the command-line, but it did NOT work. 

There's also the /usr/local/etc/pkgtools.conf file with some parameters like the following:

```
#   Name:               Example values:
#   OS_RELEASE:         "7.0-CURRENT"   "6.1-RELEASE-p8"
#   OS_REVISION:        "7.0"           "6.1"
#   OS_MAJOR:           "7"             "6"
#   OS_BRANCH:          "CURRENT"       "RELEASE"
#   OS_PATCHLEVEL:      ""              "-p8"
#   OS_PLATFORM:        "i386"          "amd64"
#   OS_PKGBRANCH:       "7-current"     "6.1-release"
```
I also set some of this variables, but did get no result.


----------



## danger@ (Dec 27, 2008)

ah, indeed. You have to set


```
ENV['OS_PKGBRANCH'] = 7-stable
```
 in pkgtools.conf in the module PkgConfig part of that file.

I hope that one will work.


----------



## osx-addict (Jun 6, 2009)

danger@ said:
			
		

> ```
> ENV['OS_PKGBRANCH'] = 7-stable
> ```



I tried this and it didn't work for my 7.1 system.. I did the folowing :


```
OS_PKGBRANCH = '7-stable'
```

When running portupgrade I see the following, but it does work from what I can tell :


```
--->  Checking for the latest package of 'math/libgmp4'
--->  Found a package of 'math/libgmp4': /usr/ports/packages/All/libgmp-4.2.3.tbz (libgmp-4.2.3)
--->  Fetching the package(s) for 'libgmp-4.3.1' (math/libgmp4)
/usr/local/etc/pkgtools.conf:168: warning: already initialized constant OS_PKGBRANCH
--->  Fetching libgmp-4.3.1
/var/tmp/portupgradeJpkg9uC9/libgmp-4.3.1.tbz 100% of  429 kB  915 kBps
```


----------



## srinivas (Sep 11, 2010)

```
OS_BRANCH ||= 'STABLE
```

Does the trick while eliminating the "already initialized constant" warning.


----------



## srinivas (Sep 11, 2010)

Make that


```
OS_BRANCH ||= 'STABLE'
```

instead.


----------

