DhMakePerl

 view release on metacpan or  search on metacpan

lib/DhMakePerl/Command/make.pm  view on Meta::CPAN

                    |CVS
                    |eg|samples?|examples?
                    |t|xt
                    |inc|privinc
                    )$/x
                )
            {
                $File::Find::prune = 1;
                return;
            }
            if (/.+\.pm$/) {
                my $mi = Module::Metadata->new_from_file($_);
                push @modules, $mi->packages_inside;
            }
        },
        $self->main_dir,
    );

    my $found;

    sub show_notice($$) {
        warn $_[0] unless $_[1];
        $_[1] = 1;
    }

    my $notice = <<EOF;
*** Notice ***
Some of the modules in the newly created package are already present
in other packages.

EOF
    my $notice_shown = 0;

    for my $mod (@modules) {
        if ($apt_contents) {
            $found = $apt_contents->find_perl_module_package($mod);

            if ($found) {
                show_notice( $notice, $notice_shown );
                warn "  $mod is in '$found' (APT)\n";
            }
        }
        if ( !$found ) {
            require Debian::DpkgLists;
            my @found = Debian::DpkgLists->scan_perl_mod($mod);

            if (@found) {
                show_notice( $notice, $notice_shown );
                warn "  $mod is in " . join( ', ', @found ), " (local .deb)\n";
                $found = 1;
            }
        }
    }

    warn "\n" if $notice_shown;

    return $found ? 1 : 0;
}

sub reset_git_environment {
    # The Git environment variables may be set from previous iterations
    # of this program being run. In this case, it's possible that the
    # Git module will use these to point to the wrong source tree.
    delete $ENV{'GIT_DIR'};
    delete $ENV{'GIT_WORK_TREE'};
}

sub git_import_upstream__init_debian {
    my ( $self ) = @_;

    require Git;

    $self->reset_git_environment();

    Git::command( 'init', $self->main_dir );
    my @git_config = ( '-c', 'user.name=' . $self->get_name,
                       '-c', 'user.email=' . $self->get_email);

    my $git = Git->repository( $self->main_dir );
    $git->command( qw(symbolic-ref HEAD refs/heads/upstream) );
    $git->command( 'add', '.' );
    $git->command( @git_config, 'commit', '-m',
              "Import original source of "
            . $self->perlname . ' '
            . $self->version );
    $git->command( 'tag', "upstream/".$self->version, 'upstream' );

    $git->command( qw( checkout -b master upstream ) );
    if ( -d $self->debian_dir ) {
      # remove debian/ directory if the upstream ships it. This goes into the
      # 'master' branch, so the 'upstream' branch contains the original debian/
      # directory, and thus matches the pristine-tar. Here I also remove the
      # debian/ directory from the working tree; git has the history, so I don't
      # need the debian.bak
      $git->command( 'rm', '-r', $self->debian_dir );
      $git->command( @git_config, 'commit', '-m',
                     'Removed debian directory embedded in upstream source' );
    }
}

sub git_add_debian {
    my ( $self, $tarball ) = @_;

    require Git;
    require File::Which;

    $self->reset_git_environment;

    my $git = Git->repository( $self->main_dir );
    my $name = $self->get_name;
    my $email = $self->get_email;
    my @git_config = ( '-c', "user.name=$name",
                       '-c', "user.email=$email");
    $git->command( 'add', 'debian' );
    $git->command( @git_config, 'commit', '-m',
        "Initial packaging by dh-make-perl $VERSION" );
    $git->command(
        qw( remote add origin ),
        sprintf( "ssh://git.debian.org/git/pkg-perl/packages/%s.git",
            $self->pkgname ),
    ) if $self->cfg->pkg_perl;



( run in 0.722 second using v1.01-cache-2.11-cpan-71847e10f99 )