diff options
-rwxr-xr-x | dh_elpa.in | 51 |
1 files changed, 31 insertions, 20 deletions
@@ -225,35 +225,47 @@ foreach my $package (@{$dh{DOPACKAGES}}) { } verbose_print("Using elpa package name $elpapkg"); - my @files; - my @dests; + my @lines; + my @actions; my $is_single_file; + my $has_package_file = 0; # Call isnative because it sets $dh{VERSION} # as a side effect. isnative($package); if ($file) { - # Don't glob yet, we need to count the words first. - @files=filedoublearray($file); + # Read in the contents of the elpa control file into an array of + # arrays. Don't glob yet, we need to count the words first. + @lines=filedoublearray($file); + + foreach my $line (@lines) { + my $action = {}; + # On lines with more than one word, the last word is the + # destination (sub)directory + if (@$line >1) { + $action->{dest} = pop(@$line); + } + + # Glob expand every word in the current line + $action->{src} = [ map { glob_expand(["."], \&glob_expand_error_handler_warn_and_discard, $_) } @$line ]; - # On lines with more than one word, the last word is the - # destination (sub)directory - @dests=map { (@$_ > 1) ? (pop @$_) : undef; } @files; + # Check for an multi-file elpa package control file + $has_package_file ||= (grep m/\b${elpapkg}-pkg.el$/, @{$action->{src}}); - # Globexpand any remaining words, leaving them grouped as one array per line. - @files=map { map { [ glob_expand(["."], \&glob_expand_error_handler_warn_and_discard, $_) ] } @$_ } @files; + push @actions, $action; + } - $is_single_file = (scalar(@files) == 1 && scalar(@{$files[0]}) == 1); + $is_single_file = (scalar(@actions) == 1 && scalar(@{$actions[0]->{src}}) == 1); - $is_single_file || grep { $_[0] =~ m/\b${elpapkg}-pkg.el$/ } @files or - warning "missing ${elpapkg}-pkg.el; will try to generate it"; + warning "missing ${elpapkg}-pkg.el; will try to generate it" + unless ($is_single_file || $has_package_file); } if (($package eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) { - push @files, @ARGV; + push @actions, map { {"src" => $_} } @ARGV; } - next PACKAGE if (scalar(@files) == 0); + next PACKAGE if (scalar(@actions) == 0); my $pkg_file; my $cwd = getcwd(); @@ -278,7 +290,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) { error "creating $tempdir"; if ($is_single_file) { - my $pkg_file=$files[0][0]; + my $pkg_file=${$actions[0]->{src}}[0]; doit_quietly(qw{emacs -batch -Q -l package}, '--eval',"(add-to-list 'package-directory-list \"$dhelpadir\")", @@ -287,18 +299,17 @@ foreach my $package (@{$dh{DOPACKAGES}}) { qw{-f dhelpa-batch-install-file}, "$tmp/$elpadir", $pkg_file, @extra_args); } else { my $stagedir = "$tempdir/$elpapkg"; - for (my $i=0; $i<scalar(@files); $i++) { + foreach my $action (@actions) { my $targetdir = $stagedir; - if (defined ($dests[$i])) { - verbose_print("dest=$dests[$i]"); - $targetdir = $stagedir . "/" . $dests[$i]; + if (defined ($action->{dest})) { + $targetdir = $stagedir . "/" . $action->{dest}; } File::Path::make_path $targetdir || error "creating $targetdir"; - foreach my $file (@{$files[$i]}) { + foreach my $file (@{$action->{src}}) { doit("cp", "-a", $file, "$targetdir"); } } |