Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] spec, Makefile: add /etc/nvme files to package files
@ 2019-04-24 21:49 Sagi Grimberg
  2019-04-24 21:49 ` [PATCH 2/2] spec, make: Add discovery.conf to the package files list Sagi Grimberg
  2019-04-25 14:59 ` [PATCH 1/2] spec, Makefile: add /etc/nvme files to package files Keith Busch
  0 siblings, 2 replies; 4+ messages in thread
From: Sagi Grimberg @ 2019-04-24 21:49 UTC (permalink / raw)


This way it can automatically be removed upon uninstallation
and we don't need %preun target. Also, this will also allow
to get these files on manual installation from sources.

Also, don't settle on the "file exists" check, use the '-s'
to check that it is not empty as well.

Lastly, in order to have hostnqn and hostid updated upon pkg
install, we have install-spec target that would omit hostnqn and
hostid files, and let the rpm %post do it (otherwise we
use the normal install target).

Signed-off-by: Sagi Grimberg <sagi at grimberg.me>
---
 Makefile     | 16 +++++++++++++++-
 nvme.spec.in | 25 +++++++++----------------
 2 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/Makefile b/Makefile
index 25c65ab09d67..02299c45734f 100644
--- a/Makefile
+++ b/Makefile
@@ -90,7 +90,21 @@ install-zsh-completion:
 	$(INSTALL) -d $(DESTDIR)$(PREFIX)/share/zsh/site-functions
 	$(INSTALL) -m 644 -T ./completions/_nvme $(DESTDIR)$(PREFIX)/share/zsh/site-functions/_nvme
 
-install: install-bin install-man install-bash-completion install-zsh-completion
+install-hostparams:
+	if [ ! -s $(DESTDIR)$(SYSCONFDIR)/nvme/hostnqn ]; then \
+		echo `$(DESTDIR)$(SBINDIR)/nvme gen-hostnqn` > $(DESTDIR)$(SYSCONFDIR)/nvme/hostnqn; \
+	fi
+	if [ ! -s $(DESTDIR)$(SYSCONFDIR)/nvme/hostid ]; then \
+		uuidgen > $(DESTDIR)$(SYSCONFDIR)/nvme/hostid; \
+	fi
+
+install-etc:
+	$(INSTALL) -d $(DESTDIR)$(SYSCONFDIR)/nvme
+	touch $(DESTDIR)$(SYSCONFDIR)/nvme/hostnqn
+	touch $(DESTDIR)$(SYSCONFDIR)/nvme/hostid
+
+install-spec: install-bin install-man install-bash-completion install-zsh-completion install-etc
+install: install-spec install-hostparams
 
 nvme.spec: nvme.spec.in NVME-VERSION-FILE
 	sed -e 's/@@VERSION@@/$(NVME_VERSION)/g' < $< > $@+
diff --git a/nvme.spec.in b/nvme.spec.in
index c16d0ec0645b..147b64a530f8 100644
--- a/nvme.spec.in
+++ b/nvme.spec.in
@@ -22,7 +22,7 @@ make
 
 %install
 rm -rf $RPM_BUILD_ROOT
-make install DESTDIR=%{buildroot} PREFIX=/usr
+make install-spec DESTDIR=%{buildroot} PREFIX=/usr
 
 %files
 %defattr(-,root,root)
@@ -31,30 +31,23 @@ make install DESTDIR=%{buildroot} PREFIX=/usr
 %{_mandir}/man1/nvme*.1*
 %{_datadir}/bash-completion/completions/nvme
 %{_datadir}/zsh/site-functions/_nvme
+%dir %{_sysconfdir}/nvme
+%{_sysconfdir}/nvme/hostnqn
+%{_sysconfdir}/nvme/hostid
 
 %clean
 rm -rf $RPM_BUILD_ROOT
 
 %post
-if [ $1 = 1 ]; then # 1 : This package is being installed for the first time
-	if [ ! -f /etc/nvme/hostnqn ]; then
-		install -D /dev/null /etc/nvme/hostnqn
-		echo $(nvme gen-hostnqn) > /etc/nvme/hostnqn
+if [ $1 -eq 1 ]; then # 1 : This package is being installed for the first time
+	if [ ! -s %{_sysconfdir}/nvme/hostnqn ]; then
+		echo $(nvme gen-hostnqn) > %{_sysconfdir}/nvme/hostnqn
         fi
-        if [ ! -f /etc/nvme/hostid ]; then
-                uuidgen > /etc/nvme/hostid
+        if [ ! -s %{_sysconfdir}/nvme/hostid ]; then
+                uuidgen > %{_sysconfdir}/nvme/hostid
         fi
 fi
 
-%preun
-if [ "$1" = "remove" ]; then
-	if [ -d /etc/nvme ]; then
-		rm -f /etc/nvme/hostnqn
-		if [ ! -n "`ls -A /etc/nvme`" ]; then
-			rm -rf /etc/nvme
-		fi
-	fi
-fi
 %changelog
 * Mon Oct 15 2018 Eyal Ben-David <eyalbe at il.ibm.com> - 1.6.81.g899a-2
 - bash-completion check
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] spec, make: Add discovery.conf to the package files list
  2019-04-24 21:49 [PATCH 1/2] spec, Makefile: add /etc/nvme files to package files Sagi Grimberg
