summaryrefslogtreecommitdiffstats
path: root/templ/perl-pkg
diff options
context:
space:
mode:
authorJustin Davis <jrcd83@gmail.com>2012-02-05 18:16:43 +0100
committerJustin Davis <jrcd83@gmail.com>2012-02-05 18:16:43 +0100
commitba97a989c2228e4840a0c58173b0d8f541911c69 (patch)
tree5e0fd4bae7c1270f3237f5415fef645baaf60c3d /templ/perl-pkg
parent30669532cbd4439ed731778c08c8636491f8fc6e (diff)
downloadgenpkg-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 'templ/perl-pkg')
-rwxr-xr-xtempl/perl-pkg121
1 files changed, 0 insertions, 121 deletions
diff --git a/templ/perl-pkg b/templ/perl-pkg
deleted file mode 100755
index 47cc682..0000000
--- a/templ/perl-pkg
+++ /dev/null
@@ -1,121 +0,0 @@
-#!/usr/bin/env perl
-
-use warnings 'FATAL' => 'all';
-use strict;
-
-my %ACTIONS_OF =
- ('MM', {
- 'build' => [ q{/usr/bin/perl Makefile.PL}, q{make} ],
- 'check' => [ q{make test} ],
- 'package' => [ q{make DESTDIR="$pkgdir" install} ]
- },
- 'MB', {
- 'build' => [ q{/usr/bin/perl Build.PL}, q{./Build} ],
- 'check' => [ q{./Build test} ],
- 'package' => [ q{./Build install} ]
- });
-
-my %FUNCFMTS;
-$FUNCFMTS{'build'} = <<'END_FMT';
-build()
-(
- export PERL_MM_USE_DEFAULT=1 PERL5LIB="" \
- PERL_AUTOINSTALL=--skipdeps \
- PERL_MM_OPT="INSTALLDIRS=vendor DESTDIR='$pkgdir'" \
- PERL_MB_OPT="--installdirs vendor --destdir '$pkgdir'" \
- MODULEBUILDRC=/dev/null
-
- cd "$_distdir"
-%s
-)
-END_FMT
-
-$FUNCFMTS{'check'} = <<'END_FMT';
-check()
-(
- export PERL_MM_USE_DEFAULT=1 PERL5LIB=""
- cd "$_distdir"
-%s
-)
-END_FMT
-
-$FUNCFMTS{'package'} = <<'END_FMT';
-package() {
- cd "$_distdir"
-%s
- find "$pkgdir" -name .packlist -o -name perllocal.pod -delete
-}
-END_FMT
-
-my $PBEND = <<'END_END';
-# Local Variables:
-# mode: shell-script
-# sh-basic-offset: 2
-# End:
-# vim:set ts=2 sw=2 et:
-END_END
-
-# Convert actions array into lines of bash to insert into template.
-sub bashify
-{
- my (@lines) = @_;
- my $txt = join qq{\n}, map { s/^/ /gm; $_ } @lines;
- return $txt
-}
-
-sub mungevars
-{
- my ($vars) = @_;
- $vars->{'options'} = [ '!emptydirs' ];
-
- # Replace version string in 'source' entry & 'distdir' with
- # $pkgver parameter.
- for my $v (qw/pkgver distdir/) {
- die "$0: $v is undefined" unless defined $vars->{$v}[0];
- }
- my $ver = $vars->{'pkgver'}[0];
- s/\Q$ver\E/\${pkgver}/g for ($vars->{'source'}[0], $vars->{'distdir'}[0]);
-
- return;
-}
-
-sub printpb
-{
- my ($btype, $pbvars) = @_;
- my $acts = $ACTIONS_OF{$btype}
- or die "$0: unknown build type ($btype)\n";
-
- my $distdir = $pbvars->{'distdir'}[0];
- print qq{_distdir="\${srcdir}/$distdir"\n};
- print "\n";
-
- for my $func (qw/build check package/) {
- my $funclines = $acts->{$func};
- printf $FUNCFMTS{$func}, bashify(@$funclines);
- print "\n";
- }
- print $PBEND;
-}
-
-sub readvars
-{
- local $/ = ""; # split records on empty lines
- my (%pbvars);
- while (<STDIN>) {
- my ($name, @vals) = split /\n/;
- $pbvars{$name} = [ @vals ];
- }
- return \%pbvars;
-}
-
-sub main
-{
- my ($type) = @_;
- my $vars = readvars();
- mungevars($vars);
- printpb($type, $vars);
- return 0;
-}
-
-my $type = shift or die qq{$0: please provide "MM" or "MB" as argument\n};
-exit main($type);