Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 24 Jun 2009 11:19:09 -0400
From:      mfv <mrkvrg@acm.org>
To:        freebsd-questions@freebsd.org
Cc:        RW <rwmaillists@googlemail.com>
Subject:   Re: upgrading installed ports: time to do it ?
Message-ID:  <200906241119.09827.mrkvrg@acm.org>
In-Reply-To: <20090622214802.0761813e@gumby.homeunix.com>
References:  <200906212038.39370.meslists@yahoo.fr> <4A3FE271.8080201@onetel.com> <20090622214802.0761813e@gumby.homeunix.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Monday, 22 June 2009 16:48:02 RW wrote:
> On Mon, 22 Jun 2009 20:58:41 +0100
>
> Chris Whitehouse <cwhiteh@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@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to
> "freebsd-questions-unsubscribe@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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200906241119.09827.mrkvrg>