Skip to content

Commit 28aeebe

Browse files
Support assembly in multi-flavour manifests
Reference: #3604 Signed-off-by: Ayan Sinha Mahapatra <[email protected]>
1 parent 50d2afe commit 28aeebe

File tree

2 files changed

+127
-5
lines changed

2 files changed

+127
-5
lines changed

src/packagedcode/plugin_package.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ def get_package_and_deps(codebase, package_adder=add_to_package, strip_root=Fals
341341
packages = []
342342
dependencies = []
343343

344-
seen_resource_paths = set()
344+
seen_resource_paths = {}
345345

346346
has_single_resource = codebase.has_single_resource
347347
# track resource ids that have been already processed
@@ -350,14 +350,24 @@ def get_package_and_deps(codebase, package_adder=add_to_package, strip_root=Fals
350350
continue
351351

352352
if resource.path in seen_resource_paths:
353-
continue
353+
seen_resource_types = seen_resource_paths[resource.path]
354+
other_package_type = False
355+
for package_data in resource.package_data:
356+
package_data = PackageData.from_dict(mapping=package_data)
357+
if package_data.type not in seen_resource_types:
358+
other_package_type = True
359+
break
360+
361+
if not other_package_type:
362+
continue
354363

355364
if TRACE:
356365
logger_debug('get_package_and_deps: location:', resource.location)
357366

358367
for package_data in resource.package_data:
359368
try:
360369
package_data = PackageData.from_dict(mapping=package_data)
370+
package_type = package_data.type
361371

362372
if TRACE:
363373
logger_debug(' get_package_and_deps: package_data.purl:', package_data.purl)
@@ -393,7 +403,9 @@ def get_package_and_deps(codebase, package_adder=add_to_package, strip_root=Fals
393403
dependencies.append(item)
394404

395405
elif isinstance(item, Resource):
396-
seen_resource_paths.add(item.path)
406+
if not item.path in seen_resource_paths:
407+
seen_resource_paths[item.path] = set()
408+
seen_resource_paths[item.path].add(package_type)
397409

398410
if TRACE:
399411
logger_debug(' get_package_and_deps: Resource:', item.path)

tests/packagedcode/data/cargo/cargo-with-workspace.expected.json

Lines changed: 112 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,72 @@
377377
"npm_package_json"
378378
],
379379
"purl": "pkg:npm/[email protected]"
380+
},
381+
{
382+
"type": "cargo",
383+
"namespace": null,
384+
"name": "api",
385+
"version": "0.1.0",
386+
"qualifiers": {},
387+
"subpath": null,
388+
"primary_language": "Rust",
389+
"description": "An example Tauri Application showcasing the api",
390+
"release_date": null,
391+
"parties": [],
392+
"keywords": [],
393+
"homepage_url": null,
394+
"download_url": null,
395+
"size": null,
396+
"sha1": null,
397+
"md5": null,
398+
"sha256": null,
399+
"sha512": null,
400+
"bug_tracking_url": null,
401+
"code_view_url": null,
402+
"vcs_url": null,
403+
"copyright": null,
404+
"holder": null,
405+
"declared_license_expression": "apache-2.0 OR mit",
406+
"declared_license_expression_spdx": "Apache-2.0 OR MIT",
407+
"license_detections": [
408+
{
409+
"license_expression": "apache-2.0 OR mit",
410+
"matches": [
411+
{
412+
"score": 100.0,
413+
"start_line": 1,
414+
"end_line": 1,
415+
"matched_length": 5,
416+
"match_coverage": 100.0,
417+
"matcher": "1-hash",
418+
"license_expression": "apache-2.0 OR mit",
419+
"rule_identifier": "apache-2.0_or_mit_36.RULE",
420+
"rule_relevance": 100,
421+
"rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/apache-2.0_or_mit_36.RULE",
422+
"matched_text": "Apache-2.0 OR MIT"
423+
}
424+
],
425+
"identifier": "apache_2_0_or_mit-70d858d7-8968-9e7f-b90f-18b72fb96bef"
426+
}
427+
],
428+
"other_license_expression": null,
429+
"other_license_expression_spdx": null,
430+
"other_license_detections": [],
431+
"extracted_license_statement": "Apache-2.0 OR MIT",
432+
"notice_text": null,
433+
"source_packages": [],
434+
"extra_data": {},
435+
"repository_homepage_url": "https://crates.io/crates/api",
436+
"repository_download_url": "https://crates.io/api/v1/crates/api/0.1.0/download",
437+
"api_data_url": "https://crates.io/api/v1/crates/api",
438+
"package_uid": "pkg:cargo/[email protected]?uuid=fixed-uid-done-for-testing-5642512d1758",
439+
"datafile_paths": [
440+
"cargo-with-workspace/examples/api/src-tauri/Cargo.toml"
441+
],
442+
"datasource_ids": [
443+
"cargo_toml"
444+
],
445+
"purl": "pkg:cargo/[email protected]"
380446
}
381447
],
382448
"dependencies": [
@@ -435,6 +501,48 @@
435501
"for_package_uid": "pkg:npm/[email protected]?uuid=fixed-uid-done-for-testing-5642512d1758",
436502
"datafile_path": "cargo-with-workspace/package.json",
437503
"datasource_id": "npm_package_json"
504+
},
505+
{
506+
"purl": "pkg:cargo/[email protected]",
507+
"extracted_requirement": "0.21.0",
508+
"scope": "dependencies",
509+
"is_runtime": true,
510+
"is_optional": false,
511+
"is_resolved": true,
512+
"resolved_package": {},
513+
"extra_data": {},
514+
"dependency_uid": "pkg:cargo/[email protected]?uuid=fixed-uid-done-for-testing-5642512d1758",
515+
"for_package_uid": "pkg:cargo/[email protected]?uuid=fixed-uid-done-for-testing-5642512d1758",
516+
"datafile_path": "cargo-with-workspace/examples/api/src-tauri/Cargo.lock",
517+
"datasource_id": "cargo_lock"
518+
},
519+
{
520+
"purl": "pkg:cargo/[email protected]",
521+
"extracted_requirement": "1.0.2",
522+
"scope": "dependencies",
523+
"is_runtime": true,
524+
"is_optional": false,
525+
"is_resolved": true,
526+
"resolved_package": {},
527+
"extra_data": {},
528+
"dependency_uid": "pkg:cargo/[email protected]?uuid=fixed-uid-done-for-testing-5642512d1758",
529+
"for_package_uid": "pkg:cargo/[email protected]?uuid=fixed-uid-done-for-testing-5642512d1758",
530+
"datafile_path": "cargo-with-workspace/examples/api/src-tauri/Cargo.lock",
531+
"datasource_id": "cargo_lock"
532+
},
533+
{
534+
"purl": "pkg:cargo/[email protected]",
535+
"extracted_requirement": "0.5.2",
536+
"scope": "dependencies",
537+
"is_runtime": true,
538+
"is_optional": false,
539+
"is_resolved": true,
540+
"resolved_package": {},
541+
"extra_data": {},
542+
"dependency_uid": "pkg:cargo/[email protected]?uuid=fixed-uid-done-for-testing-5642512d1758",
543+
"for_package_uid": "pkg:cargo/[email protected]?uuid=fixed-uid-done-for-testing-5642512d1758",
544+
"datafile_path": "cargo-with-workspace/examples/api/src-tauri/Cargo.lock",
545+
"datasource_id": "cargo_lock"
438546
}
439547
],
440548
"license_detections": [
@@ -1514,7 +1622,8 @@
15141622
}
15151623
],
15161624
"for_packages": [
1517-
"pkg:npm/[email protected]?uuid=fixed-uid-done-for-testing-5642512d1758"
1625+
"pkg:npm/[email protected]?uuid=fixed-uid-done-for-testing-5642512d1758",
1626+
"pkg:cargo/[email protected]?uuid=fixed-uid-done-for-testing-5642512d1758"
15181627
],
15191628
"detected_license_expression": null,
15201629
"detected_license_expression_spdx": null,
@@ -1591,7 +1700,8 @@
15911700
}
15921701
],
15931702
"for_packages": [
1594-
"pkg:npm/[email protected]?uuid=fixed-uid-done-for-testing-5642512d1758"
1703+
"pkg:npm/[email protected]?uuid=fixed-uid-done-for-testing-5642512d1758",
1704+
"pkg:cargo/[email protected]?uuid=fixed-uid-done-for-testing-5642512d1758"
15951705
],
15961706
"detected_license_expression": "apache-2.0 OR mit",
15971707
"detected_license_expression_spdx": "Apache-2.0 OR MIT",

0 commit comments

Comments
 (0)