# resume portmaster



## SIFE (Dec 10, 2009)

salamo alikom
i want resume  

```
portmaster -afrR
```
when it fail like 

```
portupgrade -arfR "< 20091215 15:15"
```
does this possible ?


----------



## zeiz (Dec 10, 2009)

If portupgrade failed I'd run first
`# portsclean -C`
`# pkgdb -F`
and then try portmaster:
`# portmaster -a  -f -D -R`

However in portmaster manual (run `man portmaster`) is written:
"Alternatively you could use 
`# portmaster -a -f -D` 
to do an ``in place''update of your ports.  If that process is interrupted for any reason you can use 
`# portmaster -a -f -D -R` 
to avoid rebuilding ports already rebuilt on previous runs.  However the first method (delete everything and reinstall) is preferred."


----------



## SIFE (Dec 10, 2009)

my problem in portupgrade each time tell me to run pkgdb -F after that i get a new port ,this is because i mix package from FreeBSD 7 and FreeBSD 8 building each port manually is pain so that i switch to portmaster .
each time i get msg like this :
	
	



```
===>  Installing for py25-pycrypto-2.0.1_4
===>   Generating temporary packing list
===>  Checking if security/py-pycrypto already installed
===>   py25-pycrypto-2.0.1_4 is already installed
      You may wish to ``make deinstall'' and install this port again
      by ``make reinstall'' to upgrade it properly.
      If you really wish to overwrite the old port of security/py-pycrypto
      without deleting it first, set the variable "FORCE_PKG_REGISTER"
      in your environment or the "make install" command line.
*** Error code 1

Stop in /usr/ports/security/py-pycrypto.
```
this is waste time to rebuild ports each fail .


----------



## zeiz (Dec 10, 2009)

Yes it happens quite often, but your sample is very easy: just type what it asks you, it this case type:

```
# cd /usr/ports/security/py-pycrypto 
# make deinstall
# make reinstall
# portmaster -a -f -D
```
I would also add -P option to portmaster because some packages have the same version as ports, you could save time, but it's up to you.
My personal opinion: I do not reinstall all the ports after upgrade. If you run `pkg_version -vIL=` you can see what ports are outdated. Then watch for "monsters"(global libraries, compillers, sourses, programming languages) like gtk, glib, python, qt4, gmake etc and portmaster or portupgrade them first. Don't forget to portsnap (or csup) first to update all the ports to latest versions.
Then try to reboot and see if your system works fine. If any port fails - reinstall only that port.
PS. Portmanagers are not as smart as advertised  Once I messed up my system completely (with perl depends) then I did the following:
`# pkg_delete -a`
then deleted some directories manually (it shows them)
Then:

```
pkg_add -r portupgrade portmaster
pkg_add -r xorg
pkg_add -r webfonts dejavu liberation-fonts-ttf terminus-font
pkg_add -r gnome2 ##(or/and kde4)
pkg_add -r linux_base-f10
pkg_add -r nvidia-driver nvidia-xconfig nvidia-settings
.............................. etc
portsnap fetch update
portupgrade -a
```
And it took me 2-3 hours instead of...??
Of course if you want Gnome2-2.28 (no packages yet) and stuff like this use ports instead


----------



## tangram (Dec 10, 2009)

Don't mix portmaster with portupgrade. Use one or the other.


----------



## ProFTP (Dec 10, 2009)

Super full upgrade:
(with portupgrade)


