From owner-freebsd-bugs@FreeBSD.ORG Fri Jul 15 06:20:08 2011 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2E703106566B for ; Fri, 15 Jul 2011 06:20:08 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 032968FC14 for ; Fri, 15 Jul 2011 06:20:08 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id p6F6K7Yb021489 for ; Fri, 15 Jul 2011 06:20:07 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id p6F6K7De021488; Fri, 15 Jul 2011 06:20:07 GMT (envelope-from gnats) Resent-Date: Fri, 15 Jul 2011 06:20:07 GMT Resent-Message-Id: <201107150620.p6F6K7De021488@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Scot Hetzel Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 42502106564A for ; Fri, 15 Jul 2011 06:16:46 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id 321848FC08 for ; Fri, 15 Jul 2011 06:16:46 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p6F6GjHW030427 for ; Fri, 15 Jul 2011 06:16:45 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.4/8.14.4/Submit) id p6F6GjA8030426; Fri, 15 Jul 2011 06:16:45 GMT (envelope-from nobody) Message-Id: <201107150616.p6F6GjA8030426@red.freebsd.org> Date: Fri, 15 Jul 2011 06:16:45 GMT From: Scot Hetzel To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: misc/158936: Mk/bsd.ports.mk: Add a filename field to DESKTOP_ENTRIES X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Jul 2011 06:20:08 -0000 >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: