# Small Issue With Updating Ports



## churchi (Jan 27, 2011)

Hi All

I haven't updated my system in quite a while and it seems there are lots of packages to update. The problem is the usual command that i run: portmaster -a
is not working. it is not updating the packages.

Example:

```
[root@server-01 /usr/ports/ports-mgmt/portmaster]# portsnap fetch update && portmaster -a
Looking up portsnap.FreeBSD.org mirrors... 5 mirrors found.
Fetching snapshot tag from portsnap6.FreeBSD.org... done.
Latest snapshot on server matches what we already have.
No updates needed.
Ports tree is already up to date.
===>>> Gathering distinfo list for installed ports

===>>> Starting check of installed ports for available updates
===>>> Launching child to update binutils-2.20.1_3 to binutils-2.21

===>>> Port directory: /usr/ports/devel/binutils

===>>> Launching 'make checksum' for devel/binutils in background
===>>> Gathering dependency list for devel/binutils from ports
===>>> Initial dependency check complete for devel/binutils
===>>> Returning to update check of installed ports

===>>> Launching child to update cmake-2.8.2 to cmake-2.8.3_1

===>>> Port directory: /usr/ports/devel/cmake

===>>> Launching 'make checksum' for devel/cmake in background
===>>> Gathering dependency list for devel/cmake from ports
===>>> No dependencies for devel/cmake
===>>> Returning to update check of installed ports

===>>> Launching child to update en-freebsd-doc-20100926 to en-freebsd-doc-20110110

===>>> Port directory: /usr/ports/misc/freebsd-doc-en

===>>> Launching 'make checksum' for misc/freebsd-doc-en in background
===>>> Gathering dependency list for misc/freebsd-doc-en from ports
===>>> Initial dependency check complete for misc/freebsd-doc-en
===>>> Returning to update check of installed ports

===>>> Launching child to update libnet11-1.1.2.1_2,1 to libnet11-1.1.2.1_3,1

===>>> Port directory: /usr/ports/net/libnet

===>>> Launching 'make checksum' for net/libnet in background
===>>> Gathering dependency list for net/libnet from ports
===>>> No dependencies for net/libnet
===>>> Returning to update check of installed ports

===>>> Launching child to update nasm-2.08.02,1 to nasm-2.09.04,1

===>>> Port directory: /usr/ports/devel/nasm

===>>> Launching 'make checksum' for devel/nasm in background
===>>> Gathering dependency list for devel/nasm from ports
===>>> Initial dependency check complete for devel/nasm
===>>> Returning to update check of installed ports

===>>> Launching child to update screen-4.0.3_8 to screen-4.0.3_10

===>>> Port directory: /usr/ports/sysutils/screen

===>>> Launching 'make checksum' for sysutils/screen in background
===>>> Gathering dependency list for sysutils/screen from ports
===>>> No dependencies for sysutils/screen
===>>> Returning to update check of installed ports

===>>> Launching child to update smartmontools-5.39.1 to smartmontools-5.40

===>>> Port directory: /usr/ports/sysutils/smartmontools

===>>> Launching 'make checksum' for sysutils/smartmontools in background
===>>> Gathering dependency list for sysutils/smartmontools from ports
===>>> Initial dependency check complete for sysutils/smartmontools
===>>> Returning to update check of installed ports

===>>> Launching child to update php5-mysql-5.3.3_2 to php5-mysql-5.3.5

===>>> Port directory: /usr/ports/databases/php5-mysql

===>>> Gathering dependency list for databases/php5-mysql from ports
===>>> Initial dependency check complete for databases/php5-mysql
===>>> Returning to update check of installed ports

===>>> Launching child to update php5-openssl-5.3.3_2 to php5-openssl-5.3.5

===>>> Port directory: /usr/ports/security/php5-openssl

===>>> Gathering dependency list for security/php5-openssl from ports
===>>> Initial dependency check complete for security/php5-openssl
===>>> Returning to update check of installed ports

===>>> Launching child to update php5-pdo-5.3.3_2 to php5-pdo-5.3.5

===>>> Port directory: /usr/ports/databases/php5-pdo

===>>> Gathering dependency list for databases/php5-pdo from ports
===>>> Initial dependency check complete for databases/php5-pdo
===>>> Returning to update check of installed ports

===>>> Launching child to update php5-pdo_sqlite-5.3.3_2 to php5-pdo_sqlite-5.3.5

===>>> Port directory: /usr/ports/databases/php5-pdo_sqlite

===>>> Gathering dependency list for databases/php5-pdo_sqlite from ports
===>>> Launching child to update sqlite3-3.7.2 to sqlite3-3.7.4
        php5-pdo_sqlite-5.3.3_2 >> sqlite3-3.7.2

===>>> Port directory: /usr/ports/databases/sqlite3

===>>> Launching 'make checksum' for databases/sqlite3 in background
===>>> Gathering dependency list for databases/sqlite3 from ports
===>>> Initial dependency check complete for databases/sqlite3
        php5-pdo_sqlite-5.3.3_2 >> sqlite3-3.7.2 
===>>> Continuing initial dependency check for databases/php5-pdo_sqlite
===>>> Initial dependency check complete for databases/php5-pdo_sqlite
===>>> Returning to update check of installed ports

===>>> Launching child to update php5-posix-5.3.3_2 to php5-posix-5.3.5

===>>> Port directory: /usr/ports/sysutils/php5-posix


===>>> Launching child to update php5-zlib-5.3.3_2 to php5-zlib-5.3.5

===>>> Port directory: /usr/ports/archivers/php5-zlib

===>>> Gathering dependency list for archivers/php5-zlib from ports
===>>> Initial dependency check complete for archivers/php5-zlib
===>>> Returning to update check of installed ports

===>>> Launching child to update schroedinger-1.0.9 to schroedinger-1.0.10

===>>> Port directory: /usr/ports/multimedia/schroedinger

===>>> Launching 'make checksum' for multimedia/schroedinger in background
===>>> Gathering dependency list for multimedia/schroedinger from ports
===>>> Initial dependency check complete for multimedia/schroedinger
===>>> Returning to update check of installed ports

===>>> Launching child to update x264-0.0.20100624 to x264-0.110.1820

===>>> Port directory: /usr/ports/multimedia/x264

===>>> Launching 'make checksum' for multimedia/x264 in background
===>>> Gathering dependency list for multimedia/x264 from ports
===>>> Initial dependency check complete for multimedia/x264
===>>> Returning to update check of installed ports

===>>> Launching child to update adminer-2.3.2 to adminer-3.1.0_1

===>>> Port directory: /usr/ports/databases/adminer

===>>> Launching 'make checksum' for databases/adminer in background
===>>> Gathering dependency list for databases/adminer from ports
===>>> Launching child to install databases/php5-mssql
        adminer-2.3.2 >> databases/php5-mssql

===>>> Port directory: /usr/ports/databases/php5-mssql

===>>> Gathering dependency list for databases/php5-mssql from ports
===>>> Launching child to install databases/freetds-msdblib
        adminer-2.3.2 >> databases/php5-mssql >> databases/freetds-msdblib

===>>> Port directory: /usr/ports/databases/freetds-msdblib

===>>> Launching 'make checksum' for databases/freetds-msdblib in background
===>>> Gathering dependency list for databases/freetds-msdblib from ports
===>>> Initial dependency check complete for databases/freetds-msdblib
        adminer-2.3.2 >> databases/php5-mssql >> databases/freetds-msdblib 
===>>> Continuing initial dependency check for databases/php5-mssql
===>>> Initial dependency check complete for databases/php5-mssql
        adminer-2.3.2 >> databases/php5-mssql 
===>>> Continuing initial dependency check for databases/adminer
===>>> Launching child to install databases/php5-odbc
        adminer-2.3.2 >> databases/php5-odbc

===>>> Port directory: /usr/ports/databases/php5-odbc

===>>> Gathering dependency list for databases/php5-odbc from ports
===>>> Launching child to install databases/unixODBC
        adminer-2.3.2 >> databases/php5-odbc >> databases/unixODBC

===>>> Port directory: /usr/ports/databases/unixODBC

===>>> Launching 'make checksum' for databases/unixODBC in background
===>>> Gathering dependency list for databases/unixODBC from ports
===>>> Initial dependency check complete for databases/unixODBC
        adminer-2.3.2 >> databases/php5-odbc >> databases/unixODBC 
===>>> Continuing initial dependency check for databases/php5-odbc
===>>> Initial dependency check complete for databases/php5-odbc
        adminer-2.3.2 >> databases/php5-odbc 
===>>> Continuing initial dependency check for databases/adminer
===>>> Launching child to install databases/php5-pgsql
        adminer-2.3.2 >> databases/php5-pgsql

===>>> Port directory: /usr/ports/databases/php5-pgsql

===>>> Gathering dependency list for databases/php5-pgsql from ports
===>>> Launching child to install databases/postgresql84-client
        adminer-2.3.2 >> databases/php5-pgsql >> databases/postgresql84-client

===>>> Port directory: /usr/ports/databases/postgresql84-client

===>>> Launching 'make checksum' for databases/postgresql84-client in background
===>>> Gathering dependency list for databases/postgresql84-client from ports
===>>> Initial dependency check complete for databases/postgresql84-client
        adminer-2.3.2 >> databases/php5-pgsql >> databases/postgresql84-client 
===>>> Continuing initial dependency check for databases/php5-pgsql
===>>> Initial dependency check complete for databases/php5-pgsql
        adminer-2.3.2 >> databases/php5-pgsql 
===>>> Continuing initial dependency check for databases/adminer
===>>> Initial dependency check complete for databases/adminer
===>>> Returning to update check of installed ports


===>>> The devel/automake19 port has been deleted: No longer required by any port
===>>> Aborting update

Terminated
[root@server-01 /usr/ports/ports-mgmt/portmaster]#
```

