add rpm make target and fix up spec file

Add a new make target to build an rpm. This uses rpmbuild --build-in-place,
so no SRPM is created.

Also clean up the specfile to remove manually-added Requires: that will
be auto-generated, add a couple new BuildRequires: and use macros for
file locations.

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
This commit is contained in:
Eric Sandeen 2023-03-08 09:25:13 -06:00 committed by Kent Overstreet
parent ea8adaf1cc
commit 3deb1e0b17
2 changed files with 33 additions and 34 deletions

View File

@ -82,10 +82,10 @@ LDLIBS+=-lm -lpthread -lrt -lkeyutils -laio -ldl
LDLIBS+=$(EXTRA_LDLIBS) LDLIBS+=$(EXTRA_LDLIBS)
ifeq ($(PREFIX),/usr) ifeq ($(PREFIX),/usr)
ROOT_SBINDIR=/sbin ROOT_SBINDIR?=/sbin
INITRAMFS_DIR=$(PREFIX)/share/initramfs-tools INITRAMFS_DIR=$(PREFIX)/share/initramfs-tools
else else
ROOT_SBINDIR=$(PREFIX)/sbin ROOT_SBINDIR?=$(PREFIX)/sbin
INITRAMFS_DIR=/etc/initramfs-tools INITRAMFS_DIR=/etc/initramfs-tools
endif endif
@ -176,6 +176,10 @@ clean:
deb: all deb: all
debuild -us -uc -nc -b -i -I debuild -us -uc -nc -b -i -I
.PHONY: rpm
rpm: clean
rpmbuild --build-in-place -bb --define "_version $(subst -,_,$(VERSION))" packaging/bcachefs-tools.spec
bcachefs-principles-of-operation.pdf: doc/bcachefs-principles-of-operation.tex bcachefs-principles-of-operation.pdf: doc/bcachefs-principles-of-operation.tex
pdflatex doc/bcachefs-principles-of-operation.tex pdflatex doc/bcachefs-principles-of-operation.tex
pdflatex doc/bcachefs-principles-of-operation.tex pdflatex doc/bcachefs-principles-of-operation.tex

View File

@ -1,45 +1,28 @@
Name: bcachefs-tools Name: bcachefs-tools
Version: 2020.01.21 # define with i.e. --define '_version 1.0'
Version: %{_version}
Release: 1%{?dist} Release: 1%{?dist}
Summary: Userspace tools for bcachefs Summary: Userspace tools for bcachefs
License: GPLv2 License: GPLv2
URL: https://github.com/koverstreet/bcachefs-tools URL: https://github.com/koverstreet/bcachefs-tools
Source0: %{name}-%{version}.tar.bz2
BuildRequires: epel-release
BuildRequires: bzip2
BuildRequires: gcc BuildRequires: gcc
BuildRequires: make BuildRequires: make
BuildRequires: cargo
BuildRequires: clang-devel
BuildRequires: keyutils-libs-devel BuildRequires: keyutils-libs-devel
BuildRequires: libaio-devel BuildRequires: libaio-devel
BuildRequires: libattr-devel BuildRequires: libattr-devel
BuildRequires: libblkid-devel BuildRequires: libblkid-devel
BuildRequires: libsodium-devel BuildRequires: libsodium-devel
BuildRequires: libtool-ltdl-devel
BuildRequires: libuuid-devel BuildRequires: libuuid-devel
BuildRequires: libvmmalloc-devel
BuildRequires: libzstd-devel BuildRequires: libzstd-devel
BuildRequires: lz4-devel BuildRequires: lz4-devel
BuildRequires: systemd-devel
BuildRequires: userspace-rcu-devel BuildRequires: userspace-rcu-devel
BuildRequires: valgrind-devel
BuildRequires: zlib-devel BuildRequires: zlib-devel
Requires: epel-release
Requires: bzip2
Requires: keyutils-libs
Requires: libaio
Requires: libattr
Requires: libblkid
Requires: libsodium
Requires: libtool-ltdl
Requires: libuuid
Requires: libvmmalloc
Requires: libzstd
Requires: lz4
Requires: userspace-rcu
Requires: zlib
%description %description
The bcachefs tool, which has a number of subcommands for formatting and managing bcachefs filesystems. Run bcachefs --help for full list of commands. The bcachefs tool, which has a number of subcommands for formatting and managing bcachefs filesystems. Run bcachefs --help for full list of commands.
@ -47,25 +30,37 @@ The bcachefs tool, which has a number of subcommands for formatting and managing
%setup -q %setup -q
%build %build
make %make_build V=0 --no-print-directory
%install %install
rm -rf $RPM_BUILD_ROOT rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/usr/local/sbin mkdir -p $RPM_BUILD_ROOT%{_sbindir}
mkdir -p $RPM_BUILD_ROOT/usr/local/share/man/man8 mkdir -p $RPM_BUILD_ROOT%{_mandir}/man8
%make_install %make_install PREFIX=%{_exec_prefix} ROOT_SBINDIR=%{_sbindir}
# These may be debian-specific, and for unlocking encrypted root fs
rm -f %{buildroot}/%{_datadir}/initramfs-tools/hooks/bcachefs
rm -f %{buildroot}/%{_datadir}/initramfs-tools/scripts/local-premount/bcachefs
# The library is not needed by userspace
rm -f %{buildroot}/usr/lib/libbcachefs.so
%files %files
/usr/local/sbin/bcachefs %{_sbindir}/mount.bcachefs
/usr/local/sbin/fsck.bcachefs %{_sbindir}/bcachefs
/usr/local/sbin/mkfs.bcachefs %{_sbindir}/fsck.bcachefs
/usr/local/share/man/man8/bcachefs.8 %{_sbindir}/mkfs.bcachefs
/etc/initramfs-tools/hooks/bcachefs %{_mandir}/man8/bcachefs.8.gz
/etc/initramfs-tools/scripts/local-premount/bcachefs
%changelog %changelog
* Tue Nov 15 2022 Eric Sandeen <sandeen@sandeen.net> - 2022.11.15-1
- NOTE: This binary RPM has been built directly from the bcachefs-tools
git tree with "make rpm" from the git hash indicated in the package version.
- Update spec file to allow in-tree rpm builds
- Remove maually added Requires: and unneeded build-requires
* Tue Jan 21 2020 Michael Adams <unquietwiki@gmail.com> - 2020.01.21-1 * Tue Jan 21 2020 Michael Adams <unquietwiki@gmail.com> - 2020.01.21-1
- Updated RPM package definition to reflect that changes in codebase have occurred. - Updated RPM package definition to reflect that changes in codebase have occurred.
* Tue Jan 07 2020 Michael Adams <unquietwiki@gmail.com> - 2020.01.07-1 * Tue Jan 07 2020 Michael Adams <unquietwiki@gmail.com> - 2020.01.07-1
- Initial RPM package definition - Initial RPM package definition
- Makefile needs further work to accomodate RPM macros. - Makefile needs further work to accomodate RPM macros.