diff options
Diffstat (limited to 'meta/classes-recipe')
-rw-r--r-- | meta/classes-recipe/cargo-update-recipe-crates.bbclass | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/meta/classes-recipe/cargo-update-recipe-crates.bbclass b/meta/classes-recipe/cargo-update-recipe-crates.bbclass index daa363b0dd..322b4e4d79 100644 --- a/meta/classes-recipe/cargo-update-recipe-crates.bbclass +++ b/meta/classes-recipe/cargo-update-recipe-crates.bbclass | |||
@@ -38,25 +38,12 @@ def get_crates(f): | |||
38 | if not crates_candidates: | 38 | if not crates_candidates: |
39 | raise ValueError("Unable to find any candidate crates that use crates.io") | 39 | raise ValueError("Unable to find any candidate crates that use crates.io") |
40 | 40 | ||
41 | # Build a list of crates name that have multiple version | ||
42 | crates_multiple_vers = [] | ||
43 | tmp = [] | ||
44 | for c in crates_candidates: | ||
45 | if c['name'] in tmp: | ||
46 | crates_multiple_vers.append(c['name']) | ||
47 | else: | ||
48 | tmp.append(c['name']) | ||
49 | |||
50 | # Update crates uri and their checksum, to avoid name clashing on the checksum | 41 | # Update crates uri and their checksum, to avoid name clashing on the checksum |
51 | # we need to rename crates of the same name but different version | 42 | # we need to rename crates with name and version to have a unique key |
52 | cksum_list = '' | 43 | cksum_list = '' |
53 | for c in crates_candidates: | 44 | for c in crates_candidates: |
54 | if c['name'] in crates_multiple_vers: | 45 | rename = "%s-%s" % (c['name'], c['version']) |
55 | rename = "%s-%s" % (c['name'], c['version']) | 46 | c_list += '\n crate://crates.io/%s/%s;name=%s \\\' % (c['name'], c['version'], rename) |
56 | c_list += '\n crate://crates.io/%s/%s;name=%s \\\' % (c['name'], c['version'], rename) | ||
57 | else: | ||
58 | rename = c['name'] | ||
59 | c_list += '\n crate://crates.io/%s/%s \\\' % (c['name'], c['version']) | ||
60 | if 'checksum' in c: | 47 | if 'checksum' in c: |
61 | cksum_list += '\nSRC_URI[%s.sha256sum] = "%s"' % (rename, c['checksum']) | 48 | cksum_list += '\nSRC_URI[%s.sha256sum] = "%s"' % (rename, c['checksum']) |
62 | 49 | ||
@@ -69,12 +56,22 @@ import os | |||
69 | crates = "# Autogenerated with 'bitbake -c update_crates ${PN}'\n\n" | 56 | crates = "# Autogenerated with 'bitbake -c update_crates ${PN}'\n\n" |
70 | found = False | 57 | found = False |
71 | for root, dirs, files in os.walk('${CARGO_LOCK_SRC_DIR}'): | 58 | for root, dirs, files in os.walk('${CARGO_LOCK_SRC_DIR}'): |
59 | # ignore git and patches directories | ||
60 | if root.startswith(os.path.join('${CARGO_LOCK_SRC_DIR}', '.pc')): | ||
61 | continue | ||
62 | if root.startswith(os.path.join('${CARGO_LOCK_SRC_DIR}', '.git')): | ||
63 | continue | ||
72 | for file in files: | 64 | for file in files: |
73 | if file == 'Cargo.lock': | 65 | if file == 'Cargo.lock': |
74 | crates += get_crates(os.path.join(root, file)) | 66 | try: |
75 | found = True | 67 | cargo_lock_path = os.path.join(root, file) |
68 | crates += get_crates(os.path.join(root, file)) | ||
69 | except Exception as e: | ||
70 | raise ValueError("Cannot parse '%s'" % cargo_lock_path) from e | ||
71 | else: | ||
72 | found = True | ||
76 | if not found: | 73 | if not found: |
77 | raise ValueError("Unable to find Cargo.lock in ${CARGO_LOCK_SRC_DIR}") | 74 | raise ValueError("Unable to find any Cargo.lock in ${CARGO_LOCK_SRC_DIR}") |
78 | open("${TARGET_FILE}", 'w').write(crates) | 75 | open("${TARGET_FILE}", 'w').write(crates) |
79 | EOF | 76 | EOF |
80 | 77 | ||