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"
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"
o)
crates_file="$OPTARG"
;;
+ d)
+ subdir="$OPTARG"
+ ;;
v)
version_override=1
;;
exit 1
fi
-cd "$src_dir"
+cd "$src_dir${subdir:+/$subdir}"
cargo vendor
if [ $? -ne 0 ]; then
echo "ERROR: cargo vendor failed" >&2
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