Can anyone point me in the right direction on how i can fix the updating issue?

Thanks.


----------



## DutchDaemon (Jan 27, 2011)

Do not run [cmd=]portmaster -a[/cmd] or [cmd=]portupgrade -a[/cmd] 

There are plenty of threads about why not to use that shotgun approach. 

Find out when you last updated your ports, consult /usr/ports/UPDATING for instructions for ports you have installed, or run [cmd=]/usr/sbin/pkg_updating -d yyyymmdd[/cmd] (use approximate date of last update). 

If there's too much to update (and I bet there is, even after a couple of months), use the approach at the end of portmaster(8) ("Using portmaster to do a complete reinstallation of all your ports").


----------



## vand777 (Jan 27, 2011)

churchi said:
			
		

> Hi All
> 
> I haven't updated my system in quite a while and it seems there are lots of packages to update. The problem is the usual command that i run: portmaster -a
> is not working. it is not updating the packages.
> ...



As *DutchDaemon* pointed out, before you start the update you should always read /usr/ports/UPDATING to see whether your ports need special treatment during the update process:

```
...
20101208:
  AFFECTS: autotools
  AUTHOR: autotools@FreeBSD.org

  Another stage in the autotools cleanup that reduces tree churn whilst
  updating components, a number of ports have now moved to non-versioned
  locations since there is now only the concept of legacy and current
  versions.

  # portmaster -o devel/autoconf devel/autoconf268
  # portmaster -o devel/automake devel/automake111
  # portmaster -o devel/libtool devel/libtool22
  # portmaster -o devel/libltdl devel/libltdl22

  substitute 'portupgrade' for 'portmaster' accordingly if that's your
  your upgrade tool of choice.

...

20101204:
  AFFECTS: autotools
  AUTHOR: autotools@FreeBSD.org

  The next stage in the ongoing cleanup of autotools-using ports is
  a refactoring of bsd.autotools.mk so that version numbers are no longer
  needed within the USE_AUTOTOOLS stanza.  There is either
  autoconf213/autoconf or automake14/automake (for the legacy versions,
  and the currently available versions).  This will considerably reduce
  the amount of tree-wide patching in future on an update.

  IMPORTANT: if you have either devel/autoconf-wrapper or
  devel/automake-wrapper installed on your system (and you most likely do)
  PLEASE update these ports to their new versions before updating anything
  else -- Bad Things[tm] are likely to happen otherwise.

...

 20100915:
  AFFECTS: autoconf, automake
  AUTHOR: autotools@FreeBSD.org

  autoconf has been updated from 2.62 to 2.67 -- all ports depending on
  autoconf-2.62 have had their PORTREVISIONs update, so a standard
  port updating method will suffice.

  USE_GETTEXT has been extended to also accept 'build' and 'run' for
  ports which need devel/gettext as a BUILD- or RUN-time dependency only.
  No port should now be directly depending on devel/gettext in Makefiles.

...

20070727:
  AFFECTS: autotools
  AUTHOR: ade@FreeBSD.org

  Extensive reworking of the autotools ports has occurred, putting them in
  the canonical locations, along with a suitable wrapper port to make
  developing autotools-using code (as opposed to just building ports)
  considerably easier.

  Upgrade path is as follows for portupgrade:

    1. portupgrade -f 'autoconf*' 'automake*'
    2. cd /usr/ports/devel/autotools; make install
    3. portupgrade -a

  For portmaster:

    1. portmaster autoconf automake
    2. portmaster devel/autotools
    3. portmaster -a

  The second step is optional, but is recommended to bring in all versions
  of autoconf and automake.

...
```
Looking at you ports versions, you should ignore the advice from 2007.07.27, imho.


