# $Id: Portfile 60675 2009-11-19 21:09:01Z landonf@macports.org $

PortSystem 1.0
name			dpkg
version			1.10.28
revision		1
platforms		darwin freebsd
categories		sysutils archivers
maintainers		landonf openmaintainer
description		Debian package maintenance system
homepage		http://www.debian.org/

master_sites		http://ftp.debian.org/debian/pool/main/d/dpkg/
checksums		md5 912ece8f3c39192503ff2bcb4c74182e

# Use MacPorts versions explicitly
depends_lib		port:gettext \
			port:libiconv \
			bin:perl:perl5


distname		${name}_${version}
worksrcdir		${name}-${version}

patchfiles		patch-config.h.in \
			patch-configure \
			patch-configure.in \
			patch-lib_utils.c \
			patch-lib_tarfn.c \
			patch-main_remove.c \
			patch-utils_Makefile.in \
			patch-main_archives.c \
			patch-archtable \
			patch-include_parsedump.h 

configure.args		--without-sgml-doc --with-libintl-prefix=${prefix} \
			--with-libiconv-prefix=${prefix} --with-admindir=${prefix}/var/db/dpkg \
			--mandir=${prefix}/share/man

build.type		gnu

# Does not work as of dpkg 1.10.28
use_parallel_build no

set vardpkg ${destroot}${prefix}/var/db/dpkg
destroot.keepdirs ${vardpkg} ${vardpkg}/updates ${vardpkg}/info

post-patch {
	set scripts ${worksrcpath}/scripts
	reinplace s|/etc/dpkg/|${prefix}/etc/dpkg/| \
			${scripts}/dpkg-shlibdeps.pl \
			${scripts}/dpkg-source.1

	reinplace s|/etc/|${prefix}/etc/| \
			${scripts}/update-alternatives.8

	reinplace s|/etc/alternatives|${prefix}/etc/alternatives|g \
			${scripts}/update-alternatives.pl
}

pre-destroot {
	file mkdir ${destroot}${prefix}/share/doc/dpkg
}

post-destroot {
	file mkdir ${vardpkg}
	file mkdir ${vardpkg}/updates
	file mkdir ${vardpkg}/info
	system "touch ${vardpkg}/available ${vardpkg}/status"
}

platform darwin {
	depends_build-append	bin:gnumake:gmake
	patchfiles-append patch-utils_start-stop-daemon.c bsd/patch-main_help.c
}

platform freebsd {
	depends_build-append	bin:gmake:gmake
	patchfiles-append patch-utils_start-stop-daemon.c bsd/patch-main_help.c
}

livecheck.type		regex
livecheck.url		http://ftp.debian.org/debian/pool/main/d/dpkg/
livecheck.regex		"${name}_(\\d+\\.\\d+(\\.\\d+)*)"
