]> git.proxmox.com Git - dh-cargo.git/commitdiff
Handle feature packages
authorJosh Triplett <josh@joshtriplett.org>
Sat, 3 Dec 2016 06:32:49 +0000 (22:32 -0800)
committerJosh Triplett <josh@joshtriplett.org>
Sat, 3 Dec 2016 06:32:49 +0000 (22:32 -0800)
Skip feature packages (whose names contain a '+') when looking for a lib
package name.

Symlink the doc directory of feature packages to the main lib package.

cargo.pm

index 4ca24212b1ba50dce7cd0ec6032cfece6b93066e..8dc6138e47bac101be0e18279cb7b0b748993852 100644 (file)
--- a/cargo.pm
+++ b/cargo.pm
@@ -55,8 +55,16 @@ sub pre_building_step {
     my @packages = $control->get_packages();
     $this->{libpkg} = 0;
     $this->{binpkg} = 0;
+    $this->{featurepkg} = [];
     foreach my $package (@packages) {
         if ($package->{Package} =~ /^librust-.*-dev$/ && $package->{Architecture} eq 'all') {
+            if ($package->{Package} =~ /\+/) {
+                push(@{$this->{featurepkg}}, $package->{Package});
+                next;
+            }
+            if ($this->{libpkg}) {
+                error("Multiple Cargo lib packages found: " . $this->{libpkg} . " and " . $package->{Package});
+            }
             $this->{libpkg} = $package->{Package};
         } elsif ($package->{Architecture} ne 'all') {
             $this->{binpkg} = $package->{Package};
@@ -65,6 +73,9 @@ sub pre_building_step {
     if (!$this->{libpkg} && !$this->{binpkg}) {
         error("Could not find any Cargo lib or bin packages to build.");
     }
+    if (@{$this->{featurepkg}} && !$this->{libpkg}) {
+        error("Found feature packages but no lib package.");
+    }
 
     my $parallel = $this->get_parallel();
     $this->{j} = $parallel > 0 ? ["-j$parallel"] : [];
@@ -94,6 +105,11 @@ sub install {
         doit("cp", "-at", $target, @sources);
         doit("cp", $this->get_sourcepath("debian/cargo-checksum.json"), "$target/.cargo-checksum.json");
     }
+    foreach my $pkg (@{$this->{featurepkg}}) {
+        my $target = $this->get_sourcepath("debian/$pkg/usr/share/doc");
+        doit("mkdir", "-p", $target);
+        doit("ln", "-s", $this->{libpkg}, "$target/$pkg");
+    }
     if ($this->{binpkg}) {
         my $registry = $this->{cargo_registry};
         doit("mkdir", "-p", $this->{cargo_home}, $registry);