----------



## churchi (Jan 27, 2011)

DutchDaemon said:
			
		

> Do not run [cmd=]portmaster -a[/cmd] or [cmd=]portupgrade -a[/cmd]
> 
> There are plenty of threads about why not to use that shotgun approach.
> 
> ...



Thanks DutchDaemon,

I have run the command

```
[root@server-01 /home/churchi]# /usr/sbin/pkg_updating -d 20100701
20101029:
  AFFECTS: users of ports-mgmt/portmaster
  AUTHOR: Doug Barton <dougb@FreeBSD.org>

  The changes to bsd.port.mk in 1.652 require all portmaster users to
  upgrade to version 3.1 or later.  The best method to do this will be
  to use the port, rather than portmaster itself:

  # pkg_delete -f portmaster\*
  # cd /usr/ports/ports-mgmt/portmaster && make clean && make install clean

20100912:
  AFFECTS: ftp/curl
  AUTHOR: roam@FreeBSD.org

  With version 7.21.1, the cURL port is built with stricter compiler
  checking by default (the -Werror flag is passed to the C compiler,
  making it treat any warnings as fatal errors).  If you experience
  problems building cURL, re-run "make config" in the ftp/curl
  directory and disable the WERROR knob.

20100907:
  AFFECTS: sysutils/pecl-fileinfo
  AUTHOR: ale@FreeBSD.org

  If you are using php 5.3 (lang/php5) and fileinfo extension, you
  should switch to sysutils/php5-fileinfo port:

        portmaster -o sysutils/php5-fileinfo sysutils/pecl-fileinfo

20100727:
  AFFECTS: users of security/libgcrypt
  AUTHOR: wxs@FreeBSD.org

  libgcrypt has been upgraded to 1.4.6 which has a shared library version
  bump.  You need to reinstall all ports that depend on it.  Use something
  like this:

        portupgrade -rf libgcrypt
        portmaster -r libgcrypt

[root@server-01 /home/churchi]
```

