--- open-iscsi-2.0.865.orig/debian/dirs
+++ open-iscsi-2.0.865/debian/dirs
@@ -1,3 +1,6 @@
 usr/bin
 usr/sbin
+var/lib/open-iscsi
 etc/init.d
+etc
+etc/iscsi
--- open-iscsi-2.0.865.orig/debian/README.Debian
+++ open-iscsi-2.0.865/debian/README.Debian
@@ -1,44 +1,13 @@
-linux-iscsi for Debian
+open-iscsi for Debian
 -----------------------------------
 
-The linux-iscsi package contains the userspace portion the Linux iSCSI project.
-It has a dependency on the linux-iscsi-modules package, which needs to be built from the linux-iscsi-modules-source against the specific kernel version running
-on your system.
+The open-iscsi package contains the userspace portion the Open iSCSI project.
+It depends on iSCSI modules which are already present in current (>= 2.6.18) kernels.
 
-Building
---------
-Modules cannot be built against the kernel-headers alone.  You will need
-to extract and configure your kernel tree, then use the make-kpkg command
-(from the kernel-package package) to build a new kernel and modules.
-See the make-kpkg man page, particularly the modules-image section.  The
-following example shows how to build the linux-iscsi-modules package; just
-substitute the appropriate version strings.  Follow these instructions 
-(as root) in order to build the linux-iscsi-modules package for your kernel:
+If you want to automatically connect to all discovered targets, change the following
+line:
+node.startup = manual
+to:
+node.startup = automatic
 
-dpkg -i linux-iscsi-modules-source_5.0.0.0.3rc6-363_all.deb
-cd /usr/src
-rm -rf modules/linux-iscsi
-tar jxpvf linux-iscsi-modules-source.tar.bz2
-cd linux-2.6.11.11 (or your appropriate version)
-make-kpkg --added-modules linux-iscsi modules-image
-
-By default, make-kpkg will assume /usr/src/linux-iscsi-modules-source.tar.bz2 
-has been extracted under /usr/src.  However, that also requires building as 
-root.  If you want to do the build as a non-root user, you need to use the 
-MODULE_LOC environment variable.  For example:
-
-cd ~/builds
-export MODULES_LOC=$PWD/modules
-tar jxpvf /usr/src/linux-iscsi-modules-source.tar.bz2
-cd ~/builds/linux-2.6.11.11 (or your appropriate version)
-make-kpkg --added-modules linux-iscsi modules-image
-
-Installing
-----------
-
-Once you have built the linux-iscsi-modules package, you can install the
-binaries:
-
-dpkg -i linux-iscsi_5.0.0.0.3rc6-363_i386.deb linux-iscsi-modules-2.6.11.11_5.0.0.0.3rc6-363+10.00.Custom_i386.deb
-
- -- Chad Tindel <chad.tindel@hp.com>, Mon, 30 May 2005 15:17:53 -0600
+ -- Philipp Hug <debian@hug.cx>, Tue, 07 Mar 2006 01:28:53 +0100
--- open-iscsi-2.0.865.orig/debian/open-iscsi.postinst
+++ open-iscsi-2.0.865/debian/open-iscsi.postinst
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+case "$1" in
+    configure)
+	# Move old configuration from /etc/ into /etc/iscsi/
+	# But only if configuration in /etc/iscsi is untouched
+	
+        if [ -f /etc/initiatorname.iscsi ] ; then
+            if grep -q "^GenerateName=yes" /etc/iscsi/initiatorname.iscsi ; then
+                mv /etc/initiatorname.iscsi /etc/iscsi/initiatorname.iscsi
+		chmod 600 /etc/iscsi/initiatorname.iscsi
+	    fi
+	fi
+	
+	if [ -d /var/lib/open-iscsi ]; then
+		chmod 700   /var/lib/open-iscsi
+	else
+		mkdir /var/lib/open-iscsi
+		chmod 700   /var/lib/open-iscsi
+	fi
+    ;;
+
+    abort-upgrade|abort-remove|abort-deconfigure)
+    ;;
+
+    *)
+        echo "postinst called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+#DEBHELPER#
+
+exit 0
--- open-iscsi-2.0.865.orig/debian/control.modules.in
+++ open-iscsi-2.0.865/debian/control.modules.in
@@ -1,13 +1,13 @@
 Source: linux-iscsi-modules
 Section: net
 Priority: optional
