# $Id$

PortSystem 1.0

name			rpm45
version			4.5
revision        1
platforms		darwin freebsd linux
categories		sysutils archivers
maintainers		mac.com:n3npq
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-4.5
distname		rpm-${version}-0.4
checksums		md5 9f9d2e64b93d64b8cc2c10e116e9ecd9
worksrcdir		rpm-${version}
#
### CVS source
#fetch.type      	cvs
#cvs.root		:pserver:anonymous@rpm5.org:/cvs
#cvs.module		rpm
#cvs.tag			rpm-4_5
#worksrcdir		rpm

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

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

extract.suffix		.src.rpm
extract.cmd		${filespath}/rpm2cpio.pl
extract.pre_args
extract.post_args	| cpio -dvim rpm-${version}.tar.gz && \
			  gzip -dc rpm-${version}.tar.gz | tar -xf -

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 --without-apidocs \
			--sysconfdir=${prefix}/etc/rpm

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

### CVS config
#post-fetch	{ system "cd ${worksrcpath} && ./devtool checkout" }
#post-patch { reinplace "s@po/Makefile.in@@" ${worksrcpath}/configure.ac
#reinplace "s@\"-lsqlite\"@\"-lsqlite3\"@" ${worksrcpath}/configure.ac }
#pre-configure	{ system "cd ${worksrcpath} && ./devtool autogen" }

patchfiles		patch-macros.in \
			patch-configure \
			patch-Makefile.PL \
			patch-darwin.prov \
			patch-fts.c \
			patch-rpmio.h \
			patch-rpmsq.c \
			patch-rpmevr.h

### CVS patches
#patchfiles		patch-macros.in \
#			patch-configure.ac \
#			patch-darwin.prov \
#			patch-fts.c \
#			patch-rpmsq.c \
#			patch-rpmevr.h

post-patch {
	# use external popt library
	if {[file exists ${worksrcpath}/popt]} { delete ${worksrcpath}/popt }
}

post-destroot {
	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/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

	configure.cppflags-append -I${prefix}/include/python2.5
	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/4.5/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/4.5/macros
		reinplace "s;/usr/bin/make;/usr/local/bin/gmake;" ${destroot}${prefix}/lib/rpm/4.5/macros
	}
}

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

	post-destroot {
		# Linux specific changes
	}
}

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