Alien-SNMP

 view release on metacpan or  search on metacpan

alienfile  view on Meta::CPAN

    my $dst = $dst_dir->child($rel);
    $dst->parent->mkpath;
    $dst->remove;   # blib .pm files are mode 0444: a rebuild could not reopen them
    File::Copy::copy("$src", "$dst") or die "can't copy $src to $dst: $!";
    chmod((stat "$src")[2] & 0777, "$dst");
  }, { recurse => 1 });
};

# Bundle/MakefileSubs.pm is net-snmp's own Makefile.PL helper (it declares `package
# MakefileSubs;` despite its path); only the source tree's Makefile.PLs use it.
my $not_shippable = qr{(?:^|/)Bundle/};

my $has_shippable_files = sub {
  my ($dir) = @_;
  return 0 unless $dir->is_dir;
  my $found = 0;
  $dir->visit(sub {
    my ($path) = @_;
    return if $path->is_dir || $path->basename eq '.exists';
    return if $path->relative($dir) =~ $not_shippable;
    $found = 1;
    return \0;   # Path::Tiny halts iteration on a ref to a false value
  }, { recurse => 1 });
  return $found;
};

# The bundled Perl modules have to end up in the normal perl lib dirs -- that is how
# downstream `use SNMP;` works -- but a build command must never write outside
# $DESTDIR: doing so fails wherever the real target is not writable at build time
# (CPAN smokers on system perl, root-owned site perl, packaging roots).  So hand them

alienfile  view on Meta::CPAN


  foreach my $section (qw( lib arch man3 )) {
    my $src = Path::Tiny->new('perl', 'blib', $section);
    if ($section ne 'man3' && !$has_shippable_files->($src)) {
      die "net-snmp built no perl/blib/$section, so the bundled SNMP and NetSNMP "
        . "modules would be missing from this distribution.  Check that "
        . "perl module support is still in the configure flags and that net-snmp "
        . "still builds its perl modules with ExtUtils::MakeMaker.\n";
    }
    next unless $src->is_dir;
    $copy_tree->($src, $blib->child($section), $not_shippable);
    $build->log("staged perl/blib/$section into $blib/$section");
  }
};

share {
  # Canonical raw URL serves the tarball directly (no GitHub blob-page redirects).
  # The netdisco mirror is byte-for-byte identical to the official Net-SNMP
  # release on SourceForge.
  start_url 'https://github.com/netdisco/upstream-sources/raw/refs/heads/master/net-snmp/net-snmp-5.9.5.2.tar.gz';

t/07_alienfile_hygiene.t  view on Meta::CPAN

# A substitution whose pattern mentions DESTDIR, e.g. s/^\Q$destdir\E// -- the only
# reason to write one is to turn a staged path back into a live one.  Bounded to a
# single statement so an unrelated later mention cannot trip it.
unlike $alienfile, qr/=~ \s* s [^;]{0,120} DESTDIR/xi,
  'alienfile__build_recipe__never_strips_DESTDIR_to_rebuild_an_absolute_path';

# perllocal.pod is an append-only global manifest and .packlist is per-install
# bookkeeping; both belong to whatever installs this distribution, never to us.
foreach my $artifact (qw( perllocal.pod .packlist )) {
    unlike $alienfile, qr/\Q$artifact\E/,
      "alienfile__build_recipe__does_not_handle_$artifact";
}

done_testing;

sub _slurp {
    my ($file) = @_;
    open my $fh, '<', $file or die "can't read $file: $!";
    local $/;
    my $content = <$fh>;
    close $fh;



( run in 1.108 second using v1.01-cache-2.11-cpan-0fb53d1c279 )