upgrading installed ports: time to do it ?

mfv mrkvrg at acm.org
Wed Jun 24 15:45:51 UTC 2009


On Monday, 22 June 2009 16:48:02 RW wrote:
> On Mon, 22 Jun 2009 20:58:41 +0100
>
> Chris Whitehouse <cwhiteh at onetel.com> wrote:
> > I'll probably get flamed for this but since I've been using
> > ports-mgmt/portmanager I've almost forgotten
> > about /usr/ports/UPDATING and all that pkgdb -Fu stuff or whatever it
> > was. I've upgraded ports just by doing 'portmanager -u' over one or
> > two quite major changes and not had any problems that haven't been
> > down to an individual ports.
>
> You still need to read UPDATING, portmanager handles some of the
> issues automatically, but not all.
> _______________________________________________
> freebsd-questions at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to
> "freebsd-questions-unsubscribe at freebsd.org"

Hello,

Here is a perl hack I use to automatically read and parse UPDATING as part of 
my daily upgrade routine.  It is part of a larger set of five scripts which 
use:
 1. "csup" to update ports
 2. "make index" to update the /usr/ports/INDEX
 3. "pkg_version" to identify the ports that need upgrading
 4. "portfetch" to download the tarballs
 5. a script to display the relevant contents, if any, of UPDATING using the
    hack shown below and the contents identified in step 3 above.

These five scripts are combined in a master script (csup-all) which I invoke 
the first thing in the morning.  After doing some other morning chores I then 
run "portconfig -a -v" to set up any configuration settings prior to running 
"portmaster -a -u".  Everything is automatic except for the configuration.

Here is the perl hack.  It can be improved by comparing the ports that need to 
be updated (step 3) with the ports specified within UPDATING (step 5).  The 
embedded ansi codes will work with the default FreeBSD console settings, 
otherwise they can be removed.

#!/usr/bin/perl                                                                                     
#
# file:    csup-update.pl
#                                                                                                   
# created: 2006-07-16                                                                               
#                                                                                                   
# purpose: To review update notes in /usr/ports/UPDATING                                            
#          This program will only display those notes issued                                        
#          since last csup                                                        
#                                                                                                   
# algorithm: Each line of the file /usr/ports/UPDATING is scanned and if                            
#          it finds a date in the form ^yyyymmdd$ the date is assigned                             
#          to the variable $date.  Otherwise all non-date lines are printed                         
#          to STDOUT.  As soon as this program finds a date older than the                          
#          last update this program quits and prints an appropriate closing                         
#          message.                                                                                 
#                                                                                                   
unless ( open ( MYFILE, "/usr/ports/UPDATING" ) ) {
    die ("Cannot open input file /usr/ports/UPDATING.\n") ;
}

unless ( open ( LASTUPDATE, "/root/bin/csup-lastupdate.txt" ) ) {
    die ("Cannot open file csup-lastupdate.txt.\n") ;
}

$eof = '' ;
$date = $lastupdate = <LASTUPDATE> ;
$line = <MYFILE> ;
$count = 0 ;

while ( $line ne $eof ) {
    if ( $line =~ /^2\d{7}/ ) {
        $date = $line ;
        $date =~ tr/://d ;
                $count++ ;
    }

    if ( ( $date - $lastupdate ) >= 0 ) {
        if ( $line =~ /^2\d{7}/ ) {
                        print ("^[[32m$line^[[0m") ;
        } else {
            print ("^[[0m$line") ;
                }
        $line = <MYFILE> ;
        $date = $lastupdate ;
    } else {
        $count-- ;
        if ( $count == 0 ) {
            print ( "^[[36mThere are no updates to review. ") ;
            } elsif ( $count == 1 ) {
            print ( "^[[36mThere is only one update to review. ") ;
                } else {
            print ( "^[[36mThere are $count updates to review. ") ;
        }
        chop  ( $lastupdate ) ;
        print ( "The last run of csup was on $lastupdate.^[[0m\n\n"  ) ;

        exit ;
    }
}
# EoF



More information about the freebsd-questions mailing list