From b1d75df15cfef7539030df6bb477ec903680dbd6 Mon Sep 17 00:00:00 2001 From: Krzesimir Nowak Date: Tue, 21 Dec 2021 09:53:57 +0100 Subject: [PATCH] eclass/desktop: Sync with gentoo It's from gentoo commit f6212ee060d6a2962ac27cf57ffd721d14b64215. --- .../portage-stable/eclass/desktop.eclass | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/sdk_container/src/third_party/portage-stable/eclass/desktop.eclass b/sdk_container/src/third_party/portage-stable/eclass/desktop.eclass index 6fc72ab8ec..82e764e2a1 100644 --- a/sdk_container/src/third_party/portage-stable/eclass/desktop.eclass +++ b/sdk_container/src/third_party/portage-stable/eclass/desktop.eclass @@ -1,4 +1,4 @@ -# Copyright 1999-2018 Gentoo Foundation +# Copyright 1999-2021 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: desktop.eclass @@ -10,7 +10,7 @@ if [[ -z ${_DESKTOP_ECLASS} ]]; then _DESKTOP_ECLASS=1 # @FUNCTION: make_desktop_entry -# @USAGE: make_desktop_entry(, [name], [icon], [type], [fields]) +# @USAGE: [name] [icon] [type] [fields] # @DESCRIPTION: # Make a .desktop file. # @@ -162,8 +162,15 @@ make_desktop_entry() { else local desktop_name="${PN}-${slot}" fi - local desktop="${T}/$(echo ${exec} | sed 's:[[:space:]/:]:_:g')-${desktop_name}.desktop" - #local desktop=${T}/${exec%% *:-${desktop_name}}.desktop + local desktop_exec="${exec%%[[:space:]]*}" + desktop_exec="${desktop_exec##*/}" + + # Prevent collisions if a file with the same name already exists #771708 + local desktop="${desktop_exec}-${desktop_name}" count=0 + while [[ -e ${ED}/usr/share/applications/${desktop}.desktop ]]; do + desktop="${desktop_exec}-$((++count))-${desktop_name}" + done + desktop="${T}/${desktop}.desktop" # Don't append another ";" when a valid category value is provided. type=${type%;}${type:+;}