* [PATCH 1/4] spdx.bbclass: Replace deprecated string.replace with str.replace
2018-07-16 15:05 [PATCH 0/4] Small spdx.bbclass fixes Olof Johansson
@ 2018-07-16 15:05 ` Olof Johansson
2018-07-16 15:05 ` [PATCH 2/4] spdx.bbclass: Fix undefined variable error Olof Johansson
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Olof Johansson @ 2018-07-16 15:05 UTC (permalink / raw)
To: openembedded-core; +Cc: Olof Johansson
The string.replace function is removed in python3. Instead, the str
method "replace" should be used instead.
Signed-off-by: Olof Johansson <olofjn@axis.com>
---
meta/classes/spdx.bbclass | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/meta/classes/spdx.bbclass b/meta/classes/spdx.bbclass
index c5f544d2a4f..ab2eaa5c0c1 100644
--- a/meta/classes/spdx.bbclass
+++ b/meta/classes/spdx.bbclass
@@ -226,7 +226,7 @@ def run_fossology(foss_command, full_spdx):
except subprocess.CalledProcessError as e:
return None
- foss_output = string.replace(foss_output, '\r', '')
+ foss_output = foss_output.replace('\r', '')
# Package info
package_info = {}
--
2.11.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH 2/4] spdx.bbclass: Fix undefined variable error
2018-07-16 15:05 [PATCH 0/4] Small spdx.bbclass fixes Olof Johansson
2018-07-16 15:05 ` [PATCH 1/4] spdx.bbclass: Replace deprecated string.replace with str.replace Olof Johansson
@ 2018-07-16 15:05 ` Olof Johansson
2018-07-16 15:05 ` [PATCH 3/4] spdx.bbclass: Make use of bb.utils' sha1_file() Olof Johansson
2018-07-16 15:05 ` [PATCH 4/4] spdx.bbclass: Encode strings before passing to hashlib Olof Johansson
3 siblings, 0 replies; 5+ messages in thread
From: Olof Johansson @ 2018-07-16 15:05 UTC (permalink / raw)
To: openembedded-core; +Cc: Olof Johansson
The path variable is used in an error message a few lines later, but was
never defined.
Signed-off-by: Olof Johansson <olofjn@axis.com>
---
meta/classes/spdx.bbclass | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/meta/classes/spdx.bbclass b/meta/classes/spdx.bbclass
index ab2eaa5c0c1..9e374d70a6c 100644
--- a/meta/classes/spdx.bbclass
+++ b/meta/classes/spdx.bbclass
@@ -289,7 +289,8 @@ def create_spdx_doc(file_info, scanned_files):
def get_ver_code(dirname):
chksums = []
for f_dir, f in list_files(dirname):
- hash = hash_file(os.path.join(dirname, f_dir, f))
+ path = os.path.join(dirname, f_dir, f)
+ hash = hash_file(path)
if not hash is None:
chksums.append(hash)
else:
--
2.11.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH 3/4] spdx.bbclass: Make use of bb.utils' sha1_file()
2018-07-16 15:05 [PATCH 0/4] Small spdx.bbclass fixes Olof Johansson
2018-07-16 15:05 ` [PATCH 1/4] spdx.bbclass: Replace deprecated string.replace with str.replace Olof Johansson
2018-07-16 15:05 ` [PATCH 2/4] spdx.bbclass: Fix undefined variable error Olof Johansson
@ 2018-07-16 15:05 ` Olof Johansson
2018-07-16 15:05 ` [PATCH 4/4] spdx.bbclass: Encode strings before passing to hashlib Olof Johansson
3 siblings, 0 replies; 5+ messages in thread
From: Olof Johansson @ 2018-07-16 15:05 UTC (permalink / raw)
To: openembedded-core; +Cc: Olof Johansson
The same functionality already exists within bitbake, so avoid
duplicating.
Signed-off-by: Olof Johansson <olofjn@axis.com>
---
meta/classes/spdx.bbclass | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/meta/classes/spdx.bbclass b/meta/classes/spdx.bbclass
index 9e374d70a6c..a3e22afc33d 100644
--- a/meta/classes/spdx.bbclass
+++ b/meta/classes/spdx.bbclass
@@ -202,13 +202,8 @@ def list_files(dir):
return
def hash_file(file_name):
- try:
- with open(file_name, 'rb') as f:
- data_string = f.read()
- sha1 = hash_string(data_string)
- return sha1
- except:
- return None
+ from bb.utils import sha1_file
+ return sha1_file(file_name)
def hash_string(data):
import hashlib
--
2.11.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH 4/4] spdx.bbclass: Encode strings before passing to hashlib
2018-07-16 15:05 [PATCH 0/4] Small spdx.bbclass fixes Olof Johansson
` (2 preceding siblings ...)
2018-07-16 15:05 ` [PATCH 3/4] spdx.bbclass: Make use of bb.utils' sha1_file() Olof Johansson
@ 2018-07-16 15:05 ` Olof Johansson
3 siblings, 0 replies; 5+ messages in thread
From: Olof Johansson @ 2018-07-16 15:05 UTC (permalink / raw)
To: openembedded-core; +Cc: Olof Johansson
In python3, passing a unicode object to hashlib will result in an
exception that encourages you to encode it first.
Signed-off-by: Olof Johansson <olofjn@axis.com>
---
meta/classes/spdx.bbclass | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/meta/classes/spdx.bbclass b/meta/classes/spdx.bbclass
index a3e22afc33d..fb78e274a8e 100644
--- a/meta/classes/spdx.bbclass
+++ b/meta/classes/spdx.bbclass
@@ -208,7 +208,7 @@ def hash_file(file_name):
def hash_string(data):
import hashlib
sha1 = hashlib.sha1()
- sha1.update(data)
+ sha1.update(data.encode('utf-8'))
return sha1.hexdigest()
def run_fossology(foss_command, full_spdx):
--
2.11.0
^ permalink raw reply related [flat|nested] 5+ messages in thread