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

Redo pkg-config handling with library collecting #335

Merged

Conversation

sergiusens
Copy link
Collaborator

pkg-config only handled PKG_CONFIG_SYSROOT_DIR as the stage dir
providing many issues when using packages from installdir for a part
and also build-packages from the host.

For a full implementation, elf dependency tracking from the host
to the snap is also implemented here

LP: #1549570

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

@sergiusens sergiusens force-pushed the feature/1549570/ultimate-pkg-config branch 3 times, most recently from 3b7bf1b to 3d1aa66 Compare February 25, 2016 04:46
libustr-1.0.so.1
libustr-1.0.so.1.0.4
libyaml-0.so.2
libyaml-0.so.2.0.4
Copy link
Contributor

Choose a reason for hiding this comment

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

How did you generate this list?
A README file next to this one explaining why and how would be great.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sounds like a good idea, so far I did it manually with find from an OS snap. This will probably need updating from my Qt comments from last night

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed, this could use some documentation.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@ElOpio and @kyrofa done https://github.com/ubuntu-core/snapcraft/pull/335/files#diff-2cb561c5e46512465f54a0f84d421c80R66

But is also makes me think if it is worth to make this dynamic.

Copy link
Contributor

Choose a reason for hiding this comment

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

How would you go about making it dynamic? Would you have to download the OS snap every time?

@come-maiz
Copy link
Contributor

lgtm, but the elf bits are flying over my head. I'll read more about that tomorrow.
You might want to get chipaca or mvo to take a look.

try:
check_call(['/usr/bin/pkg-config', '--exists'] + modules, env=env)
return True
except:
Copy link
Contributor

Choose a reason for hiding this comment

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

except subprocess.CalledProcessError.
We don't want to ignore any other exceptions.

@sergiusens
Copy link
Collaborator Author

@ElOpio wrt ELF I can ldd against ELF (Executable Linking Format) files. I am walking the whole tree in case someone goes with a non standard layout.

ldd_out = [l[2] for l in ldd_out if len(l) > 2 and os.path.exists(l[2])]

# Anything that is part of the project we don't need to check for
libs = list(filter(lambda x: not x.startswith(os.getcwd()), ldd_out))
Copy link
Contributor

Choose a reason for hiding this comment

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

two (silly) things that bother me about this line: you're calling os.getcwd in a loop without expecting it to change, and you switched from list comprehensions to filter+lambda.

@sergiusens sergiusens force-pushed the feature/1549570/ultimate-pkg-config branch 2 times, most recently from 5c4d3c0 to 10f8e96 Compare February 25, 2016 13:23
@sergiusens
Copy link
Collaborator Author

thanks @chipaca

@sergiusens sergiusens force-pushed the feature/1549570/ultimate-pkg-config branch 4 times, most recently from 831e80b to 8c27da5 Compare February 25, 2016 18:56
@sergiusens
Copy link
Collaborator Author

retest this please

@sergiusens sergiusens force-pushed the feature/1549570/ultimate-pkg-config branch 4 times, most recently from ffea685 to 411faa3 Compare February 28, 2016 18:35
@sergiusens
Copy link
Collaborator Author

retest this please

@sergiusens sergiusens force-pushed the feature/1549570/ultimate-pkg-config branch from 411faa3 to 6218bcc Compare February 28, 2016 21:09
@sergiusens
Copy link
Collaborator Author

retest this please

[self.snapcraft_command, 'snap'], cwd=working_dir,
stderr=subprocess.STDOUT).decode('utf-8')
[self.snapcraft_command, '--debug', 'snap'], cwd=working_dir,
stderr=subprocess.STDOUT)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@ElOpio I'm lost as with what is going on here:

Traceback (most recent call last):
  File "/home/jenkins-slave/workspace/github-snapcraft-examples-tests-cloud/examples_tests/tests.py", line 98, in test_example
    self.build_snap(self.example_dir)
  File "/home/jenkins-slave/workspace/github-snapcraft-examples-tests-cloud/examples_tests/__init__.py", line 129, in build_snap
    stderr=subprocess.STDOUT).decode('utf-8')
  File "/usr/lib/python3.5/subprocess.py", line 626, in check_output
    **kwargs).stdout
  File "/usr/lib/python3.5/subprocess.py", line 708, in run
    output=stdout, stderr=stderr)

@sergiusens sergiusens force-pushed the feature/1549570/ultimate-pkg-config branch 4 times, most recently from 7ccea33 to 6d9d14c Compare March 24, 2016 03:51
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 95.34% when pulling 6d9d14c on sergiusens:feature/1549570/ultimate-pkg-config into 2037d9c on ubuntu-core:master.

