]> www.infradead.org Git - users/hch/nvmetcli.git/commitdiff
add RPM packaging
authorChristoph Hellwig <hch@lst.de>
Thu, 2 Jun 2016 15:16:05 +0000 (17:16 +0200)
committerChristoph Hellwig <hch@lst.de>
Thu, 2 Jun 2016 15:56:23 +0000 (17:56 +0200)
Build and install tested on Fedora 23.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Makefile
rpm/nvmetcli.spec.tmpl [new file with mode: 0644]

index e13005c67b1bbaf09d3f4d9da7b8296290c674d8..a8dc9161fc407f1ae3536d38ee82515fedf2bc70 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -6,6 +6,8 @@ VERSION = $$(basename $$(git describe --tags | tr - . | sed 's/^v//'))
 all:
        @echo "Usage:"
        @echo
+       @echo "  make deb         - Builds debian packages."
+       @echo "  make rpm         - Builds rpm packages."
        @echo "  make release     - Generates the release tarball."
        @echo
        @echo "  make clean       - Cleanup the local repository build files."
@@ -56,6 +58,23 @@ build/release-stamp:
                echo " -- $${author}  $${date}"; \
                echo; \
        ) > build/${PKGNAME}-${VERSION}/debian/changelog
+       @echo "Generating rpm specfile from template..."
+       @cd build/${PKGNAME}-${VERSION}; \
+               for spectmpl in rpm/*.spec.tmpl; do \
+                       sed -i "s/Version:.*/Version: ${VERSION}/g" $${spectmpl}; \
+                       mv $${spectmpl} $$(basename $${spectmpl} .tmpl); \
+               done; \
+               rmdir rpm
+       @echo "Generating rpm changelog..."
+       @( \
+               version=${VERSION}; \
+               author=$$(git show HEAD --format="format:%an <%ae>" -s); \
+               date=$$(git show HEAD --format="format:%ad" -s \
+                       | awk '{print $$1,$$2,$$3,$$5}'); \
+               hash=$$(git show HEAD --format="format:%H" -s); \
+               echo '* '"$${date} $${author} $${version}-1"; \
+               echo "  - Generated from git commit $${hash}."; \
+       ) >> $$(ls build/${PKGNAME}-${VERSION}/*.spec)
        @find build/${PKGNAME}-${VERSION}/ -exec \
                touch -t $$(date -d @$$(git show -s --format="format:%at") \
                        +"%Y%m%d%H%M.%S") {} \;
@@ -78,3 +97,17 @@ build/deb-stamp:
        @echo "Generated debian packages:"
        @for pkg in $$(ls dist/*_${VERSION}_*.deb); do echo "  $${pkg}"; done
        @touch build/deb-stamp
+
+rpm: release build/rpm-stamp
+build/rpm-stamp:
+       @echo "Building rpm packages..."
+       @mkdir -p build/rpm
+       @build=$$(pwd)/build/rpm; dist=$$(pwd)/dist/; rpmbuild \
+               --define "_topdir $${build}" --define "_sourcedir $${dist}" \
+               --define "_rpmdir $${build}" --define "_buildir $${build}" \
+               --define "_srcrpmdir $${build}" -ba build/${PKGNAME}-${VERSION}/*.spec
+       @mv build/rpm/*-${VERSION}*.src.rpm dist/
+       @mv build/rpm/*/*-${VERSION}*.rpm dist/
+       @echo "Generated rpm packages:"
+       @for pkg in $$(ls dist/*-${VERSION}*.rpm); do echo "  $${pkg}"; done
+       @touch build/rpm-stamp
diff --git a/rpm/nvmetcli.spec.tmpl b/rpm/nvmetcli.spec.tmpl
new file mode 100644 (file)
index 0000000..03667d7
--- /dev/null
@@ -0,0 +1,57 @@
+Name:           nvmetcli
+License:        Apache License 2.0
+Group:          Applications/System
+Summary:        Command line interface for the kernel NVMe nvmet
+Version:        VERSION
+Release:        1%{?dist}
+URL:           http://git.infradead.org/users/hch/nvmetcli.git
+Source:         nvmetcli-%{version}.tar.gz
+BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-rpmroot
+BuildArch:      noarch
+BuildRequires:  python-devel python-setuptools systemd-units
+Requires:      python-configshell python-kmod
+Requires(post): systemd
+Requires(preun): systemd
+Requires(postun): systemd
+
+%description
+This package contains the command line interface to the NVMe over Fabrics
+nvmet in the Linux kernel.  It allows configuring the nvmet interactively
+as well as saving / restoring the configuration to / from a json file.
+
+%prep
+%setup -q -n nvmetcli-%{version}
+
+%build
+%{__python} setup.py build
+
+%install
+rm -rf %{buildroot}
+%{__python} setup.py install --skip-build --root=%{buildroot} --prefix=usr
+mkdir -p %{buildroot}%{_sysconfdir}/nvmet
+mkdir -p %{buildroot}/usr/sbin
+install -m 755 nvmetcli %{buildroot}/usr/sbin/nvmetcli
+mkdir -p %{buildroot}%{_unitdir}
+install -m 644 nvmet.service %{buildroot}%{_unitdir}/nvmet.service
+
+%clean
+rm -rf %{buildroot}
+
+%post
+%systemd_post nvmet.service
+
+%preun
+%systemd_preun nvmet.service
+
+%postun
+%systemd_postun_with_restart nvmet.service
+
+%files
+%defattr(-,root,root,-)
+%{python_sitelib}
+%dir %{_sysconfdir}/nvmet
+/usr/sbin/nvmetcli
+%{_unitdir}/nvmet.service
+%doc COPYING README
+
+%changelog