┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/khns
diff options
context:
space:
mode:
authorJonathan Schmidt-Dominé <[email protected]>2009-11-06 14:56:35 +0000
committerJonathan Schmidt-Dominé <[email protected]>2009-11-06 14:56:35 +0000
commit5114ab58bcf9ccc7fed7cfdd057bffeb87a2ad94 (patch)
treeef9437b0ec50188a392f955222d95f69e9e6f851 /src/khns
parent2d2aea1c5823e648dec6d15c2ebe2f644de65b7c (diff)
Initial ServiceMenu-KHotNewStuff-stuff
TODO: fix the existing servicemenus (some install-scripts are broken, some do not provide a simple CLI-interface) TODO: add support for single-desktop-file-servicemenus (for example the "open as root") svn path=/trunk/KDE/kdebase/apps/; revision=1045663
Diffstat (limited to 'src/khns')
-rw-r--r--src/khns/servicemenu.knsrc8
-rwxr-xr-xsrc/khns/servicemenudeinstallation23
-rwxr-xr-xsrc/khns/servicemenuinstallation72
3 files changed, 103 insertions, 0 deletions
diff --git a/src/khns/servicemenu.knsrc b/src/khns/servicemenu.knsrc
new file mode 100644
index 000000000..7914f7c63
--- /dev/null
+++ b/src/khns/servicemenu.knsrc
@@ -0,0 +1,8 @@
+[KNewStuff2]
+ProvidersUrl=http://download.kde.org/khotnewstuff/servicemenu-providers.xml
+ChecksumPolicy=ifpossible
+SignaturePolicy=ifpossible
+TargetDir=servicemenu-download
+Uncompress=never
+InstallationCommand=servicemenuinstallation %f
+UninstallCommand=servicemenudeinstallation %f
diff --git a/src/khns/servicemenudeinstallation b/src/khns/servicemenudeinstallation
new file mode 100755
index 000000000..eeadb4033
--- /dev/null
+++ b/src/khns/servicemenudeinstallation
@@ -0,0 +1,23 @@
+#!/usr/bin/env ruby
+require 'fileutils'
+topdir = ARGV[0] + "-dir"
+# try: deinstall.sh
+# try: deinstall
+# try: installKDE4.sh
+# try: installKDE4
+# try: install.sh
+# try: install
+dd = Dir.new(topdir)
+dd.read
+dd.read
+dir = dd.read
+def fail()
+ system("kdialog --passivepopup \"Deinstallation failed\" 15")
+ exit(-1)
+end
+if !((File.exist?(file = dir + "/deinstall.sh") || File.exist?(file = dir + "/deinstall")) && system(file))
+ fail() if !File.exist?(file = dir + "/installKDE4.sh") && !File.exist?(file = dir + "/installKDE4") && !File.exist?(file = dir + "/install.sh") && !File.exist?(file = dir + "/install")
+File.new(file).chmod(0700)
+ fail() if !system(file + " --remove") && !system(file + " --delete") && !system(file + " --uninstall") && !system(file + " --deinstall")
+end
+FileUtils.rm_r(topdir) \ No newline at end of file
diff --git a/src/khns/servicemenuinstallation b/src/khns/servicemenuinstallation
new file mode 100755
index 000000000..fc04b8c56
--- /dev/null
+++ b/src/khns/servicemenuinstallation
@@ -0,0 +1,72 @@
+#!/usr/bin/env ruby
+require 'pathname'
+require 'fileutils'
+archive = ARGV[0]
+def mimeType(filename)
+ IO.popen("file --mime-type -b " + filename).gets().strip!()
+end
+$archivetypes = { "application/x-tar" => :"tar -xf %s -C %s",
+ "application/tar" => :"tar -xf %s -C %s",
+ "application/x-gzip" => :"tar -zxf %s -C %s",
+ "application/gzip" => :"tar -zxf %s -C %s",
+ "application/x-gzip-compressed-tar" => :"tar -zxf %s -C %s",
+ "application/gzip-compressed-tar" => :"tar -zxf %s -C %s",
+ "application/x-gzip-compressed" => :"tar -zxf %s -C %s",
+ "application/gzip-compressed" => :"tar -zxf %s -C %s",
+ "application/bzip" => :"tar -jxf %s -C %s",
+ "application/bzip2" => :"tar -jxf %s -C %s",
+ "application/x-bzip" => :"tar -jxf %s -C %s",
+ "application/x-bzip2" => :"tar -jxf %s -C %s",
+ "application/bzip-compressed" => :"tar -jxf %s -C %s",
+ "application/bzip2-compressed" => :"tar -jxf %s -C %s",
+ "application/x-bzip-compressed" => :"tar -jxf %s -C %s",
+ "application/x-bzip2-compressed" => :"tar -jxf %s -C %s",
+ "application/bzip-compressed-tar" => :"tar -jxf %s -C %s",
+ "application/bzip2-compressed-tar" => :"tar -jxf %s -C %s",
+ "application/x-bzip-compressed-tar" => :"tar -jxf %s -C %s",
+ "application/x-bzip2-compressed-tar" => :"tar -jxf %s -C %s",
+ "application/zip" => :"unzip %s -d %s",
+ "application/x-zip" => :"unzip %s -d %s",
+ "application/x-zip-compressed" => :"unzip %s -d %s",
+ "multipart/x-zip" => :"unzip %s -d %s",
+ "application/tgz" => :"tar -zxf %s -C %s",
+ "application/x-compressed-gtar" => :"tar -zxf %s -C %s",
+ "application/x-gtar" => :"tar -zxf %s -C %s",
+ "file/tgz" => :"tar -zxf %s -C %s",
+ "multipart/x-tar-gz" => :"tar -zxf %s -C %s",
+ "application/x-gunzip" => :"tar -zxf %s -C %s",
+ "application/gzipped" => :"tar -zxf %s -C %s",
+ "gzip/document" => :"tar -zxf %s -C %s",
+ "application/x-bz2 " => :"tar -jxf %s -C %s",
+ "application/x-gtar" => :"tar -xf %s -C %s",
+ "multipart/x-tar" => :"tar -xf %s -C %s"
+}
+def uncompress(filename, output)
+ system(sprintf($archivetypes[mimeType(filename)].to_s, filename, output))
+end
+dir = archive + "-dir"
+if File.exist?(dir)
+ FileleUtils.rm_r(dir)
+end
+FileUtils.mkdir(dir)
+exit(-1) if !uncompress(archive, dir)
+# try: install-it.sh
+# try: install-it
+# try: installKDE4.sh
+# try: installKDE4
+# try: install.sh
+# try: install
+dd = Dir.new(dir)
+dd.read
+dd.read
+dir += "/" + dd.read
+dd = nil
+def fail()
+ system("kdialog --passivepopup \"Installation failed\" 15")
+ exit(-1)
+end
+if !((File.exist?(file = dir + "/install-it.sh") || File.exist?(file = dir + "/install-it")) && system(file))
+ fail() if !File.exist?(file = dir + "/installKDE4.sh") && !File.exist?(file = dir + "/installKDE4") && !File.exist?(file = dir + "/install.sh") && !File.exist?(file = dir + "/install")
+ File.new(file).chmod(0700)
+ fail() if !system(file + " --local") && !system(file + "--local-install") && !system(file + " --install")
+end