This patch adds the possibility to create packages without being
root. The quality Debian packages of can be enhanced by adding more
information to the package description.

Note that the default location of checkinstall is not normally
in PATH of normal users, so call it explicitly or set PATH:
   fakeroot /usr/local/sbin/checkinstall ...

Changes in this patch:
installwatch:
- preserve LD_PRELOAD, required by fakeroot
checkinstall:
- --provides now also works for .deb
- added --conflicts for .deb
- special characters caused problems in "eval echo $1", for example:
  --maintainer "Patrick Ohly <patrick.ohly@gmx.de>"
  --requires "foo (>= 1.0)"
- preserve LD_PRELOAD, required by fakeroot

#
# Patch managed by http://www.holgerschurig.de/patcher.html
#

--- checkinstall/checkinstall~nonroot
+++ checkinstall/checkinstall
@@ -131,8 +131,9 @@
    echog "--pkgaltsource=<altsource>     Set alternate source location"
    echog "--pakdir=<directory>           The new package will be saved here"
    echog "--maintainer=<email addr>      The package maintainer (.deb)"
-   echog "--provides=<list>              Features provided by this package (.rpm)"
+   echog "--provides=<list>              Features provided by this package (.rpm/.deb)"
    echog "--requires=<list>              Features required by this package"
+   echog "--conflicts=<list>             Packages that this package cannot be installed with (.deb)"
    echog "--rpmflags=<flags>             Pass this flags to the rpm installer"
    echog "--rpmi                         Use the -i flag for rpm when installing a .rpm"
    echog "--rpmu                         Use the -U flag for rpm when installing a .rpm"
@@ -386,20 +387,21 @@
 ckversion
 echo
 
-if ! [ -f /usr/local/lib/checkinstall/checkinstallrc ]; then
-   echog "The checkinstallrc file was not found at:\n/usr/local/lib/checkinstall/checkinstallrc"
+CHECKINSTALLRC=${CHECKINSTALLRC:-`dirname $0`/../lib/checkinstall/checkinstallrc}
+if ! [ -f $CHECKINSTALLRC ]; then
+   echog "The checkinstallrc file was not found at:\n$CHECKINSTALLRC"
    echo
    echog "Assuming default values."
 else
 # Get our default settings from the rc file
-source /usr/local/lib/checkinstall/checkinstallrc
+source $CHECKINSTALLRC
 fi
 
 
 # Arguments parsing
 
 CKNAME=`basename "$0"`
-PARAMS=`getopt -a -n $CKNAME -o +d:DA:t:RShHy -l arch:,type:,si,showinstall::,ss,showslack::,deldoc::,delspec::,deldesc::,strip::,addso::,install::,stripso::,gzman::,bk,backup::,autodoinst::,reset-uids::,fstrans::,spec:,exclude:,include:,pkgname:,pkgversion:,pkgrelease:,pkglicense:,pkggroup:,pkgsource:,pkgaltsource:,pakdir:,docdir:,requires:,provides:,maintainer:,dpkgflags:,rpmflags:,pkgarch:,umask:,with-tar:,inspect,review-spec,review-control,newslack,help,nodoc,rpmi,rpmu,version,copyright,default -- "$@"`
+PARAMS=`getopt -a -n $CKNAME -o +d:DA:t:RShHy -l arch:,type:,si,showinstall::,ss,showslack::,deldoc::,delspec::,deldesc::,strip::,addso::,install::,stripso::,gzman::,bk,backup::,autodoinst::,reset-uids::,fstrans::,spec:,exclude:,include:,pkgname:,pkgversion:,pkgrelease:,pkglicense:,pkggroup:,pkgsource:,pkgaltsource:,pakdir:,docdir:,requires:,provides:,conflicts:,maintainer:,dpkgflags:,rpmflags:,pkgarch:,umask:,with-tar:,inspect,review-spec,review-control,newslack,help,nodoc,rpmi,rpmu,version,copyright,default -- "$@"`
 
 [ $? -gt 0 ] && help_notice
 
@@ -474,13 +476,17 @@
          shift
          PROVIDES=`eval echo $1`
          ;;
+      --conflicts)
+         shift
+         CONFLICTS=`eval echo $1`
+         ;;
       --requires)
          shift
-         REQUIRES=`eval echo $1`
+         REQUIRES="$1"
          ;;
       --maintainer)
          shift
-         MAINTAINER=`eval echo $1`
+         MAINTAINER="$1"
          ;;
       --dpkgflags)
          shift
@@ -1272,8 +1278,8 @@
       echog "8 -  Source location: [ %s ]" "$SOURCE"
       echog "9 -  Alternate source location: [ %s ]" "$ALTSOURCE"
       echog "10 - Requires: [ %s ]" "$REQUIRES"
-      [ "$CK_REDHAT" ] && echog "11 - Provides: [ %s ]" "$PROVIDES"
-
+      ( [ "$CK_REDHAT" ] || [ "$CK_DEBIAN" ] ) && echog "11 - Provides: [ %s ]" "$PROVIDES"
+      [ "$CK_DEBIAN" ] && echog "12 - Conflicts: [ %s ]" "$CONFLICTS"
 
       echo
       echogn "Enter a number to change any of them or press ENTER to continue: "
@@ -1350,6 +1356,12 @@
             echo -n ">> "
             read PROVIDES
             ;;
+        12)
+            [ "$CK_DEBIAN" ] && { echog "Enter the conflicting packages: "
+            echo -n ">> "
+            read CONFLICTS
+            }
+            ;;
       esac
    done
    
@@ -1432,7 +1444,8 @@
    fi
 fi
 
-unset LD_PRELOAD
+# preserve LD_PRELOAD, might have been set by fakeroot 
+# unset LD_PRELOAD
 
 
 VIEWLOG="n"
@@ -2339,8 +2352,11 @@
 Architecture: $ARCHITECTURE
 Version: ${VERSION}-${RELEASE}
 Depends: $REQUIRES
-Description: $SUMMARY
 EOF
+[ "$PROVIDES" ] && echo >> $BUILD_DIR/DEBIAN/control "Provides: $PROVIDES"
+[ "$CONFLICTS" ] && echo >> $BUILD_DIR/DEBIAN/control "Conflicts: $CONFLICTS"
+echo >> $BUILD_DIR/DEBIAN/control "Description: $SUMMARY"
+
 
 # Add the description
 cat "$DIRECTORIO_FUENTE/description-pak"| egrep -v "$SUMMARY|^[ 	]*$" | while read line; do
--- checkinstall/installwatch-0.7.0beta5/installwatch~nonroot
+++ checkinstall/installwatch-0.7.0beta5/installwatch
@@ -331,7 +331,11 @@
 # ##############################################################################
 #
 
-LD_PRELOAD="$LIBDIR/installwatch.so"
+if [ "$LD_PRELOAD" ]; then
+    LD_PRELOAD="$LIBDIR/installwatch.so:$LD_PRELOAD"
+else
+    LD_PRELOAD="$LIBDIR/installwatch.so"
+fi
 export LD_PRELOAD
 
 if [ $INSTW_DBGLVL -gt 0 ]; then 

