flathub-infra / flatpak-builder-lint

A linter for flatpak-builder manifests
MIT License
49 stars 123 forks source link

Add a check to find if exportable icons exist #275

Closed bbhtt closed 7 months ago

bbhtt commented 7 months ago
This goes through icons installed in `/app/share/icons/hicolor` and
checks if any icons matching appid patterns that flatpak exports are
installed. If not return an error because without any icons exported
the icon referenced in desktop file won't be found and appear as empty
in DE overview.

This is seperate from the icon generated by appstream in app-info
because

- appinfo icons are not used by desktop files and flatpak does not
  export them
- it may happen that appstream compose created an icon and named it
  using FLATPAK_ID when no such icon with the correct filename was
  actually installed. The end result is, the flatpak ends up with no
  exportable icons

Eg. of this happening Kdevelop as of this commit https://github.com/flathub/org.kde.kdevelop/commit/9369b16e4011de25a867c512c27f2319f7b4fde4

Current state of kdevelop ```sh → tree ~/.local/share/flatpak/app/org.kde.kdevelop/current/active/files/share/icons /home/bbhtt/.local/share/flatpak/app/org.kde.kdevelop/current/active/files/share/icons └── hicolor ├── 1024x1024 │ └── apps │ └── kdevelop.png ├── 128x128 │ └── apps │ ├── bazaar.png │ ├── clazy.png │ ├── cmake.png │ ├── cppcheck.png │ ├── kdevelop.png │ └── okteta.png ├── 16x16 │ ├── actions │ │ └── breakpoint.png │ └── apps │ ├── cmake.png │ ├── github-forked.png │ ├── github-private.png │ ├── github-repo.png │ ├── kdevelop.png │ ├── kdevgh.png │ └── okteta.png ├── 22x22 │ ├── actions │ │ └── breakpoint.png │ └── apps │ └── okteta.png ├── 256x256 │ └── apps │ └── kdevelop.png ├── 32x32 │ ├── actions │ │ └── breakpoint.png │ └── apps │ ├── cmake.png │ ├── kdevelop.png │ ├── kdevgh.png │ └── okteta.png ├── 48x48 │ └── apps │ ├── kdevelop.png │ └── okteta.png ├── 512x512 │ └── apps │ └── kdevelop.png ├── 64x64 │ └── apps │ ├── cmake.png │ ├── kdevelop.png │ └── okteta.png ├── icon-theme.cache └── scalable ├── actions │ └── breakpoint.svg └── apps ├── git.svg ├── kdevelop.svg └── qtlogo.svg 26 directories, 34 files ╭─bbhtt@fedora in ~ took 5ms → tree ~/.local/share/flatpak/app/org.kde.kdevelop/current/active/files/share/app-info /home/bbhtt/.local/share/flatpak/app/org.kde.kdevelop/current/active/files/share/app-info ├── icons │ └── flatpak │ ├── 128x128 │ │ └── org.kde.kdevelop.png │ └── 64x64 │ └── org.kde.kdevelop.png └── xmls ├── io.qt.qtwebengine.BaseApp.xml.gz └── org.kde.kdevelop.xml.gz ```
bbhtt commented 7 months ago

os.walk seems to be a bit too slow here...

barthalion commented 7 months ago

https://peps.python.org/pep-0471/ this should be faster than os.walk, if you want to refactor it. Don't think it matters but up to you

bbhtt commented 7 months ago

I changed it to glob, seems fine now as far as I can see.

bbhtt commented 7 months ago

https://peps.python.org/pep-0471/ this should be faster than os.walk, if you want to refactor it. Don't think it matters but up to you

Looks like os.walk was changed to use scandir internally or something ? https://bugs.python.org/issue23605