Package: src:sg3-utils

Hi Ritesh,

Please consider this patch instead.

I noticed the previous one has bug in the initramfs hook.

If there's nothing in initramfs's /usr/bin, sg_inq is copied
as /usr/bin (file), rather than /usr/bin/sq_inq;

This breaks multipath discovery because the ID_SCSI udev properties
(from sg_inq --export) doesn't show up.

        $ interdiff sg3-utils_udev-rules.debdiff sg3-utils_udev-rules_v2.debdiff
        [snip]
        @@ -27,7 +27,7 @@
           done
         }
        
        -copy_exec /usr/bin/sg_inq /usr/bin
        +copy_exec /usr/bin/sg_inq
        
         add_udev_rules
        
Thanks!

--
Mauricio Faria de Oliveira
IBM Linux Technology Center
diff -Nru sg3-utils-1.39/debian/changelog sg3-utils-1.39/debian/changelog
--- sg3-utils-1.39/debian/changelog     2014-09-29 05:01:40.000000000 -0300
+++ sg3-utils-1.39/debian/changelog     2015-04-12 19:49:18.000000000 -0300
@@ -1,3 +1,14 @@
+sg3-utils (1.39-1udevrules1) UNRELEASED; urgency=medium
+
+  * sg3-utils-udev (new binary package):  provide the udev rules for SCSI-ID
+    mappings and symlinks at boot time for multipath-tools:
+    - debian/control: add sg3-utils-udev
+    - debian/rules: build it with override_dh_{install,clean}
+    - debian/initramfs/hooks: add_udev_rules() and copy_exec() 'sg_inq' to 
initramfs
+    - debian/sg3-utils-udev.post{inst,rm}: call update-initramfs
+
+ -- Mauricio Faria de Oliveira <mauri...@linux.vnet.ibm.com>  Sun, 12 Apr 2015 
19:22:02 -0300
+
 sg3-utils (1.39-1) unstable; urgency=medium
 
   * [a3a22b2] Imported Upstream version 1.39
diff -Nru sg3-utils-1.39/debian/control sg3-utils-1.39/debian/control
--- sg3-utils-1.39/debian/control       2014-04-03 03:37:10.000000000 -0300
+++ sg3-utils-1.39/debian/control       2015-04-12 19:21:27.000000000 -0300
@@ -62,3 +62,18 @@
  Developer files (i.e. headers and a static library) which are associated with
  the utilities in the sg3-utils package.
 
+Package: sg3-utils-udev
+Architecture: all
+Depends: sg3-utils, initramfs-tools
+Description: utilities for devices using the SCSI command set (udev rules)
+ Most OSes have SCSI pass-through interfaces that enable user space programs
+ to send SCSI commands to a device and fetch the response. With SCSI to ATA
+ Translation (SAT) many ATA disks now can process SCSI commands. Typically
+ each utility in this package implements one SCSI command. See the draft
+ standards at www.t10.org for SCSI command definitions plus SAT. ATA
+ commands are defined in the draft standards at www.t13.org . For a mapping
+ between supported SCSI and ATA commands and utility names in this package
+ see the COVERAGE file.
+ .
+ udev rules which are associated with the utilities in the sg3-utils package.
+
diff -Nru sg3-utils-1.39/debian/initramfs/hooks 
sg3-utils-1.39/debian/initramfs/hooks
--- sg3-utils-1.39/debian/initramfs/hooks       1969-12-31 21:00:00.000000000 
-0300
+++ sg3-utils-1.39/debian/initramfs/hooks       2015-04-12 19:21:27.000000000 
-0300
@@ -0,0 +1,33 @@
+#!/bin/sh
+# (based on multipath-tools-boot)
+
+PREREQS="udev"
+
+prereqs() { echo "$PREREQS"; }
+
+case $1 in
+prereqs)
+       prereqs
+       exit 0
+       ;;
+esac
+
+if [ ! -x /usr/bin/sg_inq ]; then
+       exit 0
+fi
+
+. /usr/share/initramfs-tools/hook-functions
+
+add_udev_rules()
+{
+  for rules in 55-scsi-sg3_id.rules 58-scsi-sg3_symlink.rules; do
+    if [ -e /lib/udev/rules.d/$rules ]; then
+      cp -p /lib/udev/rules.d/$rules $DESTDIR/lib/udev/rules.d/
+    fi
+  done
+}
+
+copy_exec /usr/bin/sg_inq
+
+add_udev_rules
+
diff -Nru sg3-utils-1.39/debian/rules sg3-utils-1.39/debian/rules
--- sg3-utils-1.39/debian/rules 2014-04-03 03:37:10.000000000 -0300
+++ sg3-utils-1.39/debian/rules 2015-04-12 19:21:27.000000000 -0300
@@ -16,10 +16,32 @@
 DEB_HOST_ARCH_OS := $(shell dpkg-architecture -qDEB_HOST_ARCH_OS 2>/dev/null)
 PKG_VERS=$(shell dpkg-parsechangelog | sed -rne 's,^Version: ([^-]+).*,\1,p')
 
