[packages/rpm-build-tools] rust-crates: add support for non-top level (located in subdir) rust packages

atler atler at pld-linux.org
Sat Sep 3 12:58:18 CEST 2022


commit be8646847d29eb21b6b75a40870e3bcf85455c00
Author: Jan Palus <atler at pld-linux.org>
Date:   Sat Sep 3 12:56:54 2022 +0200

    rust-crates: add support for non-top level (located in subdir) rust packages

 rust-crates.sh | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/rust-crates.sh b/rust-crates.sh
index 8e245bc..24cebe1 100755
--- a/rust-crates.sh
+++ b/rust-crates.sh
@@ -5,6 +5,7 @@ usage() {
   echo
   echo "\t-p <package_name>\tforce cargo <package_name> for version override instead of automatic detection"
   echo "\t-o <crates_file>\tforce output file name instead of automatically determined name"
+  echo "\t-d <src subdirectory>\tsubdirectory within source directory where rust sources are located"
   echo "\t-f\t\t\toverwrite creates file if it already exists"
   echo "\t-v\t\t\tset cargo package version to @@VERSION@@ for easier crates tarball reuse"
   echo "\t-h\t\t\tprint this help"
@@ -23,7 +24,7 @@ if [ -n "$not_installed" ]; then
   exit 1
 fi
 
-while getopts :p:o:fvh OPTNAME; do
+while getopts :p:o:d:fvh OPTNAME; do
   case $OPTNAME in
     p)
       force_cargo_package="$OPTARG"
@@ -34,6 +35,9 @@ while getopts :p:o:fvh OPTNAME; do
     o)
       crates_file="$OPTARG"
       ;;
+    d)
+      subdir="$OPTARG"
+      ;;
     v)
       version_override=1
       ;;
@@ -105,7 +109,7 @@ if [ $(echo "$src_dir" | wc -l) -ne 1 ]; then
   exit 1
 fi
 
-cd "$src_dir"
+cd "$src_dir${subdir:+/$subdir}"
 cargo vendor
 if [ $? -ne 0 ]; then
   echo "ERROR: cargo vendor failed" >&2
@@ -128,8 +132,8 @@ if [ -n "$version_override" ]; then
   perl -pi -e 'BEGIN { undef $/;} s/(\[\[package\]\]\nname\s*=\s*"'"$cargo_package"'"\nversion\s*=\s*")[^"]+/$1\@\@VERSION\@\@/m' Cargo.lock
 fi
 
-cd ..
-tar cJf "$pkg_dir/$crates_file" "$src_dir"/{Cargo.lock,vendor}
+cd "$tmpdir"
+tar cJf "$pkg_dir/$crates_file" "$src_dir${subdir:+/$subdir}"/{Cargo.lock,vendor}
 echo "Created $pkg_dir/$crates_file"
 
 # vim: expandtab shiftwidth=2 tabstop=2
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/rpm-build-tools.git/commitdiff/be8646847d29eb21b6b75a40870e3bcf85455c00



More information about the pld-cvs-commit mailing list