Alien-Packages

 view release on metacpan or  search on metacpan

lib/Alien/Packages/Base.pm  view on Meta::CPAN


=head2 new

Instantiates new object, no attributes evaluated.

=cut

sub _run_ipc_cmd
{
    $_[0]->isa('Alien::Packages::Base') and shift;
    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = IPC::Cmd::run(@_);
    $stdout_buf = [ join( "", @$stdout_buf ) ];
    $stderr_buf = [ join( "", @$stderr_buf ) ];
    return ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf );
}

sub new
{
    my $class = $_[0];
    my $self = bless( {}, $class );
    return $self;
}

=head2 pkgtype

lib/Alien/Packages/Dpkg.pm  view on Meta::CPAN


Returns the list of installed I<dpkg> packages.

=cut

sub list_packages
{
    my $self = $_[0];
    my @packages;

    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
      $self->_run_ipc_cmd(
                     command => [ $dpkg_query, '-W', q(-f=${Package}:${Version}:${Description}\n) ],
                     verbose => 0, );

    if ($success)
    {
        chomp $stdout_buf->[0];
        my @pkglist = split( /\n/, $stdout_buf->[0] );
        my %pkg_details;
        foreach my $pkg (@pkglist)

lib/Alien/Packages/Dpkg.pm  view on Meta::CPAN


=cut

sub list_fileowners
{
    my ( $self, @files ) = @_;
    my %file_owners;

    foreach my $file (@files)
    {
        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
          $self->_run_ipc_cmd( command => [ $dpkg_query, '-S', $file ],
                               verbose => 0, );

        if ($success)
        {
            chomp $stdout_buf->[0];
            my @pkglist = split( /\n/, $stdout_buf->[0] );
            foreach my $pkg (@pkglist)
            {
                if ( my ( $pkg_names, $fn ) = $pkg =~ m/^([^:]+):\s+([^\s].*)$/ )

lib/Alien/Packages/LsLpp.pm  view on Meta::CPAN


Get's the list of installed filesets.

=cut

sub list_packages
{
    my $self = $_[0];
    my @packages;

    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
      $self->_run_ipc_cmd( command => [ $lslpp, '-lc' ],
                           verbose => 0, );

    if ($success)
    {
        chomp $stdout_buf->[0];
        my @pkglist = split( /\n/, $stdout_buf->[0] );
        foreach my $pkg (@pkglist)
        {
            next if ( $pkg =~ m/^#/ );

lib/Alien/Packages/LsLpp.pm  view on Meta::CPAN


=cut

sub list_fileowners
{
    my ( $self, @files ) = @_;
    my %file_owners;

    foreach my $file (@files)
    {
        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
          $self->_run_ipc_cmd( command => [ $lslpp, '-wc', $file ],
                               verbose => 0, );

        if ($success)
        {
            chomp $stdout_buf->[0];
            my @output = split( /\n/, $stdout_buf->[0] );
            foreach my $line (@output)
            {
                next if ( $line =~ m/^#/ );

lib/Alien/Packages/PkgInfo.pm  view on Meta::CPAN


Returns the list of installed packages.

=cut

sub list_packages
{
    my $self = $_[0];
    my @packages;

    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
      $self->_run_ipc_cmd( command => [ $pkginfo, '-x' ],
                           verbose => 0, );

    if ($success)
    {
        while ( $stdout_buf->[0] =~ m/(\w+)\s+([^\s].*)\s+(\(\w+\))\s(\d[\d.]+,REV=[^\s]+)/gx )
        {
            push(
                  @packages,
                  {

lib/Alien/Packages/PkgInfo.pm  view on Meta::CPAN

      File::Spec->catfile( File::Spec->tmpdir(), join( "_", qw(alias pkg list fileowner), $$ ) );

    foreach my $file (@files)
    {
        my $fh;
        open( $fh, ">", $tmpfile ) or die "Can't open $tmpfile: $!";
        print $fh "$file\n";
        close($fh) or die "Can't close $tmpfile: $!";

        # that seems to fail on OpenSolaris - Solaris 10u8 on sparc64 succeeds
        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
          $self->_run_ipc_cmd( command => [ $pkgchk, '-i', $tmpfile, '-l' ],
                               verbose => 0, );

        if ($success)
        {
            while ( $stdout_buf->[0] =~
                m/Pathname:\s*(.*?)\n.*Referenced\sby\sthe\sfollowing\spackages:\s+([A-Za-z0-9]+)/xsg
              )
            {
                push( @{ $file_owners{$1} }, { Package => $2 } );

lib/Alien/Packages/Pkg_Info/pkgsrc.pm  view on Meta::CPAN

            require File::Which;
            @pkg_info = File::Which::where('pkg_info');
        };
        if ($@)
        {
            @pkg_info = grep { $_ } ( IPC::Cmd::can_run('pkg_info') );
        }

        foreach my $piexe (@pkg_info)
        {
            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
              IPC::Cmd::run( command => [ $piexe, '-V' ],
                             verbose => 0, );
            my $pkgsrc = $success && @{$stdout_buf} && $stdout_buf->[0] =~ m/^\d{4}\d{2}\d{2}$/;
            $pkgsrc and $pkg_info = $piexe and last;
        }

        defined($pkg_info) or $pkg_info = '';
    }

    return $pkg_info;

lib/Alien/Packages/Pkg_Info/pkgsrc.pm  view on Meta::CPAN


Returns the list of installed I<pkgsrc> packages.

=cut

sub list_packages
{
    my $self = $_[0];
    my @packages;

    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
      $self->_run_ipc_cmd( command => [$pkg_info],
                           verbose => 0, );

    if ($success)
    {
        my @pkglist = split( /\n/, $stdout_buf->[0] );
        foreach my $pkg (@pkglist)
        {
            my @pkg_details = split( ' ', $pkg, 2 );
            if ( $pkg_details[0] =~ m/^(.*)-([^-]*)$/ )

lib/Alien/Packages/Pkg_Info/pkgsrc.pm  view on Meta::CPAN


=cut

sub list_fileowners
{
    my ( $self, @files ) = @_;
    my %file_owners;

    foreach my $file (@files)
    {
        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
          $self->_run_ipc_cmd( command => [ $pkg_info, '-Fe', $file ],
                               verbose => 0, );

        if ($success)
        {
            chomp $stdout_buf->[0];
            if ( $stdout_buf->[0] =~ m/^(.*)-([^-]*)$/ )
            {
                push( @{ $file_owners{$file} }, { Package => $1 } );
            }

lib/Alien/Packages/Pkg_Info/ports.pm  view on Meta::CPAN

            require File::Which;
            @pkg_info = File::Which::where('pkg_info');
        };
        if ($@)
        {
            @pkg_info = grep { $_ } ( IPC::Cmd::can_run('pkg_info') );
        }

        foreach my $piexe (@pkg_info)
        {
            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
              IPC::Cmd::run( command => [ $piexe, '-qP' ],
                             verbose => 0, );
            my $ports = $success && @{$stdout_buf} && $stdout_buf->[0] =~ m/^\d{4}\d{2}\d{2}$/;
            $ports and $pkg_info = $piexe and last;
        }

        defined($pkg_info) or $pkg_info = '';
    }

    return $pkg_info;

lib/Alien/Packages/Pkg_Info/ports.pm  view on Meta::CPAN


Returns the list of installed FreeBSD ports.

=cut

sub list_packages
{
    my $self = $_[0];
    my @packages;

    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
      $self->_run_ipc_cmd( command => [$pkg_info],
                           verbose => 0, );

    if ($success)
    {
        my @pkglist = split( /\n/, $stdout_buf->[0] );
        foreach my $pkg (@pkglist)
        {
            my @pkg_details = split( ' ', $pkg, 2 );
            if ( $pkg_details[0] =~ m/^(.*)-([^-]*)$/ )

lib/Alien/Packages/Pkg_Info/ports.pm  view on Meta::CPAN


=cut

sub list_fileowners
{
    my ( $self, @files ) = @_;
    my %file_owners;

    foreach my $file (@files)
    {
        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
          $self->_run_ipc_cmd( command => [ $pkg_info, '-q', '-W', $file ],
                               verbose => 0, );

        if ($success)
        {
            chomp $stdout_buf->[0];
            if ( $stdout_buf->[0] =~ m/^(.*)-([^-]*)$/ )
            {
                push( @{ $file_owners{$file} }, { Package => $1 } );
            }

lib/Alien/Packages/Rpm.pm  view on Meta::CPAN


Returns the list of installed I<rpm> packages.

=cut

sub list_packages
{
    my $self = $_[0];
    my @packages;

    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
      $self->_run_ipc_cmd(
        command => [ $rpm, '-qa', '--queryformat', '"%{NAME}:%{VERSION}:%{RELEASE}:%{SUMMARY}\n"' ],
        verbose => 0, );

    if ($success)
    {
        my @pkglist = split( /\n/, $stdout_buf->[0] );
        foreach my $pkg (@pkglist)
        {
            next if ( $pkg =~ m/^#/ );

lib/Alien/Packages/Rpm.pm  view on Meta::CPAN


=cut

sub list_fileowners
{
    my ( $self, @files ) = @_;
    my %file_owners;

    foreach my $file (@files)
    {
        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = $self->_run_ipc_cmd(
                       command => [ $rpm, '-qf', $file ],    # XXX received with or without versions
                       verbose => 0, );

        if ($success)
        {
            chomp $stdout_buf->[0];
            push( @{ $file_owners{$file} }, { Package => $stdout_buf->[0] } );
        }
    }



( run in 0.631 second using v1.01-cache-2.11-cpan-4d50c553e7e )