Skip to content

Commit

Permalink
cpanminus: regenerate attestations, build :all bottle
Browse files Browse the repository at this point in the history
This formula has a bunch of `/usr/local` references that may as well be
`HOMEBREW_PREFIX` references. We also build with Homebrew `perl` to
ensure that embedded versions refereces in the manpages are the same.

Also fixes an attestation verification failure spotted at #191588.
  • Loading branch information
carlocab committed Sep 24, 2024
1 parent 4637f7e commit 3ff77ae
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions Formula/c/cpanminus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Cpanminus < Formula
sha256 cellar: :any_skip_relocation, x86_64_linux: "7901d4e2cf8cf79ccd841ec638bfd5450c14efc2abd07ef90ee024e954b93f6d"
end

uses_from_macos "perl"
depends_on "perl" => :build

def install
cd "App-cpanminus" if build.head?
Expand All @@ -31,15 +31,18 @@ def install
"INSTALLSITEMAN1DIR=#{man1}",
"INSTALLSITEMAN3DIR=#{man3}"
system "make", "install"
end

def post_install
cpanm_lines = (bin/"cpanm").read.lines
return if cpanm_lines.first.match?(%r{^#!/usr/bin/env perl})

ohai "Adding `/usr/bin/env perl` shebang to `cpanm`..."
cpanm_lines.unshift "#!/usr/bin/env perl\n"
(bin/"cpanm").atomic_write cpanm_lines.join
inreplace_files = [
buildpath/"README",
bin/"cpanm",
lib/"perl5/App/cpanminus/fatscript.pm",
lib/"perl5/App/cpanminus.pm",
man3/"App::cpanminus.3",
]
inreplace inreplace_files, "/usr/local", HOMEBREW_PREFIX, audit_result: build.stable?

# Needed for dependents that might use Homebrew perl or system perl.
inreplace bin/"cpanm", %r{^#!#{Regexp.escape(Formula["perl"].opt_bin)}/perl$}, "#!/usr/bin/env perl"
end

test do
Expand Down

0 comments on commit 3ff77ae

Please sign in to comment.