Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Redo pkg-config handling with library collecting #335
Conversation
elopio
reviewed
Feb 25, 2016
| +libustr-1.0.so.1 | ||
| +libustr-1.0.so.1.0.4 | ||
| +libyaml-0.so.2 | ||
| +libyaml-0.so.2.0.4 |
elopio
Feb 25, 2016
Member
How did you generate this list?
A README file next to this one explaining why and how would be great.
sergiusens
Feb 25, 2016
Collaborator
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
sergiusens
Feb 29, 2016
Collaborator
@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.
kyrofa
Feb 29, 2016
Member
How would you go about making it dynamic? Would you have to download the OS snap every time?
elopio
reviewed
Feb 25, 2016
| @@ -30,6 +31,9 @@ | ||
| _plugindir = _DEFAULT_PLUGINDIR | ||
| _DEFAULT_SCHEMADIR = '/usr/share/snapcraft/schema' | ||
| _schemadir = _DEFAULT_SCHEMADIR | ||
| +_DEFAULT_LIBRARIESDIR = 'usr/share/snapcraft/libraries' |
sergiusens
Feb 25, 2016
Collaborator
yeah; I really want to to a massive replace of all the <something>dir to be <something>_dir
elopio
reviewed
Feb 25, 2016
| - **kwargs).decode('utf8').strip() | ||
| + return subprocess.check_output([ | ||
| + '/bin/sh', f.name] + cmd, **kwargs).decode( | ||
| + sys.getfilesystemencoding()).strip() |
elopio
Feb 25, 2016
Member
This looks good, but it means that if f.name prints a character that's not ascii when the system doesn't have utf8, it will raise an exception. This was the problem we had in a couple of places. So this possible error might need better handling.
sergiusens
Feb 25, 2016
Collaborator
I went under the assumption that stdout and stderr are also just files. In fairness I was trying to get rid of this error:
'utf-8' codec can't encode character '\\udcc3' in position 137:\nsurrogates not allowed\n"
chipaca
Feb 25, 2016
Member
This changes the signature of run_output from returning a string to returning bytes. This on its own won't raise an exception, but the caller needs to handle it differently from before (because it's different).
elopio
reviewed
Feb 25, 2016
| + lib_path = os.path.join(common.get_librariesdir(), release) | ||
| + | ||
| + if not os.path.exists(lib_path): | ||
| + logger.warning('No libraries to exclude from this release') |
elopio
Feb 25, 2016
Member
From the text in this message, it's not clear why it is a warning. How can affect the execution that there are no libraries to exclude?
|
lgtm, but the elf bits are flying over my head. I'll read more about that tomorrow. |
elopio
reviewed
Feb 25, 2016
| + try: | ||
| + check_call(['/usr/bin/pkg-config', '--exists'] + modules, env=env) | ||
| + return True | ||
| + except: |
elopio
Feb 25, 2016
Member
except subprocess.CalledProcessError.
We don't want to ignore any other exceptions.
|
@elopio wrt |
chipaca
reviewed
Feb 25, 2016
| + 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)) |
chipaca
Feb 25, 2016
Member
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.
chipaca
reviewed
Feb 25, 2016
| + | ||
| + # Now lets filter out what would be on the system | ||
| + system_libs = _get_system_libs() | ||
| + libs = list(filter(lambda x: not os.path.basename(x) in system_libs, libs)) |
chipaca
Feb 25, 2016
Member
and here it seems you switched to filter+lambda entirely. Not sure I understand why you're using both idioms in a single function (and why you use filter but flatten it into a list for an intermediate result)
chipaca
reviewed
Feb 25, 2016
| + logger.warning('No libraries to exclude from this release') | ||
| + | ||
| + with open(lib_path) as fn: | ||
| + _libraries = fn.read().split() |
chipaca
Feb 25, 2016
Member
From what I can tell, you could make _libraries a frozenset and carry on using it as you are, but slightly faster.
chipaca
reviewed
Feb 25, 2016
| + logger.debug('Skipped link {!r} when parsing {!r}'.format( | ||
| + path, workdir)) | ||
| + continue | ||
| + if ms.file(path).startswith('ELF'): |
|
thanks @chipaca |
|
retest this please |
|
retest this please |
|
retest this please |
sergiusens
reviewed
Feb 28, 2016
| - [self.snapcraft_command, 'snap'], cwd=working_dir, | ||
| - stderr=subprocess.STDOUT).decode('utf-8') | ||
| + [self.snapcraft_command, '--debug', 'snap'], cwd=working_dir, | ||
| + stderr=subprocess.STDOUT) |
sergiusens
Feb 28, 2016
Collaborator
@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)
|
retest this please |
kyrofa
reviewed
Feb 29, 2016
| +To update the list of libraries that get excluded from inclusion into a | ||
| +snap run: | ||
| + | ||
| + ./libraries/generate_list.py libraries/<release> |
|
retest this please |
didrocks
reviewed
Mar 1, 2016
| + | ||
| +e.g.; to update the list for 16.04, | ||
| + | ||
| + ./libraries/generate_lib_list.py libraries/16.04 |
didrocks
Mar 1, 2016
Contributor
What do you think of having this running as a git release hook? I'm afraid that updates will be sporadic otherwise and ofc, there is no way of getting that running during package build (as accessing external servers).
|
I'm investigating why this doesn't work for the opencv example. |
|
So the reason this doesn't work with opencv is the same reason is won't work for anything with a lib in a non-standard area (non-standard being defined as anything not placed in |
coveralls
commented
Mar 24, 2016
sergiusens
reviewed
Mar 24, 2016
| @@ -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) |
sergiusens
Mar 24, 2016
Collaborator
Needs tracking and library paths used need to be exported to env
hint for @kyrofa
coveralls
commented
Mar 24, 2016
sergiusens
reviewed
Mar 24, 2016
| @@ -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 |
sergiusens
reviewed
Mar 29, 2016
| + 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) |
sergiusens
Mar 29, 2016
Collaborator
@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
commented
Mar 29, 2016
|
@elopio given these pass on |
|
@elopio I'm still seeing _testtools.testresult.real.StringException: output: {{{No module named 'magic'}}} |
sergiusens
reviewed
Mar 29, 2016
| env += part.env(part.installdir) | ||
| env += _runtime_env(stagedir) | ||
| env += _runtime_env(part.installdir) | ||
| + env += _runtime_env(part.ubuntu_unpackdir) |
sergiusens
Mar 29, 2016
Collaborator
@kyrofa python plugins fail to work, I'm thinking it might be due to this, did it work for you?
|
retest this please |
|
retest this please |
|
Thanks @elopio |
|
@elopio final call is on you |
|
flashing... |
|
@elopio how is it doing? |
|
@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 |
|
@elopio hmm, maybe we can fix the sudo issue for armhf this cycle :-) |
|
@sergiusens I can take a look at that. |
sergiusens commentedFeb 25, 2016
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