Menu

#2127 Recent Icon rework breaks installing to stage dir

v3.x
open-need-info
compyx
None
GTK3
Buildsystem
2026-01-22
2025-02-22
No

Hi,

The newly introduced rework of (desktop) icons breaks installing to stage dir

Right now the state of the head of the vice-emu repo is that you cannot build and install into stage dir as a non-privileged user as the desktop icon install requires super-user (root) and ignores the stage dir location

Building and installing to stage dirs are usually something that distribution-package-builders do in order to snapshot the full hierarchical structure into an archive (distribution package) without installing.

Below is the last failing parts of an attempt to install into stage dir "/tmp/vice-3.9/" (by setting DESTDIR)

make  install-data-hook
make[5]: Entering directory '/tmp/vice-emu-devel/_build.out/gtk/data/common'
xdg-icon-resource install --size 32 /tmp/vice-emu-devel/data/common/vice-x64_32.png vice-x64
xdg-icon-resource install --size 48 /tmp/vice-emu-devel/data/common/vice-x64_48.png vice-x64
xdg-icon-resource install --size 64 /tmp/vice-emu-devel/data/common/vice-x64_64.png vice-x64
xdg-icon-resource install --size 256 /tmp/vice-emu-devel/data/common/vice-x64_256.png vice-x64
...
...
...
xdg-icon-resource install --size 32 /tmp/vice-emu-devel/data/common/vice-vsid_32.png vice-vsid
xdg-icon-resource install --size 48 /tmp/vice-emu-devel/data/common/vice-vsid_48.png vice-vsid
xdg-icon-resource install --size 64 /tmp/vice-emu-devel/data/common/vice-vsid_64.png vice-vsid
xdg-icon-resource install --size 256 /tmp/vice-emu-devel/data/common/vice-vsid_256.png vice-vsid
desktop-file-install /tmp/vice-emu-devel/data/common/x64.desktop
Error on file "/tmp/vice-emu-devel/data/common/x64.desktop": Failed to create file “/usr/share/applications/x8S312”: Permission denied
make[5]: *** [Makefile:982: install-desktop-files] Error 1
make[5]: Leaving directory '/tmp/vice-emu-devel/_build.out/gtk/data/common'
make[4]: *** [Makefile:798: install-data-am] Error 2
make[4]: Leaving directory '/tmp/vice-emu-devel/_build.out/gtk/data/common'
make[3]: *** [Makefile:747: install-am] Error 2
make[3]: Leaving directory '/tmp/vice-emu-devel/_build.out/gtk/data/common'
make[2]: *** [Makefile:459: install-recursive] Error 1

There are several ways to workaround this issue - either:

1) add something similar to option "--dir=$(DESTDIR)/share/applications" to "desktop-file-install" - but only in situations where DESTDIR is actually set... (env var DESKTOP_FILE_INSTALL_DIR works equivalent of the option)

2) setting env-var RPM_BUILD_ROOT before calling "desktop-file-install" will also do the job - but the paths it populates below DESTDIR is a little different the option 1)

see man page of "desktop-file-install" for more info...

br/Uffe

Discussion

