From 7687af08616870b4cd3d3625fafa84b8886e4ea8 Mon Sep 17 00:00:00 2001 From: Matt Borgerson Date: Sun, 4 Jan 2026 23:04:49 -0700 Subject: [PATCH] scripts/archive-source.sh: Support prefixing tar --- scripts/archive-source.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/archive-source.sh b/scripts/archive-source.sh index 12d2897689..bf147ab342 100755 --- a/scripts/archive-source.sh +++ b/scripts/archive-source.sh @@ -15,10 +15,13 @@ error() { } if test $# -lt 1; then - error "Usage: $0 " + error "Usage: $0 " fi tar_file=$(realpath "$1") +tar_prefix=${2:-./} +[[ "$tar_prefix" == ./* && "$tar_prefix" == */ ]] || { echo "Invalid prefix (should be .//)"; exit 1; } + sub_tdir=$(mktemp -d "${tar_file%.tar}.sub.XXXXXXXX") sub_file="${sub_tdir}/submodule.tar" @@ -78,14 +81,14 @@ function subproject_dir() { echo "${dir:-$1}" } -git archive --format tar "$(tree_ish)" > "$tar_file" +git archive --format tar "$(tree_ish)" --prefix="$tar_prefix" > "$tar_file" test $? -ne 0 && error "failed to archive qemu" meson subprojects download -j8 $subprojects # test $? -ne 0 && error "failed to download subprojects" for sp in $subprojects; do - tar --append --file "$tar_file" --exclude=.git subprojects/"$(subproject_dir $sp)" + tar --append --file "$tar_file" --exclude=.git --transform "s,^./,$tar_prefix," ./subprojects/"$(subproject_dir $sp)" test $? -ne 0 && error "failed to append subproject $sp to $tar_file" done