3 # Copyright (C) 2009 Jonathan Schmidt-Dominé <devel@the-user.org>
4 # Copyright (C) 2019 Harald Sitter <sitter@kde.org>
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the
18 # Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 # @param log_msg [String] error that gets logged to CLI
26 def fail(log_msg
: nil)
27 # FIXME: this is not translated...
28 msg
= 'Dolphin service menu installation failed'
29 warn log_msg
if log_msg
30 system('kdialog', '--passivepopup', msg
, '15')
34 if ARCHIVE
.end_with
?('.desktop')
35 data_location
= `qtpaths --writable-path GenericDataLocation`.strip
37 fail(log_msg
: "Could not get GenericDataLocation #{data_location}")
39 FileUtils
.rm("#{data_location}/kservices5/ServiceMenus/#{File.basename(ARCHIVE)}")
42 dir
= "#{ARCHIVE}-dir"
45 %w
[deinstall
.sh deinstall
].find
do |script
|
46 deinstaller
= Dir
.glob("#{dir}/**/#{script}")[0]
50 %w
[install-it
.sh install-it installKDE4
.sh installKDE4 install
.sh install
].find
do |script
|
51 installer
= Dir
.glob("#{dir}/**/#{script}")[0]
57 [deinstaller
, installer
].uniq
.compact
.each
{ |f
| File
.chmod(0o700
, f
) }
60 puts
"[servicemenudeinstallation]: Trying to run deinstaller #{deinstaller}"
61 deinstalled
= system(deinstaller
)
63 puts
"[servicemenudeinstallation]: Trying to run installer #{installer}"
64 %w
[--remove
--delete
--uninstall
--deinstall
].any
? do |arg
|
65 deinstalled
= system(installer
, arg
)
69 fail
unless deinstalled