>Number:         158936
>Category:       misc
>Synopsis:       Mk/bsd.ports.mk: Add a filename field to DESKTOP_ENTRIES
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jul 15 06:20:07 UTC 2011
>Closed-Date:
>Last-Modified:
>Originator:     Scot Hetzel
>Release:        
>Organization:
>Environment:
>Description:
Currently, DESKTOP_ENTRIES creates a filename for the .desktop file from the 
Exec field.  The problem with this approach is that you can't specify arguments 
to the command, otherwise you will get strangely name .desktop files.
>How-To-Repeat:
install any one of these 3 ports that use arguments in their Exec field:

www/links
misc/metalink-editor
games/tome
>Fix:
Create a new DESKTOP_ENTRIES variable that has a field for the filename.  The 
attached patch adds a new DESKTOP_ENTRIESv2 variable that handles this.





Patch attached with submission follows:

Index: bsd.port.mk
===================================================================
RCS file: /home/ncvs/ports/Mk/bsd.port.mk,v
retrieving revision 1.687
diff -u -r1.687 bsd.port.mk
--- bsd.port.mk 3 Jul 2011 15:51:18 -0000       1.687
+++ bsd.port.mk 15 Jul 2011 00:46:44 -0000
@@ -1046,7 +1046,20 @@
 # DESKTOP_ENTRIES
 #                              - List of desktop entry files to generate and 
install in
 #                                ${DESKTOPDIR}. The format is
+#
 #                                "Name" "Comment" "Icon" "Exec" "Categories" 
StartupNotify
+#
+#                                Notes:
+#                                      * Exec will also be used to name the 
.desktop file.
+#                                        If you need to use arguments in your 
.desktop file, then
+#                                        use the DESKTOP_ENTRIESv2 format.
+#                              - See DESKTOP_ENTRIESv2 for additional info.
+# DESKTOP_ENTRIESv2
+#                              - List of desktop entry files to generate and 
install in
+#                                ${DESKTOPDIR}. The format is
+#
+#                                "Filename" "Name" "Comment" "Icon" "Exec" 
"Categories" StartupNotify
+#
 #                                Rules:
 #                                      * Only add desktop entries for 
applications which do not
 #                                        require a terminal (ie. X 
applications).
@@ -1064,9 +1077,10 @@
 #                                        If the deduction fails, you will have 
to set Categories
 #                                        manually. You should check the 
generated value using
 #                                        "make desktop-categories", and 
override it if necessary.
-#                                      * Exec will also be used to name the 
.desktop file.
+#                                      * Exec can also include arguments 
(DESKTOP_ENTRIESv2 Only).
 #                                      * The files will be automatically added 
to ${PLIST}.
 #                                Example:
+#                                      "wininfo" \
 #                                      "X Window Information" \
 #                                      "Get information about X windows" \
 #                                      "wininfo.png" \
@@ -6368,7 +6382,61 @@
        GNOME GTK Qt Motif Java ConsoleOnly AdvancedSettings
 
 check-desktop-entries:
-.if defined(DESKTOP_ENTRIES)
+.if defined(DESKTOP_ENTRIESv2)
+       @set -- ${DESKTOP_ENTRIESv2} XXX; \
+       if [ `${EXPR} \( $$# - 1 \) % 7` -ne 0 ]; then \
+               ${ECHO_MSG} "${PKGNAME}: Makefile error: the DESKTOP_ENTRIES 
list must contain one or more groups of 7 elements"; \
+               exit 1; \
+       fi; \
+       num=1; \
+       while [ $$# -gt 7 ]; do \
+               entry="#$$num"; \
+               if [ -n "$$5" ]; then \
+                       entry="$$entry ($$4)"; \
+               elif [ -n "$$2" ]; then \
+                       entry="$$entry ($$2)"; \
+               fi; \
+               if [ -z "$$1" ]; then \
+                       ${ECHO_MSG} "${PKGNAME}: Makefile error: in desktop 
entry $$entry: field 1 (Filename) is empty"; \
+                       exit 1; \
+               fi
+               if [ -z "$$2" ]; then \
+                       ${ECHO_MSG} "${PKGNAME}: Makefile error: in desktop 
entry $$entry: field 2 (Name) is empty"; \
+                       exit 1; \
+               fi; \
+               if [ -z "$$5" ]; then \
+                       ${ECHO_MSG} "${PKGNAME}: Makefile error: in desktop 
entry $$entry: field 5 (Exec) is empty"; \
+                       exit 1; \
+               fi; \
+               if [ -n "$$6" ]; then \
+                       for c in `${ECHO_CMD} "$$6" | ${TR} ';' ' '`; do \
+                               if ! ${ECHO_CMD} ${VALID_DESKTOP_CATEGORIES} | 
${GREP} -wq $$c; then \
+                                       ${ECHO_CMD} "${PKGNAME}: Makefile 
error: in desktop entry $$entry: category $$c is not a valid desktop category"; 
\
+                                       exit 1; \
+                               fi; \
+                       done; \
+                       if ! ${ECHO_CMD} "$$6" | ${GREP} -q ';$$'; then \
+                               ${ECHO_MSG} "${PKGNAME}: Makefile error: in 
desktop entry $$entry: field 6 (Categories) does not end with a semicolon"; \
+                               exit 1; \
+                       fi; \
+               else \
+                       if [ -z "`cd ${.CURDIR} && ${MAKE} ${__softMAKEFLAGS} 
desktop-categories`" ]; then \
+                               ${ECHO_MSG} "${PKGNAME}: Makefile error: in 
desktop entry $$entry: field 6 (Categories) is empty and could not be deduced 
from the CATEGORIES variable"; \
+                               exit 1; \
+                       fi; \
+               fi; \
+               if [ -z "$$7" ]; then \
+                       ${ECHO_MSG} "${PKGNAME}: Makefile error: in desktop 
entry $$entry: field 7 (StartupNotify) is empty"; \
+                       exit 1; \
+               fi; \
+               if [ "x$$7" != "xtrue" ] && [ "x$$7" != "xfalse" ]; then \
+                       ${ECHO_MSG} "${PKGNAME}: Makefile error: in desktop 
entry $$entry: field 7 (StartupNotify) is not \"true\" or \"false\""; \
+                       exit 1; \
+               fi; \
+               shift 7; \
+               num=`${EXPR} $$num + 1`; \
+       done
+.elif defined(DESKTOP_ENTRIES)
        @set -- ${DESKTOP_ENTRIES} XXX; \
        if [ `${EXPR} \( $$# - 1 \) % 6` -ne 0 ]; then \
                ${ECHO_MSG} "${PKGNAME}: Makefile error: the DESKTOP_ENTRIES 
