c71cfe517173652dd8296309f04a466246eb4219
[gentoo.git] / app-arch / rpm / rpm-4.14.1.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 PYTHON_COMPAT=( python2_7 python3_6 )
7
8 inherit autotools flag-o-matic perl-module python-single-r1 eapi7-ver
9
10 DESCRIPTION="Red Hat Package Management Utils"
11 HOMEPAGE="https://rpm.org
12         https://github.com/rpm-software-management/rpm"
13 SRC_URI="http://ftp.rpm.org/releases/rpm-$(ver_cut 1-2).x/${P}.tar.bz2"
14
15 LICENSE="GPL-2 LGPL-2"
16 SLOT="0"
17 KEYWORDS="~alpha amd64 arm arm64 ~hppa ia64 ~mips ppc ppc64 s390 ~sh ~sparc x86 ~amd64-linux ~x86-linux"
18
19 # Tests are broken. See bug 657500
20 RESTRICT="test"
21
22 IUSE="acl caps doc lua nls python selinux test"
23 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
24
25 CDEPEND="!app-arch/rpm5
26         app-arch/libarchive
27         >=sys-libs/db-4.5:*
28         >=sys-libs/zlib-1.2.3-r1
29         >=app-arch/bzip2-1.0.1
30         >=dev-libs/popt-1.7
31         >=app-crypt/gnupg-1.2
32         dev-libs/elfutils
33         virtual/libintl
34         >=dev-lang/perl-5.8.8
35         dev-libs/nss
36         python? ( ${PYTHON_DEPS} )
37         nls? ( virtual/libintl )
38         lua? ( >=dev-lang/lua-5.1.0:*[deprecated] )
39         acl? ( virtual/acl )
40         caps? ( >=sys-libs/libcap-2.0 )
41 "
42 DEPEND="${CDEPEND}
43         nls? ( sys-devel/gettext )
44         doc? ( app-doc/doxygen )
45         virtual/pkgconfig
46         test? ( sys-apps/fakechroot )
47 "
48 RDEPEND="${CDEPEND}
49         selinux? ( sec-policy/selinux-rpm )
50 "
51
52 src_prepare() {
53         eapply "${FILESDIR}"/${PN}-4.11.0-autotools.patch
54         eapply "${FILESDIR}"/${PN}-4.8.1-db-path.patch
55         eapply "${FILESDIR}"/${PN}-4.9.1.2-libdir.patch
56
57         # fix #356769
58         sed -i 's:%{_var}/tmp:/var/tmp:' macros.in || die "Fixing tmppath failed"
59         # fix #492642
60         sed -i "s:@__PYTHON@:${PYTHON}:" macros.in || die "Fixing %__python failed"
61
62         eapply_user
63
64         eautoreconf
65
66         # Prevent automake maintainer mode from kicking in (#450448).
67         touch -r Makefile.am preinstall.am
68 }
69
70 src_configure() {
71         append-cppflags -I"${EPREFIX}/usr/include/nss" -I"${EPREFIX}/usr/include/nspr"
72         econf \
73                 --without-selinux \
74                 --with-external-db \
75                 --with-crypto=nss \
76                 $(use_enable python) \
77                 $(use_with doc hackingdocs) \
78                 $(use_enable nls) \
79                 $(use_with lua) \
80                 $(use_with caps cap) \
81                 $(use_with acl)
82 }
83
84 src_install() {
85         default
86
87         # remove la files
88         find "${ED}" -name '*.la' -delete || die
89
90         # fix symlinks to /bin/rpm (#349840)
91         for binary in rpmquery rpmverify;do
92                 ln -sf rpm "${ED}"/usr/bin/${binary} || die
93         done
94
95         if ! use nls; then
96                 rm -rf "${ED}"/usr/share/man/?? || die
97         fi
98
99         keepdir /usr/src/rpm/{SRPMS,SPECS,SOURCES,RPMS,BUILD}
100
101         dodoc CREDITS README*
102         if use doc; then
103                 for docname in hacking librpm; do
104                         docinto "html/${docname}"
105                         dodoc -r "doc/${docname}/html/."
106                 done
107         fi
108
109         # Fix perllocal.pod file collision
110         perl_delete_localpod
111 }
112
113 src_test() {
114         # Known to fail with FEATURES=usersandbox (bug #657500):
115         if has usersandbox $FEATURES ; then
116                 ewarn "You are emerging ${P} with 'usersandbox' enabled." \
117                         "Expect some test failures or emerge with 'FEATURES=-usersandbox'!"
118         fi
119
120         emake check
121 }
122
123 pkg_postinst() {
124         if [[ -f "${EROOT}"/var/lib/rpm/Packages ]] ; then
125                 einfo "RPM database found... Rebuilding database (may take a while)..."
126                 "${EROOT}"/usr/bin/rpmdb --rebuilddb --root="${EROOT}" || die
127         else
128                 einfo "No RPM database found... Creating database..."
129                 "${EROOT}"/usr/bin/rpmdb --initdb --root="${EROOT}" || die
130         fi
131 }