You are not logged in.

#1 2014-10-01 04:35:21

silverhammermba
Wiki Maintainer
Registered: 2011-04-14
Posts: 156

PKGBUILD Tips for Funky Java App

I'm trying to make a PKGBUILD for the GURPS character sheet program. It's a Java app, so I tried to follow the Java PKGBUILD guidelines from the wiki, but gcs has a weird build system that made things difficult. The main annoyances are that it tries to include its own JRE, and rather than running using a normal jar it includes a binary launcher for which I can't find the source.

Here's my PKGBUILD that just tries to whip the binary package into shape:

pkgname=gcs
pkgver=4.0.1
pkgrel=1
pkgdesc="An editor for building character sheets for GURPS 4th Edition."
arch=('i686' 'x86_64')
url="http://gurpscharactersheet.com"
license=('MPL')
depends=('java-runtime')
src="$pkgname-$pkgver-linux"
if test "$CARCH" == i686; then
src+='-32'
fi
source=("${src}.zip::http://sourceforge.net/projects/gcs-java/files/${src}.zip/download")
md5sums=('SKIP')

build() {
	pushd $srcdir/$src
	rm -r support/jre
	ln -s /usr/lib/jvm/default/jre support/jre
	popd
}

package() {
	install -d $pkgdir/usr/{bin,share}
	cp -dr --no-preserve=ownership ${src} $pkgdir/usr/share/gcs
	ln -s $pkgdir/usr/share/gcs/gcs $pkgdir/usr/bin/gcs
}

Am I doing anything stupid?

Offline

#2 2014-10-01 08:16:32

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 14,893

Re: PKGBUILD Tips for Funky Java App

http://gurpscharactersheet.com/development.php has instructions to build from command line with ant, have you tried to apply those ?

Edit :

gurpscharactersheet appears to need java 8, you should require that version in the dependencies.

Last edited by Lone_Wolf (2014-10-01 08:17:58)


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

#3 2014-10-01 13:33:16

silverhammermba
Wiki Maintainer
Registered: 2011-04-14
Posts: 156

Re: PKGBUILD Tips for Funky Java App

Unfortunately the launcher binary is included as-is in the git source. But I think I might've found a way to bypass the launcher entirely.

Offline

#4 2014-10-01 15:16:39

silverhammermba
Wiki Maintainer
Registered: 2011-04-14
Posts: 156

Re: PKGBUILD Tips for Funky Java App

How are you supposed to configure a package that requires Java 8? Should I not use $JAVA_HOME since that could be pointing to an older version?

Anyway, I've produced a better package, but the build process is still kinda ugly.

I couldn't figure out a way to use ant's bundle (which includes the JRE and the precompiled binaries), so I skipped that entirely and just copied everything myself - that let me use the recommended /usr/share/java organization. But since the app expects everything to be in one directory (with a fixed path), I had to patch it to let me configure the app directory using an environment variable.

Here's a git repo for the files: https://github.com/silverhammermba/gcs

And my new PKGBUILD:

pkgname=gcs
pkgver=4.0.1
pkgrel=1
pkgdesc="A WYSIWYG editor for building character sheets for GURPS 4th Edition."
arch=('any')
url="http://gurpscharactersheet.com"
license=('MPL')
makedepends=('git' 'apache-ant')
depends=('java-runtime')
source=(
	'git://code.trollworks.com/apple_stubs.git'
	"git://code.trollworks.com/gcs.git#tag=$pkgver"
	"git://code.trollworks.com/toolkit.git#tag=$pkgver"
)
md5sums=('SKIP' 'SKIP' 'SKIP')

prepare() {
	cd "$srcdir/toolkit"
	git apply "$startdir/set_app_path_from_env.patch"
}

build() {
	cd "$srcdir/apple_stubs"
	ant
	cd "$srcdir/toolkit"
	ant
	cd "$srcdir/gcs"
	ant
}

