diff --git a/projects/gnu.org/autoconf/package.yml b/projects/gnu.org/autoconf/package.yml index 6035dac6..e4e69467 100644 --- a/projects/gnu.org/autoconf/package.yml +++ b/projects/gnu.org/autoconf/package.yml @@ -22,17 +22,35 @@ build: dependencies: tea.xyz/gx/cc: c99 tea.xyz/gx/make: '*' + git-scm.org: 2 script: |- ./configure \ --build={{ hw.target }} \ --prefix="{{ prefix }}" make --jobs {{ hw.concurrency }} install + cd "{{prefix}}"/bin + + fix-shebangs.ts * + + perl -pi -e 's|\x27{{prefix}}|"\$PREFIX"\x27|g' ./autoconf + + # fix specific m4 and perl paths + perl -pi -e 's|/opt/perl.org/v[^/]+/bin/perl|perl|g' * + perl -pi -e 's|/opt/gnu.org/m4/v[^/]+/bin/m4|m4|g' * + + # fix hardcoded paths + perl -pi -e "s|'{{prefix}}/|\\\$prefix.'/|" * + git -C .. apply {{ pkg.pantry-prefix }}/relocatable.diff + + cd ../share/autoconf + perl -pi -e 's|{{prefix}}|\$PREFIX|' autom4te.cfg + test: dependencies: tea.xyz/gx/cc: c99 script: | - autoconf + autoconf --verbose --debug ./configure test -f config.status test -f config.log diff --git a/projects/gnu.org/autoconf/relocatable.diff b/projects/gnu.org/autoconf/relocatable.diff new file mode 100644 index 00000000..ce39c32e --- /dev/null +++ b/projects/gnu.org/autoconf/relocatable.diff @@ -0,0 +1,152 @@ +diff --git a/bin/autoconf b/bin/autoconf +index 90e1822..3b58d1f 100755 +--- a/bin/autoconf ++++ b/bin/autoconf +@@ -19,6 +19,8 @@ + # You should have received a copy of the GNU General Public License + # along with this program. If not, see . + ++PREFIX="$(cd "$(dirname "$0")/.." && pwd)" ++ + ## -------------------- ## + ## M4sh Initialization. ## + ## -------------------- ## +diff --git a/bin/autoheader b/bin/autoheader +index 2994b69..4cd2587 100755 +--- a/bin/autoheader ++++ b/bin/autoheader +@@ -29,9 +29,14 @@ eval 'case $# in 0) exec perl -S "$0";; *) exec perl + use 5.006; + use strict; + use warnings FATAL => 'all'; ++use Cwd qw(abs_path); ++use File::Basename; + ++my $prefix; + BEGIN + { ++ $prefix = dirname(dirname(abs_path(__FILE__))); ++ + my $pkgdatadir = $ENV{'autom4te_perllibdir'} || $prefix.'/share/autoconf'; + unshift @INC, "$pkgdatadir"; + +diff --git a/bin/autom4te b/bin/autom4te +index 215c42a..2a9e9ea 100755 +--- a/bin/autom4te ++++ b/bin/autom4te +@@ -25,9 +25,14 @@ eval 'case $# in 0) exec perl -S "$0";; *) exec perl + use 5.006; + use strict; + use warnings FATAL => 'all'; ++use Cwd qw(abs_path); ++use File::Basename; + ++my $prefix; + BEGIN + { ++ $prefix = dirname(dirname(abs_path(__FILE__))); ++ + my $pkgdatadir = $ENV{'autom4te_perllibdir'} || $prefix.'/share/autoconf'; + unshift @INC, $pkgdatadir; + +@@ -393,6 +398,9 @@ Try '$me --help' for more information." + $tcache = "$cache/traces."; + $ocache = "$cache/output."; + ++ # added by tea ++ @prepend_include = map { $_ =~ s/\$PREFIX/$prefix/r } @prepend_include; ++ + # Normalize the includes: the first occurrence is enough, several is + # a pain since it introduces a useless difference in the path which + # invalidates the cache. And strip '.' which is implicit and always +diff --git a/bin/autoreconf b/bin/autoreconf +index 69c27ea..96d3ab9 100755 +--- a/bin/autoreconf ++++ b/bin/autoreconf +@@ -28,10 +28,15 @@ eval 'case $# in 0) exec perl -S "$0";; *) exec perl + use 5.006; + use strict; + use warnings FATAL => 'all'; ++use Cwd qw(abs_path); ++use File::Basename; + ++my $prefix; + my $buildauxdir; + BEGIN + { ++ $prefix = dirname(dirname(abs_path(__FILE__))); ++ + my $pkgdatadir = $ENV{'autom4te_perllibdir'} || $prefix.'/share/autoconf'; + unshift @INC, $pkgdatadir; + +diff --git a/bin/autoscan b/bin/autoscan +index b41d9f3..815bb7c 100755 +--- a/bin/autoscan ++++ b/bin/autoscan +@@ -27,9 +27,14 @@ eval 'case $# in 0) exec perl -S "$0";; *) exec perl + use 5.006; + use strict; + use warnings FATAL => 'all'; ++use Cwd qw(abs_path); ++use File::Basename; + ++my $prefix; + BEGIN + { ++ $prefix = dirname(dirname(abs_path(__FILE__))); ++ + my $pkgdatadir = $ENV{'autom4te_perllibdir'} || $prefix.'/share/autoconf'; + unshift @INC, $pkgdatadir; + +diff --git a/bin/autoupdate b/bin/autoupdate +index 156d508..e31c5d1 100755 +--- a/bin/autoupdate ++++ b/bin/autoupdate +@@ -28,9 +28,14 @@ eval 'case $# in 0) exec perl -S "$0";; *) exec perl + use 5.006; + use strict; + use warnings FATAL => 'all'; ++use Cwd qw(abs_path); ++use File::Basename; + ++my $prefix; + BEGIN + { ++ $prefix = dirname(dirname(abs_path(__FILE__))); ++ + my $pkgdatadir = $ENV{'autom4te_perllibdir'} || $prefix.'/share/autoconf'; + unshift @INC, $pkgdatadir; + +diff --git a/bin/ifnames b/bin/ifnames +index c5823fc..3177eb0 100755 +--- a/bin/ifnames ++++ b/bin/ifnames +@@ -32,9 +32,14 @@ eval 'case $# in 0) exec perl -S "$0";; *) exec perl + use 5.006; + use strict; + use warnings FATAL => 'all'; ++use Cwd qw(abs_path); ++use File::Basename; + ++my $prefix; + BEGIN + { ++ $prefix = dirname(dirname(abs_path(__FILE__))); ++ + my $pkgdatadir = $ENV{'autom4te_perllibdir'} || $prefix.'/share/autoconf'; + unshift @INC, $pkgdatadir; + +diff --git a/bin/autom4te b/bin/autom4te + index 042ece6..89e4968 100755 + --- a/bin/autom4te + +++ b/bin/autom4te + @@ -393,6 +393,9 @@ Try '$me --help' for more information." + $tcache = "$cache/traces."; + $ocache = "$cache/output."; + + + # added by tea + + @prepend_include = map { $_ =~ s/\$PREFIX/$prefix/r } @prepend_include; + + + # Normalize the includes: the first occurrence is enough, several is + # a pain since it introduces a useless difference in the path which + # invalidates the cache. And strip '.' which is implicit and always diff --git a/projects/gnu.org/automake/package.yml b/projects/gnu.org/automake/package.yml index 79601fcc..4503e52f 100644 --- a/projects/gnu.org/automake/package.yml +++ b/projects/gnu.org/automake/package.yml @@ -2,7 +2,7 @@ distributable: url: http://ftp.gnu.org/gnu/automake/automake-{{ version }}.tar.xz strip-components: 1 -#FIXME: need versions +#FIXME: need to parse versions from someplace versions: - 1.16.5 @@ -10,23 +10,33 @@ provides: - bin/aclocal - bin/automake +dependencies: + gnu.org/autoconf: ^2.65.0 + perl.org: '*' + build: dependencies: tea.xyz/gx/cc: c99 tea.xyz/gx/make: '*' - gnu.org/autoconf: ^2.65.0 - perl.org: '*' #TODO `inherit` + git-scm.org: 2 script: |- ./configure \ --build={{ hw.target }} \ --prefix="{{ prefix }}" make --jobs {{ hw.concurrency }} install + cd "{{prefix}}"/bin + + # fix hardcoded paths + perl -pi -e "s|'{{prefix}}/|\\\$prefix.'/|" * ../share/automake-{{version.marketing}}/Automake/Config.pm + git -C .. apply {{ pkg.pantry-prefix }}/relocatable.diff + + fix-shebangs.ts * + # TODO to prove automake doesn't require autoconf we should # use “depend” on the autoconf test to generate our `configure` separately test: dependencies: - gnu.org/autoconf: ^2.65.0 tea.xyz/gx/cc: c99 tea.xyz/gx/make: '*' script: | diff --git a/projects/gnu.org/automake/relocatable.diff b/projects/gnu.org/automake/relocatable.diff new file mode 100644 index 00000000..937e22eb --- /dev/null +++ b/projects/gnu.org/automake/relocatable.diff @@ -0,0 +1,47 @@ +diff --git a/bin/aclocal b/bin/aclocal +index 6b58b9b..ad251a7 100755 +--- a/bin/aclocal ++++ b/bin/aclocal +@@ -23,8 +23,11 @@ use 5.006; + use strict; + use warnings FATAL => 'all'; + ++use Cwd qw(abs_path); use File::Basename; ++my $prefix; + BEGIN + { ++ $prefix = dirname(dirname(abs_path(__FILE__))); + unshift (@INC, $prefix.'/share/automake-1.16') + unless $ENV{AUTOMAKE_UNINSTALLED}; + } +diff --git a/bin/automake b/bin/automake +index ff1f453..e26e80c 100755 +--- a/bin/automake ++++ b/bin/automake +@@ -26,8 +26,11 @@ use 5.006; + use strict; + use warnings FATAL => 'all'; + ++use Cwd qw(abs_path); use File::Basename; ++my $prefix; + BEGIN + { ++ $prefix = dirname(dirname(abs_path(__FILE__))); + unshift (@INC, $prefix.'/share/automake-1.16') + unless $ENV{AUTOMAKE_UNINSTALLED}; + +diff --git a/share/automake-1.16/Automake/Config.pm b/share/automake-1.16/Automake/Config.pm +index f0d78c9..35af767 100644 +--- a/share/automake-1.16/Automake/Config.pm ++++ b/share/automake-1.16/Automake/Config.pm +@@ -21,6 +21,10 @@ use 5.006; + use strict; + use warnings FATAL => 'all'; + ++use Cwd qw(abs_path); ++use File::Basename; ++my $prefix = dirname(dirname(dirname(dirname(abs_path(__FILE__))))); ++ + use Exporter; + + our @ISA = qw (Exporter); diff --git a/scripts/brewkit/fix-shebangs.ts b/scripts/brewkit/fix-shebangs.ts index 6ab0d6a5..bc300c6d 100755 --- a/scripts/brewkit/fix-shebangs.ts +++ b/scripts/brewkit/fix-shebangs.ts @@ -47,18 +47,18 @@ for (const path of Deno.args) { const [line0, ...lines] = txt.split("\n") //lol const match = line0.match(/^#!\s*(\/[^\s]+)/) - if (match) { - switch (match[1]) { - case "/usr/bin/env": - case "/bin/sh": - console.verbose({ line0, path }) - console.verbose("^^ skipped acceptable shebang") - continue - } + if (!match) throw new Error() + const interpreter = match[1] + + switch (interpreter) { + case "/usr/bin/env": + case "/bin/sh": + console.verbose({ line0, path }) + console.verbose("^^ skipped acceptable shebang") + continue } - const interpreter = new Path(line0.slice(2)).basename() - const shebang = `#!/usr/bin/env ${interpreter}` + const shebang = `#!/usr/bin/env ${new Path(interpreter).basename()}` const rewrite = undent` ${shebang}