summaryrefslogtreecommitdiff
blob: 451e0e01cd1df0ec0da57027301a9406202806a4 (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
# Copyright 1999-2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

EAPI=5

inherit check-reqs

DESCRIPTION="Nalimov chess endgame tablebases for up to 5 pieces"
HOMEPAGE="http://tablebase.sesse.net/"

tb34=()
tb5=()
m=(p n b r q k)
for ((i=4; i>=0; i--)); do
	tb34+=(k${m[i]}k) # 2+1
	for ((j=i; j>=0; j--)); do
		tb34+=(k${m[i]}k${m[j]} k${m[i]}${m[j]}k) # 2+2, 3+1
		for ((k=4; k>=0; k--)); do
			tb5+=(k${m[i]}${m[j]}k${m[k]}) # 3+2
			((k<=j)) && tb5+=(k${m[i]}${m[j]}${m[k]}k) # 4+1
		done
	done
done

SRC_URI="http://tablebase.sesse.net/README -> ${P}-README"
for i in "${tb34[@]}"; do
	SRC_URI+=" http://tablebase.sesse.net/3-4-5/${i}.nbw.emd"
	SRC_URI+=" http://tablebase.sesse.net/3-4-5/${i}.nbb.emd"
done
SRC_URI+=" tb5? ("
for i in "${tb5[@]}"; do
	SRC_URI+=" http://tablebase.sesse.net/3-4-5/${i}.nbw.emd"
	SRC_URI+=" http://tablebase.sesse.net/3-4-5/${i}.nbb.emd"
done
SRC_URI+=" )"
unset i j k m tb34 tb5

LICENSE="public-domain"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="+tb5"
RESTRICT="mirror"				# not on Gentoo mirrors

S="${WORKDIR}"

CHECKREQS_DISK_USR="7230M"
CHECKREQS_DISK_BUILD="${CHECKREQS_DISK_USR}"

pkg_pretend() {
	use tb5 && check-reqs_pkg_pretend
}

pkg_setup() {
	use tb5 && check-reqs_pkg_setup
}

src_unpack() { :; }

src_install() {
	local f
	insinto /usr/share/${PN}
	for f in ${A}; do
		[[ ${f} = *.emd ]] && echo "${DISTDIR}"/${f}
	done | xargs doins
	newdoc "${DISTDIR}"/${P}-README README
}