From 5945e78564e7bed10c8e824503e420c447d3cbc6 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Thu, 2 Jun 2016 17:16:05 +0200 Subject: [PATCH] add RPM packaging Build and install tested on Fedora 23. Signed-off-by: Christoph Hellwig --- Makefile | 33 ++++++++++++++++++++++++ rpm/nvmetcli.spec.tmpl | 57 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 rpm/nvmetcli.spec.tmpl diff --git a/Makefile b/Makefile index e13005c..a8dc916 100644 --- 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 index 0000000..03667d7 --- /dev/null +++ b/rpm/nvmetcli.spec.tmpl @@ -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 -- 2.49.0