60c60,105
< exec sudo chroot "$CHROOT_PATH" su -l -c "$ENV_EXPORT exec \$SHELL $SU_CMD" build
---
> # Mount every local repository in the chroot's sources.list file that doesn't 
> # exist in the chroot file system.
> 
> # All the local repositories mentioned in chroot's sources.list file
> localReps=$(egrep -o '(file:[^[:space:]]+)' < "$CHROOT_PATH/etc/apt/sources.list" | sed 's/file://')
> 
> for localRep in $localReps
> do
>     # If the directory doesn't exist in the chroot file system
>     if [ ! -d "$CHROOT_PATH$localRep" ]
>     then
>         # If the directory does exist in the exterior file system
>         if [ -d "$localRep" ]
>         then
>             # Make a mount dir and mount the exterior repository dir to it
>             sudo mkdir "$CHROOT_PATH$localRep"
>             sudo mount --bind "$localRep" "$CHROOT_PATH$localRep"
>         fi
>     fi
> done
> 
> sudo chroot "$CHROOT_PATH" su -l -c "$ENV_EXPORT exec \$SHELL $SU_CMD" build
> 
> # Strip any useless trailing dots and slashes from the chroot path
> trimmedChrootPath=$(echo $CHROOT_PATH | sed 's|/\.\?$||')
> 
> for localRep in $localReps
> do
>     # If the local rep has a dir in the chroot fs
>     if [ -d "$trimmedChrootPath$localRep" ]
>     then
>         # If the local rep dir in the chroot fs has been mounted
>         if fgrep -q "$trimmedChrootPath$localRep" < "/etc/mtab"
>         then
>             # Unmount it
>             sudo umount "$trimmedChrootPath$localRep" "$localRep"
>         fi
>         
>         # If the local rep dir in the chroot fs is now empty
>         if [ -z `ls $trimmedChrootPath$localRep` ]
>         then
>             # Delete it
>             sudo rm -r "$trimmedChrootPath$localRep"
>         fi
>     fi
> done