I have completed the following as well

```
20101208:
  AFFECTS: autotools
  AUTHOR: autotools@FreeBSD.org

  Another stage in the autotools cleanup that reduces tree churn whilst
  updating components, a number of ports have now moved to non-versioned
  locations since there is now only the concept of legacy and current
  versions.

  # portmaster -o devel/autoconf devel/autoconf268
  # portmaster -o devel/automake devel/automake111
  # portmaster -o devel/libtool devel/libtool22
  # portmaster -o devel/libltdl devel/libltdl22

  substitute 'portupgrade' for 'portmaster' accordingly if that's your
  your upgrade tool of choice.

...

20101204:
  AFFECTS: autotools
  AUTHOR: autotools@FreeBSD.org

  The next stage in the ongoing cleanup of autotools-using ports is
  a refactoring of bsd.autotools.mk so that version numbers are no longer
  needed within the USE_AUTOTOOLS stanza.  There is either
  autoconf213/autoconf or automake14/automake (for the legacy versions,
  and the currently available versions).  This will considerably reduce
  the amount of tree-wide patching in future on an update.

  IMPORTANT: if you have either devel/autoconf-wrapper or
  devel/automake-wrapper installed on your system (and you most likely do)
  PLEASE update these ports to their new versions before updating anything
  else -- Bad Things[tm] are likely to happen otherwise.

...

 20100915:
  AFFECTS: autoconf, automake
  AUTHOR: autotools@FreeBSD.org

  autoconf has been updated from 2.62 to 2.67 -- all ports depending on
  autoconf-2.62 have had their PORTREVISIONs update, so a standard
  port updating method will suffice.

  USE_GETTEXT has been extended to also accept 'build' and 'run' for
  ports which need devel/gettext as a BUILD- or RUN-time dependency only.
  No port should now be directly depending on devel/gettext in Makefiles.
```

