]> git.pld-linux.org Git - packages/rust-cbindgen.git/commitdiff
up to 0.17.0
authorJan Palus <atler@pld-linux.org>
Tue, 23 Feb 2021 16:56:24 +0000 (17:56 +0100)
committerJan Palus <atler@pld-linux.org>
Tue, 23 Feb 2021 16:56:50 +0000 (17:56 +0100)
- adapt create-crates.sh script from delta

create-crates.sh [new file with mode: 0755]
rust-cbindgen.spec

diff --git a/create-crates.sh b/create-crates.sh
new file mode 100755 (executable)
index 0000000..f74b258
--- /dev/null
@@ -0,0 +1,72 @@
+#!/bin/sh
+
+force_cargo_package="cbindgen"
+force_source_name="cbindgen"
+
+for cmd in bsdtar rpm-specdump cargo perl; do
+  if ! command -v $cmd > /dev/null 2> /dev/null; then
+    not_installed="$not_installed$cmd "
+  fi
+done
+
+if [ -n "$not_installed" ]; then
+  echo "ERROR: required commands not found: $not_installed" >&2
+  exit 1
+fi
+
+pkg_dir=$(readlink -f $(dirname "$0"))
+pkg_name=$(basename "$pkg_dir")
+
+if [ ! -f "$pkg_dir/$pkg_name.spec" ]; then
+  echo "ERROR: unable to determine package name" >&2
+  exit 1
+fi
+
+spec_dump=$(rpm-specdump "$pkg_dir/$pkg_name.spec")
+pkg_version=$(echo "$spec_dump" | grep PACKAGE_VERSION | cut -f3 -d' ')
+pkg_src=$(basename $(echo "$spec_dump" | grep SOURCEURL0 | cut -f3- -d' '))
+crates_file="${force_source_name:-$pkg_name}-crates-$pkg_version.tar.xz"
+cargo_package=${force_cargo_package:-$pkg_name}
+
+if [ -e "$pkg_dir/$crates_file" ]; then
+  echo "ERROR: crates file $crates_file already exists" >&2
+  exit 1
+fi
+
+if [ ! -f "$pkg_dir/$pkg_src" ]; then
+  echo "ERROR: source file $pkg_src not found" >&2
+  exit 1
+fi
+
+tmpdir=$(mktemp -d)
+
+rm_tmpdir() {
+  if [ -n "$tmpdir" -a -d "$tmpdir" ]; then
+    rm -rf "$tmpdir"
+  fi
+}
+
+trap rm_tmpdir EXIT INT HUP
+
+cd "$tmpdir"
+bsdtar xf "$pkg_dir/$pkg_src"
+src_dir=$(ls)
+if [ $(echo "$src_dir" | wc -l) -ne 1 ]; then
+  echo "ERROR: unexpected source structure:\n$src_dir" >&2
+  exit 1
+fi
+
+cd "$src_dir"
+cargo vendor
+if [ $? -ne 0 ]; then
+  echo "ERROR: cargo vendor failed" >&2
+  exit 1
+fi
+
+# replace cargo package version with @@VERSION@@
+perl -pi -e 'BEGIN { undef $/;} s/(\[\[package\]\]\nname\s*=\s*"'"$cargo_package"'"\nversion\s*=\s*")[^"]+/$1\@\@VERSION\@\@/m' Cargo.lock
+
+cd ..
+tar cJf "$pkg_dir/$crates_file" "$src_dir"/{Cargo.lock,vendor}
+
+# vim: expandtab shiftwidth=2 tabstop=2
index 40195da80beb641441f397e0fdcacb13c3143d61..f04f87915a0b4a0b276fb0b9b80995d5aef0b154 100644 (file)
@@ -1,20 +1,22 @@
 # TODO: use shared crates?
+%define                crates_ver      0.17.0
+
 Summary:       Tool for generating C bindings to Rust code
 Summary(pl.UTF-8):     Narzędzie do generowania wiązań C do kodu w języku Rust
 Name:          rust-cbindgen
-Version:       0.15.0
+Version:       0.17.0
 Release:       1
 License:       MPL v2.0
 Group:         Development/Tools
 #Source0Download: https://github.com/eqrion/cbindgen/releases
 Source0:       https://github.com/eqrion/cbindgen/archive/v%{version}/cbindgen-%{version}.tar.gz
-# Source0-md5: 396f97c1d79ee5307611e7d586b4b011
+# Source0-md5: 319023d51257da454f9a30aa3a358429
 # cd cbindgen-%{version}
 # cargo vendor
 # cd ..
 # tar cJf cbindgen-crates-%{version}.tar.xz cbindgen-%{version}/{vendor,Cargo.lock}
-Source1:       cbindgen-crates-%{version}.tar.xz
-# Source1-md5: 446fd55fe1d587ec28ad6f9bc938b50c
+Source1:       cbindgen-crates-%{crates_ver}.tar.xz
+# Source1-md5: 591b55e08ff5221aa86ab761b5a73ef6
 URL:           https://github.com/eqrion/cbindgen
 BuildRequires: cargo
 BuildRequires: rust
@@ -28,7 +30,10 @@ This project can be used to generate C bindings for Rust code.
 Ten projekt służy do generowania wiązań C do kodu w języku Rust.
 
 %prep
-%setup -q -n cbindgen-%{version} -b1
+%setup -q -n cbindgen-%{version} -a1
+
+%{__mv} cbindgen-%{crates_ver}/* .
+sed -i -e 's/@@VERSION@@/%{version}/' Cargo.lock
 
 # use our offline registry
 export CARGO_HOME="$(pwd)/.cargo"
This page took 0.220478 seconds and 4 git commands to generate.