App-Pm2Port

 view release on metacpan or  search on metacpan

MANIFEST  view on Meta::CPAN

.portupload.yml
Changes
ignore.txt
inc/Module/AutoInstall.pm
inc/Module/Install.pm
inc/Module/Install/AutoInstall.pm
inc/Module/Install/Base.pm
inc/Module/Install/Can.pm
inc/Module/Install/Fetch.pm
inc/Module/Install/Include.pm
inc/Module/Install/Makefile.pm

README  view on Meta::CPAN


  perl_version_parse
    Args: $version

    Converts perl version number to something understandable by FreeBSD

  get_dependencies
    Returns FreeBSD-style list of dependencies.

  create_makefile
    Args: $metafile, $portupload_file, $man1, $man3

  create_config
    Creates config file for module

  run
    Makes actually all work

  generate_plist
    created list of manpages and pg-plist

lib/App/Pm2Port.pm  view on Meta::CPAN

package App::Pm2Port;

#===============================================================================
#
#         FILE:  portupload.pl
#
#        USAGE:  ./portupload.pl
#
#  DESCRIPTION:  upload
#
#      OPTIONS:  ---
# REQUIREMENTS:  ---
#         BUGS:  ---
#        NOTES:  ---
#       AUTHOR:  Andrey Kostenko (), <andrey@kostenko.name>
#      COMPANY:  Rambler Internet Holding
#      VERSION:  1.0
#      CREATED:  26.06.2009 02:13:30 MSD
#     REVISION:  ---

lib/App/Pm2Port.pm  view on Meta::CPAN


            #die "Missing dependency for $distribution";
            unless (fork) {
                my $a = App::Pm2Port->new( module => $module );
                $a->run;
                exit;
            }
            wait;
            $location =
                '/usr/ports/'
              . LoadFile( glob "~/.portupload/$module.yml" )->{category}
              . "/$distribution";
        }
        $location =~ s!/usr/ports!\${PORTSDIR}!;
        push @deps, "$distribution>=$requires->{$module}:$location";
    }
    unshift @deps, '' if $ports;
    @deps = sort @deps;
    join " \\\n\t\t", @deps;
}

=head2 create_makefile

Args: $metafile, $portupload_file, $man1, $man3

=cut

sub create_makefile {
    my $self            = shift;
    my $file            = shift;
    my $portupload_file = shift;
    my $man1            = shift;
    my $man3            = shift;
    my $module  = shift;
    open +( my $makefile ), '>', 'Makefile';
    ( my $comment = $file->{abstract} ) =~ s/\.$//;
    $comment = ucfirst $comment;
    print $makefile "# New ports collection makefile for:  $file->{name}\n";
    print $makefile "# Date created: " . `date "+\%d \%B \%Y"`;
    print $makefile "# Whom: $portupload_file->{maintainer}\n";
    print $makefile "#\n"; 
    print $makefile "# \$FreeBSD\$\n\n";
    print $makefile "PORTNAME=	$file->{name}\n";
    print $makefile "PORTVERSION=	$file->{version}\n";
    print $makefile "CATEGORIES=	$portupload_file->{category} perl5\n";
    print $makefile "MASTER_SITES=	"
      . ( $portupload_file->{master_sites} || 'CPAN' ) . "\n";
    print $makefile "PKGNAMEPREFIX=	p5-\n";
    print $makefile "\n";
    print $makefile "MAINTAINER=	$portupload_file->{maintainer}\n";
    print $makefile "COMMENT=	$comment\n";
    print $makefile "\n";
    print $makefile "BUILD_DEPENDS=	"
      . $self->get_dependencies( $file->{requires} )
      . $self->get_dependencies( $portupload_file->{requires}, 1 ) . "\n";
    print $makefile "RUN_DEPENDS=\t\${BUILD_DEPENDS}\n";
    print $makefile "\n";
    print $makefile "USE_APACHE=" . $portupload_file->{apache} . "\n"
      if $portupload_file->{apache};
    print $makefile "PERL_MODBUILD=	YES\n" if $module->get_installer_type =~ /build/i;
    print $makefile "PERL_CONFIGURE=	"
      . (
          $file->{requires}{perl}
        ? $self->perl_version_parse( $file->{requires}{perl} ) . "+"
        : 'YES'
      ) . "\n";
    print $makefile "MAN1=	" . $man1 . "\n" if $man1;
    print $makefile "MAN3=	" . $man3 . "\n" if $man3;
    print $makefile "\n";

    if ( $portupload_file->{additional} ) {
        print $makefile ".include <bsd.port.pre.mk>\n";
        $portupload_file->{additional} =~ s/ {4}/\t/g;
        print $makefile $portupload_file->{additional};
        print $makefile ".include <bsd.port.post.mk>\n";
    }
    else {
        print $makefile ".include <bsd.port.mk>\n";
    }
    close $makefile;
}

