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
repo: normalize if stage-packages and check types (CRAFT-222) #3529
Conversation
Normalization takes place across the entire working tree for a part. As a side effect, files that are not part of stage-packages are also normalized, for that matter, stage-snaps, as those are unpacked first. When considering the pc snap, Snapcraft creates a snap.pc to correctly namespace the snaps snap directory. The .pc artifact fixes does not filter on file type, fileinput is used for the fixup and internally creates a .bak file as a backup which fails as snap.pc is a directory and not a file. Signed-off-by: Sergio Schvezov <sergio.schvezov@canonical.com>
for pkg_path in stage_packages_path.glob("*.deb"): | ||
stage_packages = stage_packages_path.glob("*.deb") | ||
|
||
if not stage_packages: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This hunk do anything?
if not stage_packages
will never be true AFAIK because glob() returns a generator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wasn't that iglob?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes. glob returns a list of paths, and iglob is returns an iterator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For completion
>>> import glob
>>> glob.glob("*.py")
['setup.py', 'units.py']
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a catch here, glob.glob()
returns a list of paths but Path.glob()
still returns a generator:
>>> import pathlib
>>> p = pathlib.Path("/")
>>> p.glob("*")
<generator object Path.glob at 0x7fa9a7356f20>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sergiusens may want to fix that in a follow-up.
dropping in to say I reported the initial error. gave this branch a test, and it work for me (building a snap gadget that stages |
iglob is generator based, glob returns a list
This is a port of PR canonical/snapcraft#3529. Original description follows: Normalization takes place across the entire working tree for a part. As a side effect, files that are not part of stage-packages are also normalized, for that matter, stage-snaps, as those are unpacked first. When considering the pc snap, Snapcraft creates a snap.pc to correctly namespace the snaps snap directory. The .pc artifact fixes does not filter on file type, fileinput is used for the fixup and internally creates a .bak file as a backup which fails as snap.pc is a directory and not a file. Co-authored-by: <Sergio Schvezov sergio.schvezov@canonical.com> Signed-off-by: Claudio Matsuoka <claudio.matsuoka@canonical.com>
Normalization takes place across the entire working tree for a part.
As a side effect, files that are not part of stage-packages are also
normalized, for that matter, stage-snaps, as those are unpacked first.
When considering the pc snap, Snapcraft creates a snap.pc to correctly
namespace the snaps snap directory. The .pc artifact fixes does not
filter on file type, fileinput is used for the fixup and internally
creates a .bak file as a backup which fails as snap.pc is a directory
and not a file.
Signed-off-by: Sergio Schvezov sergio.schvezov@canonical.com
./runtests.sh static
?./runtests.sh tests/unit
?