Mail-Toaster

 view release on metacpan or  search on metacpan

lib/Mail/Toaster/FreeBSD.pm  view on Meta::CPAN

    my $r = $self->is_port_installed( $package, alt => $alt, %args );
    if ( ! $r ) {
        carp "  : Sorry, I couldn't install $package!\n";
        return;
    }

    return $r;
}

sub install_port_try_manual {
    my ($self, $portname, $path ) = @_;
    print <<"EO_PORT_TRY_MANUAL";

    Automatic installation of port $portname failed! You can try to install $portname manually
using the following commands:

        cd $path
        make
        make install clean

    If that does not work, make sure your ports tree is up to date and
    try again. See also "Dealing With Broken Ports":

        http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/ports-broken.html

If manual installation fails, there may be something "unique" about your system
or the port may be broken. You can:

    a. Wait until the port is fixed
    b. Try fixing the port
    c. Get someone else to fix it

EO_PORT_TRY_MANUAL
}

sub port_options {
    my $self = shift;
    my %p = validate(
        @_,
        {   port  => SCALAR,
            opts  => SCALAR,
            cat   => SCALAR,
            $self->get_std_opts,
        },
    );

    my ( $port, $cat, $opts ) = ( $p{port}, $p{cat}, $p{opts} );
    my %args = $self->toaster->get_std_args( %p );

    return $p{test_ok} if defined $p{test_ok};

    my $opt_dir = "/var/db/ports/$cat".'_'.$port;
    if ( !-d $opt_dir ) {
        $self->util->mkdir_system( dir => $opt_dir, %args,);
    }

    my $prefix = '# This file installed by Mail::Toaster';
    $self->util->file_write( "$opt_dir/options", lines => [$prefix,$opts], %args );
}

sub update_ports {
    my $self = shift;
    my %p = validate( @_, { $self->get_std_opts, } );
    my %args = $self->toaster->get_std_args( %p );

    return $p{test_ok} if defined $p{test_ok};

    return $self->error( "you do not have write permission to /usr/ports.",%args) if ! $self->util->is_writable('/usr/ports', %args);

    my $supfile = $self->conf->{'cvsup_supfile_ports'} || "portsnap";

    return $self->portsnap( %args);

    return 1;
}

sub portsnap {
    my $self = shift;
    my %p    = validate( @_, { $self->get_std_opts, },);

    my %args = $self->toaster->get_std_args( %p );

    return $p{'test_ok'} if defined $p{'test_ok'};

    # should be installed already on FreeBSD 5.5 and 6.x
    my $portsnap = $self->util->find_bin( "portsnap", fatal => 0 );
    my $ps_conf = "/etc/portsnap.conf";

    unless ( $portsnap && -x $portsnap ) {
        $self->install_port( "portsnap" );

        $ps_conf = '/usr/local/etc/portsnap.conf';
        if ( !-e $ps_conf ) {
            if ( -e "$ps_conf.sample" ) {
                copy( "$ps_conf.sample", $ps_conf );
            }
            else {
                warn "WARNING: portsnap configuration file is missing!\n";
            }
        }

        $portsnap = $self->util->find_bin( "portsnap", fatal => 0 );
        unless ( $portsnap && -x $portsnap ) {
            return $self->util->error(
                "portsnap is not installed (correctly). I cannot go on!");
        }
    }

    if ( !-e $ps_conf ) {
        $portsnap .= " -s portsnap.freebsd.org";
    }

    # grabs the latest updates from the portsnap servers
    system $portsnap, 'fetch';

    if ( !-e "/usr/ports/.portsnap.INDEX" ) {
        print "\a
    COFFEE BREAK TIME: this step will take a while, dependent on how fast your
    disks are. After this initial extract, portsnap updates are much quicker than
    doing a cvsup and require less bandwidth (good for you, and the FreeBSD
    servers). Please be patient.\n\n";



( run in 2.528 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )