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

elf: search for host libraries within search paths #2909

Merged
merged 2 commits into from
Feb 5, 2020

Conversation

sergiusens
Copy link
Collaborator

A regression was introduced with commit 76e8a3f
which considered elf files on the host system to be valid. Additionally, since
the host-found libraries were absolute paths, an os.path.join suffixing the
search paths snapcraft cared about were ignored.

A unit test which considers this scenario was added.

LP: #1860766

Signed-off-by: Sergio Schvezov sergio.schvezov@canonical.com

  • Have you followed the guidelines for contributing?
  • Have you signed the CLA?
  • Have you successfully run ./runtests.sh static?
  • Have you successfully run ./runtests.sh tests/unit?

A regression was introduced with commit 76e8a3f
which considered elf files on the host system to be valid. Additionally, since
the host-found libraries were absolute paths, an os.path.join suffixing the
search paths snapcraft cared about were ignored.

A unit test which considers this scenario was added.

LP: #1860766

Signed-off-by: Sergio Schvezov <sergio.schvezov@canonical.com>
@codecov-io
Copy link

codecov-io commented Feb 4, 2020

Codecov Report

Merging #2909 into master will increase coverage by <.01%.
The diff coverage is 80%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #2909      +/-   ##
=========================================
+ Coverage    87.9%   87.9%   +<.01%     
=========================================
  Files         229     229              
  Lines       16517   16517              
  Branches     2548    2549       +1     
=========================================
+ Hits        14519   14520       +1     
+ Misses       1444    1443       -1     
  Partials      554     554
Impacted Files Coverage Δ
snapcraft/internal/elf.py 80.25% <80%> (+0.31%) ⬆️

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 c13c79d...3a55d1b. Read the comment docs.

cjp256
cjp256 previously approved these changes Feb 4, 2020
Copy link
Contributor

@cjp256 cjp256 left a comment

Choose a reason for hiding this comment

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

lgtm

if self._is_valid_elf(self.soname_path):
valid_search_paths = [p for p in self.search_paths if os.path.exists(p)]
in_search_paths = any(
[self.soname_path.startswith(p) for p in valid_search_paths]
Copy link
Contributor

Choose a reason for hiding this comment

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

Not that it matters here, but I think in this would be a good case for a generator (lose the list brackets):
any(self.soname_path.startswith(p) for p in valid_search_paths)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I am a fan of generators in general

@sergiusens sergiusens merged commit 12f05b3 into master Feb 5, 2020
@sergiusens sergiusens deleted the fix-elf-regression branch November 26, 2021 17:50
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