Strange, the wrapper script didn't make it in to v3 of the patch.  Here is v4.
diff -urN btrfs-progs-xnox/debian/btrfs-progs.examples btrfs-progs-sten/debian/btrfs-progs.examples
--- btrfs-progs-xnox/debian/btrfs-progs.examples	1969-12-31 19:00:00.000000000 -0500
+++ btrfs-progs-sten/debian/btrfs-progs.examples	2016-05-28 20:07:20.909766909 -0400
@@ -0,0 +1 @@
+debian/local/btrfs-convert.hook
diff -urN btrfs-progs-xnox/debian/local/btrfs-convert.hook btrfs-progs-sten/debian/local/btrfs-convert.hook
--- btrfs-progs-xnox/debian/local/btrfs-convert.hook	1969-12-31 19:00:00.000000000 -0500
+++ btrfs-progs-sten/debian/local/btrfs-convert.hook	2016-05-28 20:07:55.477726627 -0400
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+. /usr/share/initramfs-tools/hook-functions
+
+if command -v /bin/btrfs-convert >/dev/null 2>&1; then
+    copy_exec /bin/btrfs-convert bin/btrfs-convert
+    copy_exec /bin/btrfs-convert.real bin/btrfs-convert.real
+fi
diff -urN btrfs-progs-xnox/debian/local/btrfs-convert.wrapper btrfs-progs-sten/debian/local/btrfs-convert.wrapper
--- btrfs-progs-xnox/debian/local/btrfs-convert.wrapper	1969-12-31 19:00:00.000000000 -0500
+++ btrfs-progs-sten/debian/local/btrfs-convert.wrapper	2016-05-28 20:08:19.741698356 -0400
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+cat << !EOF!
+********  WARNING ********
+Btrfs-convert is known to fail. An upstream rewrite of the
+utility is currently in progress. At this point in time,
+btrfs-convert is provided for experimental purposes only.
+
+Please do not convert filesystems filled with data you value.
+Expect that you will need to restore from backup.  Beware,
+the dataloss may not be immediately apparent, and may take
+some time to manifest.
+
+If you choose to experiment with btrfs-convert, please do so
+with the willingness to work with linux-bt...@vger.kernel.org
+
+!EOF!
+echo -n 'Proceed (Yes/No)?: '
+
+while true; do
+    read -r choice
+    case "$choice" in
+        yes | y | Yes | YES )
+            exec /bin/btrfs-convert.real "$@"
+            exit $?
+            ;;
+        no | n | No | NO )
+            echo "Thank you for making the safe choice"
+            exit 0
+            ;;
+        * )
+            echo -n "Please answer Yes or No: "
+            ;;
+    esac
+done
diff -urN btrfs-progs-xnox/debian/rules btrfs-progs-sten/debian/rules
--- btrfs-progs-xnox/debian/rules	2016-05-28 19:46:20.907183008 -0400
+++ btrfs-progs-sten/debian/rules	2016-05-28 20:07:20.909766909 -0400
@@ -28,6 +28,11 @@
 	install -D -m 0755 debian/local/btrfs.hook debian/btrfs-progs/usr/share/initramfs-tools/hooks/btrfs
 	install -D -m 0755 debian/local/btrfs.local-premount debian/btrfs-progs/usr/share/initramfs-tools/scripts/local-premount/btrfs
 
+# divert btrfs-convert to btrfs-convert.real
+# and use a wrapper script to notify it is dangerous
+	mv debian/btrfs-progs/bin/btrfs-convert debian/btrfs-progs/bin/btrfs-convert.real
+	install -D -m 0755 debian/local/btrfs-convert.wrapper debian/btrfs-progs/bin/btrfs-convert
+
 # Needs autopkgtest
 override_dh_auto_test:
 

Reply via email to