Here’s a quick tutorial on how to package things for Zero install. I am going to package the latest Groovy (2.0.4 at the time of this writing). There’s a tutorial on the site itself – check this.
Install 0publish-gui
I’m using Xubuntu 12.04, so I am going to install 0publish-gui – seems that for Windows you should use a different version, see the tutorial page for that. To install it, run this:
$ 0alias 0publish-gui http://0install.net/2007/interfaces/0publish-gui.xml
Creating a new feed
Start the program:
$ 0publish-gui
On the first dialog that opens:
click New feed.
Populate About tab
Populate the About tab like this:
All this is readily available from Groovy’s main site.
Versions tab
On the versions tab:
click Add Group, clcik OK to add an empty group, then add the Groovy binary archive by clicking Add archive button. You can find one from the Groovy’s download page, currently it’s http://dist.groovy.codehaus.org/distributions/groovy-binary-2.0.4.zip:
Click Download. After the zip has been downloaded:
click OK.
Version properties
Populate the version properties dialog like this:
Add dependencies
Groovy requires JDK, so let’s add that one as a dependency:
Click Add Requires:
From the Roscidus.com mirror search for “openjdk”. You should find this one. There’s a link under “Full name” section – the link is http://repo.roscidus.com/java/openjdk-jdk, so paste it here:
After clicking OK, you should have this:
To have the actual java
command, openjdk-jre (http://repo.roscidus.com/java/openjdk-jre) is also needed, so add that, too:
Publishing tab
To publish the feed, enter the url and the key:
The above assumes you already have a GPG key to use for signing. If you do not have a GPG key generated, click on Add. This will open a GPG window, which you can populate like this (of course, change the personal information):
Saving the feed
Click Save now, you should get a confirmation of the files getting saved:
It will ask you for the GPG key password again:
After all that, you should have the following files:
total 27M 4.0K BC15B8C183209EDE.gpg 27M groovy-binary-2.0.4.zip 4.0K groovy.xml 8.0K interface.xsl
Adding multiple commands
Exit 0publish-gui and edit the script to something like this:
<?xml version="1.0" ?> <?xml-stylesheet type='text/xsl' href='interface.xsl'?> <interface uri="https://icyrock.com/0install/ext/groovy.xml" xmlns="http://zero-install.sourceforge.net/2004/injector/interface"> <name>groovy</name> <summary>agile and dynamic language for the Java Virtual Machine</summary> <description> Groovy... is an agile and dynamic language for the Java Virtual Machine builds upon the strengths of Java but has additional power features inspired by languages like Python, Ruby and Smalltalk makes modern programming features available to Java developers with almost- zero learning curve provides the ability to statically type check and statically compile your code supports Domain-Specific Languages and other compact syntax so your code becomes easy to read and maintain makes writing shell and build scripts easy with its powerful processing primitives, OO abilities and an Ant DSL increases developer productivity by reducing scaffolding code when developing web, GUI, database or console applications simplifies testing by supporting unit testing and mocking out-of-the-box seamlessly integrates with all existing Java classes and libraries compiles straight to Java bytecode so you can use it anywhere you can use Java</description> <homepage>http://groovy.codehaus.org/</homepage> <category>Development</category> <group> <needs-terminal/> <command name="grape" path="bin/grape"/> <command name="groovy" path="bin/groovy"/> <command name="groovyc" path="bin/groovyc"/> <command name="groovyConsole" path="bin/groovyConsole"/> <command name="groovydoc" path="bin/groovydoc"/> <command name="groovysh" path="bin/groovysh"/> <command name="java2groovy" path="bin/java2groovy"/> <command name="startGroovy" path="bin/startGroovy"/> <environment name="GROOVY_HOME" insert="." mode="replace" /> <implementation id="sha1new=d0f6ef2a42b0f5479993e0dd4e5d66b622d18a99" license="The Apache License 2.0" main="bin/groovy" released="2012-09-30" version="2.0.4"> <archive extract="groovy-2.0.4" href="http://dist.groovy.codehaus.org/distributions/groovy-binary-2.0.4.zip" size="28273120" type="application/zip"/> <requires interface="http://repo.roscidus.com/java/openjdk-jre"> <environment name="JAVA_HOME" insert="." mode="replace" /> </requires> <requires interface="http://repo.roscidus.com/java/openjdk-jdk"> <environment name="JAVA_HOME" insert="." mode="replace" /> </requires> </implementation> </group> </interface>
Save the file, exit the editor, open 0publish-gui, open the feed and do the signing again and you now have multiple commands. E.g. to run groovysh instead of groovy, you can do this:
$ 0alias --command groovysh groovysh https://icyrock.com/0install/ext/groovy.xml
Publishing on the Web server
The only thing needed at this point is to publish them on your Web server. You need only the three files generated by the program, not the archive itself – the archive will be downloaded from the URL you gave (so in this case Groovy’s main site) and it will be checked to confirm it did not change (thus all the SHA info in the groovy.xml file if you open it). This depends on the server you are using, but usually just putting it in the required folder should be sufficient. Obviously, the URL should match what was entered on the Publishing tab.
Testing the feed
When you install on the Web server (you can even test on your local server for that matter), you can test by using 0alias as usual:
$ 0alias groovy https://icyrock.com/0install/ext/groovy.xml $ 0alias --command groovysh groovysh https://icyrock.com/0install/ext/groovy.xml
You should be prompted with an “unknown key” dialog:
Make sure the key fingerprint is the one you trust. After you trust a key, all programs signed with that key will be trusted for installation, so you better trust the owner of the key…
After accepting the key and installing, you should be able to use groovy or groovysh:
$ groovy --version Groovy Version: 2.0.4 JVM: 1.7.0_04 Vendor: Oracle Corporation OS: Linux $ groovysh -V Groovy Shell 2.0.4
Adding to the feed search engine
As per this, you are able to add your programs to this feed list. This is a good way to contribute to 0install, so if you package someting, announce it there.