Bug#969340: nvme-cli: generate /etc/nvme/host* files at install time, not build time

2020-08-31 Thread Dan Streetman
v2 debdiff, with slight adjustment that may be better
diff -Nru --exclude package.bash-completion --exclude changelog --exclude control nvme-cli-1.12/debian/nvme-cli.postinst nvme-cli-1.12/debian/nvme-cli.postinst
--- nvme-cli-1.12/debian/nvme-cli.postinst	1969-12-31 19:00:00.0 -0500
+++ nvme-cli-1.12/debian/nvme-cli.postinst	2020-08-31 15:41:46.0 -0400
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+set -e
+
+if [ "$1" = "configure" ]; then
+if [ ! -s /etc/nvme/hostnqn ]; then
+nvme gen-hostnqn > /etc/nvme/hostnqn
+fi
+
+if [ ! -s /etc/nvme/hostid ]; then
+uuidgen > /etc/nvme/hostid
+fi
+fi
+
+#DEBHELPER#
diff -Nru --exclude package.bash-completion --exclude changelog --exclude control nvme-cli-1.12/debian/rules nvme-cli-1.12/debian/rules
--- nvme-cli-1.12/debian/rules	2018-08-06 12:12:32.0 -0400
+++ nvme-cli-1.12/debian/rules	2020-08-31 14:11:23.0 -0400
@@ -7,6 +7,10 @@
 
 override_dh_auto_install:
 	dh_auto_install -- PREFIX=/usr
+	# Remove build-time unique id files, instead these will be
+	# generated by the postinst script
+	rm -f debian/nvme-cli/etc/nvme/hostid
+	rm -f debian/nvme-cli/etc/nvme/hostnqn
 
 override_dh_auto_test:
 	# Overriding auto test, since the tests require that the build machine


Bug#969340: nvme-cli: generate /etc/nvme/host* files at install time, not build time

2020-08-31 Thread Dan Streetman
Package: nvme-cli
Version: 1.12-1
Severity: normal
Tags: patch
User: ubuntu-de...@lists.ubuntu.com
Usertags: origin-ubuntu groovy ubuntu-patch

Dear Maintainer,

The nvme-cli package currently generates the /etc/nvme/hostnqn and
/etc/nvme/hostid files during the build, which results in the content
of the files being identical for all installed systems. Since these
files are supposed to contain ids unique to the installed system,
having them included in the binary package is incorrect, and instead
they should be generated during package install.

This patch removes the files from the binary package, and adds a postinst
to generate the files (if needed).

Note that this also requires the patch from:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=969183
because without that patch, the build doesn't include uuid-dev, and the
nvme 'gen-hostnqn' command is not able to be built.

This is also tracked in Ubuntu bug:
https://bugs.launchpad.net/ubuntu/+source/nvme-cli/+bug/1867366

Thanks for considering the patch.
diff -Nru nvme-cli-1.12/debian/nvme-cli.postinst 
nvme-cli-1.12/debian/nvme-cli.postinst
--- nvme-cli-1.12/debian/nvme-cli.postinst  1969-12-31 19:00:00.0 
-0500
+++ nvme-cli-1.12/debian/nvme-cli.postinst  2020-08-31 14:11:37.0 
-0400
@@ -0,0 +1,11 @@
+#!/bin/sh -e
+
+if [ ! -s /etc/nvme/hostnqn ]; then
+nvme gen-hostnqn > /etc/nvme/hostnqn
+fi
+
+if [ ! -s /etc/nvme/hostid ]; then
+uuidgen > /etc/nvme/hostid
+fi
+
+exit 0
diff -Nru nvme-cli-1.12/debian/package.bash-completion 
nvme-cli-1.12/debian/package.bash-completion
--- nvme-cli-1.12/debian/package.bash-completion2017-02-06 
08:20:45.0 -0500
+++ nvme-cli-1.12/debian/package.bash-completion1969-12-31 
19:00:00.0 -0500
@@ -1 +0,0 @@
-bash_completion.d/nvme
diff -Nru nvme-cli-1.12/debian/rules nvme-cli-1.12/debian/rules
--- nvme-cli-1.12/debian/rules  2018-08-06 12:12:32.0 -0400
+++ nvme-cli-1.12/debian/rules  2020-08-31 14:11:23.0 -0400
@@ -7,6 +7,10 @@
 
 override_dh_auto_install:
dh_auto_install -- PREFIX=/usr
+   # Remove build-time unique id files, instead these will be
+   # generated by the postinst script
+   rm -f debian/nvme-cli/etc/nvme/hostid
+   rm -f debian/nvme-cli/etc/nvme/hostnqn
 
 override_dh_auto_test:
# Overriding auto test, since the tests require that the build machine