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
5 changes: 5 additions & 0 deletions snapcraft/extractors/appstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ def _get_icon_from_desktop_file(
entry = DesktopEntry()
entry.parse(os.path.join(workdir, path))
icon = entry.getIcon()

lucyllewy marked this conversation as resolved.
Show resolved Hide resolved
if icon.startswith(r"${SNAP}/"):
icon = icon[8:] # strip the '${SNAP}' prefix.
icon = os.path.join(workdir, icon)

icon_path = (
icon
if os.path.isabs(icon)
Expand Down
10 changes: 10 additions & 0 deletions tests/unit/extractors/test_appstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,16 @@ def test_appstream_no_icon_desktop_fallback_icon_exists(self):
open("icon.png", "w").close()
self._expect_icon("/icon.png")

def test_appstream_no_icon_desktop_fallback_icon_exists_with_snap_variable_prefix(
self
):
self._create_appstream_file()
_create_desktop_file(
"usr/share/applications/my.app.desktop", icon="${{SNAP}}/icon.png"
) # icon: '${SNAP}/icon.png'.
open("icon.png", "w").close()
self._expect_icon("/icon.png")

def test_appstream_no_icon_theme_fallback_png(self):
self._create_appstream_file()
_create_desktop_file("usr/share/applications/my.app.desktop", icon="icon")
Expand Down