# $Id: Portfile 91796 2012-04-10 18:42:20Z afb@macports.org $

PortSystem 1.0

name		yum
version		3.2.29
set branch	[join [lrange [split ${version} .] 0 1] .]
platforms	darwin
categories	sysutils archivers
maintainers	mac.com:n3npq afb
supported_archs	noarch

description	Automatic updater and package installer/remover for RPM
long_description	Yum is an automatic updater and package installer/remover for \
			rpm systems. It automatically computes dependencies and figures \
			out what things should occur to install packages. It makes it \
			easier to maintain groups of machines without having to manually \
			update each one using rpm.

homepage	http://yum.baseurl.org/
master_sites	${homepage}download/${branch}/
checksums	md5 8b6b106190980c606b77ebf6a81b5f70 \
		sha1 30207763c6a6fbf2f5dc32512bd3eb208f7d39d1 \
		rmd160 ab885fc93875925ae57ceabc8731357221d1fae3

patchfiles	patch-prefix.diff patch-sqlutils.py patch-packages.py

depends_lib	lib:librpm:rpm
depends_build	port:intltool

set python.bin  ""

patch {
		foreach patch $patchfiles {
			system "cd '${workpath}/${distname}' && \
			sed -e 's#@@PREFIX@@#${prefix}#g' -e 's#@@PYTHON@@#${python.bin}#g' '${portpath}/${filesdir}/${patch}' | patch -p0"
		}
}

post-patch {
		# problem with case-insensitive filesystem:
		file delete ${workpath}/${distname}/INSTALL
}

use_configure	no

destroot.args	PYSYSDIR="${prefix}"

pre-build {
	build.args-append	PYTHON="${python.bin}"
}

pre-destroot {
	destroot.args-append	PYTHON="${python.bin}"
}

variant python25 conflicts python26 description "use python 2.5" {
	depends_lib-append	port:python25 port:py25-celementtree port:py25-urlgrabber port:py25-libxml2 port:py25-yum-metadata-parser port:py25-iniparse port:py25-pygpgme
	depends_build-append	port:py25-nose
	set python.bin		${prefix}/bin/python2.5
}

variant python26 conflicts python25 description "use python 2.6" {
	depends_lib-append	port:python26 port:py26-celementtree port:py26-urlgrabber port:py26-libxml2 port:py26-yum-metadata-parser port:py26-iniparse port:py26-pygpgme
	depends_build-append	port:py26-nose
	set python.bin		${prefix}/bin/python2.6
}

if {![variant_isset python25] && ![variant_isset python26]} {
	default_variants +python25
}

post-destroot	{
		xinstall -d -m 755 ${destroot}${prefix}/etc/yum/repos.d
		xinstall -d -m 755 ${destroot}${prefix}/var/cache/yum/release/headers
		xinstall -d -m 755 ${destroot}${prefix}/var/cache/yum/release/packages
		copy -force ${filespath}/yum.conf ${destroot}${prefix}/etc/yum/yum.conf
		reinplace "s|@@PREFIX@@|$prefix|g" ${destroot}${prefix}/etc/yum/yum.conf
		reinplace "s|@@PLATFORM@@|${os.platform}|g" ${destroot}${prefix}/etc/yum/yum.conf
		destroot.keepdirs ${destroot}${prefix}/etc/yum/repos.d \
		${destroot}${prefix}/var/cache/yum/release/headers \
		${destroot}${prefix}/var/cache/yum/release/packages \
		${destroot}${prefix}/var/log \
		${destroot}${prefix}/var/run
		# don't install the update notifier dbus daemon
		delete ${destroot}${prefix}/etc/dbus-1/system.d/yum-updatesd.conf \
		${destroot}${prefix}/etc/rc.d/init.d/yum-updatesd \
		${destroot}${prefix}/etc/yum/yum-updatesd.conf \
		${destroot}${prefix}/sbin/yum-updatesd \
		${destroot}${prefix}/share/man/man5/yum-updatesd.conf.5 \
		${destroot}${prefix}/share/man/man8/yum-updatesd.8
		delete ${destroot}${prefix}/etc/cron.daily \
		${destroot}${prefix}/etc/sysconfig
}

test.run	yes

livecheck.type	regex
# get the last modified tarball
livecheck.url	${master_sites}?C=M\;O=D
livecheck.regex	${name}-(\[0-9\\.\]+)${extract.suffix}
