Closes: https://bugs.gentoo.org/771708
Reported-by: Sergey Torokhov <[email protected]>
Suggested-by: Ionen Wolkens <[email protected]>
Signed-off-by: Ulrich Müller <[email protected]>
---
eclass/desktop.eclass | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/eclass/desktop.eclass b/eclass/desktop.eclass
index 7d5c0f0f9a26..72d315448266 100644
--- a/eclass/desktop.eclass
+++ b/eclass/desktop.eclass
@@ -1,4 +1,4 @@
-# Copyright 1999-2020 Gentoo Authors
+# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: desktop.eclass
@@ -163,7 +163,14 @@ make_desktop_entry() {
local desktop_name="${PN}-${slot}"
fi
local desktop="${exec%%[[:space:]]*}"
- desktop="${T}/${desktop##*/}-${desktop_name}.desktop"
+ desktop="${desktop##*/}-${desktop_name}"
+
+ # Prevent collisions if a file with the same name already exists #771708
+ local desktop_base="${desktop}" count=0
+ while [[ -e ${ED}/usr/share/applications/${desktop}.desktop ]]; do
+ desktop="${desktop_base}-$((++count))"
+ done
+ desktop="${T}/${desktop}.desktop"
# Don't append another ";" when a valid category value is provided.
type=${type%;}${type:+;}
--
2.30.1