Skip to contentSkip to conversation

scripts/archive-source: Use GNU tar on Darwin

PATCH In review Philippe Mathieu-Daudé 3 participants 5 messages Dec 9, 2022 – Jan 12, 2023

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 scripts/archive-source: Use GNU tar on Darwin

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

'tar' default to the BSD implementation:

  $ tar --version
  bsdtar 3.5.3 - libarchive 3.5.3 zlib/1.2.11 liblzma/5.0.5 bz2lib/1.0.8

Try to use the GNU implementation if it is available (from homebrew).

---
Supersedes: <[email protected]>

---
 scripts/archive-source.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/archive-source.sh +2 -1
index 23e042dacd..e3d0c23fe5 100755
@@ -18,6 +18,7 @@ if test $# -lt 1; then
     error "Usage: $0 <output tarball>"
 fi
 
+test $(uname -s) = "Darwin" && tar=gtar || tar=tar
 tar_file=$(realpath "$1")
 sub_tdir=$(mktemp -d "${tar_file%.tar}.sub.XXXXXXXX")
 sub_file="${sub_tdir}/submodule.tar"
@@ -67,7 +68,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 --concatenate --file "$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

ping?

Quoted 45 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

'tar' default to the BSD implementation:

   $ tar --version
   bsdtar 3.5.3 - libarchive 3.5.3 zlib/1.2.11 liblzma/5.0.5 bz2lib/1.0.8

Try to use the GNU implementation if it is available (from homebrew).

---
Supersedes: <[email protected]>

---
  scripts/archive-source.sh | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
scripts/archive-source.sh +2 -1
index 23e042dacd..e3d0c23fe5 100755
@@ -18,6 +18,7 @@ if test $# -lt 1; then
      error "Usage: $0 <output tarball>"
  fi
 
+test $(uname -s) = "Darwin" && tar=gtar || tar=tar
  tar_file=$(realpath "$1")
  sub_tdir=$(mktemp -d "${tar_file%.tar}.sub.XXXXXXXX")
  sub_file="${sub_tdir}/submodule.tar"
@@ -67,7 +68,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 --concatenate --file "$tar_file" "$sub_file"
      test $? -ne 0 && error "failed append submodule $sm to $tar_file"
  done
  exit 0
#2 lore raw
Quoted 1 line · Philippe Mathieu-Daudé

ping?

Who's supposed to take this?

Quoted 25 lines · Philippe Mathieu-Daudé
Quoted 24 lines

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

'tar' default to the BSD implementation:

   $ tar --version
   bsdtar 3.5.3 - libarchive 3.5.3 zlib/1.2.11 liblzma/5.0.5 bz2lib/1.0.8

Try to use the GNU implementation if it is available (from homebrew).

---
Supersedes: <[email protected]>
---
  scripts/archive-source.sh | 3 ++-

  1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 8 lines
Quoted 8 lines
scripts/archive-source.sh +0 -0
index 23e042dacd..e3d0c23fe5 100755
@@ -18,6 +18,7 @@ if test $# -lt 1; then

      error "Usage: $0 <output tarball>"
  fi
+test $(uname -s) = "Darwin" && tar=gtar || tar=tar

I wonder whether this script works on other *BSDs ... maybe it would be better to test "tar --version | grep -q GNU" to make this even work on non-Darwin systems where "tar" is not GNU's tar?

Thomas

Quoted 13 lines
Quoted 12 lines

  tar_file=$(realpath "$1")
  sub_tdir=$(mktemp -d "${tar_file%.tar}.sub.XXXXXXXX") sub_file="${sub_tdir}/submodule.tar"

scripts/archive-source.sh +0 -0
@@ -67,7 +68,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 --concatenate --file "$tar_file" "$sub_file"
      test $? -ne 0 && error "failed append submodule $sm to $tar_file" done
  exit 0

#3 lore raw
Quoted 30 lines · Thomas Huth
Quoted 1 line · Philippe Mathieu-Daudé

ping?

Who's supposed to take this?

Quoted 25 lines · Philippe Mathieu-Daudé
Quoted 24 lines

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

'tar' default to the BSD implementation:

   $ tar --version
   bsdtar 3.5.3 - libarchive 3.5.3 zlib/1.2.11 liblzma/5.0.5 bz2lib/1.0.8

Try to use the GNU implementation if it is available (from homebrew).

---
Supersedes: <[email protected]>
---
  scripts/archive-source.sh | 3 ++-

  1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 12 lines
Quoted 8 lines
Quoted 8 lines
scripts/archive-source.sh +0 -0
index 23e042dacd..e3d0c23fe5 100755
@@ -18,6 +18,7 @@ if test $# -lt 1; then

      error "Usage: $0 <output tarball>"
  fi
+test $(uname -s) = "Darwin" && tar=gtar || tar=tar

I wonder whether this script works on other *BSDs ... maybe it would be better to test "tar --version | grep -q GNU" to make this even work on non-Darwin systems where "tar" is not GNU's tar?

Perhaps something like

  tar=$(which gtar >/dev/null 2>&1 && echo gtar || echo tar)
  $tar --version | grep GNU >/dev/null 2>&1 ||  { echo "$tar does not appear to be GNU tar" ; exit 1 }

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
In reply to Thomas Huth
Quoted 4 lines · Thomas Huth
Quoted 1 line · Philippe Mathieu-Daudé

ping?

Who's supposed to take this?

Alex Bennée? I'll precise in v3.

Quoted 25 lines
Quoted 25 lines · Philippe Mathieu-Daudé
Quoted 24 lines

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

'tar' default to the BSD implementation:

   $ tar --version
   bsdtar 3.5.3 - libarchive 3.5.3 zlib/1.2.11 liblzma/5.0.5 bz2lib/1.0.8

Try to use the GNU implementation if it is available (from homebrew).

---
Supersedes: <[email protected]>
---
  scripts/archive-source.sh | 3 ++-

  1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 10 lines
Quoted 8 lines
Quoted 8 lines
scripts/archive-source.sh +0 -0
index 23e042dacd..e3d0c23fe5 100755
@@ -18,6 +18,7 @@ if test $# -lt 1; then

      error "Usage: $0 <output tarball>"
  fi
+test $(uname -s) = "Darwin" && tar=gtar || tar=tar

I wonder whether this script works on other *BSDs ... maybe it would be better to test "tar --version | grep -q GNU" to make this even work on non-Darwin systems where "tar" is not GNU's tar?

Clever, I like it!