summaryrefslogtreecommitdiff
blob: 25c0e21dd0c4875f390099e528b0684bcf33872c (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
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/x11-misc/openclipart/openclipart-0.18-r1.ebuild,v 1.4 2007/10/15 07:33:09 nelchael Exp $

DESCRIPTION="Open Clip Art Library (openclipart.org)"
HOMEPAGE="http://www.openclipart.org/"

# Ugly stuff warning:
SRC_URI="svg? ( !wmf? ( !png? ( !pdf? ( !doc? (
			http://download.openclipart.org/downloads/${PV}/${P}-svgonly.tar.bz2
		) ) ) )
		png? ( http://download.openclipart.org/downloads/${PV}/${P}-full.tar.bz2 )
		pdf? ( http://download.openclipart.org/downloads/${PV}/${P}-full.tar.bz2 )
		wmf? ( http://download.openclipart.org/downloads/${PV}/${P}-full.tar.bz2 )
		doc? ( http://download.openclipart.org/downloads/${PV}/${P}-full.tar.bz2 )
	)
	!svg? ( http://download.openclipart.org/downloads/${PV}/${P}-full.tar.bz2 )"

LICENSE="public-domain" # creative commons
SLOT="0"
KEYWORDS="~amd64 ~ppc x86"
IUSE="doc svg png pdf wmf gzip"

# We don't really need anything to run
DEPEND=""
RDEPEND=""

# Nothing to strip
RESTRICT="strip"

# suggested basedir for cliparts
CLIPART="/usr/share/clipart/${PN}"

src_unpack() {

	unpack "${A}"

	if ! use svg && ! use png && ! use pdf && ! use wmf; then
		ewarn "No image formats specified - defaulting to all"
	else
		! use pdf && MY_REMOVE="${MY_REMOVE} pdf"
		! use png && MY_REMOVE="${MY_REMOVE} png"
		! use svg && MY_REMOVE="${MY_REMOVE} svg"
		! use wmf && MY_REMOVE="${MY_REMOVE} wmf"
	fi

	! use doc && MY_REMOVE="${MY_REMOVE} txt"

	export MY_REMOVE

	MY_S="${WORKDIR}/openclipart-${PV}-"
	if use wmf || use png || use pdf || use doc || ! use svg; then
		MY_S="${MY_S}full"
	else
		MY_S="${MY_S}svgonly"
	fi
	export MY_S

	cd "${MY_S}/clipart/"
	einfo "Removing useless files..."

	find \
		\( -name "automatic" -o -name "move" -o -name "*.rdf" -o \
			-name "*.spec" -o -name "*.log" -o -name "*.sxd" -o \
			-name "*~" -o -name ".*.swp" \
		\) -exec rm -f {} \; || die "Failed"

	rm -f LICENSE.txt LOG.txt PASSFAIL README README.txt \
		TODO index.xml keywords.idx || die "Failed"

}

src_compile() {

	cd "${MY_S}/clipart/"
	for ext in ${MY_REMOVE}; do
		einfo "Removing files - ${ext}..."
		find -name "*.${ext}" -exec rm -f {} \; \
			|| die "Failed - remove"
	done

	if use gzip; then

		einfo "Compressing SVG files..."
		find -name "*.svg" -print0 | xargs -L 1 -0 \
			bash -c 'gzip -9c "${1}" > "${1}z"; rm -f "${1}"' --

	fi

	einfo "Compressing docs..."
	find \
		\( -name "*.txt" -o -name "README" -o -name "AUTHORS" -o \
			-name "COPYING" \
		\) -exec gzip -9 {} \; || die "Failed - compress docs"

}

src_install() {

	dodir "${CLIPART}" || die "Failed - dodir"

	cd "${MY_S}/clipart"
	find -type f -exec cp --parents {} "${D}/${CLIPART}" \; || \
		die "Failed - install"

	cd "${MY_S}"
	dodoc LICENSE README NEWS VERSION ChangeLog

}