Control: tag -1 +patch

attached.

-- 
Best,
Lumin
diff --git a/debian/changelog b/debian/changelog
index 57a60c1..dd55da6 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+zfs-linux (0.6.5.7-2.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Configure "zfs_arc_max" in /etc/modprobe.d/zfs.conf . (Closes: #837049)
+
+ -- Zhou Mo <cdlumin...@gmail.com>  Sun, 11 Sep 2016 08:23:02 +0000
+
 zfs-linux (0.6.5.7-2) unstable; urgency=medium
 
   [ Aron Xu ]
diff --git a/debian/zfs-dkms.config b/debian/zfs-dkms.config
index ad7e160..1422e10 100644
--- a/debian/zfs-dkms.config
+++ b/debian/zfs-dkms.config
@@ -1,7 +1,20 @@
 #!/bin/sh
-
 set -e
 
+ZFSCONF=/etc/modprobe.d/zfs.conf
+# helper funtion for scanning zfs.conf for zfs_arc_max config.
+scan_for_present_config () {
+  local zfs_arc_max
+  if ! test -e $ZFSCONF; then return; fi
+  for param in `awk '/^options .*zfs .*zfs_arc_max/{print}' $ZFSCONF`; do
+    case $param in
+      (zfs_arc_max=*) zfs_arc_max=${param#zfs_arc_max=} ;;
+    esac
+  done
+  echo $zfs_arc_max
+}
+ZFS_ARC_MAX_PRESENT=`scan_for_present_config`
+
 # Source debconf library
 . /usr/share/debconf/confmodule
 
@@ -26,6 +39,29 @@ if [ $kernelbits != 64 ]; then
 		db_input critical zfs-dkms/stop-build-for-unknown-kernel || true
 		db_go || true
 	fi
+else
+  if ! test -z $ZFS_ARC_MAX_PRESENT; then
+    # detected existing zfs_arc_max config in zfs.conf
+    db_set zfs-dkms/zfs_arc_max_config custom
+    db_set zfs-dkms/zfs_arc_max_value $ZFS_ARC_MAX_PRESENT
+  else
+    # found no zfs_arc_max in zfs.conf
+    db_input high zfs-dkms/zfs_arc_max_config || true
+    db_go || true
+    db_get zfs-dkms/zfs_arc_max_config
+    if test "$RET" = "custom"; then
+      while true; do
+        db_input high zfs-dkms/zfs_arc_max_value || true
+        db_go || true
+        db_get zfs-dkms/zfs_arc_max_value
+        if test 0 -le $RET 2>/dev/null; then break; fi # break until valid
+      done
+    elif test "$RET" = "nolimit"; then
+      db_set zfs-dkms/zfs_arc_max_value 0
+    elif test "$RET" = "recommend"; then
+      db_set zfs-dkms/zfs_arc_max_value 536870912 # FIXME: what is recommended?
+    fi
+  fi
 fi
 
 #DEBHELPER#
diff --git a/debian/zfs-dkms.postinst b/debian/zfs-dkms.postinst
index cb87e1c..cc88fa4 100644
--- a/debian/zfs-dkms.postinst
+++ b/debian/zfs-dkms.postinst
@@ -1,6 +1,21 @@
 #!/bin/sh
 set -e
 
+ZFSCONF=/etc/modprobe.d/zfs.conf
+# helper function for scanning zfs.conf for zfs_arc_max config.
+scan_for_present_config () {
+  local zfs_arc_max
+  if ! test -e $ZFSCONF; then return; fi
+  for param in `awk '/^options .*zfs .*zfs_arc_max/{print}' $ZFSCONF`; do
+    case $param in
+      (zfs_arc_max=*) zfs_arc_max=${param#zfs_arc_max=} ;;
+    esac
+  done
+  echo $zfs_arc_max
+}
+ZFS_ARC_MAX_PRESENT=`scan_for_present_config`
+
+
 # Source debconf library (see dh_installdebconf(1) and #106070 #626312)
 . /usr/share/debconf/confmodule
 
@@ -44,6 +59,23 @@ fi
 
 case $1 in
 	(configure)
+
+        db_get zfs-dkms/zfs_arc_max_config
+        zfs_arc_max_config=$RET
+        db_get zfs-dkms/zfs_arc_max_value
+        zfs_arc_max_value=$RET
+      
+        if ! test -e $ZFSCONF; then
+          # create zfs.conf, append setting on zfs.conf
+          echo "options zfs zfs_arc_max=$zfs_arc_max_value" > $ZFSCONF
+          zfsconf_sha1sum=`echo "options zfs zfs_arc_max=$zfs_arc_max_value" | sha1sum | awk '{print $1}'`
+          # zfsconf_sha1sum is used by postrm to decide whether zfs.conf should be removed
+          db_set zfs-dkms/zfsconf_sha1sum $zfsconf_sha1sum
+        else
+          # zfs.conf already exists, so preventing postrm from removing it.
+          db_set zfs-dkms/zfsconf_sha1sum ""
+        fi
+
 		if [ -x /usr/share/update-notifier/notify-reboot-required ]; then
 			/usr/share/update-notifier/notify-reboot-required
 		fi
diff --git a/debian/zfs-dkms.templates b/debian/zfs-dkms.templates
index 475fb66..f35ae44 100644
--- a/debian/zfs-dkms.templates
+++ b/debian/zfs-dkms.templates
@@ -37,3 +37,21 @@ _Description: Licenses of ZFS and Linux are incompatible
  You are going to build ZFS using DKMS in which way they are not going to be built
  into one monolithic binary. Please be aware that distributing both of the binaries
  in the same media (disk images, virtual appliances, etc) may lead to infringing.
+
+Template: zfs-dkms/zfs_arc_max_config
+Type: select
+Choices: nolimit, recommend, custom
+Default: nolimit
+_Description: Please select your prefered zfs_arc_max configuration:
+ FIXME config prompt
+
+Template: zfs-dkms/zfs_arc_max_value
+Type: string
+Default: 0
+_Description: Please input your prefered zfs_arc_max value:
+ FIXME value prompt
+
+Template: zfs-dkms/zfsconf_sha1sum
+Type: string
+Default:
+_Description: sha1sum

Reply via email to