Skip to content

Conversation

@Thomas1664
Copy link
Contributor

@Thomas1664 Thomas1664 commented Mar 8, 2025

@Thomas1664
Copy link
Contributor Author

Thomas1664 commented Mar 8, 2025

@BillyONeal I'm not sure how to handle the path issue:

From microsoft/vcpkg#44188 (comment):

Also, Paths are also invalid:

"fileName": ".//home/igor/development/vcpkg/vcpkg_original/ports/bzip2/bzip2.pc.in",

The code expects relative paths:

const auto& path = relative_paths[i];
const auto& hash = hashes[i];
auto& obj = files.push_back(Json::Object());
obj.insert(SpdxFileName, "./" + path.generic_u8string());
const auto ref = fmt::format("SPDXRef-file-{}", i);

but we feed in absolute paths by including the port directory:

const auto& abs_port_file = files.emplace_back(port_dir / port_file);

abi_info.relative_port_files = std::move(files);

fs.write_contents_and_dirs(
json_path,
create_spdx_sbom(
action, abi.relative_port_files, abi.relative_port_hashes, now, doc_ns, std::move(heuristic_resources)),
VCPKG_LINE_INFO);

However, I think we should be using absolute paths because we might lose the information of where a file comes from in case of overlay ports.

On the other hand, absolute paths are invalid after downloading from a binary cache on different machines.

@BillyONeal
Copy link
Member

On the other hand, absolute paths are invalid after downloading from a binary cache on different machines.

Right, this is why the paths have to be relative.

However, I think we should be using absolute paths because we might lose the information of where a file comes from in case of overlay ports.

That's why the SHAs of the files are also in the SPDX. It isn't there's a hard link between any particular absolute path and anything else, any more than there is between that relative path and anything else.

Copy link
Member

@BillyONeal BillyONeal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test? Would merge this with one.

@BillyONeal BillyONeal marked this pull request as draft March 21, 2025 18:44
@Thomas1664
Copy link
Contributor Author

Can you add a test? Would merge this with one.

Hi @BillyONeal,

I added a unit test to check the correct replacement of ${VERSION} in all CMake functions and to ensure that all instances of those functions are found.

As you proposed, I didn't fix the absolute path issue mentioned in microsoft/vcpkg#44188. Therefore, plese don't close that issue yet - I will fix the absolute path issue in a different PR.

@Thomas1664 Thomas1664 marked this pull request as ready for review March 22, 2025 11:42
@BillyONeal BillyONeal enabled auto-merge (squash) March 31, 2025 20:21
@BillyONeal BillyONeal merged commit 7e38286 into microsoft:main Mar 31, 2025
7 checks passed
@Thomas1664 Thomas1664 deleted the fix-spdx-distfile branch April 1, 2025 05:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generated SPDX Files contain not evaluated CMake variables in filenames and URLs [vcpkg-tool] generated spdx files should contain correct URLS

2 participants