diff options
author | Justin Davis <jrcd83@gmail.com> | 2012-02-05 18:16:43 +0100 |
---|---|---|
committer | Justin Davis <jrcd83@gmail.com> | 2012-02-05 18:16:43 +0100 |
commit | ba97a989c2228e4840a0c58173b0d8f541911c69 (patch) | |
tree | 5e0fd4bae7c1270f3237f5415fef645baaf60c3d /metas/perl.d/perl-dist-funcs | |
parent | 30669532cbd4439ed731778c08c8636491f8fc6e (diff) | |
download | genpkg-ba97a989c2228e4840a0c58173b0d8f541911c69.tar.gz genpkg-ba97a989c2228e4840a0c58173b0d8f541911c69.tar.xz |
Start of big rewrite of pkg tweaking.
The current setup is only really good for modifying PKGBUILD fields. The
modification of PKGBUILD funcs is hackish. Instead, the tweaks will be
written in a scripting language (like Io) where both PKGBUILD fields
and function code can be easily modified.
Fields should be able to be modified just like arrays, but with easier
package matching going on. PKGBUILD bash functions are simply arrays
of lines, but they are not as sophisticated. Instead they can only be
appended to.
Package files are represented as trees. Each file (PKGBUILD pkg.install)
is a child of the top-level node of the tree. Each child of the file
node is a section of the file (intro, body, end). Each section can
also have its own intro, body, and end node. In this way each bash
function is a node with its own intro, body, and end node. Prepending
to a function appends to its intro node. Appending to a function appends
to its end child node. The body cannot be modified.
Diffstat (limited to 'metas/perl.d/perl-dist-funcs')
-rwxr-xr-x | metas/perl.d/perl-dist-funcs | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/metas/perl.d/perl-dist-funcs b/metas/perl.d/perl-dist-funcs new file mode 100755 index 0000000..cc9ba19 --- /dev/null +++ b/metas/perl.d/perl-dist-funcs @@ -0,0 +1,101 @@ +#!/usr/bin/env perl + +use warnings 'FATAL' => 'all'; +use strict; + +my $PROG = 'perl-dist-funcs'; + +my %BODYFOR = + ('MM', { + 'build' => [ + q{/usr/bin/perl Makefile.PL } + . q{DESTDIR="$pkgdir" INSTALLDIRS=vendor}, + q{make}, + ], + 'check' => [ q{make test} ], + 'package' => [ q{make install} ], + }, + 'MB', { + 'build' => [ + q{/usr/bin/perl Build.PL } + . q{--destdir "$pkgdir" --installdirs vendor}, + q{./Build}, + ], + 'check' => [ q{./Build test} ], + 'package' => [ q{./Build install} ], + }); + +my %FUNC; +$FUNC{'build'}{'intro'} = <<'END_INTRO'; +cd "$_distdir" +PERL_MM_USE_DEFAULT=1 PERL_AUTOINSTALL=--skipdeps MODULEBUILDRC=/dev/null +export PERL_MM_USE_DEFAULT PERL_AUTOINSTALL MODULEBUILDRC +unset PERL_MM_OPT PERL_MB_OPT PERL5LIB +END_INTRO + +$FUNC{'check'}{'intro'} = <<'END_INTRO'; +cd "$_distdir" +PERL_MM_USE_DEFAULT=1 +export PERL_MM_USE_DEFAULT +unset PERL_MM_OPT PERL_MB_OPT PERL5LIB +END_INTRO + +$FUNC{'package'}{'intro'} = <<'END_INTRO'; +cd "$_distdir" +unset PERL_MM_OPT PERL_MB_OPT PERL5LIB +END_INTRO + +$FUNC{'package'}{'end'} = <<'END_END'; +find "$pkgdir" -name .packlist -o -name perllocal.pod -delete +END_END + +my $PBEND = <<'END_END'; +# Local Variables: +# mode: shell-script +# sh-basic-offset: 2 +# End: +# vim:set ts=2 sw=2 et: +END_END + +sub printfunc +{ + my($name, $func) = @_; + print "BEGNODE $name\n"; + for my $sect (qw/intro body end/){ + if(exists $func->{$sect}){ + my $txt = $func->{$sect}; + $txt .= "\n" unless($txt =~ /\n\z/); + print "BEGNODE $sect\n", $txt, "ENDNODE $sect\n"; + } + } + print "ENDNODE $name\n"; + return; +} + +sub printfuncs +{ + my($btype) = @_; + my $acts = $BODYFOR{$btype} or die "$PROG: unknown build type: $btype"; + + print "BEGNODE PKGBUILD\n", "BEGNODE body\n"; + for my $f (keys %FUNC){ + $FUNC{$f}{'body'} = join q{}, map { "$_\n" } @{$acts->{$f}}; + printfunc($f, $FUNC{$f}); + } + print "ENDNODE body\n"; + print "BEGNODE end\n", $PBEND, "ENDNODE end\n"; + print "ENDNODE PKGBUILD\n"; + return; +} + +sub main +{ + if(@_ == 0 || ($_[0] ne 'MM' && $_[0] ne 'MB')){ + print STDERR qq{usage: $PROG ["MM" or "MB"] > PKGFUNCS\n}; + return 1; + } + printfuncs(shift); + return 0; +} + +exit main(@ARGV); |