# $Id: Portfile 92837 2012-05-09 00:51:48Z ryandesign@macports.org $

PortSystem 1.0

name			rpm52
version			5.2.1
revision		6
platforms		darwin freebsd linux
license			LGPL-2.1
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/rpm/rpm-5.2/
distname		rpm-${version}
checksums		md5 71f825ede4a2ddc191132ae017c9a6e4 \
			sha1 77f2d1b24301ed3743d8bbc57e57710c0eff7bc8 \
			rmd160 a66017c6b8a7e0a1de6be945e3823a7ab2051c75
worksrcdir		rpm-${version}

depends_build		port:expat port:neon \
			port:python25 port:perl5.8 \
			port:readline port:beecrypt \
			port:libiconv port:gettext

depends_lib		lib:libhistory.5:readline port:gettext \
			port:popt port:sqlite3 port:xar-devel \
			port:liblzma port:pcre port:ossp-uuid

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

patchfiles		patch-macros.in patch-configure.ac patch-configure

build.type		gnu

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 --with-sqlite --with-dbapi=sqlite \
			--with-xar=external --with-xz=external --with-pcre=external --with-uuid=external \
			--without-apidocs --sysconfdir=${prefix}/etc --with-path-cfg=${prefix}/etc/rpm
configure.env		__PYTHON=${prefix}/bin/python2.5 __PERL=${prefix}/bin/perl5.8 \
			PERL=${prefix}/bin/perl5.8


configure.args-append	--with-js=internal --with-lua=internal --with-db=internal
configure.cppflags-append	-I${prefix}/include/xar -I${prefix}/include/ossp

post-destroot {
	xinstall -d -m 755 ${destroot}${prefix}/etc/rpm
	system "${worksrcpath}/rpm --macros=${worksrcpath}/macros --eval='%{_target_platform}' > ${destroot}${prefix}/etc/rpm/platform"
	system "${worksrcpath}/rpm --macros=${worksrcpath}/macros --eval='noarch-%{_target_vendor}-%{_target_os}%{?_gnu}' >> ${destroot}${prefix}/etc/rpm/platform"

	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/rpm/BUILD\
			  ${destroot}${prefix}/src/rpm/RPMS\
			  ${destroot}${prefix}/src/rpm/SOURCES\
			  ${destroot}${prefix}/src/rpm/SPECS\
			  ${destroot}${prefix}/src/rpm/SRPMS
}

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

	post-destroot {
		# Mac OS X specific changes
	}
}

platform freebsd {

	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 {

	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
}

variant python26 description { use python 2.6 instead of python 2.5 } {
	depends_build-delete	port:python25
	depends_build-append	port:python26
	configure.args-delete	--with-python=2.5
	configure.args-append	--with-python=2.6
	configure.env-delete	__PYTHON=${prefix}/bin/python2.5
	configure.env-append	__PYTHON=${prefix}/bin/python2.6
}

variant python27 description { use python 2.7 instead of python 2.5 } {
	depends_build-delete	port:python25
	depends_build-append	port:python27
	configure.args-delete	--with-python=2.5
	configure.args-append	--with-python=2.7
	configure.env-delete	__PYTHON=${prefix}/bin/python2.5
	configure.env-append	__PYTHON=${prefix}/bin/python2.7
}

variant perl5_10 description { use perl 5.10 instead of perl 5.8 } {
	depends_build-delete	port:perl5.8
	depends_build-append	port:perl5.10
	configure.env-delete	PERL=${prefix}/bin/perl5.8
	configure.env-append	PERL=${prefix}/bin/perl5.10
	configure.env-delete	__PERL=${prefix}/bin/perl5.8
	configure.env-append	__PERL=${prefix}/bin/perl5.10
}

variant perl5_12 description { use perl 5.12 instead of perl 5.8 } {
	depends_build-delete	port:perl5.8
	depends_build-append	port:perl5.12
	configure.env-delete	PERL=${prefix}/bin/perl5.8
	configure.env-append	PERL=${prefix}/bin/perl5.12
	configure.env-delete	__PERL=${prefix}/bin/perl5.8
	configure.env-append	__PERL=${prefix}/bin/perl5.12
}

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