summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Müller <ulm@gentoo.org>2021-02-21 15:13:21 +0100
committerUlrich Müller <ulm@gentoo.org>2021-02-24 16:32:07 +0100
commitf6212ee060d6a2962ac27cf57ffd721d14b64215 (patch)
treed19a9db8f84161190dfdbc4fb05aaf76e6ed661e /eclass/desktop.eclass
parentsys-apps/portage: 3.0.15-r1 revbump for bug 772386 (diff)
downloadgentoo-f6212ee060d6a2962ac27cf57ffd721d14b64215.tar.gz
gentoo-f6212ee060d6a2962ac27cf57ffd721d14b64215.tar.bz2
gentoo-f6212ee060d6a2962ac27cf57ffd721d14b64215.zip
desktop.eclass: Avoid file collisions in make_desktop_entry()
Closes: https://bugs.gentoo.org/771708 Reported-by: Sergey Torokhov <torokhov-s-a@yandex.ru> Suggested-by: Ionen Wolkens <sudinave@gmail.com> Signed-off-by: Ulrich Müller <ulm@gentoo.org>
Diffstat (limited to 'eclass/desktop.eclass')
-rw-r--r--eclass/desktop.eclass13
1 files changed, 10 insertions, 3 deletions
diff --git a/eclass/desktop.eclass b/eclass/desktop.eclass
index 7d5c0f0f9a26..82e764e2a1a4 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
@@ -162,8 +162,15 @@ make_desktop_entry() {
else
local desktop_name="${PN}-${slot}"
fi
- local desktop="${exec%%[[:space:]]*}"
- desktop="${T}/${desktop##*/}-${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:+;}