-Maintainer: Chad Tindel <chad.tindel@hp.com>
+Maintainer: Philipp Hug <debian@hug.cx>
 Build-Depends: debhelper (>> 4.1.0), bzip2
 Standards-Version: 3.6.1
 
 Package: linux-iscsi-modules-_KVERS_
 Architecture: any
-Depends: modutils, linux-iscsi
+Depends: modutils, open-iscsi
 Provides: linux-iscsi-modules
 Description: Linux Kernel Driver Modules for Linux iSCSI (kernel _KVERS_)
  This is a Linux driver for iSCSI initiator functionality.
--- open-iscsi-2.0.865.orig/debian/manpages
+++ open-iscsi-2.0.865/debian/manpages
@@ -0,0 +1,3 @@
+doc/iscsid.8
+doc/iscsiadm.8
+debian/iscsi-iname.8
--- open-iscsi-2.0.865.orig/debian/docs
+++ open-iscsi-2.0.865/debian/docs
@@ -1,4 +1 @@
 README
-COPYING
-THANKS
-TODO
--- open-iscsi-2.0.865.orig/debian/initiatorname.iscsi
+++ open-iscsi-2.0.865/debian/initiatorname.iscsi
@@ -0,0 +1 @@
+GenerateName=yes
--- open-iscsi-2.0.865.orig/debian/rules
+++ open-iscsi-2.0.865/debian/rules
@@ -19,6 +19,7 @@
 
 
 CFLAGS = -Wall -g
+export OPTFLAGS =-DDISCOVERY_FILE=\"/var/lib/open-iscsi/discovery\" -DNODE_FILE=\"/var/lib/open-iscsi/node\"
 
 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
 	CFLAGS += -O0
@@ -35,13 +36,14 @@
 
 
 #Architecture 
-build: build-arch build-indep
+build: build-arch
 
 build-arch: build-arch-stamp
 build-arch-stamp: configure-stamp 
 
 	# Add here commands to compile the arch part of the package.
 	$(MAKE) -C usr
+	$(MAKE) -C utils
 
 	touch build-arch-stamp
 
@@ -55,16 +57,20 @@
 clean:
 	dh_testdir
 	dh_testroot
-	rm -f build-arch-stamp build-indep-stamp #CONFIGURE-STAMP#
+	rm -f build-arch-stamp build-indep-stamp configure-stamp
 
 	# Add here commands to clean up after the build process.
 	$(MAKE) -C usr clean
+	$(MAKE) -C utils clean
 	rm -rf modules
 
 	dh_clean 
 
-install: install-indep install-arch
+install: install-arch
+# disabled kernel module package for now because source is already in debian stock kernelsy
 install-indep:
+
+disabled-install-indep:
 	dh_testdir
 	dh_testroot
 	dh_clean -k -i 
@@ -100,12 +106,12 @@
 	dh_installdirs -s
 
 	# Add here commands to install the arch part of the package into 
-	# debian/linux-iscsi.
-	install -m 755 usr/iscsiadm $(CURDIR)/debian/linux-iscsi/usr/bin
-	install -m 755 usr/iscsid $(CURDIR)/debian/linux-iscsi/usr/sbin
-	install -m 644 etc/iscsid.conf $(CURDIR)/debian/linux-iscsi/etc/iscsid.conf.example
-	install -m 755 etc/initd/initd.debian $(CURDIR)/debian/linux-iscsi/etc/init.d/iscsid
-	make clean
+	# debian/open-iscsi.
+	install -m 755 usr/iscsiadm $(CURDIR)/debian/open-iscsi/usr/bin
+	install -m 755 utils/iscsi-iname $(CURDIR)/debian/open-iscsi/usr/sbin
+	install -m 755 usr/iscsid $(CURDIR)/debian/open-iscsi/usr/sbin
+	install -m 644 etc/iscsid.conf $(CURDIR)/debian/open-iscsi/etc/iscsi
+	install -m 644 debian/initiatorname.iscsi $(CURDIR)/debian/open-iscsi/etc/iscsi/initiatorname.iscsi
 
 	dh_install -s
 
@@ -118,22 +124,12 @@
 	dh_installchangelogs 
 	dh_installdocs
 	dh_installexamples
-#	dh_installmenu
-#	dh_installdebconf	
-#	dh_installlogrotate	
-#	dh_installemacsen
-#	dh_installpam
-#	dh_installmime
-#	dh_installinit
-#	dh_installcron
-#	dh_installinfo
+	dh_installinit
 	dh_installman
 	dh_link
 	dh_strip
 	dh_compress 
 	dh_fixperms
