]> git.proxmox.com Git - mirror_spl-debian.git/commitdiff
Deal with /etc/hostid in postinst of spl package
authorAron Xu <aronxu@gnome.org>
Tue, 27 Sep 2016 17:52:29 +0000 (01:52 +0800)
committerAron Xu <aronxu@gnome.org>
Tue, 27 Sep 2016 18:16:32 +0000 (02:16 +0800)
debian/spl-dkms.postinst [deleted file]
debian/spl-modules-_KVERS_.postinst.in
debian/spl.postinst [new file with mode: 0644]

diff --git a/debian/spl-dkms.postinst b/debian/spl-dkms.postinst
deleted file mode 100644 (file)
index 10683a4..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/bin/sh
-set -e
-# The hostname and hostid of the last system to access a ZFS pool are stored in
-# the ZFS pool itself.  A pool is foreign if, during `zpool import`, the
-# current hostname and hostid are different than the stored values thereof.
-#
-# The hostid on Solaris is intrinsic, but is not on Linux (see #595790), so the
-# spl kernel module invokes /usr/bin/hostid from the userland in its initialization
-# routine.
-#
-# /usr/bin/hostid will return the 4 first bytes of the file /etc/hostid.
-# If this file is not present or contains less than 4 bytes, then /usr/bin/hostid
-# will return the bytes of the IP address of $(hostname) flipped, or zero if
-# such IP couldn't be obtained
-#
-# This means that things like a DHCP lease change can affect the hostid.
-#
-# Therefore the only way of having a stable hostid is to define it on /etc/hostid.
-# This postinst helper will check if we already have the hostid stabilized by
-# checking the existence of the file /etc/hostid to be 4 bytes at least.
-# If this file don't already exists on our system or has less than 4 bytes, then
-# we will stabilize our current hostid by writing its value to /etc/hostid
-
-if [ ! -f /etc/hostid ] || [ $(stat -c %s /etc/hostid) -lt 4 ] ; then
-
-       # Write our current hostid to /etc/hostid
-       HOSTID=$(hostid)
-       AA=$(echo $HOSTID | cut -b 1,2)
-       BB=$(echo $HOSTID | cut -b 3,4)
-       CC=$(echo $HOSTID | cut -b 5,6)
-       DD=$(echo $HOSTID | cut -b 7,8)
-
-       # Big Endian
-       if echo | gcc -E -dM - | grep -q "__BYTE_ORDER__.*__ORDER_BIG_ENDIAN__"; then
-               # Invoke the printf from coreutils. shell builtin lacks the byte format.
-               /usr/bin/printf "\x$AA\x$BB\x$CC\x$DD" >/etc/hostid
-       else
-       # Little Endian
-               /usr/bin/printf "\x$DD\x$CC\x$BB\x$AA" >/etc/hostid
-       fi
-fi
-
-#DEBHELPER#
index a795753c5e72b058a9921336cf646788242d5df5..4e1baa5b934df2dbb82eb7626edf6245c63ad786 100644 (file)
@@ -1,47 +1,7 @@
 #!/bin/sh
 set -e
-# The hostname and hostid of the last system to access a ZFS pool are stored in
-# the ZFS pool itself.  A pool is foreign if, during `zpool import`, the
-# current hostname and hostid are different than the stored values thereof.
-#
-# The hostid on Solaris is intrinsic, but is not on Linux (see #595790), so the
-# spl kernel module invokes /usr/bin/hostid from the userland in its initialization
-# routine.
-#
-# /usr/bin/hostid will return the 4 first bytes of the file /etc/hostid.
-# If this file is not present or contains less than 4 bytes, then /usr/bin/hostid
-# will return the bytes of the IP address of $(hostname) flipped, or zero if
-# such IP couldn't be obtained
-#
-# This means that things like a DHCP lease change can affect the hostid.
-#
-# Therefore the only way of having a stable hostid is to define it on /etc/hostid.
-# This postinst helper will check if we already have the hostid stabilized by
-# checking the existence of the file /etc/hostid to be 4 bytes at least.
-# If this file don't already exists on our system or has less than 4 bytes, then
-# we will stabilize our current hostid by writing its value to /etc/hostid
 
-# Run depmod first
+# Run depmod after module installation.
 depmod
 
-# Deal with hostid issue as usual
-if [ ! -f /etc/hostid ] || [ $(stat -c %s /etc/hostid) -lt 4 ] ; then
-
-       # Write our current hostid to /etc/hostid
-       HOSTID=$(hostid)
-       AA=$(echo $HOSTID | cut -b 1,2)
-       BB=$(echo $HOSTID | cut -b 3,4)
-       CC=$(echo $HOSTID | cut -b 5,6)
-       DD=$(echo $HOSTID | cut -b 7,8)
-
-       # Big Endian
-       if echo | gcc -E -dM - | grep -q "__BYTE_ORDER__.*__ORDER_BIG_ENDIAN__"; then
-               # Invoke the printf from coreutils. shell builtin lacks the byte format.
-               /usr/bin/printf "\x$AA\x$BB\x$CC\x$DD" >/etc/hostid
-       else
-       # Little Endian
-               /usr/bin/printf "\x$DD\x$CC\x$BB\x$AA" >/etc/hostid
-       fi
-fi
-
 #DEBHELPER#
diff --git a/debian/spl.postinst b/debian/spl.postinst
new file mode 100644 (file)
index 0000000..10683a4
--- /dev/null
@@ -0,0 +1,43 @@
+#!/bin/sh
+set -e
+# The hostname and hostid of the last system to access a ZFS pool are stored in
+# the ZFS pool itself.  A pool is foreign if, during `zpool import`, the
+# current hostname and hostid are different than the stored values thereof.
+#
+# The hostid on Solaris is intrinsic, but is not on Linux (see #595790), so the
+# spl kernel module invokes /usr/bin/hostid from the userland in its initialization
+# routine.
+#
+# /usr/bin/hostid will return the 4 first bytes of the file /etc/hostid.
+# If this file is not present or contains less than 4 bytes, then /usr/bin/hostid
+# will return the bytes of the IP address of $(hostname) flipped, or zero if
+# such IP couldn't be obtained
+#
+# This means that things like a DHCP lease change can affect the hostid.
+#
+# Therefore the only way of having a stable hostid is to define it on /etc/hostid.
+# This postinst helper will check if we already have the hostid stabilized by
+# checking the existence of the file /etc/hostid to be 4 bytes at least.
+# If this file don't already exists on our system or has less than 4 bytes, then
+# we will stabilize our current hostid by writing its value to /etc/hostid
+
+if [ ! -f /etc/hostid ] || [ $(stat -c %s /etc/hostid) -lt 4 ] ; then
+
+       # Write our current hostid to /etc/hostid
+       HOSTID=$(hostid)
+       AA=$(echo $HOSTID | cut -b 1,2)
+       BB=$(echo $HOSTID | cut -b 3,4)
+       CC=$(echo $HOSTID | cut -b 5,6)
+       DD=$(echo $HOSTID | cut -b 7,8)
+
+       # Big Endian
+       if echo | gcc -E -dM - | grep -q "__BYTE_ORDER__.*__ORDER_BIG_ENDIAN__"; then
+               # Invoke the printf from coreutils. shell builtin lacks the byte format.
+               /usr/bin/printf "\x$AA\x$BB\x$CC\x$DD" >/etc/hostid
+       else
+       # Little Endian
+               /usr/bin/printf "\x$DD\x$CC\x$BB\x$AA" >/etc/hostid
+       fi
+fi
+
+#DEBHELPER#