Subject: Desktop files, 2nd round
To: None <tech-pkg@NetBSD.org>
From: Julio M. Merino Vidal <jmmv84@gmail.com>
List: tech-pkg
Date: 01/30/2005 16:51:38
--=-UQZ9FRvpBfFRpwr+Brh9
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
Hi again,
I've reworked desktop.mk and many other related things since my previous
mail. Here is how it should work now:
- Any package installing .desktop files has to set USE_DESKTOP=YES and
forget about anything else (directories, mime types, etc.)
- desktopdb.mk from desktop-file-utils disappears, as well as many stuff
from this package. Everything is merged into mk/desktop.mk and
mk/install/desktop.
- The desktop-file-utils is not a dependency of any package any more
(except for maybe nautilus or gnome-vfs2; I don't know yet).
The mk/install/desktop file will only update the mime database when
the package is installed; otherwise nothing will happen. I.e., the
database only exists iff desktop-file-utils is installed.
- If a package has .desktop files in its FILESDIR, they get
automatically processed and installed. This is to be used to easily
provide .desktop files from pkgsrc.
- If a distfile includes any .desktop file, the Exec line is "fixed" to
use absolute paths.
Patch attached. It includes the new files and modifies vim-gtk2 and
gedit (which represent the two possible situations, a desktop file from
pkgsrc and one from the distfile). After that, I'll fix all packages
that install .desktop files to set USE_DESKTOP=YES and to not depend
on desktop-file-utils.
Comments?
Thanks,
--
Julio M. Merino Vidal <jmmv84@gmail.com>
http://www.livejournal.com/users/jmmv/
The NetBSD Project - http://www.NetBSD.org/
--=-UQZ9FRvpBfFRpwr+Brh9
Content-Disposition: attachment; filename=patch.diff
Content-Type: text/x-patch; name=patch.diff; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
Index: mk/bsd.pkg.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/bsd.pkg.mk,v
retrieving revision 1.1578
diff -u -u -r1.1578 bsd.pkg.mk
--- mk/bsd.pkg.mk 28 Jan 2005 21:05:59 -0000 1.1578
+++ mk/bsd.pkg.mk 30 Jan 2005 15:40:27 -0000
@@ -750,6 +750,12 @@
#
.include "../../mk/alternatives.mk"
+# Handle desktop files
+#
+.if defined(USE_DESKTOP) && !empty(USE_DESKTOP:M[Yy][Ee][Ss])
+. include "../../mk/desktop.mk"
+.endif
+
# CONF_DEPENDS notes a dependency where the config directory for the
# package matches the dependency's config directory. CONF_DEPENDS is
# only meaningful if ${PKG_INSTALLATION_TYPE} == "pkgviews".
Index: editors/vim-gtk2/Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/editors/vim-gtk2/Makefile,v
retrieving revision 1.12
diff -u -u -r1.12 Makefile
--- editors/vim-gtk2/Makefile 25 Jan 2005 13:48:54 -0000 1.12
+++ editors/vim-gtk2/Makefile 30 Jan 2005 15:40:27 -0000
@@ -1,7 +1,7 @@
# $NetBSD: Makefile,v 1.12 2005/01/25 13:48:54 jmmv Exp $
PKGNAME= vim-gtk2-${VIM_VERSION}.${VIM_PATCHLEVEL}
-PKGREVISION= 1
+PKGREVISION= 2
COMMENT= Vim editor (vi clone) with X11 GTK2 GUI
@@ -11,6 +11,7 @@
CONFLICTS+= vim-[0-9]* vim-gtk-[0-9]* vim-motif-[0-9]*
CONFLICTS+= vim-xaw-[0-9]* vim-kde-[0-9]*
+USE_DESKTOP= yes
USE_X11= yes
CONFIGURE_ARGS+= --enable-gui=gtk2
CONFIGURE_ARGS+= --with-tlib=ncurses
Index: editors/vim-gtk2/PLIST
===================================================================
RCS file: /cvsroot/pkgsrc/editors/vim-gtk2/PLIST,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 PLIST
--- editors/vim-gtk2/PLIST 2 Jun 2003 08:24:45 -0000 1.1.1.1
+++ editors/vim-gtk2/PLIST 30 Jan 2005 15:40:27 -0000
@@ -10,3 +10,5 @@
man/man1/gview.1
man/man1/rgvim.1
man/man1/rgview.1
+share/applications/gvim.desktop
+@comment in xdg-dirs: @dirrm share/applications
Index: editors/gedit/Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/editors/gedit/Makefile,v
retrieving revision 1.40
diff -u -u -r1.40 Makefile
--- editors/gedit/Makefile 28 Dec 2004 21:52:40 -0000 1.40
+++ editors/gedit/Makefile 30 Jan 2005 15:40:27 -0000
@@ -2,6 +2,7 @@
#
DISTNAME= gedit-2.8.2
+PKGREVISION= 1
CATEGORIES= editors gnome
MASTER_SITES= ${MASTER_SITE_GNOME:=sources/gedit/2.8/}
EXTRACT_SUFX= .tar.bz2
@@ -14,6 +15,7 @@
USE_PERL5= build
USE_BUILDLINK3= YES
+USE_DESKTOP= YES
USE_DIRS+= gnome2-1.5
USE_PKGLOCALEDIR= YES
USE_GNU_TOOLS+= make
@@ -35,7 +37,6 @@
.include "../../devel/pkgconfig/buildlink3.mk"
.include "../../devel/popt/buildlink3.mk"
.include "../../print/libgnomeprintui/buildlink3.mk"
-.include "../../sysutils/desktop-file-utils/desktopdb.mk"
.include "../../textproc/aspell/buildlink3.mk"
.include "../../textproc/intltool/buildlink3.mk"
.include "../../textproc/scrollkeeper/omf.mk"
Index: sysutils/desktop-file-utils/INSTALL
===================================================================
RCS file: /cvsroot/pkgsrc/sysutils/desktop-file-utils/INSTALL,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 INSTALL
--- sysutils/desktop-file-utils/INSTALL 21 Sep 2004 17:03:53 -0000 1.1.1.1
+++ sysutils/desktop-file-utils/INSTALL 30 Jan 2005 15:40:27 -0000
@@ -1,11 +1,11 @@
# $NetBSD: INSTALL,v 1.1.1.1 2004/09/21 17:03:53 jmmv Exp $
-APPLICATIONS_PATH="@APPLICATIONS_PATH@"
+APPLICATIONS_DIR="@APPLICATIONS_DIR@"
UPDATE_DESKTOPDB="@UPDATE_DESKTOPDB@"
case ${STAGE} in
POST-INSTALL)
- ${UPDATE_DESKTOPDB} ${APPLICATIONS_PATH}
+ ${UPDATE_DESKTOPDB} ${APPLICATIONS_DIR}
;;
POST-DEINSTALL)
${RM} -f ${APPLICATIONS_PATH}/mimeinfo.cache
Index: sysutils/desktop-file-utils/Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/sysutils/desktop-file-utils/Makefile,v
retrieving revision 1.5
diff -u -u -r1.5 Makefile
--- sysutils/desktop-file-utils/Makefile 3 Jan 2005 21:43:07 -0000 1.5
+++ sysutils/desktop-file-utils/Makefile 30 Jan 2005 15:40:27 -0000
@@ -22,7 +22,7 @@
INSTALL_EXTRA_TMPL+= ${.CURDIR}/INSTALL
DEINSTALL_EXTRA_TMPL+= ${.CURDIR}/INSTALL
-FILES_SUBST+= APPLICATIONS_PATH="${PREFIX}/share/applications"
+FILES_SUBST+= APPLICATIONS_DIR="${PREFIX}/share/applications"
FILES_SUBST+= UPDATE_DESKTOPDB="${PREFIX}/bin/update-desktop-database"
PRINT_PLIST_AWK+= /^share\/applications\/mimeinfo.cache$$/ \
Index: sysutils/desktop-file-utils/buildlink3.mk
===================================================================
RCS file: /cvsroot/pkgsrc/sysutils/desktop-file-utils/buildlink3.mk,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 buildlink3.mk
--- sysutils/desktop-file-utils/buildlink3.mk 21 Sep 2004 17:03:54 -0000 1.1.1.1
+++ sysutils/desktop-file-utils/buildlink3.mk 30 Jan 2005 15:40:27 -0000
@@ -15,20 +15,4 @@
BUILDLINK_PKGSRCDIR.desktop-file-utils?=../../sysutils/desktop-file-utils
.endif # DESKTOP_FILE_UTILS_BUILDLINK3_MK
-.if !empty(DESKTOP_FILE_UTILS_BUILDLINK3_MK:M+)
-BUILDLINK_TARGETS+= desktop-file-utils-buildlink-fake
-
-_DFU_FAKE_UPDATEDB= ${BUILDLINK_DIR}/bin/update-desktop-database
-
-desktop-file-utils-buildlink-fake:
- ${_PKG_SILENT}${_PKG_DEBUG} \
- if [ ! -f ${_DFU_FAKE_UPDATEDB} ]; then \
- ${ECHO_BUILDLINK_MSG} "Creating ${_DFU_FAKE_UPDATEDB}"; \
- ${MKDIR} ${_DFU_FAKE_UPDATEDB:H}; \
- ${ECHO} "#!/bin/sh" > ${_DFU_FAKE_UPDATEDB}; \
- ${ECHO} "echo '[pkgsrc] Doing nothing for update-desktop-database' \$$*" >> ${_DFU_FAKE_UPDATEDB}; \
- ${CHMOD} +x ${_DFU_FAKE_UPDATEDB}; \
- fi
-.endif # DESKTOP_FILE_UTILS_BUILDLINK3_MK
-
BUILDLINK_DEPTH:= ${BUILDLINK_DEPTH:S/+$//}
FILE ADDED TO REPOSITORY: mk/desktop.mk
--- /dev/null 2005-01-30 15:31:03.000000000 +0100
+++ mk/desktop.mk 2005-01-30 15:25:14.000000000 +0100
@@ -0,0 +1,121 @@
+# $NetBSD$
+#
+# This Makefile fragment is intended to be included by packages which
+# provide .desktop files, no matter if these are specific to pkgsrc or
+# come from the distfile.
+#
+# DESKTOP_FILES If the package provides desktop files in
+# ${FILESDIR}, this variable can be set to
+# list their file names. However, this is
+# automatic in most cases, so it shouldn't
+# be generally used.
+#
+# DESKTOP_FILE_SRC.<file> The source file for <file>; this will be
+# run through DESKTOP_SUBST to generate the
+# desktop file.
+# Default: ${FILESDIR}/<file>.desktop for all
+# files in DESKTOP_FILES.
+#
+# SUBST_FILES.desktop List of files relative to ${WRKSRC} where
+# the Exec line has to be fixed to use an
+# absolute path.
+# Default: *.desktop */*.desktop */*/*.desktop
+#
+# SUBST_SED.desktop Arguments to sed(1) to replace the Exec line
+# in desktop files. See previous variable.
+# Default: -e '/^Exec=[^/]/s|=|=${PREFIX}/bin/|'
+#
+
+.if !defined(DESKTOP_MK)
+DESKTOP_MK= # defined
+
+# We need the xdg-dirs package to get the shared share/applications directory.
+USE_DIRS+= xdg-1.1
+
+# Directory where desktop files are installed. Cannot be changed.
+APPLICATIONS_DIR= ${PREFIX}/share/applications
+
+# Let's try to use absolute paths in desktop files included in the distfiles.
+SUBST_CLASSES+= desktop
+SUBST_STAGE.desktop= post-build
+SUBST_MESSAGE.desktop= "Setting absolute paths to binaries in desktop files"
+SUBST_FILES.desktop?= *.desktop */*.desktop */*/*.desktop
+SUBST_SED.desktop?= -e '/^Exec=[^/]/s|=|=${PREFIX}/bin/|'
+
+# The list of variables that will be substituted to generate the desktop
+# files.
+DESKTOP_SUBST+= PREFIX=${PREFIX}
+DESKTOP_SUBST_SED= ${DESKTOP_SUBST:S/=/@!/:S/$/!g/:S/^/ -e s!@/}
+
+# Get all .desktop files from ${FILESDIR} if no .desktop files were specified.
+.if !defined(DESKTOP_FILES)
+DESKTOP_FILES!= if [ -d ${FILESDIR} ]; then \
+ cd ${FILESDIR}; \
+ ${LS} *.desktop 2>/dev/null || ${TRUE}; \
+ else \
+ ${ECHO} NOFILES; \
+ fi
+.endif
+
+# If we have any custom DESKTOP_FILES, install them.
+.if ${DESKTOP_FILES} != "NOFILES"
+
+.PHONY: generate-desktop-files
+post-build: generate-desktop-files
+generate-desktop-files: # do nothing
+
+.PHONY: install-desktop-files
+post-install: install-desktop-files
+install-desktop-files: # do nothing
+
+. for f in ${DESKTOP_FILES}
+DESKTOP_FILE_SRC.${f}?= ${FILESDIR}/${f}
+DESKTOP_FILE_WRK.${f}?= ${WRKDIR}/${f}
+
+generate-desktop-files: ${DESKTOP_FILE_WRK.${f}}
+
+${DESKTOP_FILE_WRK.${f}}: ${DESKTOP_FILE_SRC.${f}}
+ @${ECHO_MSG} "=> Creating ${.TARGET}"
+ ${_PKG_SILENT}${_PKG_DEBUG}${CAT} ${.ALLSRC} | \
+ ${SED} ${DESKTOP_SUBST_SED} > ${.TARGET}
+
+install-desktop-files: install-desktop-${f}
+
+install-desktop-${f}: ${DESKTOP_FILE_WRK.${f}}
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${INSTALL_DATA} ${DESKTOP_FILE_WRK.${f}} \
+ ${APPLICATIONS_DIR}/${f}
+. endfor
+
+.endif
+
+# Handle the MIME database stored in APPLICATIONS_DIR.
+USE_PKGINSTALL= YES
+INSTALL_EXTRA_TMPL+= ${.CURDIR}/../../mk/install/desktop
+DEINSTALL_EXTRA_TMPL+= ${.CURDIR}/../../mk/install/desktop
+
+EVAL_PREFIX+= PREFIX.desktop-file-utils=desktop-file-utils
+PREFIX.desktop-file-utils_DEFAULT= ${LOCALBASE}
+UPDATE_DESKTOPDB= ${PREFIX.desktop-file-utils}/bin/update-desktop-database
+
+FILES_SUBST+= APPLICATIONS_DIR="${APPLICATIONS_DIR}"
+FILES_SUBST+= UPDATE_DESKTOPDB="${UPDATE_DESKTOPDB}"
+
+PRINT_PLIST_AWK+= /^share\/applications\/mimeinfo.cache$$/ { next }
+
+USE_BUILDLINK3= YES
+BUILDLINK_TARGETS+= desktop-file-utils-buildlink-fake
+
+_DFU_FAKE_UPDATEDB= ${BUILDLINK_DIR}/bin/update-desktop-database
+
+desktop-file-utils-buildlink-fake:
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ if [ ! -f ${_DFU_FAKE_UPDATEDB} ]; then \
+ ${ECHO_BUILDLINK_MSG} "Creating ${_DFU_FAKE_UPDATEDB}"; \
+ ${MKDIR} ${_DFU_FAKE_UPDATEDB:H}; \
+ ${ECHO} "#!/bin/sh" > ${_DFU_FAKE_UPDATEDB}; \
+ ${ECHO} "echo '[pkgsrc] Doing nothing for update-desktop-database' \$$*" >> ${_DFU_FAKE_UPDATEDB}; \
+ ${CHMOD} +x ${_DFU_FAKE_UPDATEDB}; \
+ fi
+
+.endif # DESKTOP_MK
FILE ADDED TO REPOSITORY: mk/install/desktop
--- /dev/null 2005-01-30 15:31:03.000000000 +0100
+++ mk/install/desktop 2005-01-30 14:52:42.000000000 +0100
@@ -0,0 +1,14 @@
+# $NetBSD$
+#
+# Handle desktop entries.
+#
+
+APPLICATIONS_DIR="@APPLICATIONS_DIR@"
+UPDATE_DESKTOPDB="@UPDATE_DESKTOPDB@"
+
+case ${STAGE} in
+POST-INSTALL|DEINSTALL)
+ ${TEST} -x ${UPDATE_DESKTOPDB} && \
+ ${UPDATE_DESKTOPDB} ${APPLICATIONS_DIR}
+ ;;
+esac
FILE ADDED TO REPOSITORY: editors/vim-gtk2/files/gvim.desktop
--- /dev/null 2005-01-30 15:31:03.000000000 +0100
+++ editors/vim-gtk2/files/gvim.desktop 2005-01-30 15:08:37.000000000 +0100
@@ -0,0 +1,22 @@
+# $NetBSD$
+#
+
+[Desktop Entry]
+Encoding=UTF-8
+Name=VIM text editor
+Name[ca]=Editor de texts VIM
+Name[en_CA]=VIM text editor
+Name[en_GB]=VIM text editor
+Name[es]=Editor de textos VIM
+Comment=Edit text files using a Vi-like interface
+Comment[ca]=Edita fitxers de text usant una interfÃcie d'estil Vi
+Comment[en_CA]=Edit text files using a Vi-like interface
+Comment[en_GB]=Edit text files using a Vi-like interface
+Comment[es]=Edita archivos de texto usando una interfaz de tipo Vi
+Exec=@PREFIX@/bin/gvim %U
+Terminal=false
+Type=Application
+Icon=gtkvim.png
+Categories=Application;Utility;TextEditor;
+StartupNotify=true
+MimeType=text/plain;
FILE REMOVED FROM REPOSITORY: sysutils/desktop-file-utils/desktopdb.mk
FILE REMOVED FROM REPOSITORY: sysutils/desktop-file-utils/files/install.tmpl
--=-UQZ9FRvpBfFRpwr+Brh9--