1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
#!/usr/bin/env ruby
# Copyright (C) 2009 Jonathan Schmidt-Dominé <[email protected]>
# Copyright (C) 2019 Harald Sitter <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
require 'fileutils'
ARCHIVE = ARGV[0]
# @param log_msg [String] error that gets logged to CLI
def fail(log_msg: nil)
# FIXME: this is not translated...
msg = 'Dolphin service menu installation failed'
warn log_msg if log_msg
system('kdialog', '--passivepopup', msg, '15')
abort
end
if ARCHIVE.end_with?('.desktop')
data_location = `qtpaths --writable-path GenericDataLocation`.strip
unless $?.success?
fail(log_msg: "Could not get GenericDataLocation #{data_location}")
end
FileUtils.rm("#{data_location}/kservices5/ServiceMenus/#{File.basename(ARCHIVE)}")
exit(0)
end
dir = "#{ARCHIVE}-dir"
deinstaller = nil
%w[deinstall.sh deinstall].find do |script|
deinstaller = Dir.glob("#{dir}/**/#{script}")[0]
end
installer = nil
%w[install-it.sh install-it installKDE4.sh installKDE4 install.sh install].find do |script|
installer = Dir.glob("#{dir}/**/#{script}")[0]
end
Dir.chdir(dir) do
deinstalled = false
[deinstaller, installer].uniq.compact.each { |f| File.chmod(0o700, f) }
if deinstaller
puts "[servicemenudeinstallation]: Trying to run deinstaller #{deinstaller}"
deinstalled = system(deinstaller)
elsif installer
puts "[servicemenudeinstallation]: Trying to run installer #{installer}"
%w[--remove --delete --uninstall --deinstall].any? do |arg|
deinstalled = system(installer, arg)
end
end
fail unless deinstalled
end
FileUtils.rm_r(dir)
|