Bug 194957

Summary: x11-fonts/linux-{c6,f10}-fontconfig: linux- apps pollute user cache with system fonts
Product: Ports & Packages Reporter: Jan Beich <jbeich>
Component: Ports FrameworkAssignee: freebsd-emulation (Nobody) <emulation>
Status: Open ---    
Severity: Affects Only Me CC: emulation, tijl, x11, xmj
Priority: --- Flags: linimon: maintainer-feedback? (emulation)
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
incomplete fix
none
x11-fonts/noto log
none
x11-fonts/linux-f10-fontconfig log
none
incomplete fix none

Description Jan Beich freebsd_committer freebsd_triage 2014-11-12 03:32:42 UTC
Created attachment 149304 [details]
incomplete fix

According fonts-conf(5) fontconfig uses cache in the form of <hash value>-<architecture>.cache-<version>. And fc-cache(1) explicitly notes that for every architecture a separate run is required. However, as x11-fonts/linux-*-fontconfig tries to use native fontconfig it completely ignores/predates architecture distinction in cache filenames.

Steps to reproduce:

1. install www/linux-firefox (or any port using linux-*-fontconfig)
2. install x11-fonts/noto (or any port invoking fc-cache)
3. start linux-firefox then quit it
4. notice ~/.cache/fontconfig or ~/.fontconfig now has files with the
   same hash as /var/db/fontconfig but for different architecture

Those directories may contain files:

  *-x86.cache-2 (linux-f10- i386)
  *-le32d4.cache-3 (linux-c6- i386)
  *-le64.cache-4 (native amd64)

In some cases ~/.cache expansion may be broken and `fontconfig' directory would appear directly under $HOME.

x11@ is CC'd in case multilib infra ever materializes and they (not gnome@) own Keywords/fc*ucl, so may help un-hardcode /compat/linux from the patch.
Comment 1 Jan Beich freebsd_committer freebsd_triage 2014-11-12 04:02:36 UTC
Actually, the issue may happen even on i386 because:

- x86 became le32d4 and cache version bump in 2.8.0 per
  http://cgit.freedesktop.org/fontconfig/commit/?id=1845f31
  http://cgit.freedesktop.org/fontconfig/commit/?id=1f4e6fe
- cache version bump in 2.11.0 per
  http://cgit.freedesktop.org/fontconfig/commit/?id=62b7d76

while

- x11-fonts/linux-f10-fontconfig is at 2.6.0
- x11-fonts/linux-c6-fontconfig is at 2.8.0
- x11-fonts/fontconfig is at 2.11.0 (latest is 2.11.1)
Comment 2 Johannes Jost Meixner freebsd_committer freebsd_triage 2014-11-14 10:40:39 UTC
Patch to Keywords/fc.ucl assumes that linux-[c6,f10]-fontconfig is installed on every system, else the executables will not be found.

Have you tested what happens if this patch is present on systems lacking linux- fontconfig packages?
Comment 3 Jan Beich freebsd_committer freebsd_triage 2014-11-14 14:55:00 UTC
Created attachment 149402 [details]
x11-fonts/noto log

Nothing would happen. What else do you expect from the following construct?

  nonexistent 2>/dev/null || true

.ttf and .otf can be used directly without fontconfig (e.g. by games or video players). And mkfontscale is a compat for apps that don't know about pango, fontconfig or freetype2. @fc and @fcfontsdir are similar to @desktop-file-utils and @shared-mime-info where an optional dependency becomes mandatory for everyone.
Comment 4 Jan Beich freebsd_committer freebsd_triage 2014-11-14 15:07:18 UTC
Created attachment 149403 [details]
x11-fonts/linux-f10-fontconfig log

Not sure how to avoid the following without trampling over cache from x11-fonts/fontconfig.

  ====>> Files or directories left over:
  @dir var/cache/fontconfig
  var/cache/fontconfig/3830d5c3ddfd5cd38a049b759396e72e-x86.cache-2
Comment 5 Jan Beich freebsd_committer freebsd_triage 2014-11-15 20:25:19 UTC
Created attachment 149453 [details]
incomplete fix

rebased after ports r372445 and ports r372533
Comment 6 Johannes Jost Meixner freebsd_committer freebsd_triage 2015-01-27 14:06:16 UTC
Submitter is committer.
Comment 7 Jan Beich freebsd_committer freebsd_triage 2017-02-02 09:44:16 UTC
Partially obsoleted by ports r433087.