=head2 create_config

Creates config file for module

=cut

sub create_config {
    my ( $self, $name ) = @_;
    mkdir glob "~/.portupload";
    my ($package_name) = grep /^\Qp5-$name-\E[\d.]+/, keys %{ $self->{INDEX} };
    my $pkg_info       = $self->{INDEX}{$package_name};
    my $config         = {};
    my $suggested_category;
    ( $config->{category}, $suggested_category ) =
      $self->suggest_category( $name, $pkg_info->{categories} );
    $config->{category} ||= prompt( "Port category:", $suggested_category );
    my $maintainer_email = $pkg_info->{maintainer};

    if ( -e glob '~/.porttools' ) {
        $maintainer_email ||= `. ~/.porttools;echo \$EMAIL`;
        chomp $maintainer_email;
    }
    $config->{maintainer} = $maintainer_email
      || prompt( "Maintainer email:", "$ENV{USER}\@rambler-co.ru" );
    DumpFile( glob("~/.portupload/$self->{module}.yml"), $config );
}

=head2 run

Makes actually all work

=cut

sub run {
    my ($self) = @_;
    my ( $post_on_cpan, $submit_to_freebsd );

    GetOptions(
        'h|help' => sub {
            print
qq{Usage: $0 [ --info ] [ --no-tests ] [ --no-upload ] [ --no-commit ] [ --cpan ]\n};
            exit 0;
        },
        'info' => sub {
            $ENV{INFO_ONLY} = 1;
        },
        'no-tests' => sub {
            $ENV{NOTEST} = 1;
        },
        'no-upload' => sub {
            $ENV{NO_UPLOAD} = 1;
        },
        'no-commit' => sub {
            $ENV{NO_COMMIT} = 1;
        },
        'freebsd' => sub {
            $submit_to_freebsd = 1;
        }
    );

    my $module = $self->{cpan}->parse_module( module => $self->{module} );
    $module->fetch;
    chdir $module->extract;

    $module->prepare;
    #$module->test or die unless $ENV{NOTEST};
    $module->install;
    my $file    = $self->load_meta;
    my $version = $file->{version};
    $self->create_config( $file->{name} )
      unless -f glob "~/.portupload/$self->{module}.yml";
    my $portupload_file = LoadFile( glob "~/.portupload/$self->{module}.yml" );
    my $ftp;
    printf qq{
    Tests:  %s
},
      $ENV{NOTEST}    ? 'no' : 'yes',
      $ENV{NO_UPLOAD} ? 'no' : $portupload_file->{master_sites},
      ;
    exit if $ENV{INFO_ONLY};
    print ">>> PList\n";
    my ( $man1, $man3, @pkg_plist ) = $self->generate_plist( $module->packlist );
    system("make -s clean");
    chdir tempdir();

    if (
        system(
"cvs -d :pserver:anoncvs\@anoncvs.tw.FreeBSD.org/home/ncvs co ports/$portupload_file->{category}/p5-$file->{name}"
        ) == 0
      )
    {
        chdir "ports/$portupload_file->{category}/p5-$file->{name}" or do {
            mkdir "ports";
            mkdir "ports/p5-$file->{name}" or die;
            chdir "ports/p5-$file->{name}" or die;
          }
    }

    $self->create_makefile( $file, $portupload_file, $man1, $man3, $module );
    open PLIST, '>', 'pkg-plist';
    if ( !$portupload_file->{distfiles} ) {
        print PLIST @pkg_plist;
    }
    else {
        print PLIST "\n";
    }
    close PLIST;
    open PDESCR, '>', 'pkg-descr';
    print PDESCR $file->{abstract};
    print PDESCR "\n\nWWW: http://search.cpan.org/dist/$file->{name}\n";
    if ( !system("$ENV{EDITOR} Makefile") ) {



( run in 0.839 second using v1.01-cache-2.11-cpan-b16cb0d3907 )