Would you suggest i rebuild all of my ports using this:

```
Using portmaster to do a complete reinstallation of all your ports:
	   1. portmaster --list-origins > ~/installed-port-list
	   2. Update your ports tree
	   3. portmaster --clean-distfiles-all
	   4. portmaster --check-port-dbdir
	   5. portmaster -Faf
	   6. pkg_delete '*'
	   7. rm -rf /usr/local/lib/compat/pkg
	   8. Manually check /usr/local and /var/db/pkg
	      to make sure that they are really empty
	   9. Re-install portmaster
	   10. portmaster `cat ~/installed-port-list`
```

I have:
===>>> 280 total installed ports
        ===>>> 85 have new versions available

So i believe i have quite a number of ports to update.

Thanks.


----------



## DutchDaemon (Jan 27, 2011)

With those numbers, and considering the intricacies of compiling ports recursively in the correct order (as per /usr/ports/UPDATING), I advise you to wipe and reinstall everything.

Make sure you backup files you want to keep under /usr/local/, e.g. configuration files in /usr/local/etc/, and possibly more, like websites under /usr/local/www/, etc.. Or just backup all of /usr/local/, which should not be more than 1-2 GB, usually less on servers.


----------



## churchi (Jan 28, 2011)

ok thanks for that. So in the future what could i have done to not have this problem? should i maintain my system so i get into a routine of upgrading/updating ports on a weekly or monthly basis? or course following the UPDATING guidelines. i have not updated the ports on my system for just under 5-6 months. i guess that is far too long?

could you give me some pointers on how i should regularly keep my system up to date so i don't have this issue again?

Thank you


----------



## DutchDaemon (Jan 28, 2011)

Well, this depends on available time and the amount of servers, but there are several strategies, ranging from using packages only (saving the hassle of having to compile at the cost of being slightly behind the times in terms of versions, and not having the option to choose specific port options), to not updating any ports at all, except those flagged by ports-mgmt/portaudit, all the way to looking for new ports each and every day, or at least once a week, and installing/upgrading new ports very frequently (with an eye on /usr/ports/UPDATING at all times).

My personal choice is to check for updates every day, and to install them straight away. This can lead to the occasional problem (when the updated port has an error or an omission), so you need to be able to backtrack (by keeping a backup of the replaced port, which portmaster can do by using the correct flag, or by using portmaster.rc). Using a weekly update strategy will reduce that risk significantly, at the cost of maybe having to compile more updated ports in one go. If you need a handy script for keeping you up to date on a daily basis, I have made a script for just this (portupdater), based on portmaster and portaudit. It updates the ports tree, does some port administration/checking, runs portaudit, checks relevant entries in /usr/ports/UPDATING, and prints an overview of what needs to be updated. It doesn't upgrade the installed ports, that's up to you.


----------



## churchi (Jan 28, 2011)

Fantastic advice, thank you for that. i will have that scrip (portupdater) run and e-mail me the logs once a week.

So when i recieve the e-mail from the portupdater script. what is the best way to install the ports? do you recommend

```
portmaster -r PORT_NAME_HERE
```
Or would you recommend another way?

Note: Time required to complete updates is not important.

Thanks.


----------



## DutchDaemon (Jan 28, 2011)

When there's no entry for the ports in /usr/ports/UPDATING, there's no need to run portmaster with any flags, so just run [cmd=]portmaster port1 port2 port3[/cmd] when there are three ports that need an update, e.g. [cmd=]portmaster gawk-3.1.8 intltool-0.41.1 libnice-0.0.13_3[/cmd]

When there *is* an entry for one of the updated ports in /usr/ports/UPDATING, the specific upgrade procedure will be in there, and should be carried out separately and before any other ports are updated or installed.


----------



## churchi (Jan 28, 2011)

Excellent. Thanks for that.

One final question. Since i will use your script: http://forums.freebsd.org/showpost.php?p=39092&postcount=37

What is the easiest way to make it run every week and e-mail me to an external e-mail account the results so i can then update the packages?


Thanks.


----------



## DutchDaemon (Jan 29, 2011)

```
su -
crontab -e
0 16 * * 0	/path/to/portupdater | mail -s "Output of portupdater" some.external@ddre.ss 2>&1
```

This will run it at 4 PM every Sunday (note: there's a random sleep from 0-60 minutes built in!) and send the output with a nice subject line to the external email address. Change to suit your needs.


----------



## DutchDaemon (Jan 29, 2011)

Note, the script works slightly differently when run with a parameter, e.g. [cmd=]portupdater now[/cmd] 

I advise you to do that once in a while on the command line to perform a little bit of cleaning up and administrative checks. Do not use an extra parameter in crontab though, because it may require user intervention.


----------



## churchi (Jan 31, 2011)

So i ran the scrip today and the scrip seems to freeze at this stage:


```
[root@server-01 /home/churchi]# sh portupdater.sh 

Updating portaudit first.


Checking for a current audit database:

Database created: Mon Jan 31 12:45:00 EST 2011

Checking for packages with security vulnerabilities:

Affected package: syslog-ng-1.6.12_1
Type of problem: syslog-ng2 -- startup directory leakage in the chroot environment.
Reference: <http://portaudit.FreeBSD.org/75f2382e-b586-11dd-95f9-00e0815b8da8.html>

1 problem(s) in your installed packages found.

You are advised to update or deinstall the affected package(s) immediately.

Portupdater for server-01.home.local started at Mon Jan 31 12:53:44 EST 2011

========== Fetching latest ports snapshot from server. ==================
```

Not sure how to debug this to see what the issue is.


----------



## DutchDaemon (Jan 31, 2011)

I think I've been very clear about having to use an extra parameter on the command-line, really... It's mentioned in the post before yours, and in the post explaining the script.


----------



## churchi (Jan 31, 2011)

Sorry you are right, i have run it with

```
sh portupdater.sh yes
```
And things are working.

So then from Cron i just add in this line:

```
0 16 * * 0      root    sh /home/churchi/portupdater.sh | mail -s "Output of Portupdater" user@user.com 2>&1
```

Sorry for all the easy/dumb questions. i am slowly getting there.


----------



## DutchDaemon (Jan 31, 2011)

No, I _strongly_ advise you _not_ to put anything in the system's crontab (/etc/crontab), but to use root's own, separate crontab. See post #11. Also note that if you simply make the script executable by using e.g.

[cmd=]chmod 700 /home/churchi/portupdater.sh[/cmd]

you don't have to use the separate 'sh' invocation anymore.


----------



## churchi (Feb 1, 2011)

Thanks for that. I will move the command to the roots own crontab.

Also very good tip about making the scrip executable. i have changed the scrip to be 700 and not i don't need the 'sh' in front of it.

I really appreciate your time on this.


----------