-#	dh_perl
-#	dh_python
 	dh_makeshlibs
 	dh_installdeb
 	dh_shlibdeps
@@ -142,7 +138,7 @@
 	dh_builddeb
 # Build architecture independant packages using the common target.
 binary-indep: build-indep install-indep
-	$(MAKE) -f debian/rules DH_OPTIONS=-i binary-common
+#	$(MAKE) -f debian/rules DH_OPTIONS=-i binary-common
 
 # Build architecture dependant packages using the common target.
 binary-arch: build-arch install-arch
--- open-iscsi-2.0.865.orig/debian/changelog
+++ open-iscsi-2.0.865/debian/changelog
@@ -1,6 +1,63 @@
-linux-iscsi (5.0.0.0.3rc6-363) unstable; urgency=low
+open-iscsi (2.0.865-1) unstable; urgency=low
 
-  * Initial Release.
+  * New upstream release
+  * Removed iscsi-iname patch as it's now included in upstream
+  * Moved initiatorname.iscsi to /etc/iscsi/initiatorname.iscsi
 
- -- Chad Tindel <chad.tindel@hp.com>  Mon, 30 May 2005 15:17:53 -0600
+ -- Philipp Hug <debian@hug.cx>  Sat, 16 Jun 2007 12:31:05 +0200
+
+open-iscsi (2.0.730-1) unstable; urgency=low
+
+  * Reverted to upstream init script + patches (Closes: #397363 #401579)
+  * Removed libdb dependency
+  * Create /etc/iscsi
+  * Integrated NMU changes from Martin Zobel-Helas
+     + New Upstream Release (Closes: #397636)
+     + Made /var/lib/open-iscsi 0700 (Closes: #398733)
+     + change #define INITIATOR_NAME_FILE to /etc/initiatorname.iscsi
+       in usr/initiator.h
+     + Fix package description (Closes: #380162)
+
+ -- Philipp Hug <debian@hug.cx>  Wed,  6 Dec 2006 20:22:30 +0100
+
+open-iscsi (1.0.485-4) unstable; urgency=low
+
+  * Removed bash-ism from init script
+  * Added hint about autostart to README.Debian
+  * Improved description a bit (Closes: #380162)
+
+ -- Philipp Hug <debian@hug.cx>  Mon, 21 Aug 2006 19:55:40 +0200
+
+open-iscsi (1.0.485-3) unstable; urgency=low
+
+  * Added description to man page
+
+ -- Philipp Hug <debian@hug.cx>  Sun, 23 Jul 2006 19:08:48 +0200
+
+open-iscsi (1.0.485-2) unstable; urgency=low
+
+  * Moved package to unstable
+  * Removed unused section in control
+  * Updated Standards-Version to 3.7.2.1
+  * Added INIT INFO section to init script to make it lsb compliant
+  * Removed unusued lines in rules
+  * Added man page for iscsi-iname
+
+ -- Philipp Hug <debian@hug.cx>  Sat, 22 Jul 2006 19:45:35 +0200
+
+open-iscsi (1.0.485-1) experimental; urgency=low
+
+  * Install iscsid.conf in /etc/iscsid.conf instead of /etc/iscsid.conf-example
+
+ -- Philipp Hug <debian@hug.cx>  Tue, 27 Jun 2006 14:42:20 +0200
+
+open-iscsi (1.0.485-0unreleased) dapper; urgency=low
+
+  * Initial Release (closes: Bug#333695)
+  * Updated init script
+  * Automatically generate iscsi initiator name
+  * Use Debian specific initator name prefix
+  * Put database into /var/lib/open-iscsi
+
+ -- Philipp Hug <debian@hug.cx>  Mon,  6 Mar 2006 19:20:17 +0000
 
--- open-iscsi-2.0.865.orig/debian/copyright
+++ open-iscsi-2.0.865/debian/copyright
@@ -1,9 +1,11 @@
-This package was debianized by Chad Tindel <chad.tindel@hp.com> on
-Mon, 30 May 2005 15:17:53 -0600.
+This package was debianized by Philipp Hug <debian@hug.cx> on
+Tue, 07 Mar 2005 01:22:53 +0100.
 
-It was downloaded from http://sourceforge.net/projects/linux-iscsi
+Based on linux-iscsi debianization from Chad Tindel <chad.tindel@hp.com>
 
-Copyright Holder: Dmitry Yusupov <dima@neterion.com>
+It was downloaded from http://www.open-iscsi.org/
+
+Copyright Holder: Dmitry Yusupov <dima@neterion.com> and others.
 
 License:
 
--- open-iscsi-2.0.865.orig/debian/open-iscsi.init
+++ open-iscsi-2.0.865/debian/open-iscsi.init
@@ -0,0 +1,155 @@
+#! /bin/sh
+### BEGIN INIT INFO
+# Provides:          iscsi
+# Required-Start:    $network
+# Required-Stop:
+# Default-Start:     3 5
+# Default-Stop:
+# Short-Description: Starts and stops the iSCSI initiator services and logins to default targets
+### END INIT INFO
+
+PATH=/sbin:/bin:/usr/sbin:/usr/bin
+DAEMON=/usr/sbin/iscsid
+ADM=/usr/bin/iscsiadm
+PIDFILE=/var/run/iscsid.pid
+
+[ -x "$DAEMON" ] || exit 0
+
+. /lib/lsb/init-functions
+
+if [ ! -d /sys/class/ ]; then
+  log_failure_msg "iSCSI requires a mounted sysfs, not started."
+  exit 1
+fi
+
+nodestartup_re='s/^node\.conn\[0]\.startup[ 	]*=[ 	]*//p'
+
+RETVAL=0
+
+sanitychecks() {
+        # Do sanity checks before we start..
+        if [ ! -e $CONFIGFILE ]; then
+                echo
+                echo "Error: configuration file $CONFIGFILE is missing!"
+                echo "The iSCSI driver has not been correctly installed and cannot start."
+                echo
+                exit 1
+        elif [ -s $PIDFILE ] && kill -0 `head -1 $PIDFILE` >/dev/null ; then
+		echo
+                echo "iSCSI daemon already running"
+                echo
+                exit 1
+        fi
+
+        if [ ! -f /etc/iscsi/initiatorname.iscsi ] ; then
+            echo
+            echo "Error: InitiatorName file /etc/initiatorname.iscsi is missing!"
+            echo "The iSCSI driver has not been correctly installed and cannot start."
+            echo
+            exit 1
+        fi
+
+        # see if we need to generate a unique iSCSI InitiatorName
+        # this should only happen if the
+        if grep -q "^GenerateName=yes" /etc/iscsi/initiatorname.iscsi ; then
+            if [ ! -x /usr/sbin/iscsi-iname ] ; then
+                echo "Error: /usr/sbin/iscsi-iname does not exist, driver was not successfully installed"
+                exit 1;
+            fi
+            # Generate a unique InitiatorName and save it
+            INAME=`/usr/sbin/iscsi-iname -p iqn.1993-08.org.debian:01`
+            if [ "$INAME" != "" ] ; then
+                echo "## DO NOT EDIT OR REMOVE THIS FILE!" > /etc/iscsi/initiatorname.iscsi
+                echo "## If you remove this file, the iSCSI daemon will not start." >> /etc/iscsi/initiatorname.iscsi
+                echo "## If you change the InitiatorName, existing access control lists" >> /etc/iscsi/initiatorname.iscsi
+                echo "## may reject this initiator.  The InitiatorName must be unique">> /etc/iscsi/initiatorname.iscsi
+                echo "## for each iSCSI initiator.  Do NOT duplicate iSCSI InitiatorNames." >> /etc/iscsi/initiatorname.iscsi
+                printf "InitiatorName=$INAME\n"  >> /etc/iscsi/initiatorname.iscsi
+                chmod 600 /etc/iscsi/initiatorname.iscsi
+            else
+                echo "Error: failed to generate an iSCSI InitiatorName, driver cannot start."
+                echo
+                exit 1;
+            fi
+        fi
+
+        # make sure there is a valid InitiatorName for the driver
+        if ! grep -q "^InitiatorName=[^ \t\n]" /etc/iscsi/initiatorname.iscsi ; then
+            echo
+            echo "Error: /etc/iscsi/initiatorname.iscsi does not contain a valid InitiatorName."
+            echo "The iSCSI driver has not been correctly installed and cannot start."
+            echo
+            exit 1
+        fi
+}
+
+start() {
+	log_daemon_msg "Starting iSCSI initiator service" "iscsid"
+	sanitychecks
+	modprobe -q iscsi_tcp 2>/dev/null || :
+	modprobe -q ib_iser 2>/dev/null || :
+	start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON
+	RETVAL=$?
+	log_end_msg $RETVAL
+	starttargets
+}
+
+starttargets() {
+	log_daemon_msg "Setting up iSCSI targets"
+	echo
+	$ADM -m node --loginall=automatic
+	log_end_msg 0
+}
+
+stoptargets() {
+	log_daemon_msg "Disconnecting iSCSI targets"
+	sync
+	# only logout if daemon is running, iscsiadm hangs otherwise
+        if [ -s $PIDFILE ] && kill -0 `head -1 $PIDFILE` >/dev/null ; then
+		$ADM -m node --logoutall=all
+        fi
+
+	log_end_msg 0
+}
+
+stop() {
+	stoptargets
+	log_daemon_msg "Stopping iSCSI initiator service"
+	start-stop-daemon --stop --quiet --pidfile $PIDFILE --signal KILL --exec $DAEMON
+	rm -f $PIDFILE
+	modprobe -r ib_iser 2>/dev/null
+	modprobe -r iscsi_tcp 2>/dev/null
+	log_end_msg 0
+}
+
+restart() {
+	stop
+	start
+}
+
+restarttargets() {
+	stoptargets
+	starttargets
+}
+
+status() {
+	#XXX FIXME: what to do here?
+	#status iscsid
+	# list active sessions
+	echo Current active iSCSI sessions:
+	$ADM -m session
+}
+
+case "$1" in
+	start|starttargets|stop|stoptargets|restart|restarttargets|status)
+		$1
+		;;
+	force-reload)
+		restart
+		;;
+	*)
+		echo "Usage: $0 {start|stop|restart|force-reload|status}"
+		exit 1
+		;;
+esac
+exit $RETVAL
--- open-iscsi-2.0.865.orig/debian/iscsi-iname.8
+++ open-iscsi-2.0.865/debian/iscsi-iname.8
@@ -0,0 +1,19 @@
+.TH "iscsi-iname" "8" "July 2006" "open-iscsi" "Debian Distribution" 
+.PP 
+.SH "NAME" 
+iscsi-iname \- iSCSI node name generation utility
+.PP 
+.SH "SYNOPSIS" 
+.PP 
+iscsi-iname
+.PP 
+.SH "DESCRIPTION"
+.PP
+iscsi-iname generates a unique iSCSI node name on every invocation
+.PP
+.SH "BUGS" 
+Contact Philipp Hug <debian@hug.cx>, for any bugs with this program
+.PP 
+.SH "AUTHOR" 
+This manpage was written by Philipp Hug <debian@hug.cx>, 2006
+.PP 
--- open-iscsi-2.0.865.orig/debian/control
+++ open-iscsi-2.0.865/debian/control
@@ -1,27 +1,23 @@
-Source: linux-iscsi
+Source: open-iscsi
 Section: net
 Priority: optional
-Maintainer: Chad Tindel <chad.tindel@hp.com>
-Build-Depends: debhelper (>= 4.0.0), libdb4.3, libdb4.3-dev
-Standards-Version: 3.6.1
+Maintainer: Philipp Hug <debian@hug.cx>
+Build-Depends: debhelper (>= 4.0.0), bzip2
+Standards-Version: 3.7.2.1
 
-Package: linux-iscsi
+Package: open-iscsi
 Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, linux-iscsi-modules
-Description: high performance, transport independent implementation of RFC3720. 
- linux-iscsi is a high performance, transport independent, implementation of 
- RFC3720.
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: High performance, transport independent iSCSI implementation
+ iSCSI is a network protocol standard that allows the use of the SCSI protocol
+ over TCP/IP networks.  This implementation follows RFC3720.
+ .
+  Homepage: http://www.open-iscsi.org/
 
-#Package: linux-iscsi
+#Package: linux-iscsi-modules-source
 #Architecture: all
-#Description: Documentation for linux-iscsi
-#linux-iscsi is a high performance, transport independent, implementation of 
-#RFC3720.
-
-Package: linux-iscsi-modules-source
-Architecture: all
-Depends: ${shlibs:Depends}, ${misc:Depends}, module-assistant, debhelper (>= 4.0.0), bzip2
-Description: Source Code for the Linux iSCSI Kernel Modules
- Along with make-kpkg, this package maybe used to build a linux-iscsi-modules 
- package for a kernel-image package.
+#Depends: ${shlibs:Depends}, ${misc:Depends}, module-assistant, debhelper (>= 4.0.0), bzip2
+#Description: Source Code for the Linux iSCSI Kernel Modules
+# Along with make-kpkg, this package maybe used to build a linux-iscsi-modules 
+# package for a kernel-image package.
 
