Rust subprojects have the semantic version (followed by -rs) in the subproject
name, but the full version (without -rs) is used by crates.io for the root
directory of the tarball.  Teach scripts/archive-source.sh to look for the
root directory name in wrap files.

Signed-off-by: Paolo Bonzini <pbonz...@redhat.com>
---
 scripts/archive-source.sh | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/scripts/archive-source.sh b/scripts/archive-source.sh
index 65af8063e4b..7c7727eab58 100755
--- a/scripts/archive-source.sh
+++ b/scripts/archive-source.sh
@@ -48,13 +48,33 @@ function tree_ish() {
     echo "$retval"
 }
 
+function subproject_dir() {
+    if test -f subprojects/$1.wrap; then
+      # Print the directory key of the wrap file, defaulting to the subproject 
name
+      local dir=$(sed \
+        -ne '/^\[wrap-[a-z][a-z]*\]$/!b' \
+        -e ':label' \
+        -e 'n' \
+        -e 's/^directory *= *//p' \
+        -e 'tquit' \
+        -e '/^\[$/!blabel' \
+        -e ':quit' \
+        -e 'q' \
+        subprojects/$1.wrap)
+      echo "${dir-$1}"
+    else
+      echo "error: scripts/archive-source.sh should only process wrap 
subprojects" 2>&1
+      exit 1
+    fi
+}
+
 git archive --format tar "$(tree_ish)" > "$tar_file"
 test $? -ne 0 && error "failed to archive qemu"
 
 for sp in $subprojects; do
     meson subprojects download $sp
     test $? -ne 0 && error "failed to download subproject $sp"
-    tar --append --file "$tar_file" --exclude=.git subprojects/$sp
+    tar --append --file "$tar_file" --exclude=.git 
subprojects/$(subproject_dir $sp)
     test $? -ne 0 && error "failed to append subproject $sp to $tar_file"
 done
 exit 0
-- 
2.46.2


Reply via email to