@sergiusens sergiusens force-pushed the feature/1549570/ultimate-pkg-config branch from 6d9d14c to f31718f Compare March 24, 2016 04:58
@@ -399,6 +398,7 @@ def strip(self, force=False):
self.notify_stage('Stripping')
snap_files, snap_dirs = self.migratable_fileset_for('snap')
_migrate_files(snap_files, snap_dirs, self.stagedir, self.snapdir)
_copy_dependencies(self.snapdir)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Needs tracking and library paths used need to be exported to env
hint for @kyrofa

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 95.674% when pulling f31718f on sergiusens:feature/1549570/ultimate-pkg-config into 88d21b1 on ubuntu-core:master.

@@ -265,7 +262,7 @@ def pull(self, force=False):
package_files = set()
package_directories = set()
if self.code.stage_packages:
package_files, package_directories = self._setup_stage_packages()
self._setup_stage_packages()
self.code.pull()

# Record the files and directories unpacked from the stage packages
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We probably don't need this anymore
hint @kyrofa

@sergiusens sergiusens force-pushed the feature/1549570/ultimate-pkg-config branch from f31718f to 5ba5674 Compare March 29, 2016 01:23
destination_path = os.path.join(destination, relpath)

if os.path.isdir(source_path) and not os.path.islink(source_path):
os.makedirs(destination_path, exist_ok=True)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@kyrofa do we need to create these potential empty dirs? The else clause seems will be able to ensure the directories exist and not migrated until build happens which is too late for the python plugins.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.3%) to 95.564% when pulling 5ba5674 on sergiusens:feature/1549570/ultimate-pkg-config into b18e4e9 on ubuntu-core:master.

@sergiusens
Copy link
Collaborator Author

@ElOpio given these pass on amd64 can we give this a run on armhf ?

@sergiusens
Copy link
Collaborator Author

@ElOpio I'm still seeing _testtools.testresult.real.StringException: output: {{{No module named 'magic'}}}

env += part.env(part.installdir)
env += _runtime_env(stagedir)
env += _runtime_env(part.installdir)
env += _runtime_env(part.ubuntu_unpackdir)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@kyrofa python plugins fail to work, I'm thinking it might be due to this, did it work for you?

@come-maiz
Copy link
Contributor

retest this please

1 similar comment
@come-maiz
Copy link
Contributor

retest this please

@sergiusens
Copy link
Collaborator Author

Thanks @ElOpio

@sergiusens sergiusens force-pushed the feature/1549570/ultimate-pkg-config branch from 5ba5674 to bcc0b45 Compare March 29, 2016 19:53
pkg-config only handled PKG_CONFIG_SYSROOT_DIR as the stage dir
providing many issues when using packages from installdir for a part
and also build-packages from the host.

For a full implementation, elf dependency tracking from the host
to the snap is also implemented here

Add dependency tracking and use it to determine LD_LIBRARY_PATH.

Also unpacked stage-packages into an intermediate area in pull()
and copied them into installdir in build() to make per-step
cleaning work better.

LP: #1549570

Signed-off-by: Sergio Schvezov <sergio.schvezov@ubuntu.com>
Signed-off-by: Kyle Fazzari <kyle@canonical.com>
@sergiusens sergiusens force-pushed the feature/1549570/ultimate-pkg-config branch from bcc0b45 to 4a5de24 Compare March 29, 2016 20:10
@sergiusens
Copy link
Collaborator Author

@ElOpio final call is on you 😉

@come-maiz
Copy link
Contributor

flashing...

@sergiusens
Copy link
Collaborator Author

@ElOpio how is it doing?

@come-maiz
Copy link
Contributor

@sergiusens slooooow... Running in the snappy classic in rpi2. All unit tests passed. The integration tests have been running for an hour:

(classic)ubuntu@localhost:~/snapcraft$ ./runtests.sh integration
.................[sudo] password for ubuntu:
EEEE.........[sudo] password for ubuntu:
E....[sudo] password for ubuntu:
E..

@sergiusens
Copy link
Collaborator Author

@ElOpio hmm, maybe we can fix the sudo issue for armhf this cycle :-)

@come-maiz
Copy link
Contributor

@sergiusens I can take a look at that.
The tests that could run, ran successfully. The tests that need sudo failed.
👍 from me to land this. I'll see if I can get the failed tests to pass. If they uncover an unlikely error, we can still fix it before the release.

@sergiusens sergiusens merged commit 854431f into canonical:master Mar 30, 2016
@sergiusens sergiusens deleted the feature/1549570/ultimate-pkg-config branch March 30, 2016 03:07
kalikiana pushed a commit to kalikiana/snapcraft that referenced this pull request Apr 6, 2017
…mate-pkg-config

Redo pkg-config handling with library collecting
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.

None yet

6 participants