File nvme-cli.spec of Package nvme-cli.12152

#
# spec file for package nvme-cli
#
# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


Name:           nvme-cli
Version:        1.5
Release:        0
Summary:        NVM Express user space tools
License:        GPL-2.0-only
Group:          Hardware/Other
Url:            https://github.com/linux-nvme/nvme-cli
Source:         %{name}-v%{version}.tar.gz
Source2:        nvme-cli-rpmlintrc
BuildRequires:  asciidoc
BuildRequires:  libuuid-devel
BuildRequires:  xmlto
BuildRequires:  pkgconfig(libudev)
BuildRequires:  pkgconfig(systemd)
BuildRequires:  pkgconfig(udev)
%ifarch x86_64 aarch64 i586
Requires(post): dmidecode
%endif
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Patch1:         0001-nvme-cli-add-NetApp-plugin.patch
Patch2:         0002-nvme-cli-add-netapp-smdevices-man-page.patch
Patch3:         0003-get-log-Make-log-identifier-a-required-parameter.patch
Patch4:         0004-Documentation-add-manpage-entry-for-connect-s-ctrl-l.patch
Patch5:         0005-fabrics-add-option-to-supply-keep-alive-timeout-for.patch
Patch6:         0006-fabrics-add-ctrl-loss-tmo-to-connect-all.patch
Patch7:         0007-nvme-vendor-Add-get-log-LSP-LSO-fields-from-1.3-spec.patch
Patch8:         0008-nvme-cli-Implement-nvme_get_log13.patch
Patch9:         0009-nvme-cli-Add-support-of-unsigned-long-long-to-json-r.patch
Patch10:        0010-nvme-cli-add-support-of-RAE.patch
Patch11:        0011-nvme-cli-add-minimal-ana-log-page-support.patch
Patch12:        0012-nvme-cli-add-ana-log-documentation.patch
Patch13:        0013-nvme-discover-sanitize-options.patch
Patch14:        0014-Fix-double-free-in-list_subsys.patch
Patch15:        0015-Log-error-incase-of-failure-in-get_nvme_subsystem_in.patch
Patch16:        0016-nvme-cli-move-print-function-to-nvme-print.patch
Patch17:        0017-nvme-cli-show-partial-results-if-controller-fails-du.patch
Patch19:        0019-nvme-discover-Retry-discovery-log-if-the-generation-.patch
Patch20:        0020-nvme-cli-fabrics-Fix-passing-host_traddr-for-all-tra.patch
Patch21:        0021-fabrics-write-ctrl_loss_tmo-to-fabrics-device-on-con.patch
Patch22:        0022-fabrics-write-keep-alive-timeout-to-fabrics-device-o.patch
Patch23:        0023-Fix-print-format-specifier-for-64-bit.patch
Patch24:        0024-nvme-ana-log-fixup-compiler-warning-in-show_ana_log.patch
Patch25:        0025-fabrics-make-some-arguments-integers.patch
Patch26:        0026-fabrics-don-t-fail-empty-discovery-log-page.patch
Patch27:        0027-nvme-commonize-subsystems-info-in-a-helper.patch
Patch28:        0028-nvme-ioctl-retrieve-log-pages-in-4k-chunks.patch
Patch29:        0029-nvme-discover-Re-check-generation-counter-after-log-.patch
Patch30:        0030-nvme-fixup-ANA-group-descriptor-offset.patch
Patch31:        0031-nvme-introduce-get_nvme_ctrl_attr.patch
Patch32:        0032-nvme-print-out-controller-state-for-list-subsys.patch
Patch33:        0033-nvme-list-subsys-Add-device-name-argument-and-print-.patch
Patch34:        0034-fabrics-allow-nr_io-write-poll_queues-and-queue-size.patch
Patch35:        0035-fabrics-do-not-use-queue_size-and-nr_io_queues-for-d.patch
Patch36:        0036-fabrics-mask-out-invalid-options-during-discovery.patch
Patch37:        0037-nvme-Document-Q-and-i-for-discovery-and-connect-all.patch
Patch38:        0038-nvme-cli-add-netapp-ontapdevices-command.patch
Patch39:        0039-nvme-cli-add-netapp-ontapdevices-man-page.patch
Patch40:        0040-nvme-cli-Increase-size-of-ONTAP-namespace-path-varia.patch
Patch41:        0041-nvme-vendor-fixup-c99-declaration-in-huawei-plugin.patch
Patch42:        0042-nvme-cli-fix-fc-trtype-string.patch
Patch43:        0043-flush-Use-device-NSID-if-issuing-through-block-devic.patch
Patch44:        0044-Use-NSID-all-for-error-log.patch
Patch100:       0100-nvme_fc-auto-connect-scripts.patch
Patch101:       0101-71-nvme-iopolicy-netapp.rules-add-default-rules-for-.patch
Patch102:       0102-Add-nvmefc-connect.target.patch
Patch103:       0103-Change-service-to-type-simple.patch
Patch104:       0104-nvme-cli-Fix-documentation-syntax-and-typo.patch
Patch105:       0105-nvme-cli-Check-for-sysfs-interface-before-NVMe-disco.patch
Patch106:       0106-nvme-cli-Update-nvme-connect-all-man-page.patch
Patch107:       0107-nvme-cli-add-default-IO-policy-rule-for-NetApp-E-Ser.patch
Patch108:       0108-nvme-cli-Rename-udev-rule-for-ONTAP-controller.patch
Patch109:       0109-nvme-cli-Add-script-to-determine-host-NQN.patch

%description
NVM Express (NVMe) is a direct attached storage interface. The
nvme-cli package contains core management tools with minimal
dependencies.