1 2 3 > >> (Page 1 of 3)
  • compyx

    compyx - 2025-02-24

    Thanks for reporting this.

    Option 1 seems the best since it's distro-agnostic, unlike option 2. I'll experiment a bit with DESKTOP_FILE_INSTALL_DIR in a VM.

    Do the icon files end up in the correct place at least? I know xdg-icon-resource will implicitly set its --mode argument to either 'system' or 'user' depending on whether its called as root or a normal user.

     
  • compyx

    compyx - 2025-02-24
    • assigned_to: compyx
    • Port: --> GTK3
     
  • Uffe Jakobsen

    Uffe Jakobsen - 2025-02-24

    Quote: "Do the icon files end up in the correct place at least? "

    I'm not really if your previous post actually contains a question for me ?

    without any of the above workarounds - nothing gets written due to (non-root) permission errors.

    I'm also in favour of option 1)
    Setting dir to "$(DESTDIR)/share/applications" seems to do the job

     
  • compyx

    compyx - 2025-02-24

    That was a question for you indeed =)

    It doesn't look like xdg-icon-resource triggers errors, so I'm wondering where the icons end up. I assume since you're not running as root they are installed into $XDG_DATA_HOME/icons/hicolor, e.g. ~/.local/share/icons/hicolor/, and not into the staging virtual root of, say, /tmp/vice-3.9-svn/usr/local/share/icons/hicolor/?

     
    • Uffe Jakobsen

      Uffe Jakobsen - 2025-02-24

      Ah sorry I was not up-to-par on the implementation details on your change

      But you are right - invocations of xdg-icon-resouceruns without error
      For my non-root staging installs it appears the xdg-icon-resource installs into ~/.local/share/icons/hicolor/<SIZE>x<SIZE>/apps/
      As it ran without error I did not think more about it...
      I guess that it should be directed info the staging dir - as it would be missing from the resulting distribution-packaging... ?

       
  • Olaf Seibert

    Olaf Seibert - 2025-02-24

    For inclusion in pkgsrc I had already some patches to install the gtk3 desktop files properly in the staging directory. Essentially it uses --mode system to get them to the right place (the place where a privileged install would put them even though the install is done as a mere user.

    Install .desktop files in the system location instead of
    the (fake) home directory.
    
    --- src/arch/gtk3/data/unix/Makefile.in.orig    2023-12-24 17:42:17.000000000 +0000
    +++ src/arch/gtk3/data/unix/Makefile.in
    @@ -732,7 +732,7 @@ uninstall-am:
     @INSTALL_DESKTOP_FILES_TRUE@@MACOS_COMPILE_FALSE@@UNIX_COMPILE_TRUE@           "SID_1024.svg"
    
     @INSTALL_DESKTOP_FILES_TRUE@@MACOS_COMPILE_FALSE@@UNIX_COMPILE_TRUE@install-data-hook: $(VICE_DIR_FILE) $(VICE_DESKTOP_FILES)
    -@INSTALL_DESKTOP_FILES_TRUE@@MACOS_COMPILE_FALSE@@UNIX_COMPILE_TRUE@   $(XDG_DESKTOP_MENU) install "$(VICE_DIR_FILE)" $(VICE_DESKTOP_FILES)
    +@INSTALL_DESKTOP_FILES_TRUE@@MACOS_COMPILE_FALSE@@UNIX_COMPILE_TRUE@   $(XDG_DESKTOP_MENU) install --mode system "$(VICE_DIR_FILE)" $(VICE_DESKTOP_FILES)
     @INSTALL_DESKTOP_FILES_TRUE@@MACOS_COMPILE_FALSE@@UNIX_COMPILE_TRUE@   $(XDG_DESKTOP_MENU) forceupdate
     @INSTALL_DESKTOP_FILES_TRUE@@MACOS_COMPILE_FALSE@@UNIX_COMPILE_TRUE@   @echo " "
     @INSTALL_DESKTOP_FILES_TRUE@@MACOS_COMPILE_FALSE@@UNIX_COMPILE_TRUE@   @echo "* Remember that for desktop updates to show up, you may have to log off and on,"
    @@ -745,7 +745,7 @@ uninstall-am:
     # Seems GNU disapproves of this, but it works to uninstall the .desktop/.directory
     # files.
     @INSTALL_DESKTOP_FILES_TRUE@@MACOS_COMPILE_FALSE@@UNIX_COMPILE_TRUE@uninstall-hook:
    -@INSTALL_DESKTOP_FILES_TRUE@@MACOS_COMPILE_FALSE@@UNIX_COMPILE_TRUE@   $(XDG_DESKTOP_MENU) uninstall "$(VICE_DIR_FILE)" $(VICE_DESKTOP_FILES)
    +@INSTALL_DESKTOP_FILES_TRUE@@MACOS_COMPILE_FALSE@@UNIX_COMPILE_TRUE@   $(XDG_DESKTOP_MENU) uninstall --mode system "$(VICE_DIR_FILE)" $(VICE_DESKTOP_FILES)
     @INSTALL_DESKTOP_FILES_TRUE@@MACOS_COMPILE_FALSE@@UNIX_COMPILE_TRUE@   $(XDG_DESKTOP_MENU) forceupdate
     @INSTALL_DESKTOP_FILES_TRUE@@MACOS_COMPILE_FALSE@@UNIX_COMPILE_TRUE@   @echo " "
     @INSTALL_DESKTOP_FILES_TRUE@@MACOS_COMPILE_FALSE@@UNIX_COMPILE_TRUE@   @echo "* Remember that for desktop updates to show up, you may have to log off and on,"
    

    This isnt' quite enough for the staging install, it also needs this in the pkgsrc Makefile to move some files around:

    # Mess created by xdg-utils; clean it up.
    post-install:
            ${RM} -f ${DESTDIR}${PREFIX}/share/applications/mimeinfo.cache
            cd ${DESTDIR}${PREFIX} && ${MV} etc/xdg/menus/applications-merged/vice-org-vice-org.menu share/vice/ || :
            cd ${DESTDIR}${PREFIX} && ${RMDIR} -r etc || :
    

    Note how I commented "Mess created by xdg-utils". I have a vague recollection that the xdg-tools were behaving in a very annoying way when I was trying to get the staging directory right. I am not even sure it's possible to write something that works equally well for a staging directory as a direct install. (This is why I haven't proposed to make this change to Vice itself) I blame the xdg tools. They are probably just as annoying when handling the icons.

     
  • compyx

    compyx - 2025-02-24

    I've committed a possible fix for the installation of .desktop files into a staging directory in r45506.

    The commit uses --dir=$(DESTDIR)/usr/share/applications, not $(DESTDIR)/share/applications like in the first post.
    The reason for this is that when I leave out /usr I'll have to add it to DESTDIR when invoking make, resulting in the non-desktop files ending up in /usr/usr in the staging install directory (I used --prefix=/usr when running configure).
    As far as I can tell, this is how DESTDIR is used: the "virtual root" of the staged install, when reading the docs of GNU make.

     
  • Olaf Seibert

    Olaf Seibert - 2025-02-24

    Yes your understanding of $(DESTDIR) is correct. But I would use --dir=$(DESTDIR)$(PREFIX)/share/applications instead of --dir=$(DESTDIR)/usr/share/applications, so that the value from configure --prefix=/usr/local (or whatever directory) is used.

    (there is no / needed between the two variables, because $(PREFIX) always starts with a /, and also because$(DESTDIR) can be empty.)

    In the second part, rm -f $(DESTDIR)/share/applications/x64{,dtv,sc}.desktop ;\ etc, the /usr or $(PREFIX) got lost completely.

     
  • compyx

    compyx - 2025-02-24

    Ah yes, using $(DESTDIR)$(PREFIX) would indeed allow for proper handling of --prefix. But since (at least on my Debian system) .desktop files live in /usr/share/applications (i.e. --prefix=/usr) and /usr/local/share/applications doesn't exist, I wonder if this will break the VICE default of the /usr/local prefix.

    I tend to use the /usr/local prefix (like VICE) for non-package manager software (or /opt for stuff I don't want to be available through PATH), and I think installing the .desktop files into /usr/local/share/applications would result in Gnome (and update-desktop-database) failing to notice the new files.

    And yes, looks like the uninstall-desktop-files rule got mangled during copy/paste/edit =)

     
    • compyx

      compyx - 2025-02-24

      Looking at the contents of the XDG_DATA_DIRS env var on my system, it looks like Gnome will pick up the files from /usr/local/share/applications. The variable contains /usr/share/gnome:/usr/local/share/:/usr/share/ when echoed from bash. Hopefully the same is true for non-login shells.

      Will have to test though.

       
      • Olaf Seibert

        Olaf Seibert - 2025-02-24

        That sounds promising.

        For things like pkgsrc, I am kind of assuming that if somebody is running a desktop environment built to $PREFIX, it will search for desktop files and everything else in $PREFIX/...whatever. "Assuming" because I just run ctwm and not a "desktop environment" at all.

         
  • compyx

    compyx - 2025-02-25

    Since SF is having problems, here's a diff of the changes I just tried to commit:

    Index: data/common/Makefile.am
    ===================================================================
    --- data/common/Makefile.am (revision 45506)
    +++ data/common/Makefile.am (working copy)
    @@ -348,59 +348,31 @@
     # this work for the canonical emulator names, alternate names will be a TODO.
     install-desktop-files:
     if SUPPORT_X64
    
    -   if test -n "$(DESTDIR)"; then \
    -       desktop-file-install --dir=$(DESTDIR)/usr/share/applications $(top_srcdir)/data/common/x64.desktop ;\
    -   else \
    -       desktop-file-install $(top_srcdir)/data/common/x64.desktop ;\
    -   fi
    +   desktop-file-install --dir=$(DESTDIR)${prefix}/share/applications $(top_srcdir)/data/common/x64.desktop
     endif
    -   if test -n "$(DESTDIR)"; then \
    -       desktop-file-install --dir=$(DESTDIR)/usr/share/applications $(top_srcdir)/data/common/x64sc.desktop ;\
    -       desktop-file-install --dir=$(DESTDIR)/usr/share/applications $(top_srcdir)/data/common/x64dtv.desktop ;\
    -       desktop-file-install --dir=$(DESTDIR)/usr/share/applications $(top_srcdir)/data/common/xscpu64.desktop ;\
    -       desktop-file-install --dir=$(DESTDIR)/usr/share/applications $(top_srcdir)/data/common/x128.desktop ;\
    -       desktop-file-install --dir=$(DESTDIR)/usr/share/applications $(top_srcdir)/data/common/xplus4.desktop ;\
    -       desktop-file-install --dir=$(DESTDIR)/usr/share/applications $(top_srcdir)/data/common/xvic.desktop ;\
    -       desktop-file-install --dir=$(DESTDIR)/usr/share/applications $(top_srcdir)/data/common/xpet.desktop ;\
    -       desktop-file-install --dir=$(DESTDIR)/usr/share/applications $(top_srcdir)/data/common/xcbm2.desktop ;\
    -       desktop-file-install --dir=$(DESTDIR)/usr/share/applications $(top_srcdir)/data/common/xcbm5x0.desktop ;\
    -       desktop-file-install --dir=$(DESTDIR)/usr/share/applications $(top_srcdir)/data/common/vsid.desktop ;\
    -   else \
    -       desktop-file-install $(top_srcdir)/data/common/x64sc.desktop ;\
    -       desktop-file-install $(top_srcdir)/data/common/x64dtv.desktop ;\
    -       desktop-file-install $(top_srcdir)/data/common/xscpu64.desktop ;\
    -       desktop-file-install $(top_srcdir)/data/common/x128.desktop ;\
    -       desktop-file-install $(top_srcdir)/data/common/xplus4.desktop ;\
    -       desktop-file-install $(top_srcdir)/data/common/xvic.desktop ;\
    -       desktop-file-install $(top_srcdir)/data/common/xpet.desktop ;\
    -       desktop-file-install $(top_srcdir)/data/common/xcbm2.desktop ;\
    -       desktop-file-install $(top_srcdir)/data/common/xcbm5x0.desktop ;\
    -       desktop-file-install $(top_srcdir)/data/common/vsid.desktop ;\
    -   fi
    +   desktop-file-install --dir=$(DESTDIR)${prefix}/share/applications $(top_srcdir)/data/common/x64sc.desktop
    +   desktop-file-install --dir=$(DESTDIR)${prefix}/share/applications $(top_srcdir)/data/common/x64dtv.desktop
    +   desktop-file-install --dir=$(DESTDIR)${prefix}/share/applications $(top_srcdir)/data/common/xscpu64.desktop
    +   desktop-file-install --dir=$(DESTDIR)${prefix}/share/applications $(top_srcdir)/data/common/x128.desktop
    +   desktop-file-install --dir=$(DESTDIR)${prefix}/share/applications $(top_srcdir)/data/common/xplus4.desktop
    +   desktop-file-install --dir=$(DESTDIR)${prefix}/share/applications $(top_srcdir)/data/common/xvic.desktop
    +   desktop-file-install --dir=$(DESTDIR)${prefix}/share/applications $(top_srcdir)/data/common/xpet.desktop
    +   desktop-file-install --dir=$(DESTDIR)${prefix}/share/applications $(top_srcdir)/data/common/xcbm2.desktop
    +   desktop-file-install --dir=$(DESTDIR)${prefix}/share/applications $(top_srcdir)/data/common/xcbm5x0.desktop
    +   desktop-file-install --dir=$(DESTDIR)${prefix}/share/applications $(top_srcdir)/data/common/vsid.desktop
    
     # No `desktop-file-uninstall` exists, nor is there an uninstall option for
     # `desktop-file-install` or `desktop-file-uninstall`, so a simple `rm` will
     # have to do.
     uninstall-desktop-files:
    
    -   if test -n "$(DESTDIR)"; then \
    -       rm -f $(DESTDIR)/share/applications/x64{,dtv,sc}.desktop ;\
    -       rm -f $(DESTDIR)/share/applications/xscpu64.desktop ;\
    -       rm -f $(DESTDIR)/share/applications/x128.desktop ;\
    -       rm -f $(DESTDIR)/share/applications/xplus4.desktop ;\
    -       rm -f $(DESTDIR)/share/applications/xpet.desktop ;\
    -       rm -f $(DESTDIR)/share/applications/xcbm{2,5x0}.desktop ;\
    -       rm -f $(DESTDIR)/share/applications/xvic.desktop ;\
    -       rm -f $(DESTDIR)/share/applications/vsid.desktop ;\
    -   else \
    -       rm -f /usr/share/applications/x64{,dtv,sc}.desktop ;\
    -       rm -f /usr/share/applications/xscpu64.desktop ;\
    -       rm -f /usr/share/applications/x128.desktop ;\
    -       rm -f /usr/share/applications/xplus4.desktop ;\
    -       rm -f /usr/share/applications/xpet.desktop ;\
    -       rm -f /usr/share/applications/xcbm{2,5x0}.desktop ;\
    -       rm -f /usr/share/applications/xvic.desktop ;\
    -       rm -f /usr/share/applications/vsid.desktop ;\
    -   fi
    +   rm -f $(DESTDIR)${prefix}/share/applications/x64{,dtv,sc}.desktop
    +   rm -f $(DESTDIR)${prefix}/share/applications/xscpu64.desktop
    +   rm -f $(DESTDIR)${prefix}/share/applications/x128.desktop
    +   rm -f $(DESTDIR)${prefix}/share/applications/xplus4.desktop
    +   rm -f $(DESTDIR)${prefix}/share/applications/xpet.desktop
    +   rm -f $(DESTDIR)${prefix}/share/applications/xcbm{2,5x0}.desktop
    +   rm -f $(DESTDIR)${prefix}/share/applications/xvic.desktop
    +   rm -f $(DESTDIR)${prefix}/share/applications/vsid.desktop
    
     install-data-hook: install-icons install-desktop-files
        -update-desktop-database
    

    When I get back from work I'll try to commit again.

     
  • Uffe Jakobsen

    Uffe Jakobsen - 2025-02-25

    With commit https://sourceforge.net/p/vice-emu/code/45507
    non-root installs into staging area now runs without error...

    PS: I know that the icons files are still not handled correct - but at least the install target does not error out :-)

     
  • compyx

    compyx - 2025-02-26

    Good to hear at least the .desktop file installation now works correctly =)

    The icons will be next, but xdg-icon-resource doesn't have a --dir switch to control where the icons end up. Looking at the script, it does use XDG_DATA_HOME. so perhaps passing something akin to XDG_DATA_HOME=/tmp/vice-3.9/usr/share to make install will make the icons end up in the correct location.

     
    • compyx

      compyx - 2025-02-26

      Just tried using XDG_DATA_HOME and indeed my cunning plan seems to work. I use /tmp/vice-3.9/build as my build dir and /tmp/vice-3.9/dist as the staging dir, and when running:

      make install DESTDIR=/tmp/vice-3.9/dist XDG_DATA_HOME=/tmp/vice-3.9/dist/usr/share
      `
      

      The icon files end up in /tmp/vice-3.9/dist/usr/share/icons/hicolor/{32x32,48x48,64x64,256x256}/apps/.

      I assume your RPM package manager will run post-install hooks running things like update-desktop-database and gtk-update-icon-cache after unpacking, in which case this looks like the cleanest solution for the icon files, to me.

       
  • gpz

    gpz - 2025-11-18

    Whats the status of this? Can we close the ticket? Or is there still something left that needs to be fixed?

     
  • gpz

    gpz - 2025-11-18
    • status: open --> open-need-info
    • Category: --> Buildsystem
     
  • Uffe Jakobsen

    Uffe Jakobsen - 2025-11-18

    Hi,

    I just checked up on this issue
    The icon files are still not installed into the staging area.
    The solution is described above - but it does not seem to be implemented into the install make target
    I can see if I can find sometime to produce a patch - if I'm lucky at $WORK - I may have some spare time tomorrow evening :-)

     
  • Uffe Jakobsen

    Uffe Jakobsen - 2025-11-19

    Ok - problems with github prevented me from working - that bought me some time to look at the patch

    This fix only kicks in with installing into stage dir (using DESTDIR) - if that is not the case everything works unchanged

    Patch attached

    diff --git data/common/Makefile.am data/common/Makefile.am
    index 54cb1d41f2..0575ac467a 100644
    --- data/common/Makefile.am
    +++ data/common/Makefile.am
    @@ -261,6 +261,7 @@ if INSTALL_DESKTOP_FILES
     # Install icon files in their proper place. The default context is 'apps' and
     # the default mode is 'system' when running as root and 'user' when not running
     # as root, both defaults are what we want.
    +$(if $(DESTDIR),install-icons: XDG_DATA_HOME=$(DESTDIR)$(prefix)/share)
     install-icons:
        xdg-icon-resource install --size 32 $(top_srcdir)/data/common/vice-x64_32.png vice-x64
        xdg-icon-resource install --size 48 $(top_srcdir)/data/common/vice-x64_48.png vice-x64
    @@ -299,6 +300,7 @@ install-icons:
        xdg-icon-resource install --size 64 $(top_srcdir)/data/common/vice-vsid_64.png vice-vsid
        xdg-icon-resource install --size 256 $(top_srcdir)/data/common/vice-vsid_256.png vice-vsid
    
    +$(if $(DESTDIR),uninstall-icons: XDG_DATA_HOME=$(DESTDIR)$(prefix)/share)
     uninstall-icons:
        xdg-icon-resource uninstall --size 32 vice-x64
        xdg-icon-resource uninstall --size 48 vice-x64
    
     
  • gpz

    gpz - 2025-11-19

    applied to r45858 - please test.

     
  • gpz

    gpz - 2025-11-19

    Mmmh that said, are the icons actually installed - as in copied into the system somewhere? i cant find them anywhere, except in the sourcetree, after "make install" shrug

     
    😄
    1
    • gpz

      gpz - 2025-11-19

      nevermind, found them... they are renamed in the process :o)

       
      👍
      1
  • Uffe Jakobsen

    Uffe Jakobsen - 2025-11-19

    I can confirm that the current code fulfills my needs (as I made the patch :-D )
    Icon files are now installed into the staging dir (and that was what I needed)

     
  • gpz

    gpz - 2025-11-20

    Fine, closing :)

     
  • gpz

    gpz - 2025-11-20
    • status: open-need-info --> closed-fixed
     
1 2 3 > >> (Page 1 of 3)

Log in to post a comment.

MongoDB Logo MongoDB