Skip to contentSkip to conversation

scripts/archive-source: Use more portable argument with tar command

PATCH In review Philippe Mathieu-Daudé 4 participants 5 messages Dec 8, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scripts/archive-source: Use more portable argument with tar command

When using the archive-source.sh script on Darwin we get:

tar: Option --concatenate is not supported Usage:
List: tar -tf <archive-filename>
Extract: tar -xf <archive-filename>
Create: tar -cf <archive-filename> [filenames...]
Help: tar --help

Replace the long argument added by commit 8fc76176f6 ("scripts: use git-archive in archive-source") by their short form to keep this script functional.

---
 scripts/archive-source.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/archive-source.sh +1 -1
index 23e042dacd..6a710a212e 100755
@@ -67,7 +67,7 @@ for sm in $submodules; do
     esac
     (cd $sm; git archive --format tar --prefix "$sm/" $(tree_ish)) > "$sub_file"
     test $? -ne 0 && error "failed to archive submodule $sm ($smhash)"
-    tar --concatenate --file "$tar_file" "$sub_file"
+    tar -c -f "$tar_file" "$sub_file"
     test $? -ne 0 && error "failed append submodule $sm to $tar_file"
 done
 exit 0
Signature · 1 line
2.38.1
#1 lore raw
Quoted 24 lines · Philippe Mathieu-Daudé

When using the archive-source.sh script on Darwin we get:

tar: Option --concatenate is not supported Usage:
List: tar -tf <archive-filename>
Extract: tar -xf <archive-filename>
Create: tar -cf <archive-filename> [filenames...]
Help: tar --help

Replace the long argument added by commit 8fc76176f6 ("scripts: use git-archive in archive-source") by their short form to keep this script functional.

---
 scripts/archive-source.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/archive-source.sh +0 -0
index 23e042dacd..6a710a212e 100755

scripts/archive-source.sh for sm in $submodules; do · line 70

Quoted 5 lines
scripts/archive-source.sh +1 -1
@@ -67,7 +67,7 @@ for sm in $submodules; do
     esac
     (cd $sm; git archive --format tar --prefix "$sm/" $(tree_ish)) > "$sub_file"
     test $? -ne 0 && error "failed to archive submodule $sm ($smhash)"
-    tar --concatenate --file "$tar_file" "$sub_file"
+    tar -c -f "$tar_file" "$sub_file"

'-c' is not the short-form option of '--concatenate': that would be '-A'. The problem is not long vs short options, but that BSD-style tar does not support the --concatenate functionality at all.

scripts/archive-source.sh for sm in $submodules; do · line 73

Quoted 3 lines
scripts/archive-source.sh +0 -0
     test $? -ne 0 && error "failed append submodule $sm to $tar_file"
 done
 exit 0

thanks
-- PMM

#2 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 23 lines · Philippe Mathieu-Daudé

When using the archive-source.sh script on Darwin we get:

tar: Option --concatenate is not supported Usage:
List: tar -tf <archive-filename>
Extract: tar -xf <archive-filename>
Create: tar -cf <archive-filename> [filenames...]
Help: tar --help

Replace the long argument added by commit 8fc76176f6 ("scripts: use git-archive in archive-source") by their short form to keep this script functional.

---
 scripts/archive-source.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/archive-source.sh +0 -0
index 23e042dacd..6a710a212e 100755

scripts/archive-source.sh for sm in $submodules; do · line 70

Quoted 5 lines
scripts/archive-source.sh +1 -1
@@ -67,7 +67,7 @@ for sm in $submodules; do
     esac
     (cd $sm; git archive --format tar --prefix "$sm/" $(tree_ish)) > "$sub_file"
     test $? -ne 0 && error "failed to archive submodule $sm ($smhash)"
-    tar --concatenate --file "$tar_file" "$sub_file"
+    tar -c -f "$tar_file" "$sub_file"

I'm not sure that is correct. The gnu shortform for --concatenate is -A, -c is specifically create so I suspect you end up re-creating the tarball rather than adding to it.

Quoted 3 lines
scripts/archive-source.sh +0 -0
     test $? -ne 0 && error "failed append submodule $sm to $tar_file"
 done
 exit 0
Signature · 1 line
Alex Bennée
#3 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 9 lines · Philippe Mathieu-Daudé

When using the archive-source.sh script on Darwin we get:

tar: Option --concatenate is not supported Usage:
List: tar -tf <archive-filename>
Extract: tar -xf <archive-filename>
Create: tar -cf <archive-filename> [filenames...]
Help: tar --help

Quoted 3 lines

Replace the long argument added by commit 8fc76176f6 ("scripts: use git-archive in archive-source") by their short form to keep this script functional.

Or install a better tar implementation from brew ?

https://formulae.brew.sh/formula/gnu-tar

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#4 lore raw
Quoted 10 lines · Daniel P. Berrangé
Quoted 9 lines · Philippe Mathieu-Daudé

When using the archive-source.sh script on Darwin we get:

tar: Option --concatenate is not supported Usage:
List: tar -tf <archive-filename>
Extract: tar -xf <archive-filename>
Create: tar -cf <archive-filename> [filenames...]
Help: tar --help

Quoted 7 lines
Quoted 3 lines

Replace the long argument added by commit 8fc76176f6 ("scripts: use git-archive in archive-source") by their short form to keep this script functional.

Or install a better tar implementation from brew ?

https://formulae.brew.sh/formula/gnu-tar

Good idea, this works for me:

-- >8 --

scripts/archive-source.sh +2 -1
index 23e042dacd..150bdf5536 100755
@@ -20,2 +20,3 @@ fi
 
+tar=$(command -v gtar || command -v tar)
 tar_file=$(realpath "$1")
@@ -69,3 +70,3 @@ for sm in $submodules; do
     test $? -ne 0 && error "failed to archive submodule $sm ($smhash)"
-    tar --concatenate --file "$tar_file" "$sub_file"
+    $tar --concatenate --file "$tar_file" "$sub_file"
     test $? -ne 0 && error "failed append submodule $sm to $tar_file"

---