@ 2019-04-24 21:49 ` Sagi Grimberg
  2019-04-25  1:15   ` Minwoo Im
  2019-04-25 14:59 ` [PATCH 1/2] spec, Makefile: add /etc/nvme files to package files Keith Busch
  1 sibling, 1 reply; 4+ messages in thread
From: Sagi Grimberg @ 2019-04-24 21:49 UTC (permalink / raw)


Lets add it as part of the package with a little documentation.

Signed-off-by: Sagi Grimberg <sagi at grimberg.me>
---
 Makefile              | 3 +++
 etc/discovery.conf.in | 4 ++++
 nvme.spec.in          | 1 +
 3 files changed, 8 insertions(+)
 create mode 100644 etc/discovery.conf.in

diff --git a/Makefile b/Makefile
index 02299c45734f..4bfbebbd156a 100644
--- a/Makefile
+++ b/Makefile
@@ -102,6 +102,9 @@ install-etc:
 	$(INSTALL) -d $(DESTDIR)$(SYSCONFDIR)/nvme
 	touch $(DESTDIR)$(SYSCONFDIR)/nvme/hostnqn
 	touch $(DESTDIR)$(SYSCONFDIR)/nvme/hostid
+	if [ ! -f $(DESTDIR)$(SBINDIR)/nvme/discovery.conf ]; then \
+		$(INSTALL) -m 644 -T ./etc/discovery.conf.in $(DESTDIR)$(SYSCONFDIR)/nvme/discovery.conf; \
+	fi
 
 install-spec: install-bin install-man install-bash-completion install-zsh-completion install-etc
 install: install-spec install-hostparams
diff --git a/etc/discovery.conf.in b/etc/discovery.conf.in
new file mode 100644
index 000000000000..14e0d9c3dcbf
--- /dev/null
+++ b/etc/discovery.conf.in
@@ -0,0 +1,4 @@
+# Used for extracting default parameters for discovery
+#
+# Example:
+# --transport=<trtype> --traddr=<traddr> --trsvcid=<trsvcid> --host-traddr=<host-traddr>
diff --git a/nvme.spec.in b/nvme.spec.in
index 147b64a530f8..6934f8fd605b 100644
--- a/nvme.spec.in
+++ b/nvme.spec.in
@@ -34,6 +34,7 @@ make install-spec DESTDIR=%{buildroot} PREFIX=/usr
 %dir %{_sysconfdir}/nvme
 %{_sysconfdir}/nvme/hostnqn
 %{_sysconfdir}/nvme/hostid
+%{_sysconfdir}/nvme/discovery.conf
 
 %clean
 rm -rf $RPM_BUILD_ROOT
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] spec, make: Add discovery.conf to the package files list
  2019-04-24 21:49 ` [PATCH 2/2] spec, make: Add discovery.conf to the package files list Sagi Grimberg
@ 2019-04-25  1:15   ` Minwoo Im
  0 siblings, 0 replies; 4+ messages in thread
From: Minwoo Im @ 2019-04-25  1:15 UTC (permalink / raw)


Looks good to me.

Reviewed-by: Minwoo Im <minwoo.im.dev at gmail.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] spec, Makefile: add /etc/nvme files to package files
  2019-04-24 21:49 [PATCH 1/2] spec, Makefile: add /etc/nvme files to package files Sagi Grimberg
  2019-04-24 21:49 ` [PATCH 2/2] spec, make: Add discovery.conf to the package files list Sagi Grimberg
@ 2019-04-25 14:59 ` Keith Busch
  1 sibling, 0 replies; 4+ messages in thread
From: Keith Busch @ 2019-04-25 14:59 UTC (permalink / raw)


On Wed, Apr 24, 2019@02:49:41PM -0700, Sagi Grimberg wrote:
> This way it can automatically be removed upon uninstallation
> and we don't need %preun target. Also, this will also allow
> to get these files on manual installation from sources.
> 
> Also, don't settle on the "file exists" check, use the '-s'
> to check that it is not empty as well.
> 
> Lastly, in order to have hostnqn and hostid updated upon pkg
> install, we have install-spec target that would omit hostnqn and
> hostid files, and let the rpm %post do it (otherwise we
> use the normal install target).

Sounds good, applied both patches.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-04-25 14:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-24 21:49 [PATCH 1/2] spec, Makefile: add /etc/nvme files to package files Sagi Grimberg
2019-04-24 21:49 ` [PATCH 2/2] spec, make: Add discovery.conf to the package files list Sagi Grimberg
2019-04-25  1:15   ` Minwoo Im
2019-04-25 14:59 ` [PATCH 1/2] spec, Makefile: add /etc/nvme files to package files Keith Busch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox