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

Desktop meta: strip ${SNAP} from .desktop icon #2541

Merged
merged 12 commits into from
May 10, 2019

Conversation

lucyllewy
Copy link
Contributor

@lucyllewy lucyllewy commented Apr 24, 2019

A lot of snaps are hacking the desktop file of their projects to insert a snap-relative path for their icon of the form ${SNAP}/path/to/icon.png. The current .desktop extractor implementation does not understand this format so this commit strips the ${SNAP} from the start of the path if it is present before continuing as before.

Signed-off-by: Daniel Llewellyn daniel@bowlhat.net

  • 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 lot of snaps are hacking the desktop file of their projects to insert
a snap-relative path for their icon of the form
`${SNAP}/path/to/icon.png`. The current Appstream implementation does
not understand this format so this commit strips the `${SNAP}` from the
start of the path if it is present before continuing as before.

Signed-off-by: Daniel Llewellyn <daniel@bowlhat.net>
Copy link
Contributor

@cmatsuoka cmatsuoka left a comment

Choose a reason for hiding this comment

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

Thanks for the fix, could you add a test case for that?

Desktop files might include an icon path definition with a `${SNAP}`
prefix. This commit adds a test to ensure that snapcraft correctly
handles this scenario.

Signed-off-by: Daniel Llewellyn <daniel@bowlhat.net>
@lucyllewy
Copy link
Contributor Author

Test is added :-)

@codecov-io
Copy link

codecov-io commented Apr 24, 2019

Codecov Report

Merging #2541 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2541      +/-   ##
==========================================
+ Coverage   88.96%   88.97%   +<.01%     
==========================================
  Files         204      204              
  Lines       13948    13950       +2     
  Branches     2109     2110       +1     
==========================================
+ Hits        12409    12412       +3     
+ Misses       1093     1092       -1     
  Partials      446      446
Impacted Files Coverage Δ
snapcraft/internal/meta/_desktop.py 72.34% <100%> (+1.22%) ⬆️
snapcraft/internal/elf.py 80.71% <0%> (-0.36%) ⬇️
snapcraft/internal/pluginhandler/_plugin_loader.py 85.29% <0%> (+1.96%) ⬆️

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 1c283cc...f01b3cf. Read the comment docs.

Bad spelling: applicatins != applications.

Signed-off-by: Daniel Llewellyn <daniel@bowlhat.net>
@lucyllewy
Copy link
Contributor Author

seems the unit test I added is failing. I guess I still need to do some more work...

Copy link
Collaborator

@sergiusens sergiusens left a comment

Choose a reason for hiding this comment

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

Your test spotted the issue! You can thank them!

snapcraft/extractors/appstream.py Outdated Show resolved Hide resolved
Daniel Llewellyn and others added 3 commits May 1, 2019 15:22
Add trailing slash to string to-be-stripped (`${SNAP}/`) in appstream
code.

Signed-off-by: Daniel Llewellyn <daniel@bowlhat.net>
Return an absolute icon path when stripping `${SNAP}`.

Signed-off-by: Daniel Llewellyn <daniel@bowlhat.net>
Co-Authored-By: Sergio Schvezov <sergio.schvezov@canonical.com>
@lucyllewy
Copy link
Contributor Author

looks like tests are still failing :-(

Daniel Llewellyn added 3 commits May 9, 2019 19:21
The path was not being found previously. Tests highlighted the issue and
now I've fixed the function to return the expected values. The tests
correctly pass now, and haven't been changed.

Signed-off-by: Daniel Llewellyn <daniel@bowlhat.net>
Signed-off-by: Daniel Llewellyn <daniel@bowlhat.net>
@lucyllewy lucyllewy changed the title Appstream: strip ${SNAP} from .desktop icon Desktop meta: strip ${SNAP} from .desktop icon May 10, 2019
tests/unit/test_meta.py Outdated Show resolved Hide resolved
- remove extra line accidentally added to
`snapcraft/extractors/appstream.py`.
- undelete accidentally removed assertion in `tests/unit/test_meta.py`

Signed-off-by: Daniel Llewellyn <daniel@bowlhat.net>
Signed-off-by: Daniel Llewellyn <daniel@bowlhat.net>
@sergiusens sergiusens merged commit 7b5b20d into canonical:master May 10, 2019
clobrano pushed a commit to clobrano-forks/snapcraft that referenced this pull request Jun 8, 2019
A lot of snaps are hacking the desktop file of their projects to insert
a snap-relative path for their icon of the form
`${SNAP}/path/to/icon.png`, ensure this is taken into account while
checking if the icon exists.

Signed-off-by: Daniel Llewellyn <daniel@bowlhat.net>
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.

4 participants