]> cloud.milkyroute.net Git - dolphin.git/blob - src/khns/servicemenuinstallation
Initial ServiceMenu-KHotNewStuff-stuff
[dolphin.git] / src / khns / servicemenuinstallation
1 #!/usr/bin/env ruby
2 require 'pathname'
3 require 'fileutils'
4 archive = ARGV[0]
5 def mimeType(filename)
6 IO.popen("file --mime-type -b " + filename).gets().strip!()
7 end
8 $archivetypes = { "application/x-tar" => :"tar -xf %s -C %s",
9 "application/tar" => :"tar -xf %s -C %s",
10 "application/x-gzip" => :"tar -zxf %s -C %s",
11 "application/gzip" => :"tar -zxf %s -C %s",
12 "application/x-gzip-compressed-tar" => :"tar -zxf %s -C %s",
13 "application/gzip-compressed-tar" => :"tar -zxf %s -C %s",
14 "application/x-gzip-compressed" => :"tar -zxf %s -C %s",
15 "application/gzip-compressed" => :"tar -zxf %s -C %s",
16 "application/bzip" => :"tar -jxf %s -C %s",
17 "application/bzip2" => :"tar -jxf %s -C %s",
18 "application/x-bzip" => :"tar -jxf %s -C %s",
19 "application/x-bzip2" => :"tar -jxf %s -C %s",
20 "application/bzip-compressed" => :"tar -jxf %s -C %s",
21 "application/bzip2-compressed" => :"tar -jxf %s -C %s",
22 "application/x-bzip-compressed" => :"tar -jxf %s -C %s",
23 "application/x-bzip2-compressed" => :"tar -jxf %s -C %s",
24 "application/bzip-compressed-tar" => :"tar -jxf %s -C %s",
25 "application/bzip2-compressed-tar" => :"tar -jxf %s -C %s",
26 "application/x-bzip-compressed-tar" => :"tar -jxf %s -C %s",
27 "application/x-bzip2-compressed-tar" => :"tar -jxf %s -C %s",
28 "application/zip" => :"unzip %s -d %s",
29 "application/x-zip" => :"unzip %s -d %s",
30 "application/x-zip-compressed" => :"unzip %s -d %s",
31 "multipart/x-zip" => :"unzip %s -d %s",
32 "application/tgz" => :"tar -zxf %s -C %s",
33 "application/x-compressed-gtar" => :"tar -zxf %s -C %s",
34 "application/x-gtar" => :"tar -zxf %s -C %s",
35 "file/tgz" => :"tar -zxf %s -C %s",
36 "multipart/x-tar-gz" => :"tar -zxf %s -C %s",
37 "application/x-gunzip" => :"tar -zxf %s -C %s",
38 "application/gzipped" => :"tar -zxf %s -C %s",
39 "gzip/document" => :"tar -zxf %s -C %s",
40 "application/x-bz2 " => :"tar -jxf %s -C %s",
41 "application/x-gtar" => :"tar -xf %s -C %s",
42 "multipart/x-tar" => :"tar -xf %s -C %s"
43 }
44 def uncompress(filename, output)
45 system(sprintf($archivetypes[mimeType(filename)].to_s, filename, output))
46 end
47 dir = archive + "-dir"
48 if File.exist?(dir)
49 FileleUtils.rm_r(dir)
50 end
51 FileUtils.mkdir(dir)
52 exit(-1) if !uncompress(archive, dir)
53 # try: install-it.sh
54 # try: install-it
55 # try: installKDE4.sh
56 # try: installKDE4
57 # try: install.sh
58 # try: install
59 dd = Dir.new(dir)
60 dd.read
61 dd.read
62 dir += "/" + dd.read
63 dd = nil
64 def fail()
65 system("kdialog --passivepopup \"Installation failed\" 15")
66 exit(-1)
67 end
68 if !((File.exist?(file = dir + "/install-it.sh") || File.exist?(file = dir + "/install-it")) && system(file))
69 fail() if !File.exist?(file = dir + "/installKDE4.sh") && !File.exist?(file = dir + "/installKDE4") && !File.exist?(file = dir + "/install.sh") && !File.exist?(file = dir + "/install")
70 File.new(file).chmod(0700)
71 fail() if !system(file + " --local") && !system(file + "--local-install") && !system(file + " --install")
72 end