[bitbake-devel] [PATCH 1/3] utils.py: Add sha1_file call
Peter Kjellerstedt
peter.kjellerstedt at axis.com
Mon Feb 29 10:14:41 UTC 2016
> -----Original Message-----
> From: bitbake-devel-bounces at lists.openembedded.org [mailto:bitbake-
> devel-bounces at lists.openembedded.org] On Behalf Of
> brendan.le.foll at intel.com
> Sent: den 25 februari 2016 16:07
> To: bitbake-devel at lists.openembedded.org
> Subject: [bitbake-devel] [PATCH 1/3] utils.py: Add sha1_file call
>
> From: Brendan Le Foll <brendan.le.foll at intel.com>
>
> This is useful as npm-lockdown uses sha1 because npm releases the sha1 of
> packages and whilst this is undocumented it seems no other algorithm is
> supported
>
> Signed-off-by: Brendan Le Foll <brendan.le.foll at intel.com>
> ---
> lib/bb/utils.py | 15 +++++++++++++++
> 1 file changed, 15 insertions(+)
>
> diff --git a/lib/bb/utils.py b/lib/bb/utils.py
> index 82579b8..7ab8927 100644
> --- a/lib/bb/utils.py
> +++ b/lib/bb/utils.py
> @@ -534,6 +534,21 @@ def sha256_file(filename):
> s.update(line)
> return s.hexdigest()
>
> +def sha1_file(filename):
> + """
> + Return the hex string representation of the SHA1 checksum of the filename
I saw that this was already integrated, but I think the above
description is very misleading. I read it as that the function
returns the SHA-1 checksum of the file name, but by reading the
code it is obvious that it returns the SHA-1 checksum of the
file contents...
I would change "the filename" to "a file".
> + """
> + try:
> + import hashlib
> + except ImportError:
> + return None
> +
> + s = hashlib.sha1()
> + with open(filename, "rb") as f:
> + for line in f:
> + s.update(line)
> + return s.hexdigest()
> +
> def preserved_envvars_exported():
> """Variables which are taken from the environment and placed in and exported
> from the metadata"""
> --
> 2.7.1
//Peter
More information about the bitbake-devel
mailing list