summaryrefslogtreecommitdiff
blob: 76a8099f0b3972d8761ed63079eb8b0968c99b00 (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
# Copyright 1999-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header $

inherit eutils

DESCRIPTION="Excellent text file viewer, patched with additional selection feature"
HOMEPAGE="http://www.greenwoodsoftware.com/less/"
PATCHVER=436
SRC_URI="http://www.greenwoodsoftware.com/less/less-${PV}.tar.gz
	http://www-zeuthen.desy.de/~friebel/unix/less/code2color
	http://www.mathematik.uni-wuerzburg.de/~vaeth/download/less-select-patch-${PATCHVER}.tar.gz"

LICENSE="|| ( GPL-3 BSD-2 )"
SLOT="0"
KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~sparc-fbsd ~x86 ~x86-fbsd"
IUSE="unicode dummy-less"

DEPEND=">=sys-libs/ncurses-5.2
	!dummy-less? ( !sys-apps/less )"

S="${WORKDIR}/less-${PV}"

MYSUBDIR="${S}/less-select-patch-${PATCHVER}"

src_unpack() {
	cd "${WORKDIR}"
	unpack "less-${PV}.tar.gz"
	cd "${S}"
	cp "${DISTDIR}"/code2color "${S}"/
	epatch "${FILESDIR}"/code2color.patch
	unpack "less-select-patch-${PATCHVER}.tar.gz"
	mv "${MYSUBDIR}/INSTALL" "${MYSUBDIR}/README.less-select"
	if [ -e "${MYSUBDIR}/less-${PV}-select.patch" ]; then
		epatch "${MYSUBDIR}/less-${PV}-select.patch" || die "Patch less-${PV}-select failed"
	else
		epatch "${MYSUBDIR}/less-${PATCHVER}-select.patch" || die "Patch less-${PATCHVER}-select failed"
	fi
	"${MYSUBDIR}"/after-patch || die "${MYSUBDIR}/after-patch failed"
}

yesno() { use $1 && echo yes || echo no ; }
src_compile() {
	export ac_cv_lib_ncursesw_initscr=$(yesno unicode)
	export ac_cv_lib_ncurses_initscr=$(yesno !unicode)
	econf || die
	emake || die
	./lesskey -o less-normal-key.bin "${MYSUBDIR}/less-normal-key.src" || die
	./lesskey -o less-select-key.bin "${MYSUBDIR}/less-select-key.src" || die
}

src_install() {
	emake install DESTDIR="${D}" || die

	dobin code2color || die "dobin"
	newbin "${FILESDIR}"/lesspipe.sh lesspipe || die "newbin"
	dosym lesspipe /usr/bin/lesspipe.sh
	echo 'LESSOPEN="|lesspipe.sh %s"
LESS="-sFR -iMX --shift 5"' > 70less
	doenvd 70less

	dodoc NEWS README* "${FILESDIR}"/README.Gentoo "${MYSUBDIR}"/README.less-select

	newbin "${MYSUBDIR}/less-select" less-select

	insinto /etc
	newins less-normal-key.bin lesskey.bin
	newins less-select-key.bin less-select-key.bin
	newins "${MYSUBDIR}/less-normal-key.src" lesskey.src
	newins "${MYSUBDIR}/less-select-key.src" less-select-key.src
}

pkg_postinst() {
	einfo "lesspipe offers colorization options.  Run 'lesspipe.sh -h' for info."
}