```
#!/usr/bin/perl

$nn = 0;

while (1) {

    $nn++;

    open( OPERN, "portversion |" );

    my @all2 = <OPERN>;

    close OPERN;

    my @all;

    for ( $i = 0 ; $i < @all2 ; $i++ ) {

        my ( $pp, $st ) = split( / /, $all2[$i], 2 );
        if ( $st =~ '<' ) {

            push @all, $pp;    # $all[$i] = $pp;

        }

    }

    exit if ( !$all[0] || $nn > 2 );

    while (1) {

        last if !$all[0];

        print "$all[0]\n";

        logsave( get_time(), $all[0] );

        system("portupgrade -rf $all[0]");  
      # system("portupgrade -Rf $all[0]");

      # Ð¿ÐµÑ€Ð²Ñ‹Ð¹ Ð¿Ð¾Ñ€Ñ‚ Ð¿Ð¾Ð¿Ñ€Ð¾Ð±Ð¾Ð²Ð°Ñ‚ÑŒ Ð¾Ð±Ð½Ð¾Ð²Ð¸Ñ‚ÑŒ Ð²Ð´Ð¾Ð»ÑŒ Ð¸ Ð¿Ð¾Ð¿ÐµÑ€ÐµÐº
      # (Ð²Ñ‹ÑˆÐµ system Ð½ÑƒÐ¶Ð½Ð¾ Ð·Ð°ÐºÐ¾Ð¼Ð¼ÐµÐ½Ñ‚Ð¸Ñ€Ð¾Ð²Ð°Ñ‚ÑŒ)
      # if ($nn == 1) {
      #  system("portupgrade -rRf $all[0]");
      #  } else {
      #  system("portupgrade -rf $all[0]");
      #  }

   #  # experimentally: 
   #  # use "Enter"
   #    $timeout = '800';
   #    use IO::Select;  
   #     my $select = IO::Select->new;
   #   # for(@array) 
   #     open my $pipe, "| portupgrade -rf $all[0]";
   #     $select->add($pipe);
   #   # }
   #    my @waiters = $select->can_write($timeout);
   #    print $_ "\x0a" for @waiters; 


        logsave( get_time(), $all[0] );

        shift @all;

        my @all = old(@all);

    }

}

sub old {

    my @all = @_;

    open( OPEN2, "portversion |" );

    my @all_all = <OPEN2>;

    close OPEN2;

    my @old;
    my @no_old;

    foreach my $p (@all_all) {

        my ( $pname, $status ) = split( / /, $p, 2 );

        if ( $status =~ '<' ) {

            push @old, $pname;

        }
        else {
            push @no_old, $pname;
        }
    }

    my %seen;
    @seen{@all} = ();
    delete @seen{@no_old};
    return keys %seen;

}

sub get_time {
    my ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst ) =
      localtime(time);
    $mon++;
    $year += 1900;
    if ( $mday < 10 ) { $mday = "0$mday"; }
    if ( $mon < 10 )  { $mon  = "0$mon"; }
    if ( $min < 10 )  { $min  = "0$min"; }
    my $date        = "$mday $mon $year";
    my $time        = "$hour:$min:$sec";
    my $cur_all_day = $mday + $mon * 30 + $year * 365;
    my $radate      = "$year-$mon-$mday $hour:$min:$sec";
    return $radate;
}


sub logsave {
    my ( $time, $ports ) = @_;
    my $logfile;
    $logfile = "\n time:  $time \n  ports: $ports \n\n";
    system("touch /var/log/portupgrade.log");
    open( DB2, "/var/log/portupgrade.log" ) || die "Cannot open file: $!";
    my @base = <DB2>;
    close(DB2);
    open( DB, ">/var/log/portupgrade.log" ) || die "Cannot open file : $!";
    print DB @base;
    print DB $logfile;
    close(DB);
}
```


----------



## zeiz (Dec 10, 2009)

@tangram: Why not (after portsclean -C and pkgdb -F)?

@ProFTP: How long does it take? Same as porupgrade -arf? 
         Can it do "deinstall/reinstall"?


----------



## ProFTP (Dec 10, 2009)

zeiz, deinstall/install recursively


----------



## zeiz (Dec 10, 2009)

The script do works as a charm to me. 
Unfortunately I had only 4 ports to go (8.0-RELEASE > 9-CURRENT).
Nonetheless, what about building gcc first? (just kidding )


----------



## ProFTP (Dec 10, 2009)

I on before does not know
can be whatever

about gcc, it can be needed to add

make.conf

```
WITHOUT_JAVA=YES
```


----------