%package -n     nvme-cli-regress-script
Summary:        A small script to test the nvme binary for regressions
Group:          Hardware/Other
Requires:       nvme-cli

%description -n nvme-cli-regress-script
A small shell script to test the nvme binary for regressions. It requires an
NVMe device for testing purposes. Do NOT use in a production environment.

%prep
%setup -q -n %{name}-v%{version}
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9 -p1
%patch10 -p1
%patch11 -p1
%patch12 -p1
%patch13 -p1
%patch14 -p1
%patch15 -p1
%patch16 -p1
%patch17 -p1
%patch19 -p1
%patch20 -p1
%patch21 -p1
%patch22 -p1
%patch23 -p1
%patch24 -p1
%patch25 -p1
%patch26 -p1
%patch27 -p1
%patch28 -p1
%patch29 -p1
%patch30 -p1
%patch31 -p1
%patch32 -p1
%patch33 -p1
%patch34 -p1
%patch35 -p1
%patch36 -p1
%patch37 -p1
%patch38 -p1
%patch39 -p1
%patch40 -p1
%patch41 -p1
%patch42 -p1
%patch43 -p1
%patch44 -p1
%patch100 -p1
%patch101 -p1
%patch102 -p1
%patch103 -p1
%patch104 -p1
%patch105 -p1
%patch106 -p1
%patch107 -p1
%patch108 -p1
%patch109 -p1

%build
echo %{version} > version
make CFLAGS="%{optflags}" PREFIX=%{_prefix} %{?_smp_mflags} all
# nvme-cli-regress-script subpackage: remove make and install steps
sed -i '/make.*/d' regress

%install
make PREFIX=%{_prefix} DESTDIR=%{buildroot} install-bin install-man %{?_smp_mflags}
install -m 644 -D /dev/null %{buildroot}%{_sysconfdir}/nvme/hostnqn
install -m 644 -D completions/bash-nvme-completion.sh %{buildroot}%{_datadir}/bash_completion/completions/nvme
install -m 644 -D nvme-fc-autoconnect/nvmefc-boot-connections.service %{buildroot}%{_unitdir}/nvmefc-boot-connections.service
install -m 644 -D nvme-fc-autoconnect/nvmefc-connect@.service %{buildroot}%{_unitdir}/nvmefc-connect@.service
install -m 644 -D nvme-fc-autoconnect/nvmefc-connect.target %{buildroot}%{_unitdir}/nvmefc-connect.target
install -m 644 -D nvme-fc-autoconnect/70-nvmefc-autoconnect.rules %{buildroot}%{_udevrulesdir}/70-nvmefc-autoconnect.rules
install -m 644 -D scripts/71-nvme-iopolicy-netapp-ONTAP.rules %{buildroot}%{_udevrulesdir}/71-nvme-iopolicy-netapp-ONTAP.rules
install -m 644 -D scripts/71-nvme-iopolicy-netapp-E-Series.rules %{buildroot}%{_udevrulesdir}/71-nvme-iopolicy-netapp-E-Series.rules
%ifarch x86_64 aarch64 i586
install -m 744 -D scripts/det-hostnqn.sh %{buildroot}%{_sbindir}/nvme-det-hostnqn
%endif
# for subpackage nvme-cli-regress-script:
install -m 744 -D regress %{buildroot}%{_sbindir}/nvme-regress

%define services nvmefc-boot-connections.service nvmefc-connect.target

%pre
%service_add_pre %services nvmefc-connect@.service

%post
%ifarch x86_64 aarch64 i586
if [ ! -s %{_sysconfdir}/nvme/hostnqn ]; then
	%{_sbindir}/nvme-det-hostnqn > %{_sysconfdir}/nvme/hostnqn
fi
%endif
if [ ! -s %{_sysconfdir}/nvme/hostnqn ]; then
	%{_bindir}/echo "Generating random host NQN."
	%{_sbindir}/nvme gen-hostnqn > %{_sysconfdir}/nvme/hostnqn
fi
if [ ! -s %{_sysconfdir}/nvme/hostid ]; then
	%{_bindir}/uuidgen > %{_sysconfdir}/nvme/hostid
fi
%service_add_post %services nvmefc-connect@.service

%preun
%service_del_preun -f %services

%postun
%service_del_postun %services

%posttrans
if [ -f /sys/class/fc/fc_udev_device/nvme_discovery ]; then
	%{_bindir}/echo add > /sys/class/fc/fc_udev_device/nvme_discovery
fi

%files
%defattr(-,root,root)
%doc README.md LICENSE
%{_sbindir}/nvme
%ifarch x86_64 aarch64 i586
%{_sbindir}/nvme-det-hostnqn
%endif
%{_mandir}/man1/nvme*.1*
%dir %{_sysconfdir}/nvme/
%dir %{_datadir}/bash_completion
%dir %{_datadir}/bash_completion/completions/
%{_datadir}/bash_completion/completions/nvme
%{_udevrulesdir}/70-nvmefc-autoconnect.rules
%{_udevrulesdir}/71-nvme-iopolicy-netapp-ONTAP.rules
%{_udevrulesdir}/71-nvme-iopolicy-netapp-E-Series.rules
%{_unitdir}/nvmefc-boot-connections.service
%{_unitdir}/nvmefc-connect@.service
%{_unitdir}/nvmefc-connect.target
%ghost %{_sysconfdir}/nvme/hostnqn
%ghost %{_sysconfdir}/nvme/hostid

%files -n nvme-cli-regress-script
%defattr(-,root,root)
%{_sbindir}/nvme-regress

%changelog
openSUSE Build Service is sponsored by