#!/usr/bin/env python import sys, os, tempfile def do(cmd): if os.system(cmd): raise Exception('Execution of "%s" failed; aborting.' % cmd) print "!!! WARNING WARNING WARNING !!!" print "I'm about to download and execute an unsigned script " print "from the Klik server (in the same way that running a " print "program normally using klik does). This is totally insecure!" print "Don't run this with permission to do anything nasty!" print if len(sys.argv) != 2: raise Exception('Usage: klik2zero ') app = sys.argv[1] tmp = tempfile.mkdtemp(prefix = 'klik-') print "Using temporary directory '%s'" % tmp os.chdir(tmp) os.system('wget --user-agent="klik/0.1.3cli (Linux nono 2.6.16.2talex #1 SMP PREEMPT Sun Apr 9 13:17:37 BST 2006 i686 GNU/Linux @@)" -O script http://134.169.172.48/apt/?package=' + app) realhome = os.environ['HOME'] os.environ['HOME'] = tmp os.mkdir('Apps') config = file(tmp + '/.klikrc', 'w') config.write('SOURCES=CPX-MINI\n') config.close() do('sh ./script') os.environ['HOME'] = realhome appdirname = os.listdir('Apps')[0] print print "Created application directory %s" % appdirname os.system("convert Apps/*/.DirIcon %s.png" % app) do("cd Apps && tar cjf ../%s.tar.bz2 *" % app) print "Time to create an interface for it. Set the summary, but don't " print "worry too much about the other fields. You'll have to change something, " print "though, or it will abort!" print do("0launch http://0install.net/2006/interfaces/0publish %s.xml" % app) do(("0launch http://0install.net/2006/interfaces/0publish " "--set-main=wrapper " "--archive-extract=%s " "--archive-url=http://myserver/%s.tar.bz2 " "--archive-file=%s.tar.bz2 %s.xml") % (appdirname, app, app, app)) print print "OK, everything is in %s:\n" % tmp print "The interface is %s.xml" % app print "The archive is %s.tar.bz2" % app print "The icon is %s.png" % app print print "$ cd %s" % tmp print "- Upload the icon and archive somewhere." print "- Edit %s.xml to give correct locations for them." % app print "- Test with:" print "$ 0launch ./%s.xml" % app print "- Set uri in interface, sign it, and upload it somewhere."