# Copyright 1999-2008 Gentoo Foundation
# Copyright 2009 Ricardo Salveti de Araujo
# Distributed under the terms of the GNU General Public License v2

inherit bash-completion eutils autotools

DESCRIPTION="Debian repository creator and maintainer application"
HOMEPAGE="http://packages.debian.org/reprepro"
SRC_URI="mirror://debian/pool/main/r/${PN}/${PN}_${PV}.orig.tar.gz"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~x86 ~amd64"
IUSE="bzip2 bash-completion"

DEPEND="app-arch/gzip
	bzip2? ( app-arch/bzip2 )
	app-arch/libarchive
	app-crypt/gpgme
	>=sys-libs/db-4.3"
RDEPEND="${DEPEND}"

src_unpack() {
	unpack ${A}
	cd "${S}"
	# Ubuntu fixes to compile with latest db
	epatch "${FILESDIR}/${P}-6ubuntu1.diff"
	epatch "${FILESDIR}/${P}-gpgme-header-check-1.patch"
	eautoreconf
}

src_compile() {
	econf --with-libarchive \
		$(use_with bzip2 libbz2) \
		|| die
	emake || die "emake failed"
}

src_install() {
	emake install DESTDIR="${D}" || die "emake install failed"

	if use bash-completion ; then
		dobashcompletion docs/reprepro.bash_completion ${PN}
	fi

	dodoc AUTHORS COPYING INSTALL NEWS README TODO docs/recovery \
		docs/short-howto
	dohtml docs/manual.html
}