#!/bin/sh

. config/options


PKG_DIR=`find $PACKAGES -type d -name $1`

mkdir -p $INSTALL/etc
  cp -P $PKG_BUILD/modules/pam_env/environment $INSTALL/etc
#  cp -P $PKG_BUILD/data/pam.conf $INSTALL/etc

mkdir -p $INSTALL/etc/pam.d
  cp -P $PKG_DIR/config/* $INSTALL/etc/pam.d

mkdir -p $INSTALL/etc/security
  cp -P $PKG_BUILD/modules/pam_access/access.conf $INSTALL/etc/security
  cp -P $PKG_BUILD/modules/pam_group/group.conf $INSTALL/etc/security
  cp -P $PKG_BUILD/modules/pam_limits/limits.conf $INSTALL/etc/security
  cp -P $PKG_BUILD/modules/pam_env/pam_env.conf $INSTALL/etc/security
  cp -P $PKG_BUILD/modules/pam_time/time.conf $INSTALL/etc/security

mkdir -p $INSTALL/lib/security
  cp -P $PKG_BUILD/modules/pam_mkhomedir/.libs/mkhomedir_helper $INSTALL/lib/security
#  cp -P $PKG_BUILD/modules/pam_tally/pam_tally $INSTALL/lib/security
  cp -P $PKG_BUILD/modules/pam_tally2/.libs/pam_tally2 $INSTALL/lib/security
  cp -P $PKG_BUILD/modules/pam_unix/unix_chkpwd $INSTALL/lib/security
    echo "chmod 4755 $INSTALL/lib/security/unix_chkpwd" >> $FAKEROOT_SCRIPT
  cp -P $PKG_BUILD/modules/pam_unix/unix_update $INSTALL/lib/security

mkdir -p $INSTALL/usr/lib
  cp -P $PKG_BUILD/libpam/.libs/*.so* $INSTALL/usr/lib
  cp -P $PKG_BUILD/libpam_misc/.libs/*.so* $INSTALL/usr/lib
  rm -rf $INSTALL/usr/lib/libpam_misc.so*T
  cp -P $PKG_BUILD/libpamc/.libs/*.so* $INSTALL/usr/lib

mkdir -p $INSTALL/usr/lib/security
  cp -P $PKG_BUILD/modules/*/.libs/*.so $INSTALL/usr/lib/security

mkdir -p $INSTALL/usr/lib/security/pam_filter
  cp -P $PKG_BUILD/modules/pam_filter/upperLOWER/.libs/upperLOWER $INSTALL/usr/lib/security/pam_filter

mkdir -p $INSTALL/sbin
  cp -P $PKG_BUILD/modules/pam_tally/pam_tally $INSTALL/sbin
