summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 3b169a8b51871418b64f031d37bd8a074d3b4465 (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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# Maintainer: Giovanni Santini "ItachiSan" <giovannisantini93@yahoo.it>

pkgname=yawls
pkgver=1.2.2
pkgrel=4
pkgdesc="Adjust the brightness level of your display by using the internal/external webcam of your notebook as an ambient light sensor"
url="https://launchpad.net/yawls"
arch=('any')
license=("GPL3")
depends=(
	"java-runtime-headless>=7"
	"gettext-java"
	"gtk3"
	"java-gnome"
	"opencv-java"
	"polkit-gnome"
)
makedepends=(
	"java-environment>=7"
	"gettext-java"
	"java-gnome"
	"opencv-java"
	"apache-ant"
	"po4a"
	"gzip"
)
provides=('yawls')
conflicts=('yawls-bzr')

# Sources
# Magic: with ${VAR%PATT} you can remove from PATT the shortest occurrence of PATT starting from the end
# of PATT. In this case, removing the last character ("?": generic character) and setting it as 'x'
source=(
	https://launchpad.net/${pkgname}/${pkgver%?}x/${pkgver}/+download/${pkgname}_${pkgver}.tar.gz{,.asc}
	${pkgname}d.service
	)
install="$pkgname.install"
# Got from Launchpad downloads page: https://launchpad.net/yawls/+download
md5sums=('e898ad27f010b621404be95baea3dbeb'
         'SKIP'
         'ae6497e82edd0e43914ebc72f1975fa0')

# Adding developer's GPG key for more checks
# Dominik Brämer: https://launchpad.net/~thedsweb (see 'OpenPGP keys')
validpgpkeys=('F74B9AC531171E84713929BB5291C9C1E5CEA885')

# Build steps
prepare() {
	cd "$srcdir/$pkgname-$pkgver"

	# Fix paths because of ArchLinux packaging
	# Its conventions are different than Ubuntu ones
	sed "s,share/OpenCV,share/opencv,g" -i yawls_cli.sh
	sed "s,share/OpenCV,share/opencv,g" -i build.xml
	sed "s,java-7-openjdk-\*,default-runtime," -i yawls_cli.sh
	# Fix also comments, lol
	sed "s/openjdk 7/the default JVM/" -i yawls_cli.sh

	# Using $(arch) instead of $(uname -m)... GOD WHY
	sed "s/\$(arch)/\"\$(uname -m)\"/" -i yawls_cli.sh

	# Prevent errors in refreshing symlink for the OpenCV library
	sed "s,ls /usr/share/opencv/java,ls -1 /usr/share/opencv/java/ \| grep jar," -i yawls_cli.sh

	# Add the native library to the Java library path
	sed "s,\$OPTIONS,\$OPTIONS -Djava.library.path=/usr/share/opencv/java," -i yawls_cli.sh

	# We use systemd on Arch
	sed "/prerotate/d" -i yawls
	sed "/invoke-rc.d --quiet yawls stop/d" -i yawls
	sed "/rm \/var\/log\/yawls*/d" -i yawls
	sed "/invoke-rc.d --quiet yawls start/d" -i yawls
	sed "/endscript/d" -i yawls

	# Remove useless part in logrotate script

	# Fix build on OpenCV 3
	sed "s/highgui/videoio/" -i src/com/blogspot/thedsweb/engine/Brightness.java
}

build() {
	cd "$srcdir/$pkgname-$pkgver"
	# Compile the package...
	ant compile
	# And build the language files
	./build.sh
}

package() {
	cd "$srcdir/$pkgname-$pkgver"

	# Cron job
	mkdir -p "$pkgdir/etc/cron.d"
	cp "debian/yawls.cron.d" "$pkgdir/etc/cron.d/yawls"

	# Logrotate
	mkdir -p "$pkgdir/etc/logrotate.d"
	cp "yawls" "$pkgdir/etc/logrotate.d/yawls"

	# Common stuff
	mkdir -p "$pkgdir/usr/share/yawls"
	install -Dm644 "yawls.jar" "$pkgdir/usr/share/yawls"
	install -Dm755 "yawls_cli.sh" "$pkgdir/usr/share/yawls"
	install -Dm644 "lbpcascade_frontalface.xml" "$pkgdir/usr/share/yawls"
	install -Dm644 "yawls.properties" "$pkgdir/etc"
	# Common symlinks
	mkdir -p "$pkgdir/usr/bin"
	ln -s "/usr/share/yawls/yawls_cli.sh" "$pkgdir/usr/bin/yawls"
	ln -s "/usr/share/java/opencv.jar" "$pkgdir/usr/share/yawls/opencv.jar"

	# GUI specific stuff (Maybe I'll split packages...?)
	# Destkop file things
	install -Dm755 "yawls_gui.sh" "$pkgdir/usr/share/yawls"
	install -Dm644 "yawls_icon_64x64.png" "$pkgdir/usr/share/yawls"
	mkdir -p "$pkgdir/usr/share/applications"
	install -Dm644 "Yawls.desktop" "$pkgdir/usr/share/applications"
	# Polkit policies
	mkdir -p "$pkgdir/usr/share/polkit-1/actions"
	install -Dm644 "yawls.brightness.control.gui.policy" "$pkgdir/usr/share/polkit-1/actions"

	# Man pages, handled manually
	for page in $(ls man)
	do
		_lang=$(echo $page | cut -d. -f 2 | cut -d. -f 1)
		# Case of generic page
		if [ "$_lang" == "1" ]
		then
			mkdir -p "$pkgdir/usr/share/man/man1/"
			install -Dm644 "man/$page" "$pkgdir/usr/share/man/man1/"
		else
			mkdir -p "$pkgdir/usr/share/man/$_lang/man1/"
			install -Dm644 "man/$page" "$pkgdir/usr/share/man/$_lang/man1/yawls.1"
		fi
	done

	# Hand-written junk
	# systemd service
	mkdir -p "$pkgdir/usr/lib/systemd/system/"
	install -Dm644 "$srcdir/yawlsd.service" "$pkgdir/usr/lib/systemd/system/"
}