diff options
author | Kamel Bouhara <kamel.bouhara@bootlin.com> | 2021-01-14 08:12:34 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-02-11 17:46:11 +0000 |
commit | 68443cef53b243d157fa75acf3e3be62a3754d37 (patch) | |
tree | e6fc341a8cdffabcc080bcdd5d04099ac5131351 /meta | |
parent | 2cf4a6a6306228204574a60724d4e58debb26317 (diff) | |
download | poky-68443cef53b243d157fa75acf3e3be62a3754d37.tar.gz |
npm.bbclass: make shrinkwrap file optional
Some packages don't have shrinkwrap file which
means no npmsw uri is provided in the recipe.
(From OE-Core rev: 2c17be47120d388cffafe8213a4b8a92d537805c)
Signed-off-by: Kamel Bouhara <kamel.bouhara@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 47760b0d7d66b2b68ee197d359f0b7b17374d742)
Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r-- | meta/classes/npm.bbclass | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/meta/classes/npm.bbclass b/meta/classes/npm.bbclass index 068032a1e5..d3dd1a9ab8 100644 --- a/meta/classes/npm.bbclass +++ b/meta/classes/npm.bbclass | |||
@@ -130,11 +130,17 @@ python npm_do_configure() { | |||
130 | cached_manifest.pop("dependencies", None) | 130 | cached_manifest.pop("dependencies", None) |
131 | cached_manifest.pop("devDependencies", None) | 131 | cached_manifest.pop("devDependencies", None) |
132 | 132 | ||
133 | with open(orig_shrinkwrap_file, "r") as f: | 133 | has_shrinkwrap_file = True |
134 | orig_shrinkwrap = json.load(f) | ||
135 | 134 | ||
136 | cached_shrinkwrap = copy.deepcopy(orig_shrinkwrap) | 135 | try: |
137 | cached_shrinkwrap.pop("dependencies", None) | 136 | with open(orig_shrinkwrap_file, "r") as f: |
137 | orig_shrinkwrap = json.load(f) | ||
138 | except IOError: | ||
139 | has_shrinkwrap_file = False | ||
140 | |||
141 | if has_shrinkwrap_file: | ||
142 | cached_shrinkwrap = copy.deepcopy(orig_shrinkwrap) | ||
143 | cached_shrinkwrap.pop("dependencies", None) | ||
138 | 144 | ||
139 | # Manage the dependencies | 145 | # Manage the dependencies |
140 | progress = OutOfProgressHandler(d, r"^(\d+)/(\d+)$") | 146 | progress = OutOfProgressHandler(d, r"^(\d+)/(\d+)$") |
@@ -165,8 +171,10 @@ python npm_do_configure() { | |||
165 | progress.write("%d/%d" % (progress_done, progress_total)) | 171 | progress.write("%d/%d" % (progress_done, progress_total)) |
166 | 172 | ||
167 | dev = bb.utils.to_boolean(d.getVar("NPM_INSTALL_DEV"), False) | 173 | dev = bb.utils.to_boolean(d.getVar("NPM_INSTALL_DEV"), False) |
168 | foreach_dependencies(orig_shrinkwrap, _count_dependency, dev) | 174 | |
169 | foreach_dependencies(orig_shrinkwrap, _cache_dependency, dev) | 175 | if has_shrinkwrap_file: |
176 | foreach_dependencies(orig_shrinkwrap, _count_dependency, dev) | ||
177 | foreach_dependencies(orig_shrinkwrap, _cache_dependency, dev) | ||
170 | 178 | ||
171 | # Configure the main package | 179 | # Configure the main package |
172 | with tempfile.TemporaryDirectory() as tmpdir: | 180 | with tempfile.TemporaryDirectory() as tmpdir: |
@@ -181,16 +189,19 @@ python npm_do_configure() { | |||
181 | cached_manifest[depkey] = {} | 189 | cached_manifest[depkey] = {} |
182 | cached_manifest[depkey][name] = version | 190 | cached_manifest[depkey][name] = version |
183 | 191 | ||
184 | _update_manifest("dependencies") | 192 | if has_shrinkwrap_file: |
193 | _update_manifest("dependencies") | ||
185 | 194 | ||
186 | if dev: | 195 | if dev: |
187 | _update_manifest("devDependencies") | 196 | if has_shrinkwrap_file: |
197 | _update_manifest("devDependencies") | ||
188 | 198 | ||
189 | with open(cached_manifest_file, "w") as f: | 199 | with open(cached_manifest_file, "w") as f: |
190 | json.dump(cached_manifest, f, indent=2) | 200 | json.dump(cached_manifest, f, indent=2) |
191 | 201 | ||
192 | with open(cached_shrinkwrap_file, "w") as f: | 202 | if has_shrinkwrap_file: |
193 | json.dump(cached_shrinkwrap, f, indent=2) | 203 | with open(cached_shrinkwrap_file, "w") as f: |
204 | json.dump(cached_shrinkwrap, f, indent=2) | ||
194 | } | 205 | } |
195 | 206 | ||
196 | python npm_do_compile() { | 207 | python npm_do_compile() { |