Skip to content

Instantly share code, notes, and snippets.

@tcurdt
Last active June 19, 2018 20:41
Show Gist options
  • Save tcurdt/9275523 to your computer and use it in GitHub Desktop.
Save tcurdt/9275523 to your computer and use it in GitHub Desktop.
towards the jdeb 2.0 syntax
<target name="package" depends="jar">
<taskdef name="deb" classname="org.vafer.jdeb.ant.DebAntTask"/>
<deb destfile="${build.dir}/${ant.project.name}.deb" verbose="true">
<control>
<package>(no default)</package>
<version>(no default)</version>
<section>(default 'misc')</section>
<priority>(default 'low')</priority>
<architecture>(default 'all')</architecture>
<maintainer>(no default)</maintainer>
<pre-inst src="${basedir}/someshell.sh"/>
<pre-rm src="${basedir}/someshell.sh"/>
<post-inst src="${basedir}/someshell.sh"/>
<post-rm src="${basedir}/someshell.sh"/>
</control>
<data>
... see maven
</data>
</deb>
</target>
<plugin>
<artifactId>jdeb</artifactId>
<groupId>org.vafer</groupId>
<version>2.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jdeb</goal>
</goals>
<configuration>
<verbose>true</verbose>
<token open="[[" close="]]"/>
<control>
<package>(default from pom)</package>
<version>(default from pom)</version>
<section>(default 'misc')</section>
<priority>(default 'low')</priority>
<architecture>(default 'all')</architecture>
<maintainer>(default from pom)</maintainer>
<pre-inst src="${basedir}/someshell.sh"/>
<pre-rm src="${basedir}/someshell.sh"/>
<post-inst src="${basedir}/someshell.sh"/>
<post-rm src="${basedir}/someshell.sh"/>
</control>
<!-- defaults:
dir: own=root:root mod=750
file: own=root:root mod=640 token=no compress=no
-->
<data>
<dir>
<dir>
<name>usr</name>
<own>root:root</own>
<mod>755</mod>
<dir>
<name>bin</bin>
<file>
<name>test</test>
<own>root:root</own>
<mod>755</mod>
<src>${basedir}/someshell.sh</src>
<token>yes|no</token>
</file>
<file>
<name>test-as-link</test>
<own>root:root</own>
<mod>755</mod>
<type>symbolic</type>
<target>test</target>
</file>
</dir>
<dir>
<name>lib</bin>
<file>
<name>${project.build.finalName}.jar</test>
<mod>755</mod>
<src>${project.build.directory}/${project.build.finalName}.jar</src>
</file>
<file>
<name>${project.build.finalName}.man.gz</test>
<mod>755</mod>
<src>somepath</src>
<compress>gzip</compress>
</file>
</dir>
<dir>
<name>doc</bin>
<src>${basedir}/docs</src>
<own>auto</own>
<mod>auto</mod>
<dir>
<name>examples</bin>
<src>${basedir}/examples.tgz</src>
<own>auto</own>
<mod>auto</mod>
</dir>
</dir>
</dir>
</data>
<!-- rules for defaults -->
<rules>
<match>
<src>*.man</src> or <dst>*.man.gz</dst>
<file>
<own>root:root</own>
<mod>640</mod>
<token>yes</token>
<compress>gzip</compress>
</file>
<dir>
<own>tcurdt:tcurdt</own>
</dir>
</match>
</rules>
</configuration>
</execution>
</executions>
</plugin>
@tcurdt
Copy link
Author

tcurdt commented May 6, 2014

I fear maven still doesn't support attributes for the plugin configurations hence it will be much more verbose (unfortunately).

Copy link

ghost commented May 13, 2014

The example that uses Ant seems to be more straightforward than with jdeb 1.0, there is no separate control file, this is really more readable :)

Is the control file mandatory in jdeb 1.0?

How do you plan to handle the dependencies (especially to specify that Java 1.x is required)? It would be fine to show a simple example (a JAR + a desktop file + an icon + a script to run the application + a preinst script to create the shortcut + a postrm script to remove the shortcut) using both jdeb 1.0 and jdeb 2.0.

@tcurdt
Copy link
Author

tcurdt commented Jun 21, 2014

Starting with an example and working towards it sounds like a good idea.

Copy link

ghost commented Oct 9, 2014

I try to provide a working example here:
https://jogamp.org/wiki/index.php/Foreign_Packaging#JDeb

Actually, I had to look at the pom file to guess which third party libraries are required to use JDeb. Moreover, this line of code doesn't show the full stack in Eclipse:
https://github.com/tcurdt/jdeb/blob/master/src/main/java/org/vafer/jdeb/ant/DebAntTask.java#L174
My example above is wrong because "control" must be a directory, not a file:
https://github.com/tcurdt/jdeb/blob/master/src/examples/ant/build.xml#L39

My complete example is here:
https://svn.code.sf.net/p/tuer/code/pre_beta/build.xml

Concerning, the suggested syntax for JDeb 2.0, I would prefer to use some attributes for the control parameters (without a control markup). Please don't drive the syntax for Ant more verbose just to align with Maven. The data should use some existing file sets (if possible as most Ant users are familiar with them (like Redline RPM).

@michael-schnell
Copy link

Hi there,

I think re-using the syntax of ANT FileSet/PatternSet/Selectors is a good idea. It's well documented and widely kown. It should also be possible to use the ANTcode as a library for doing parts of the work.

In general I'd prefer to have a separate XML file for the configuration that is only referenced in ANT's build.xml or Maven's pom.xml. This way it's easily possible to work standolone, in a build system or even in an IDE (Example: Eclipse Plugin). Parsing and also writing the separated XML is easy if it's done using JAXB. We could also provide an XML schema (XSD) for the configuration that makes manual editing easier.

I'm personally interested in creating a small UI for JDeb 2.0 using JavaFX.

What do you think?

Cheers,
Michael

@tcurdt
Copy link
Author

tcurdt commented Dec 15, 2014

@michael-schnell the problem with external files is the use of ant's file selectors or variable expansions. It would make many things much easier though. Feel free to come up with an example.

@michael-schnell
Copy link

Hi,

I created a small experimental project:
https://github.com/michael-schnell/experimental-jaxb-ant

The following file loads the XML and executes an ANT copy task:
https://github.com/michael-schnell/experimental-jaxb-ant/blob/master/src/test/java/org/fuin/examples/anttryout/CopyTaskExample.java

When I created it, I dived into the depth of the Ant source and it remembered me why I finally moved to Maven... ;-)

XML "if-else" stuff like this is pretty ugly:
<includesfile name="some-file"/>
<includesfile name="${some-other-file}" if="some-other-file"

The JavaDoc is also odd:
/** Appends excludes to the current list of exclude patterns.*/
public void setExcludes(String excludes) { ... }
(Why is the name "setExcludes" if it means "addExclude"?)

I'm not sure if it makes sense (or even is possible) to clone all of the Ant data structures.
Maybe it's better to define some kind ob subset just keeping the best of it.

Cheers,
Michael

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment