1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-11-20 00:21:35 +00:00
freebsd-ports/Mk/Scripts/install-desktop-entries.sh
Mathieu Arnold 5d33e04596
framework: Remove $FreeBSD$
Where appropriate fiddle with a few other things.
2021-04-06 16:27:10 +02:00

67 lines
1.4 KiB
Bash

#!/bin/sh
#
# MAINTAINER: portmgr@FreeBSD.org
set -e
set -o pipefail
. "${dp_SCRIPTSDIR}/functions.sh"
validate_env dp_SED dp_ECHO_CMD dp_STAGEDIR dp_DESKTOPDIR
[ -n "${DEBUG_MK_SCRIPTS}" ] || [ -n "${DEBUG_MK_SCRIPTS_INSTALL_DESKTOP_ENTRIES}" ] && set -x
set -u
while [ $# -ge 6 ]; do
Name="${1}"
Comment="${2}"
Icon="${3}"
Exec="${4}"
Categories="${5}"
StartupNotify="${6}"
shift 6
filename="$(${dp_ECHO_CMD} "${Exec}" | ${dp_SED} -e 's,^/,,g;s,[/ ],_,g;s,[^_[:alnum:]],,g').desktop"
pathname="${dp_STAGEDIR}${dp_DESKTOPDIR}/${filename}"
${dp_ECHO_CMD} "${dp_DESKTOPDIR}/${filename}" >> "${dp_TMPPLIST}"
{
${dp_ECHO_CMD} "[Desktop Entry]"
${dp_ECHO_CMD} "Type=Application"
${dp_ECHO_CMD} "Version=1.0"
${dp_ECHO_CMD} "Name=${Name}"
} > "${pathname}"
if [ -n "${Comment}" ]; then
comment="${Comment}"
else
comment="$(cd "${dp_CURDIR}" && ${dp_MAKE} -VCOMMENT)"
fi
${dp_ECHO_CMD} "GenericName=${comment}" >> "${pathname}"
${dp_ECHO_CMD} "Comment=${comment}" >> "${pathname}"
if [ -n "${Icon}" ]; then
${dp_ECHO_CMD} "Icon=${Icon}" >> "${pathname}"
fi
${dp_ECHO_CMD} "Exec=${Exec}" >> "${pathname}"
if [ -n "${Categories}" ]; then
categories="${Categories}"
else
categories="$(cd "${dp_CURDIR}" && ${dp_MAKE} desktop-categories)"
fi
${dp_ECHO_CMD} "Categories=${categories}" >> "${pathname}"
if [ -n "${StartupNotify}" ]; then
${dp_ECHO_CMD} "StartupNotify=${StartupNotify}" >> "${pathname}"
fi
done