diff mbox series

sanity: check for GNU tar specifically

Message ID 20221028152354.652211-1-ross.burton@arm.com
State Accepted, archived
Commit 7dd2b1cd1bb10e67485dab8600c0787df6c2eee7
Headers show
Series sanity: check for GNU tar specifically | expand

Commit Message

Ross Burton Oct. 28, 2022, 3:23 p.m. UTC
We need the system tar to be GNU tar, as we reply on --xattrs.  Some
distributions may be using libarchive's tar binary, which is definitely
not as featureful, so check for this and abort early with a clear
message instead of later with mysterious errors.

Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 meta/classes-global/sanity.bbclass | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Peter Kjellerstedt Oct. 29, 2022, 2:43 p.m. UTC | #1
> -----Original Message-----
> From: openembedded-core@lists.openembedded.org <openembedded-core@lists.openembedded.org> On Behalf Of Ross Burton
> Sent: den 28 oktober 2022 17:24
> To: openembedded-core@lists.openembedded.org
> Cc: nd@arm.com
> Subject: [OE-core] [PATCH] sanity: check for GNU tar specifically
> 
> We need the system tar to be GNU tar, as we reply on --xattrs.  Some

Change "reply" to "rely".

> distributions may be using libarchive's tar binary, which is definitely
> not as featureful, so check for this and abort early with a clear
> message instead of later with mysterious errors.
> 
> Signed-off-by: Ross Burton <ross.burton@arm.com>
> ---
>  meta/classes-global/sanity.bbclass | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/meta/classes-global/sanity.bbclass b/meta/classes-global/sanity.bbclass
> index 15067e78d3c..606444cae18 100644
> --- a/meta/classes-global/sanity.bbclass
> +++ b/meta/classes-global/sanity.bbclass
> @@ -504,6 +504,14 @@ def check_tar_version(sanity_data):
>      version = result.split()[3]
>      if bb.utils.vercmp_string_op(version, "1.28", "<"):
>          return "Your version of tar is older than 1.28 and does not have the support needed to enable reproducible builds. Please install a newer version of tar (you could use the project's buildtools-tarball from our last release or use scripts/install-buildtools).\n"
> +
> +    try:
> +        result = subprocess.check_output(["tar", "--help"], stderr=subprocess.STDOUT).decode('utf-8')
> +        if "--xattrs" not in result:
> +            return "Your tar doesn't support --xattrs, please use GNU tar.\n"
> +    except subprocess.CalledProcessError as e:
> +        return "Unable to execute tar --help, exit code %d\n%s\n" % (e.returncode, e.output)
> +

Would it make sense to actually check that it is GNU tar that is being 
used, and do that before the version check above? Because the version 
check does not make much sense if it is not GNU tar...

>      return None
> 
>  # We use git parameters and functionality only found in 1.7.8 or later
> --
> 2.34.1

//Peter
diff mbox series

Patch

diff --git a/meta/classes-global/sanity.bbclass b/meta/classes-global/sanity.bbclass
index 15067e78d3c..606444cae18 100644
--- a/meta/classes-global/sanity.bbclass
+++ b/meta/classes-global/sanity.bbclass
@@ -504,6 +504,14 @@  def check_tar_version(sanity_data):
     version = result.split()[3]
     if bb.utils.vercmp_string_op(version, "1.28", "<"):
         return "Your version of tar is older than 1.28 and does not have the support needed to enable reproducible builds. Please install a newer version of tar (you could use the project's buildtools-tarball from our last release or use scripts/install-buildtools).\n"
+
+    try:
+        result = subprocess.check_output(["tar", "--help"], stderr=subprocess.STDOUT).decode('utf-8')
+        if "--xattrs" not in result:
+            return "Your tar doesn't support --xattrs, please use GNU tar.\n"
+    except subprocess.CalledProcessError as e:
+        return "Unable to execute tar --help, exit code %d\n%s\n" % (e.returncode, e.output)
+
     return None
 
 # We use git parameters and functionality only found in 1.7.8 or later