package() {
	install -d "$pkgdir/usr/share/java/gcs"
	find "$srcdir" -name '*.jar' ! -name '*-src.*' -execdir install -m644 {} "$pkgdir/usr/share/java/gcs" \;
	mv $pkgdir/usr/share/java/gcs/gcs-*.jar "$pkgdir/usr/share/java/gcs/gcs.jar"

	install -d "$pkgdir/usr/share/gcs"
	cp -dr --no-preserve=ownership "$srcdir/gcs/Library" "$pkgdir/usr/share/gcs"

	install -Dm755 "$startdir/gcs.sh" "$pkgdir/usr/bin/gcs"
}

Last edited by silverhammermba (2014-10-01 15:23:13)

Offline

#5 2014-10-02 10:58:38

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 14,893

Re: PKGBUILD Tips for Funky Java App

to get ant working, you'll need the full jdk package jdk8-openjdk  , the jre is not sufficient to compile java programs.

In the dependencies, use java-runtime=8 for jre .   for jdk , it's java-environment=8 .

for detecting and/or switching jvm , use the archlinux-java command .
see https://wiki.archlinux.org/index.php/Ja … etween_JVM


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

#6 2014-10-02 13:23:26

silverhammermba
Wiki Maintainer
Registered: 2011-04-14
Posts: 156

Re: PKGBUILD Tips for Funky Java App

Sorry, I should clarify: ant has worked fine the whole time (pacman grabs the JDK dependency). It's specifically the "ant bundle" command which I find useless, since that doesn't compile anything - it just creates a zip with the JRE and precompiled binaries. I don't think it makes sense to use that in the PKGBUILD since I would need to undo most of what it does in the package() function.

Also I'm familiar with archlinux-java, but I can't use that to switch the active Java in the PKGBUILD (that requires root). So what is the "proper" procedure? Should I detect which version of Java they're using and echo some warning if it's not 8?

And what about users with multiple Java versions installed? Is it expected that they're just going to need to run the appropriate archlinux-java command before running each app, or is there some way to make only gcs always use Java 8?

Offline

#7 2014-10-02 14:37:48

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 14,893

Re: PKGBUILD Tips for Funky Java App

silverhammermba wrote:

Sorry, I should clarify: ant has worked fine the whole time (pacman grabs the JDK dependency). It's specifically the "ant bundle" command which I find useless, since that doesn't compile anything - it just creates a zip with the JRE and precompiled binaries. I don't think it makes sense to use that in the PKGBUILD since I would need to undo most of what it does in the package() function.

look for a folder with the file build.xml in the sourcecode.
if you run ant -p in that folder, it should show which targets are supported by the project.
(I don't know of any java source build in the official repos, but if you want an example PKGBUILD, check my freecol-git package in aur ).

silverhammermba wrote:

Also I'm familiar with archlinux-java, but I can't use that to switch the active Java in the PKGBUILD (that requires root). So what is the "proper" procedure? Should I detect which version of Java they're using and echo some warning if it's not 8?

That seems the best option.

silverhammermba wrote:

And what about users with multiple Java versions installed? Is it expected that they're just going to need to run the appropriate archlinux-java command before running each app, or is there some way to make only gcs always use Java 8?

don't know, the archlinux-java seems to be written with manual switching in mind.
You might want to post on the arch-general ML about this.


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

#8 2014-10-09 20:21:16

silverhammermba
Wiki Maintainer
Registered: 2011-04-14
Posts: 156

Re: PKGBUILD Tips for Funky Java App

Just to follow up, I've uploaded the package to the AUR: https://aur.archlinux.org/packages/gcs/

I got a bit of advice from the mailing list, but it sounds like there isn't an agreed upon solution for accommodating users with multiple JVMs installed. For now you just get errors if the current java isn't version 8 and it's up to you to switch to a proper version.

Offline

Board footer

Powered by FluxBB