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

EAPI=6

DESCRIPTION="Printer descriptions (PPDs) and filters for Kyocera 1x2x MFP"
HOMEPAGE="http://www.kyoceradocumentsolutions.eu"
SRC_URI="LinuxDrv_${PV}_FS-1x2xMFP.zip"

LICENSE="GPL-2 kyocera-mita-ppds"
SLOT="0"

KEYWORDS="-* ~amd64"

IUSE_L10N=(en ar cs de el es fr he hu it ko pl pt ro ru th tr vi zh-CN zh-TW)
IUSE="+rastertokpsl-fix +${IUSE_L10N[@]/#/l10n_}"
REQUIRED_USE="|| ( ${IUSE_L10N[@]/#/l10n_} )"

RDEPEND="net-print/cups"
DEPEND="app-arch/unzip"
RESTRICT="fetch mirror"
QA_PREBUILT="/usr/libexec/cups/filter/rastertokpsl"

get_tarball_name() {
	# Note the capitalization inconsistency. Don't "fix" that.
	case "$1" in
		ar) echo arabic ;;
		cs) echo czech ;;
		de) echo German ;;
		el) echo greek ;;
		en) echo English ;;
		es) echo Spanish ;;
		fr) echo French ;;
		he) echo hebrew ;;
		hu) echo hungarian ;;
		it) echo Italian ;;
		ko) echo Korean ;;
		pl) echo polish ;;
		pt) echo Portuguese ;;
		ro) echo romanian ;;
		ru) echo russian ;;
		th) echo thai ;;
		tr) echo turkish ;;
		vi) echo vietnamese ;;
		zh-CN) echo simplified ;;
		zh-TW) echo traditional ;;
		*) die ;;
	esac
}

pkg_nofetch() {
	einfo "Please, navigate your browser to the following URL and manually"
	einfo "download the file named '${A}', then put it into your DISTDIR."
	einfo "https://www.kyoceradocumentsolutions.eu/index/service/dlc.false.driver.FS1025MFP._.EN.html"
	einfo
	einfo "Consider keeping a local copy of the file since there're chances"
	einfo "the company is going to eventually stop hosting it for whatever"
	einfo "reason."
}

src_unpack() {
	unpack ${A}
	S="${WORKDIR}/Linux/$(usex amd64 64bit 32bit)/Global"

	cd "${S}" || die
	local l10n
	for l10n in ${L10N}; do
		local language="$(get_tarball_name "${l10n}")"
		unpack "./${language}.tar.gz"
	done
}

src_prepare() {
	eapply_user

	# Original PPD files need patching, since they expect their filter
	# program to reside under /usr/lib, but Gentoo uses /usr/libexec.

	local orig="/usr/lib/cups/filter/rastertokpsl"
	local repl="/usr/libexec/cups/filter/rastertokpsl"
	if use rastertokpsl-fix; then
		repl+="-fix.sh"
	fi

	sed -i "s|${orig}|${repl}|g" ./*/Kyocera*.ppd || die
}

src_install() {
	insinto /usr/share/cups/model/KyoceraMita

	install_with_l10n_suffix() {
		local l10n="$1"; shift
		local file
		for file; do
			local bn="${file}"
			bn="${bn##*/}"
			bn="${bn%.ppd}"
			newins "${file}" "${bn}_${l10n}.ppd"
		done
	}

	local l10n
	for l10n in ${L10N}; do
		local language="$(get_tarball_name "${l10n}")"
		install_with_l10n_suffix "${l10n}" "./${language}"/Kyocera*.ppd
	done

	exeinto /usr/libexec/cups/filter

	# Each unpacked tarball contains an exact copy of 'rastertokpsl',
	# just take any of them.
	local rasterfile="$(find -name rastertokpsl -print -quit)"
	[[ $? -eq 0 && -n "${rasterfile}" ]] || die
	doexe "${rasterfile}"

	if use rastertokpsl-fix; then
		doexe "${FILESDIR}/rastertokpsl-fix.sh"
	fi

	dodoc ../../Readme.htm

	elog "This packages installs Kyocera's 'Readme.htm' file (see package"
	elog "documentation directory) which lists several common problems and"
	elog "workarounds. You might want to have a look on it."
	elog "(Merging the package with 'rastertokpsl-fix' USE flag can save you"
	elog "from getting some of these problems.)"
	elog
	elog "Hint: try socket:// protocol when configuring network printing."
}