Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle duplicate symlink in multiple slices of a package #36

Merged
merged 2 commits into from
Jan 25, 2023

Conversation

woky
Copy link
Contributor

@woky woky commented Oct 17, 2022

In the current code, a copyright file from a package is added to every
slice of that package. This went unnoticed because the file was silently
overwritten from successive slices of the same package. However, the
openssl's copyright file is a symlink to the libssl3's copyright file,
and creating a symlink on the same path for the second time fails. Fix
it by adding a copyright file to only the first slice of a package.

@woky
Copy link
Contributor Author

woky commented Oct 17, 2022

@niemeyer There's not any new test to test this regression simply because I don't think that adding more packages as base64 is sustainable (baseFilesBase64 in pkgdata.go). It's very hard to review so I think we should come up with other way to package packages into tests. Current tests pass. Can we merge this without any new regression test?

Copy link
Contributor

@niemeyer niemeyer left a comment

Choose a reason for hiding this comment

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

However, the openssl's copyright file is a symlink to the libssl3's copyright file, and creating a symlink on the same path for the second time fails.

What happens if one actual symlink is referred by two different slices?

@woky
Copy link
Contributor Author

woky commented Nov 28, 2022

What happens if one actual symlink is referred by two different slices?

When a symlink is directly specified in two different slices of a same package, this happens:

error: cannot extract from package "openssl": symlink ../libssl3/copyright /home/woky/tmp/chisel-out/usr/share/doc/openssl/copyright: file exists

This was fixed by Rafid in d2099b9 but the PR was closed. Do you want to cherry-pick that commit into new PR?

@niemeyer
Copy link
Contributor

This was fixed by Rafid in d2099b9 but the PR was closed. Do you want to cherry-pick that commit into new PR?

We might have logic to not attempt to create if we have matching content. With that said, that change from Rafid looks like a fine and simple, and it goes towards the conversation we've been having of preserving content that is already in place rather than overwritng it, so +1.

Either option needs testing, though.

@woky
Copy link
Contributor Author

woky commented Dec 15, 2022

We might have logic to not attempt to create if we have matching content. With that said, that change from Rafid looks like a fine and simple, and it goes towards the conversation we've been having of preserving content that is already in place rather than overwritng it, so +1.

This doesn't apply to this PR though, does it? The mistake being fixed here is that copyright file was included in multiple slices of a same package. In other words, the following could be called more than once with same extractPackage and copyrightPath values for one package:

                       extractPackage[copyrightPath] = append(extractPackage[copyrightPath], deb.ExtractInfo{
                               Path:     copyrightPath,
                               Optional: true,
                       })

Fixing it by making the symlink function ignore existing symlink would just hide the mistake.

Either option needs testing, though.

I've rebased this PR on top of #42 and added tests.

@niemeyer
Copy link
Contributor

Fixing it by making the symlink function ignore existing symlink would just hide the mistake.

As I mentioned in the history above, that "mistake" can happen in normal circumstances by simply referring to the same symlink in two different slices, so the problem has nothing to do with copyrights. The fix should be to not make the general mechanism fail in such a normal scenario, which it looks like you believe Rafid's fix addresses, and which I mentioned above seems okay too.

Copy link
Contributor

@niemeyer niemeyer left a comment

Choose a reason for hiding this comment

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

This has gone through many updates, but the issue remains the same since the first conversation long ago: this is a general issue that must be fixed generally.

@niemeyer
Copy link
Contributor

Thanks. Can you please push it again once the pre-req is in? There are some easy comments there.

@woky woky force-pushed the fix-copyright-symlink branch 4 times, most recently from c93d4f5 to af22d98 Compare January 11, 2023 16:19
@woky woky changed the title Add copyright only once per package Handle duplicate symlink in multiple slices of a package Jan 11, 2023
@woky
Copy link
Contributor Author

woky commented Jan 11, 2023

Thanks. Can you please push it again once the pre-req is in? There are some easy comments there.

@niemeyer I've updated the linked PR #42 and rebased this one. (TIL --update-refs: https://github.blog/2022-10-03-highlights-from-git-2-38/.)

rebornplusplus and others added 2 commits January 24, 2023 20:38
In bf2a16e copyright files are added to every selected slice of a
package. Check that it's OK even when copyright file is a symlink.
Copy link
Contributor

@niemeyer niemeyer left a comment

Choose a reason for hiding this comment

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

Thanks!

@niemeyer niemeyer merged commit c30c81f into canonical:main Jan 25, 2023
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.

3 participants