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

repo: normalize if stage-packages and check types (CRAFT-222) #3529

Merged
merged 3 commits into from May 31, 2021

Conversation

sergiusens
Copy link
Collaborator

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

  • 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?

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>
cjp256
cjp256 previously requested changes May 26, 2021
for pkg_path in stage_packages_path.glob("*.deb"):
stage_packages = stage_packages_path.glob("*.deb")

if not stage_packages:
Copy link
Contributor

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Wasn't that iglob?

Copy link

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.

Copy link
Collaborator Author

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']

Copy link
Contributor

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>

Copy link
Contributor

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.

@j5awry
Copy link

j5awry commented May 26, 2021

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 pc and then adds more files)

@sergiusens sergiusens dismissed cjp256’s stale review May 26, 2021 21:25

iglob is generator based, glob returns a list

@sergiusens sergiusens requested a review from cjp256 May 26, 2021 21:25
cmatsuoka added a commit to cmatsuoka/craft-parts that referenced this pull request May 27, 2021
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>
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

4 participants