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

install_symlink: Handle $DESTDIR case for links with absolute path #10176

Merged
merged 1 commit into from
Mar 24, 2022

Conversation

3v1n0
Copy link
Contributor

@3v1n0 3v1n0 commented Mar 24, 2022

In case a link is pointing_to an absolute path and we are using $DESTDIR
we fail in case the target is missing.

This is incorrect because we may need to use an absolute path to an
already installed file that is in $DESTDIR.

So if an absolute target is not existing, check if we have such file in
$DESTDIR before failing for real.

@3v1n0 3v1n0 requested a review from jpakkane as a code owner March 24, 2022 11:43
@codecov
Copy link

codecov bot commented Mar 24, 2022

Codecov Report

Merging #10176 (e06fc61) into master (dac212e) will decrease coverage by 0.02%.
The diff coverage is 66.66%.

❗ Current head e06fc61 differs from pull request most recent head 0b09311. Consider uploading reports for the commit 0b09311 to get more accurate results

@@            Coverage Diff             @@
##           master   #10176      +/-   ##
==========================================
- Coverage   66.14%   66.11%   -0.03%     
==========================================
  Files         406      406              
  Lines       86634    86640       +6     
  Branches    19161    19157       -4     
==========================================
- Hits        57305    57283      -22     
- Misses      24897    24934      +37     
+ Partials     4432     4423       -9     
Impacted Files Coverage Δ
mesonbuild/minstall.py 69.37% <25.00%> (-0.27%) ⬇️
mesonbuild/scripts/__init__.py 100.00% <100.00%> (ø)
mesonbuild/scripts/vcstagger.py 87.50% <0.00%> (-4.17%) ⬇️
mesonbuild/modules/java.py 67.85% <0.00%> (-3.58%) ⬇️
mesonbuild/cmake/tracetargets.py 80.00% <0.00%> (-2.67%) ⬇️
mesonbuild/compilers/d.py 59.63% <0.00%> (-2.57%) ⬇️
mesonbuild/dependencies/dev.py 63.63% <0.00%> (-1.61%) ⬇️
mesonbuild/compilers/detect.py 54.77% <0.00%> (-1.33%) ⬇️
mesonbuild/dependencies/misc.py 50.00% <0.00%> (-0.50%) ⬇️
minstall.py 68.80% <0.00%> (-0.27%) ⬇️
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dac212e...0b09311. Read the comment docs.

mesonbuild/minstall.py Outdated Show resolved Hide resolved
In case a link is pointing_to an absolute path and we are using $DESTDIR
we fail in case the target is missing.

This is incorrect because we may need to use an absolute path to an
already installed file that is in $DESTDIR.

So if an absolute target is not existing, check if we have such file in
$DESTDIR before failing for real.
@3v1n0 3v1n0 force-pushed the symlinks-destdir branch 3 times, most recently from 519be99 to e06fc61 Compare March 24, 2022 13:14
@eli-schwartz
Copy link
Member

eli-schwartz commented Mar 24, 2022

But also rewritten destdir_join to use pathlib as it was suggested long time ago

Please don't. We already offer a battle-tested high level abstraction for this, while using pathlib pays the cost of the pathlib abstraction and makes for an abstraction of an abstraction while... simultaneously solving none of the ugliness of string slicing.

@3v1n0
Copy link
Contributor Author

3v1n0 commented Mar 24, 2022

Please don't. We already offer a battle-tested high level abstraction for this, while using pathlib pays the cost of the pathlib abstraction and makes for an abstraction of an abstraction while... simultaneously solving none of the ugliness of string slicing.

Well, the comment on the code was mentioning the idea of using it, so I tried. But I'm happy to revert if there's no consesus.

@eli-schwartz
Copy link
Member

Well, "consider". :p

As it turns out, after consideration I don't think pathlib has a straightforward way to do what actually turns out to not be path-like semantics (at least as pathlib defines it). And it shows in the fact that the proposed implementation still has to drop back down to strings and do string slicing.

Anyway, the first patch is useful on its own and seems correct. Thanks.

@3v1n0
Copy link
Contributor Author

3v1n0 commented Mar 24, 2022

@eli-schwartz ok I've dropped the 2nd commit, I can propose it in another PR in case.

@@ -431,10 +431,12 @@ def do_copyfile(self, from_file: str, to_file: str,
append_to_log(self.lf, to_file)
return True

def do_symlink(self, target: str, link: str, full_dst_dir: str, allow_missing: bool) -> bool:
def do_symlink(self, target: str, link: str, destdir: str, full_dst_dir: str, allow_missing: bool) -> bool:
Copy link
Member

Choose a reason for hiding this comment

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

Actually I wonder. We use both target and link, but we don't "use" full_destdir, we just need it to define the abs_target. I am not sure whether here or at the call site is maybe a better place to calculate this?
(I genuinely am not sure.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was thinking about that, but full_dst_dir is still used by parent to create the directory,

We could definitely do that under symlink, but we'd still need to bring the DirMaker with us

@3v1n0
Copy link
Contributor Author

3v1n0 commented Mar 24, 2022

Wondering: In such cases, and so when the absolute path is something that meson has installed, shouldn't we try to convert the symlink to be relative instead?

@eli-schwartz
Copy link
Member

I would say in such a case, if the project developers specified an absolute path how do we know they want it to be turned into a relative one?

Probably the only case that would ever be true, they really want fs_mod.relative_to().

@eli-schwartz
Copy link
Member

CI failure on Cygwin is caused by gcovr/gcovr#576 -- yippee for strange Windows envs that cannot be baked into a CI image which is regularly updated and tested before being released as a new frozen image. Not only is it slow to repeatedly install everything, it also periodically changes the versions of everything installed, then breaks sometimes. ;)

All the rest of the CI passes, and the breakage is known and shortly to be fixed. Merging.

@eli-schwartz eli-schwartz merged commit b0d300e into mesonbuild:master Mar 24, 2022
@nirbheek nirbheek added this to the 0.62.1 milestone Apr 19, 2022
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.

4 participants