#!/bin/sh
# DocumentId:	$Id: dpsch-installusers,v 1.7 2001/09/07 09:18:10 ola Exp $
# Author:	$Author: ola $
#		Ola Lundqvist <opal@debian.org>
# Arguments:	
# Summary:
#	Install users information to a package name.

. /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

handle() {
    mkdir -p debian/$PKG$USERSRC/$PKG
    find $DIR -maxdepth 1 -mindepth 1 -type d -exec \
	cp -aRf {} debian/$PKG$USERSRC/$PKG \;
    find $DIR -maxdepth 1 -mindepth 1 -type f -name "*.conf" |{
	while read D ; do
	    N=$(echo "$D" | sed -e "s|^.*/\([^/]*\).conf$|\1|;")
	    cp -f $D debian/$PKG$USERSRC/$N
	done
    }
}

dpsch-listbinpkgs | {
    while read PKG ; do
	if [ -e debian/$PKG.users ] ; then
	    cat debian/$PKG.users | {
		while read DIR ; do
		    handle
		done
	    }
	fi
    done
}

dpsch-showfirstbinpkg | {
    while read PKG ; do
	if [ -e debian/users ] ; then
	    cat debian/users | {
		while read DIR ; do
		    handle
		done
	    }
	fi
    done
}
