mirror of
https://github.com/gentoo-mirror/gentoo.git
synced 2025-12-21 21:17:37 -08:00
desktop.eclass: make_desktop_entry: die on duplicate file unless --force
Pre- --eapi9 behavior masked such collisions by suffixing the resulting desktop file name by an auto-incrementing number. This led to undetected desktop file duplications if e.g. upstream began to ship their own, when ebuilds had been compensating via make_desktop_entry() previously. With --desktopid, we now have necessary direct control over the resulting file name, so the auto-increment file suffix was dropped. Without this change, doins would happily overwrite an existing file. Bug: https://bugs.gentoo.org/771708 Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
This commit is contained in:
parent
e1ed9311cd
commit
6f742be11d
@ -50,6 +50,7 @@ _DESKTOP_IDS=()
|
|||||||
# defined in code (including reverse qualified domain if set);
|
# defined in code (including reverse qualified domain if set);
|
||||||
# defaults to <command>
|
# defaults to <command>
|
||||||
# comment: Comment (menu entry tooltip), defaults to DESCRIPTION
|
# comment: Comment (menu entry tooltip), defaults to DESCRIPTION
|
||||||
|
# force: Force-write resulting desktop file (overwrite existing)
|
||||||
# @CODE
|
# @CODE
|
||||||
#
|
#
|
||||||
# Example usage:
|
# Example usage:
|
||||||
@ -82,7 +83,7 @@ make_desktop_entry() {
|
|||||||
[[ -z ${1} ]] && die "make_desktop_entry: You must specify at least a command"
|
[[ -z ${1} ]] && die "make_desktop_entry: You must specify at least a command"
|
||||||
|
|
||||||
if [[ ${eapi9} ]]; then
|
if [[ ${eapi9} ]]; then
|
||||||
local args cats cmd comment desktopid entries icon name
|
local args cats cmd comment desktopid entries force icon name
|
||||||
while [[ $# -gt 0 ]] ; do
|
while [[ $# -gt 0 ]] ; do
|
||||||
case "${1}" in
|
case "${1}" in
|
||||||
-a|--args)
|
-a|--args)
|
||||||
@ -95,6 +96,8 @@ make_desktop_entry() {
|
|||||||
desktopid="${2}"; shift 2 ;;
|
desktopid="${2}"; shift 2 ;;
|
||||||
-e|--entry)
|
-e|--entry)
|
||||||
entries+=( "${2}" ); shift 2 ;;
|
entries+=( "${2}" ); shift 2 ;;
|
||||||
|
-f|--force)
|
||||||
|
force=1; shift 1 ;;
|
||||||
-i|--icon)
|
-i|--icon)
|
||||||
icon="${2}"; shift 2 ;;
|
icon="${2}"; shift 2 ;;
|
||||||
-n|--name)
|
-n|--name)
|
||||||
@ -259,6 +262,9 @@ make_desktop_entry() {
|
|||||||
_DESKTOP_IDS+=( "${desktopid}" )
|
_DESKTOP_IDS+=( "${desktopid}" )
|
||||||
fi
|
fi
|
||||||
local desktop="${T}/${desktopid}.desktop"
|
local desktop="${T}/${desktopid}.desktop"
|
||||||
|
if [[ ! ${force} && -e ${ED}/usr/share/applications/${desktopid}.desktop ]]; then
|
||||||
|
die "make_desktop_entry: desktopid \"${desktopid}\" already exists, must be unique"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
local desktop_exec="${cmd%%[[:space:]]*}"
|
local desktop_exec="${cmd%%[[:space:]]*}"
|
||||||
desktop_exec="${desktop_exec##*/}"
|
desktop_exec="${desktop_exec##*/}"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user