]> git.proxmox.com Git - dh-cargo.git/commitdiff
Pass cargo-version not Debian-version to `cargo install`
authorXimin Luo <infinity0@debian.org>
Thu, 7 Jun 2018 02:57:00 +0000 (19:57 -0700)
committerXimin Luo <infinity0@debian.org>
Thu, 7 Jun 2018 02:57:00 +0000 (19:57 -0700)
cargo.pm
debian/changelog

index d1d77fddfe88d2f11cc1ba7dea3d62a305f017e1..c850b3673731959b51803af0969e977dbfaaf96b 100644 (file)
--- a/cargo.pm
+++ b/cargo.pm
@@ -11,12 +11,22 @@ use Debian::Debhelper::Dh_Lib;
 use Dpkg::Changelog::Debian;
 use Dpkg::Control::Info;
 use Dpkg::Version;
+use JSON::PP;
 use base 'Debian::Debhelper::Buildsystem';
 
 sub DESCRIPTION {
     "Rust Cargo"
 }
 
+sub cargo_version {
+    my $src = shift;
+    open(F, "cargo metadata --manifest-path $src --no-deps --format-version 1 |");
+    local $/;
+    my $json = JSON::PP->new;
+    my $manifest = $json->decode(<F>);
+    return %{@{%{$manifest}{'packages'}}[0]}{'version'} . "\n";
+}
+
 sub check_auto_buildable {
     my $this = shift;
     if (-f $this->get_sourcepath("Cargo.toml")) {
@@ -153,7 +163,9 @@ sub install {
     }
     if ($this->{binpkg}) {
         my $target = $this->get_sourcepath("debian/" . $this->{binpkg} . "/usr");
-        doit("cargo", "install", $this->{crate}, "--verbose", "--vers", $this->{version}, "--root", $target, @{$this->{j}});
+        doit("cargo", "install", $this->{crate}, "--verbose", @{$this->{j}},
+            "--vers", cargo_version($this->get_sourcepath("Cargo.toml")),
+            "--root", $target);
         doit("rm", "$target/.crates.toml");
     }
 }
index 452148f9594427b20fc448df40dfb51ae87ecf30..be6ee122d983433e45c7fc2ec049dc1be073dc83 100644 (file)
@@ -1,3 +1,9 @@
+dh-cargo (4) UNRELEASED; urgency=medium
+
+  * Pass cargo-version not Debian-version to `cargo install`.
+
+ -- Ximin Luo <infinity0@debian.org>  Wed, 06 Jun 2018 19:50:22 -0700
+
 dh-cargo (3) unstable; urgency=medium
 
   * Update to latest Standards-Version; no changes required.