- added helper scripts to build cargo vendor tarball auto/th/cargo-0.19.0-0.1
authorJan Rękorajski <baggins@pld-linux.org>
Tue, 27 Jun 2017 19:16:16 +0000 (21:16 +0200)
committerJan Rękorajski <baggins@pld-linux.org>
Tue, 27 Jun 2017 19:16:16 +0000 (21:16 +0200)
build-cargo-vendor.sh [new file with mode: 0755]
cargo-checksums-prune.py [new file with mode: 0755]
vendor-tarball-filter.txt [new file with mode: 0644]

diff --git a/build-cargo-vendor.sh b/build-cargo-vendor.sh
new file mode 100755 (executable)
index 0000000..74e382d
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+# Script to build vendor tarball
+#
+# Prerequisites:
+# - installed cargo and rust
+# - installed cargo-vendor from https://github.com/alexcrichton/cargo-vendor
+
+CARGO_VER=$1
+VENDOR_FILTER=../vendor-tarball-filter.txt
+
+tar xzf cargo-${CARGO_VER}.tar.gz
+cd cargo-${CARGO_VER}
+cargo vendor --explicit-version --verbose
+
+grep -v '^#' ${VENDOR_FILTER} | xargs  -I% sh -c 'rm -rf vendor/%'
+for i in vendor/* ; do
+       ../cargo-checksums-prune.py "$i"
+done
+
+tar cJvf cargo-${CARGO_VER}-vendor.tar.xz vendor
diff --git a/cargo-checksums-prune.py b/cargo-checksums-prune.py
new file mode 100755 (executable)
index 0000000..5589799
--- /dev/null
@@ -0,0 +1,28 @@
+#!/usr/bin/env python3
+
+# Copyright: 2015 The Debian Project
+# License: MIT-License or Apache-2.0
+#
+# Helper to remove removed-files from .cargo-checksum
+# TODO: rewrite to perl and add to dh-cargo, maybe?
+
+from collections import OrderedDict
+import json
+import os
+import sys
+
+def main(pkgdir):
+  os.chdir(pkgdir)
+  with open(".cargo-checksum.json") as fp:
+    sums = json.load(fp, object_pairs_hook=OrderedDict)
+  
+  oldfiles = sums["files"]
+  newfiles = OrderedDict([entry for entry in oldfiles.items() if os.path.exists(entry[0])])
+  sums["files"] = newfiles
+  
+  if len(oldfiles) > len(newfiles):
+    with open(".cargo-checksum.json", "w") as fp:
+      json.dump(sums, fp, separators=(',', ':'))
+
+if __name__ == "__main__":
+  main(sys.argv[1] if len(sys.argv) > 1 else ".")
diff --git a/vendor-tarball-filter.txt b/vendor-tarball-filter.txt
new file mode 100644 (file)
index 0000000..0b9ffd3
--- /dev/null
@@ -0,0 +1,9 @@
+# This is a list of files and dirs that should be filtered from
+# deps tarball for copyright/duplication reasons
+curl-sys-*/curl/
+libgit2-sys-*/libgit2*/
+libssh2-sys-*/libssh2*/
+libz-sys-*/src/zlib-*/
+
+# To clean deps before making a new tarball, run
+# grep -v '^#' debian/deps-tarball-filter.txt | xargs -I% sh -c 'rm -rf %'
This page took 0.061215 seconds and 4 git commands to generate.