+INITRAMFS=$(CURDIR)/debian/sg3-utils-udev/usr/share/initramfs-tools/
+
 get-orig-source:
        uscan --force-download --rename --repack --download-version=$(PKG_VERS) 
--destdir=.
 
 %:
        dh "$@" --with autoreconf
 
+override_dh_install:
+       dh_testdir
+       dh_install
+
+       [ ! -f scripts/55-scsi-sg3_id.rules ] || cp 
scripts/55-scsi-sg3_id.rules debian/sg3-utils-udev.scsi-sg3_id.udev
+       [ ! -f scripts/58-scsi-sg3_symlink.rules ] || cp 
scripts/58-scsi-sg3_symlink.rules debian/sg3-utils-udev.scsi-sg3_symlink.udev
+
+       dh_installudev -psg3-utils-udev --priority=55 --name=scsi-sg3_id 
+       dh_installudev -psg3-utils-udev --priority=58 --name=scsi-sg3_symlink 
+
+       install -D -m 755 debian/initramfs/hooks $(INITRAMFS)/hooks/sg3-utils
+
+override_dh_clean:
+       dh_testdir
+
+       rm -f debian/sg3-utils-udev.scsi-sg3_id.udev
+       rm -f debian/sg3-utils-udev.scsi-sg3_symlink.udev
+
+       dh_clean
+
 .PHONY: get-orig-source
diff -Nru sg3-utils-1.39/debian/sg3-utils-udev.postinst 
sg3-utils-1.39/debian/sg3-utils-udev.postinst
--- sg3-utils-1.39/debian/sg3-utils-udev.postinst       1969-12-31 
21:00:00.000000000 -0300
+++ sg3-utils-1.39/debian/sg3-utils-udev.postinst       2015-04-12 
19:21:27.000000000 -0300
@@ -0,0 +1,35 @@
+#!/bin/sh
+# postinst script for sg3-utils-udev
+# (based on multipath-tools-boot)
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# Source debconf library.
+. /usr/share/debconf/confmodule
+
+case "$1" in
+    configure)
+       if [ -x /usr/sbin/update-initramfs -a -e 
/etc/initramfs-tools/initramfs.conf ]; then
+               update-initramfs -u
+       fi
+    ;;
+
+    abort-upgrade|abort-remove|abort-deconfigure)
+    ;;
+
+    *)
+        echo "postinst called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
+
+
diff -Nru sg3-utils-1.39/debian/sg3-utils-udev.postrm 
sg3-utils-1.39/debian/sg3-utils-udev.postrm
--- sg3-utils-1.39/debian/sg3-utils-udev.postrm 1969-12-31 21:00:00.000000000 
-0300
+++ sg3-utils-1.39/debian/sg3-utils-udev.postrm 2015-04-12 19:21:27.000000000 
-0300
@@ -0,0 +1,46 @@
+#!/bin/sh
+# postrm script for sg3-utils-udev
+# (based on multipath-tools-boot)
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <postrm> `remove'
+#        * <postrm> `purge'
+#        * <old-postrm> `upgrade' <new-version>
+#        * <new-postrm> `failed-upgrade' <old-version>
+#        * <new-postrm> `abort-install'
+#        * <new-postrm> `abort-install' <old-version>
+#        * <new-postrm> `abort-upgrade' <old-version>
+#        * <disappearer's-postrm> `disappear' <overwriter>
+#          <overwriter-version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+case "$1" in
+    remove)
+       if [ -x /usr/sbin/update-initramfs -a -e 
/etc/initramfs-tools/initramfs.conf ]; then
+               update-initramfs -u
+       fi
+    ;;
+
+    purge|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
+    ;;
+
+    *)
+        echo "postrm called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
+
+

Reply via email to