index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
author | Dominik Fischer <d.f.fischer@web.de> | 2015-04-23 16:41:46 +0200 |
---|---|---|
committer | Allan McRae <allan@archlinux.org> | 2015-05-12 14:00:54 +1000 |
commit | b0ae59724ed36242459a91c0f9c5ce036c46de41 (patch) | |
tree | d7dc9ed3bdf32e62d5fee5f5c014c2cd661f2184 /scripts | |
parent | d4e5de4bf6b14a51f6ab23c1d80f38c2380917d8 (diff) |
-rwxr-xr-x | scripts/makepkg-template.pl.in | 37 |
diff --git a/scripts/makepkg-template.pl.in b/scripts/makepkg-template.pl.in index 71d2aae2..98777968 100755 --- a/scripts/makepkg-template.pl.in +++ b/scripts/makepkg-template.pl.in @@ -27,7 +27,7 @@ use Module::Load::Conditional qw(can_load); my %opts = ( input => '@BUILDSCRIPT@', - template_dir => '@TEMPLATE_DIR@', + template_dir => ['@TEMPLATE_DIR@'], ); my $template_name_charset = qr/[[:alnum:]+_.@-]/; @@ -98,26 +98,31 @@ sub load_template { my $ret = ""; - my $path; + my $template_name = "$values->{name}"; if (!$opts{newest} and $values->{version}) { - $path = "$opts{template_dir}/$values->{name}-$values->{version}.template"; - } else { - $path = "$opts{template_dir}/$values->{name}.template"; + $template_name .= "-$values->{version}"; } + $template_name .= ".template"; - # resolve symlink(s) and use the real file's name for version detection - my ($version) = (abs_path($path) =~ /-([0-9.]+)[.]template$/); + foreach my $dir (reverse @{$opts{template_dir}}) { + my $path = "$dir/$template_name"; + if ( -e $path ) { + # resolve symlink(s) and use the real file's name for version detection + my ($version) = (abs_path($path) =~ /-([0-9.]+)[.]template$/); - if (!$version) { - die sprintf(gettext("Couldn't detect version for template '%s'\n"), $values->{name}); - } + if (!$version) { + die sprintf(gettext("Couldn't detect version for template '%s'\n"), $path); + } - my $parsed = process_file($path); + my $parsed = process_file($path); - $ret .= "# template start; name=$values->{name}; version=$version;\n"; - $ret .= $parsed; - $ret .= "# template end;\n"; - return $ret; + $ret .= "# template start; name=$values->{name}; version=$version;\n"; + $ret .= $parsed; + $ret .= "# template end;\n"; + return $ret; + } + } + die sprintf(gettext("Failed to find template file matching '%s'\n"), $template_name); } # process input file and load templates for all markers found @@ -199,7 +204,7 @@ GetOptions( "input|p=s" => \$opts{input}, "output|o=s" => \$opts{output}, "newest|n" => \$opts{newest}, - "template-dir=s" => \$opts{template_dir}, + "template-dir=s@" => \$opts{template_dir}, ) or usage(1); $opts{output} = $opts{input} unless $opts{output}; |