summaryrefslogtreecommitdiff
path: root/dh_elpa
blob: be68a1f24b0f14bab4e006859ea8c14af170c7fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/perl

use strict;
use Cwd qw{ getcwd };
use File::Temp qw{ tempdir };

use Debian::Debhelper::Dh_Lib;

init();

my $elpadir="/usr/share/emacs/site-lisp/elpa";

foreach my $package (@{$dh{DOPACKAGES}}) {

  my $tmp=tmpdir($package);
  my $file=pkgfile($package,"elpa");

  my @files;

  # Call isnative because it sets $dh{VERSION}
  # as a side effect.
  isnative($package);
  if ($file) {
    @files=filearray($file, ".");
  }
  if (($package eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL})
      && @ARGV) {
    push @files, @ARGV;
  }

  my $pkg_file;
  if (scalar(@files) == 1) {
    $pkg_file=$files[0];
  } else {
    # TODO: add CLEANUP when somewhat debugged.
    my $tempdir = tempdir();
    my $version = $dh{VERSION} or die "version not found!";
    $version =~ s/-[^-]+//;  # strip Debian version
    my $pkg_dir = "$package-$version";

    $pkg_file = "$tempdir/$pkg_dir.tar";
    mkdir "$tempdir/$pkg_dir" or die "$!";

    # copy files into tempdir, flattening hierarchy
    # TODO: do this more correctly
    foreach my $el_file (@files) {
      doit("cp", "-a", $el_file, "$tempdir/$pkg_dir");
    }

    my $cwd = getcwd();
    chdir $tempdir or die "$!";
    doit("tar","cf",$pkg_file,$pkg_dir);
    chdir $cwd or die "$!";
  }

  doit(qw{emacs -batch -Q -l package},
       '--eval',"(add-to-list 'package-directory-list \"$elpadir\")",
       qw{-f package-initialize -l dh-elpa.el},
       qw{-f dhelpa-batch-install-file}, "$tmp/$elpadir", $pkg_file);
}