summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 4dd3145a5e82cab2a0619d6f4aca54861c6924b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
pkgname="californium-tools-git"
pkgver=1.0.2
pkgrel=1
pkgdesc="Californium tools, including cf-client, cf-server and cf-browser."
url="https://eclipse.dev/californium/"
arch=("x86_64")
license=("Eclipse Distribution License 1.0 or Eclipse Public License 2.0")
makedepends=()
optdepends=()
depends=('maven' 'liberica-jdk-11-full-bin' 'coreutils')
source=("git+https://github.com/eclipse-californium/californium.tools.git")
sha256sums=("SKIP")

build() {
	cd "$srcdir/californium.tools"
	export JAVA_HOME="/usr/lib/jvm/liberica-jdk-11-full"
	mvn -T $(nproc) clean install -Daether.dependencyCollector.impl=bf

	rm -fr jars bin applications 
	mkdir jars bin applications

	add_bin() {
		identifier="$1"
		jar_local_dir="$2"
		
		jar_file=$(find $jar_local_dir | grep "$identifier" | grep 'SNAPSHOT\.jar$' | head -n 1)
		cp "$jar_file" "jars/$identifier.jar"

		echo "#!/bin/sh
export JAVA_HOME='/usr/lib/jvm/liberica-jdk-11-full'
/usr/lib/jvm/liberica-jdk-11-full/bin/java -jar /usr/share/californium-tools/jars/$identifier.jar "'$@'"
" > "bin/$identifier"
		chmod a+x "bin/$identifier"

	}
	add_app() {
		name="$1"
		identifier="$2"

		echo "[Desktop Entry]
Name=$name
Comment=Part of the Californium tools.
Exec=/usr/share/californium-tools/bin/$identifier
Terminal=false
Type=Application
MimeType=
" > "applications/$identifier.desktop"
	}

	add_bin "cf-browser"       "cf-browser/target"
	add_bin "cf-client"        "cf-client/target"
	add_bin "cf-jmeter-plugin" "cf-jmeter-plugin/target"
	add_bin "cf-rd"            "cf-rd/target"
	# note : These do not produce a target directory.
	# add_bin "cf-coapbench"     "cf-coapbench/target"
	# add_bin "cf-polyfill"      "cf-polyfill/target"
	# add_bin "cf-server"        "cf-server/target"
	
	add_app "Californium Browser" "cf-browser"
}

package() {
	cd "$srcdir/californium.tools"

	mkdir -p "$pkgdir/usr/share/californium-tools/"
	cp -r jars bin applications "$pkgdir/usr/share/californium-tools/"
	mkdir -p "$pkgdir/usr/bin" "$pkgdir/usr/share/applications"

	for binary in $(cd bin && ls)
	do ln -s "/usr/share/californium-tools/bin/$binary" "$pkgdir/usr/bin/$binary"
	done

	for application in $(cd applications && ls)
	do ln -s "/usr/share/californium-tools/applications/$application" "$pkgdir/usr/share/applications/$application"
	done
}