summaryrefslogtreecommitdiff
blob: 8aa9b74749d32a53c8f7ebea46016b0e699005bb (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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# Copyright 1999-2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/app-arch/rpm5/rpm5-5.3.5.ebuild,v 1.3 2014/03/01 22:13:59 mgorny Exp $

EAPI=4

PYTHON_DEPEND="2"

MY_PN="rpm"
MY_P="${MY_PN}-${PV}"

inherit eutils multilib python user versionator

DESCRIPTION="RPM Package Manager"
HOMEPAGE="http://rpm5.org/"
SRC_URI="http://rpm5.org/files/${MY_PN}/${MY_PN}-$(get_version_component_range 1-2)/${MY_P}.tar.gz"

LICENSE="GPL-2 LGPL-2"
SLOT="0"
KEYWORDS="~amd64-linux ~x86-linux ~ppc-macos"
IUSE="acl augeas berkdb +bzip2 crypt debug expat gnutls keyutils lua lzma nls nss openssl pcre perl pkcs11 readline ruby selinux sqlite ssl tcl uuid webdav-neon xar xattr +zlib"

RDEPEND="!app-arch/rpm
	dev-libs/beecrypt
	dev-libs/popt
	sys-apps/file
	acl? ( sys-apps/acl )
	augeas? ( app-admin/augeas )
	berkdb? ( sys-libs/db )
	bzip2? ( app-arch/bzip2 )
	crypt? ( dev-libs/libgcrypt:0 )
	expat? ( dev-libs/expat )
	keyutils? ( sys-apps/keyutils )
	lua? ( dev-lang/lua )
	lzma? ( app-arch/xz-utils )
	pcre? ( dev-libs/libpcre )
	perl? ( dev-lang/perl )
	pkcs11? ( dev-libs/pakchois )
	readline? ( sys-libs/readline:0 )
	ruby? ( >=dev-lang/ruby-1.9 )
	selinux? (
		sys-libs/libselinux
		sys-libs/libsemanage
		sys-libs/libsepol
	)
	sqlite? ( dev-db/sqlite:3 )
	ssl? (
		nss? ( dev-libs/nss )
		openssl? ( dev-libs/openssl )
		gnutls? (
			dev-libs/libtasn1
			net-libs/gnutls
		)
	)
	tcl? ( dev-lang/tcl )
	uuid? ( dev-libs/ossp-uuid )
	webdav-neon? ( net-libs/neon )
	xar? ( app-arch/xar )
	xattr? ( sys-apps/attr )
	zlib? ( sys-libs/zlib )
"
DEPEND="${RDEPEND}
	virtual/pkgconfig
	virtual/yacc
	nls? ( sys-devel/gettext )
"

REQUIRED_USE="
	ssl? (
		^^ (
			gnutls
			nss
			openssl
		)
	)
"

S="${WORKDIR}/${MY_P}"

pkg_setup () {
	python_set_active_version 2
	python_pkg_setup
}

src_configure() {
	local myconf=""

	# default internal/external switches
	# crypto default is beecrypt, user can change this on runtime
	#   and we build beecrypt every time
	# tomcrypt is not in portage
	# cudf is not in portage
	# users usually do not want to use debug malloc
	myconf+="
		--with-usecrypto=beecrypt
		--with-beecrypt=external
		--with-file=external
		--with-popt=external
		--without-tomcrypt
		--without-cudf
		--without-dmalloc
	"

	# ssl handling
	# tasn1 is handled in most portage packages with gnutls, do the same
	if use ssl; then
		myconf+="
			$(use_with gnutls)
			$(use_with gnutls libtasn1)
			$(use_with nss)
			$(use_with openssl)
		"
	else
		myconf+="
			--without-gnutls
			--without-libtasn1
			--without-nss
			--without-openssl
		"
	fi

	# enable db if we use berkdb or sqlite
	if use berkdb || use sqlite; then
		myconf+="
			--with-dbsql=external
		"
	else
		myconf+="
			--without-dbsql
		"
	fi

	# for berkdb enable the options if possible
	if use berkdb; then
		myconf+="
			--with-db-largefile
			--with-db-rpc
		"
	fi

	# we need python by default anyway so always --with-python
	econf \
		--disable-rpath \
		--disable-dependency-tracking \
		--enable-build-pic \
		--enable-build-pie \
		--enable-largefile \
		--with-python \
		--without-pythonembed \
		--with-python-lib-dir="${EPREFIX}$(python_get_libdir)" \
		--with-python-inc-dir="${EPREFIX}$(python_get_includedir)" \
		$(use_enable nls) \
		$(use_enable debug build-debug) \
		$(use_with acl) \
		$(use_with augeas) \
		$(use_with berkdb db) \
		$(use_with bzip2) \
		$(use_with crypt gcrypt) \
		$(use_with expat) \
		$(use_with keyutils) \
		$(use_with lua lua external) \
		$(use_with lzma xz external) \
		$(use_with pcre pcre external) \
		$(use_with perl) \
		$(use_with pkcs11 pakchois) \
		$(use_with readline) \
		$(use_with selinux) \
		$(use_with selinux semanage) \
		$(use_with selinux sepol) \
		$(use_with sqlite) \
		$(use_with tcl) \
		$(use_with uuid) \
		$(use_with webdav-neon neon external) \
		$(use_with xar xar external) \
		$(use_with xattr attr) \
		$(use_with zlib) \
		${myconf}

	# TODO: see files/remaining-5.3.5.txt
	ewarn "This package is far from complete"
	ewarn "If you want to test it please see \"${FILESDIR}/remaining-5.3.5.txt\""
	ewarn "and implement missing features."
	ewarn "Do NOT report bugs without providing patches!"
}

src_install() {
	emake DESTDIR="${D}" INSTALLDIRS=vendor install || die "emake install failed"
	dodoc CHANGES CREDITS NEWS README TODO
}

pkg_preinst() {
	enewgroup rpm 37
	enewuser rpm 37 /bin/sh /var/lib/rpm rpm
}

pkg_postinst() {
	chown -R rpm:rpm "${EROOT}"/usr/$(get_libdir)/rpm
	chown -R rpm:rpm "${EROOT}"/var/lib/rpm
	chown rpm:rpm "${EROOT}"/usr/bin/rpm{,2cpio,build,constant}
	if [[ ${ROOT} == "/" ]] ; then
		if [[ -f ${EROOT}/var/lib/rpm/Packages ]] ; then
			einfo "RPM database found... Rebuilding database (may take a while)..."
			"${EROOT}"/usr/bin/rpm --rebuilddb --root="${EROOT}"
		else
			einfo "No RPM database found... Creating database..."
			"${EROOT}"/usr/bin/rpm --initdb --root="${EROOT}"
		fi
	fi
	chown rpm:rpm "${EROOT}"/var/lib/rpm/*

	python_mod_optimize rpm
}

pkg_postrm() {
	python_mod_cleanup rpm
}