# $Id: Portfile 91657 2012-04-07 09:49:22Z jmr@macports.org $

PortSystem 1.0

name		apt-rpm
version		0.5.15lorg3.93
platforms	darwin freebsd
categories	sysutils
maintainers	nomaintainer
description	Automatic updater and package installer/remover for RPM
long_description	APT-RPM is a port of Debian's apt tools for RPM based distributions. \
			It provides the apt-get utility that provides a simple, safe way to \
			install and upgrade packages. APT features complete installation \
			ordering, multiple source capability and several other useful \
			features.

homepage	http://apt-rpm.org/
master_sites	${homepage}testing/
distname	apt-${version}
use_bzip2	yes
checksums	md5 5437ac203f7fe15b9bbd74b3c99e2b6a

depends_build   port:pkgconfig
depends_lib	lib:librpm:rpm port:libxml2 lib:libsqlite3:sqlite3

post-extract {
		file attributes ${worksrcpath}/buildlib/install-sh -permissions 0755
}

patchfiles	patch-genbasedir.diff patch-rpmsense.diff

post-patch {
		reinplace "s;\"/\";\"${prefix}\";" ${worksrcpath}/apt-pkg/init.cc
		reinplace "s;/bin/rpm;${prefix}/bin/rpm;" ${worksrcpath}/apt-pkg/rpm/rpmsystem.cc
		reinplace "s;/var/cache/apt;${prefix}/var/cache/apt;" ${worksrcpath}/tools/cached_md5.cc
}

configure.cxxflags -I${prefix}/include/rpm

post-destroot {
		copy -force ${filespath}/apt.conf ${destroot}${prefix}/etc/apt/apt.conf
		reinplace "s|@@ARCH@@|${os.arch}|g" ${destroot}${prefix}/etc/apt/apt.conf
		copy ${filespath}/sources.list ${destroot}${prefix}/etc/apt/sources.list
		reinplace "s|@@PLATFORM@@|${os.platform}|g" ${destroot}${prefix}/etc/apt/sources.list
		copy ${filespath}/rpmpriorities ${destroot}${prefix}/etc/apt/rpmpriorities
		xinstall -d -m 755 ${destroot}${prefix}/etc/apt/apt.conf.d
		xinstall -d -m 755 ${destroot}${prefix}/etc/apt/sources.list.d
		xinstall -d -m 755 ${destroot}${prefix}/etc/apt/vendors.list.d
		xinstall -d -m 755 ${destroot}${prefix}/var/cache/apt/archives/partial
		xinstall -d -m 755 ${destroot}${prefix}/var/lib/apt/lists/partial
		destroot.keepdirs ${destroot}${prefix}/etc/apt/apt.conf.d \
		                  ${destroot}${prefix}/etc/apt/sources.list.d \
		                  ${destroot}${prefix}/etc/apt/vendors.list.d \
		                  ${destroot}${prefix}/var/cache/apt/archives/partial \
		                  ${destroot}${prefix}/var/lib/apt/lists/partial
}

livecheck.type	regex
# get the last modified tarball
livecheck.url	${master_sites}?M=D
livecheck.regex	apt-(.*)${extract.suffix}