list must contain one or more groups of 6 elements"; \
@@ -6424,7 +6492,42 @@
 
 .if !target(install-desktop-entries)
 install-desktop-entries:
-.if defined(DESKTOP_ENTRIES)
+.if defined(DESKTOP_ENTRIESv2)
+       @(${MKDIR} "${DESKTOPDIR}" 2> /dev/null) || \
+               (${ECHO_MSG} "===> Cannot create ${DESKTOPDIR}, check 
permissions"; exit 1)
+       @set -- ${DESKTOP_ENTRIESv2} XXX; \
+       if [ -z "${_DESKTOPDIR_REL}" ]; then \
+               ${ECHO_CMD} "@cwd ${DESKTOPDIR}" >> ${TMPPLIST}; \
+       fi; \
+       while [ $$# -gt 7 ]; do \
+               filename="`${ECHO_CMD} "$$1" | ${SED} -E 
's/[[:space:]]+.*//'`.desktop"; \
+               pathname="${DESKTOPDIR}/$$filename"; \
+               categories="$$6"; \
+               if [ -z "$$categories" ]; then \
+                       categories="`cd ${.CURDIR} && ${MAKE} 
${__softMAKEFLAGS} desktop-categories`"; \
+               fi; \
+               ${ECHO_CMD} "${_DESKTOPDIR_REL}$$filename" >> ${TMPPLIST}; \
+               ${ECHO_CMD} "[Desktop Entry]" > $$pathname; \
+               ${ECHO_CMD} "Type=Application" >> $$pathname; \
+               ${ECHO_CMD} "Version=0.9.4" >> $$pathname; \
+               ${ECHO_CMD} "Encoding=UTF-8" >> $$pathname; \
+               ${ECHO_CMD} "Name=$$2" >> $$pathname; \
+               if [ -n "$$3" ]; then \
+                       ${ECHO_CMD} "Comment=$$3" >> $$pathname; \
+               fi; \
+               if [ -n "$$4" ]; then \
+                       ${ECHO_CMD} "Icon=$$4" >> $$pathname; \
+               fi; \
+               ${ECHO_CMD} "Exec=$$5" >> $$pathname; \
+               ${ECHO_CMD} "Categories=$$categories" >> $$pathname; \
+               ${ECHO_CMD} "StartupNotify=$$7" >> $$pathname; \
+               shift 7; \
+       done; \
+       ${ECHO_CMD} "@unexec rmdir ${DESKTOPDIR} 2>/dev/null || true" >> 
${TMPPLIST}; \
+       if [ -z "${_DESKTOPDIR_REL}" ]; then \
+               ${ECHO_CMD} "@cwd ${PREFIX}" >> ${TMPPLIST}; \
+       fi
+.elif defined(DESKTOP_ENTRIES)
        @(${MKDIR} "${DESKTOPDIR}" 2> /dev/null) || \
                (${ECHO_MSG} "===> Cannot create ${DESKTOPDIR}, check 
permissions"; exit 1)
        @set -- ${DESKTOP_ENTRIES} XXX; \


>Release-Note:
>Audit-Trail:
>Unformatted:
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "[email protected]"

Reply via email to