# $Id: Portfile 91795 2012-04-10 18:41:37Z afb@macports.org $

PortSystem 1.0

name			rpm
version			4.4.9
revision                14
platforms		darwin freebsd linux
license			GPL-2 LGPL-2
categories		sysutils archivers
maintainers		mac.com:n3npq afb
description		The RPM package management system.
long_description	The RPM Package Manager (RPM) is a powerful command line driven \
			package management system capable of installing, uninstalling, \
			verifying, querying, and updating software packages. Each software \
			package consists of an archive of files along with information about \
			the package like its version, a description, etc.

homepage		http://rpm5.org
master_sites		${homepage}/files/${name}/${name}-4.4
checksums		md5 210b768006e7d88dd8a3bcd498ea27f6

depends_build		port:python25 port:perl5.8

depends_lib		port:readline port:gettext \
			port:popt port:sqlite3 port:beecrypt \
			port:neon

depends_run		port:openssl \
			bin:gzip:gzip \
                        bin:bzip2:bzip2 \
                        bin:unzip:unzip

build.type		gnu
build.jobs		1

configure.args		--disable-nls --without-javaglue --without-included-gettext \
			--with-libintl-prefix=${prefix} --with-libiconv-prefix=${prefix} \
			--mandir=${prefix}/share/man --infodir=${prefix}/share/info \
			--with-python=2.5 --with-perl=5.8 --without-apidocs \
			--sysconfdir=${prefix}/etc

configure.env		__PYTHON=${prefix}/bin/python2.5 __PERL=${prefix}/bin/perl5.8

			# needed because it checks for sqlite3_open in sqlite lib...
configure.env-append	ac_cv_lib_sqlite_sqlite3_open=yes

			# needed because db3 configure breaks with a two-word CXX...
configure.ccache	no

patchfiles		patch-neon.diff \
			patch-macros.in \
			patch-configure \
			patch-db3-configure \
			patch-zlib-configure \
			patch-Makefile.PL \
			patch-darwin.prov \
			patch-fts.c \
			patch-rpmdav.c \
			patch-rpmsq.c \
			patch-rpmevr.h \
			patch-parseBuildInstallClean.c \
			patch-db-mutex-mut_pthread.c \
			patch-scripts-brp-nobuildrootpath

post-patch {
	# use external popt library
	delete ${worksrcpath}/popt
}

post-destroot {
	# MacPorts specific changes
	reinplace "s;%{_usrsrc}/rpm;%{_usrsrc}/macports;" ${destroot}${prefix}/lib/rpm/macros

	xinstall -d -m 755 ${prefix}/etc/rpm

	delete [glob ${destroot}${prefix}/lib/perl5/*/*/*/auto/RPM/.packlist]
	delete [glob ${destroot}${prefix}/lib/perl5/*/*/perllocal.pod]

	# where the RPM database lives
	destroot.keepdirs ${destroot}${prefix}/etc/rpm\
			  ${destroot}${prefix}/var/lib/rpm\
			  ${destroot}${prefix}/var/spool/repackage\
			  ${destroot}${prefix}/src/macports/BUILD\
			  ${destroot}${prefix}/src/macports/RPMS\
			  ${destroot}${prefix}/src/macports/SOURCES\
			  ${destroot}${prefix}/src/macports/SPECS\
			  ${destroot}${prefix}/src/macports/SRPMS
}

platform darwin {
	configure.args-append --disable-optimized --disable-aio \
			      --with-glob --enable-broken-chown \
			      --disable-rpath

	configure.cppflags-append -I${prefix}/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5

	post-destroot {
		# Mac OS X specific changes
		reinplace "s;\blibtoolize\b;glibtoolize;" ${destroot}${prefix}/lib/rpm/macros
	}
}

platform freebsd {
	post-configure {
		reinplace "s;-lrt;;" ${worksrcpath}/lua/Makefile
	}

	post-destroot {
		# FreeBSD specific changes
		reinplace "s;/usr/bin/tar;/usr/local/bin/gtar;" ${destroot}${prefix}/lib/rpm/macros
		reinplace "s;/usr/bin/make;/usr/local/bin/gmake;" ${destroot}${prefix}/lib/rpm/macros
	}
}

platform linux {
	patchfiles-append      patch-rpmdb-Makefile.am

	post-destroot {
		# Linux specific changes
	}
}

variant docs description "API documentation" {
	depends_run-append bin:doxygen:doxygen
	configure.args-delete --without-apidocs
	configure.args-append --with-apidocs
}

livecheck.type	regex
# get the last modified tarball
livecheck.url	${master_sites}
livecheck.regex	${name}-(\[0-9\\.\]+)${extract.suffix}
