aboutsummaryrefslogtreecommitdiffstats
path: root/main/kbd/APKBUILD
blob: 873c06ee18d9078c8b9fd047d5df6e5177ed39c9 (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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# Contributor: Natanael Copa <ncopa@alpinelinux.org>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=kbd
pkgver=2.2.0
pkgrel=2
pkgdesc="Tools for configuring the console (keyboard, virtual terminals, etc.)"
url="http://kbd-project.org/"
arch="all"
license="GPL-2.0-or-later"
depends="kbd-misc"
makedepends="linux-headers linux-pam-dev check-dev ckbcomp xkeyboard-config"
subpackages="$pkgname-bkeymaps::noarch $pkgname-legacy::noarch
	$pkgname-misc::noarch $pkgname-doc $pkgname-openrc $pkgname-vlock"
source="https://www.kernel.org/pub/linux/utils/kbd/kbd-$pkgver.tar.gz
	loadkeys.initd
	loadkeys.confd

	error.h
	fix-tests.patch
	0001-libkbdfile-Check-compression-suffix-even-if-the-suff.patch
	0001-libkeymap-Fix-the-compatibility-with-the-busybox-s-l.patch
	"

_datadir=/usr/share
_xmapdir="$_datadir"/keymaps/xkb
_bmapdir="$_datadir"/bkeymaps
_badmaps="pk-ara"

prepare() {
	default_prepare

	# 0001-libkeymap-Fix-the-compatibility-with-the-busybox-s-l.patch
	# makes this test fail because changes to tests were not backported.
	# Remove the following line when the patch is removed.
	truncate -s0 "$builddir"/tests/dumpkeys-bkeymap.in

	cd "$builddir"
	cp "$srcdir"/error.h .
}

build() {
	cd "$builddir"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--disable-nls \
		--prefix=/usr \
		--datadir="$_datadir" \
		--htmldir=/usr/share/html/$pkgname
	make
}

check() {
	# dumpkeys-bkeymap fails
	[ "$CARCH" = s390x ] && return 0
	cd "$builddir"
	make check
}

_listxmaps() {
	local invariant line; invariant=false
	grep -v '^$' /usr/share/X11/xkb/rules/base.lst | while read line; do
	case "$line" in
		'! variant') invariant=true ;;
		'!'*) invariant=false ;;
		*) if $invariant; then
			echo "$line" | cut -d: -f1
		fi ;;
		esac
	done
}

package() {
	cd "$builddir"
	make DESTDIR="$pkgdir" install

	install -Dm755 "$srcdir"/loadkeys.initd \
		"$pkgdir"/etc/init.d/loadkeys
	install -Dm644 "$srcdir"/loadkeys.confd \
		"$pkgdir"/etc/conf.d/loadkeys

	# Move and fixup legacy keymaps
	mkdir legacy
	mv "$pkgdir"/usr/share/keymaps/* legacy
	mv legacy "$pkgdir"/usr/share/keymaps

	cd "$pkgdir"/usr/share/keymaps/legacy/i386
	# Make ISO-8815-9 maps the default, instead of 7-bit ones
	ln -s pt-latin9.map.gz qwerty/pt.map.gz
	mv azerty/fr.map.gz azerty/fr-old.map.gz
	ln -s fr-latin9.map.gz azerty/fr.map.gz

	# Add some legacy aliases
	ln -s fr-latin9.map.gz azerty/fr-latin0.map.gz
	ln -s sv-latin1.map.gz qwerty/se-latin1.map.gz
	ln -s sr-cy.map.gz qwerty/sr-latin.map.gz

	# Rename conflicting keymaps
	mv fgGIod/trf.map.gz fgGIod/trf-fgGIod.map.gz
	mv olpc/es.map.gz olpc/es-olpc.map.gz
	mv olpc/pt.map.gz olpc/pt-olpc.map.gz
	mv qwerty/cz.map.gz qwerty/cz-qwerty.map.gz

	# Remove useless layouts
	rm -f i386/qwerty/ro_win.map.gz

	cd "$builddir"

	# Compile keymaps from X.org layouts
	mkdir -p "$pkgdir$_xmapdir"
	local layout variant
	_listxmaps | while read -r variant layout; do
		if ! test -f "$pkgdir$_xmapdir"/"$layout".map.gz; then
			echo "Generating keymap $layout..."
			ckbcomp "$layout" | gzip > "$pkgdir$_xmapdir"/"$layout".map.gz || exit 1
		fi
		echo "Generating keymap $layout-$variant..."
		ckbcomp "$layout" "$variant" | gzip > "$pkgdir$_xmapdir"/"$layout"-"$variant".map.gz || exit 1
	done

	# Do some fix-ups on X.org keymaps
	mv "$pkgdir$_xmapdir"/fi.map.gz "$pkgdir$_xmapdir"/fi-kotoistus.map.gz

	# Install html documentation
	mkdir -p "$pkgdir$_datadir"/html/$pkgname
	mv docs/doc/*.html "$pkgdir$_datadir"/html/$pkgname

	# Replace busybox setfont utility.
	mkdir -p "$pkgdir"/usr/sbin
	mv "$pkgdir"/usr/bin/setfont "$pkgdir"/usr/sbin

	# Link open to openvt
	ln -s openvt "$pkgdir"/usr/bin/open
}

vlock() {
	pkgdesc="$pkgname vlock implemantation"
	depends=

	# This is the only binary needing linux-pam so moving this to a
	# subpackage reduces the amount of depencies of the kbd package.

	mkdir -p "$subpkgdir"/usr/bin
	mv "$pkgdir"/usr/bin/vlock "$subpkgdir"/usr/bin
}

bkeymaps() {
	pkgdesc="X.org-derived binary keymaps"
	depends=
	replaces="bkeymaps"
	provides="bkeymaps"

	mkdir -p "$subpkgdir$_bmapdir"
	local map variant layout; for map in "$pkgdir$_xmapdir"/*.map.gz; do
		variant="$(basename "$map" | cut -d. -f1)"
		case "$variant" in $_badmaps) continue ;; esac

		layout="${variant%%-*}"
		mkdir -p "$subpkgdir$_bmapdir"/$layout
		echo "Generating binary keymap $variant..."
		"$pkgdir"/usr/bin/loadkeys -ub "$map" | gzip > "$subpkgdir$_bmapdir"/$layout/$variant.bmap.gz
	done
}

legacy() {
	pkgdesc="kbd legacy keymaps"
	depends=

	mkdir -p "$subpkgdir$_datadir"/keymaps
	mv "$pkgdir$_datadir"/keymaps/legacy "$subpkgdir$_datadir"/keymaps
}

misc() {
	pkgdesc="kbd keymaps and console data"
	depends=

	mkdir -p "$subpkgdir$_datadir"
	local dir; for dir in consolefonts consoletrans keymaps unimaps; do
		mv "$pkgdir$_datadir"/$dir "$subpkgdir$_datadir"
	done
}

sha512sums="17f70402126e545c318a5de0265875135b6ebdc0ff9905cb8094dc74a5b27a9d6cede05f7dd4f6f1e68d4aff113e9c82b41caf4da5657d818b4d6a6d477a2789  kbd-2.2.0.tar.gz
64b5ab4c362350521da8f507d22c0b77784da99bbe1b32f0c001cd826f63c607e3f9cd6af01f06a61af8bd709760bbf2bb3cfe2010c33925f2987a1af6ef4998  loadkeys.initd
12028796552a5ffed1d5cb19d37fc6a73fb4f2e2bf34d837a81171c7ebee98d6c3f557715bf79706d79ce053b9b2450cd8cf1c4ea045428fb7d8a5915ae3ed78  loadkeys.confd
c66f6b0d8c8b8d285c740bdbe7130dee272ac01cd5e73b35a58cedf1a77fe8d9e062631b804fb58014d8eb9861c8f28aed07bc022ef31662bcc61b5c85a21752  error.h
bb67e5bb933a48f4a04402e07d7d67169a97485e6b469f8ccd4436466eb17ec2ddcf0ef74d22b3aae9e813feaee5bef0822ec50c384e0276a8c91f9325502a5f  fix-tests.patch
edd53405ae22c19c0c4384318fde7bdea27de5428931b304b1d1a02bc268aea147ec9ff2c7296f7f22ee1b544c6ba30688d77e85a3f8751d4c5bcbe80fd0e518  0001-libkbdfile-Check-compression-suffix-even-if-the-suff.patch
af4c92c7420a42b5ad7a8d24ad97ce8fd63c75f37e5f3dbc04adfdce2509d343160475e74c03f78243eff32abe5d5efa9df61cbe9b754f4ed8f56c07d7890969  0001-libkeymap-Fix-the-compatibility-with-the-busybox-s-l.patch"