#!/bin/sh
# DocumentId:	$Id: dpsch-auto-cronapt,v 1.3 2002/05/13 14:57:16 ola Exp $
# Author:	$Author: ola $
#		Ola Lundqvist <opal@debian.org>
# Arguments:	
# Summary:
#	Install a system cron-apt file to a package.

. /etc/dpsyco/defaults.conf

if [ ! -d debian ] ; then
    echo "No debian directory, exiting."
    exit 0
fi

if [ ! -e debian/control ] ; then
    echo "No debian control file, exiting."
    exit 0
fi

PREFIX=6

dpsch-listbinpkgs | (
    while read PKG ; do
	mkdir -p debian/$PKG/etc/cron-apt/action.d
	touch debian/$PKG/etc/cron-apt/action.d/$PREFIX-$PKG
	echo "--yes --fix-missing --show-upgraded --no-remove install $PKG" \
	    >> debian/$PKG/etc/cron-apt/action.d/$PREFIX-$PKG
	umask 022
	mkdir -p debian/$PKG/DEBIAN
	touch debian/$PKG/DEBIAN/conffiles
	if ! grep "/etc/cron-apt/action.d/$PREFIX-$PKG" debian/$PKG/DEBIAN/conffiles > /dev/null 2>&1 ; then
	    echo  "/etc/cron-apt/action.d/$PREFIX-$PKG" >> debian/$PKG/DEBIAN/conffiles
	fi
    done
)
