Add RPM builds for scoutfs-kmod

This adds in the makefile targets and spec file template we need to
build RPMs. Most of the heavy lifting is taken care of by our docker
container and the rpmbuild.sh script distributed in it.

The git versioning comes from 'git describe --long', which gives us the
tag, the number of commits and the abbreviated commit name. This allows
us to use the number of commits as the RPM release version, letting yum
understand how to process 'yum update' ordering.

yum update shows us the proper processing, along with how our versioning
lines up in the RPMs:
---> Package kmod-scoutfs.x86_64 0:0-0.3.gb83d29d.el7 will be updated
---> Package kmod-scoutfs.x86_64 0:0-0.4.g2e5324e.el7 will be an update
The rpm file name is: kmod-scoutfs-0-0.4.g2e5324e.el7.x86_64.rpm

When we build release RPMS, we'll toggle _release, giving us a rpm name
and version like kmod-scoutfs-0-1.4.g2e5324e.el7.x86_64.rpm. The toggle
of 0/1 is enough to tell yum that all of the non-release RPMs with the
same version are older than the released RPMs. This allows for the
release to yum update cleanly over development versions.

The git hash helps map RPM names to the git version and the contents of
the .note-git_describe, for this RPM it was: heads/nic/rpms-0-g2e5324.
The RPM doesn't contain the branch name, but we can add that and other
info later if needed.

We are not naming the module for a kernel version, that does not seem to
be standard practice upstream. Instead, we'll make use of our
Artifactory repos and upload the RPMs to the correct places (7.3 vs 7.4
directories, etc).
This commit is contained in:
Nic Henke
2017-11-28 14:47:20 -07:00
committed by Zach Brown
parent 995e43aa18
commit 22f1ded17b
3 changed files with 122 additions and 0 deletions

2
kmod/.gitignore vendored
View File

@@ -10,3 +10,5 @@ cscope.*
*.spec
*.sw[po]
rpmbuild/
scoutfs-*.git*/

View File

@@ -24,11 +24,59 @@ SCOUTFS_ARGS := SCOUTFS_GIT_DESCRIBE=$(SCOUTFS_GIT_DESCRIBE) \
CONFIG_SCOUTFS_FS=m -C $(SK_KSRC) M=$(CURDIR)/src \
EXTRA_CFLAGS="-Werror"
# move damage locally, this will also help make it easier to cleanup after the build
RPM_DIR = $(shell pwd)/rpmbuild
# - We use the git describe from tags to set up the RPM versioning
RPM_VERSION := $(shell git describe --long --tags | awk -F '-' '{gsub(/^v/,""); print $$1}')
RPM_RELEASE := $(shell git describe --long --tags | awk -F '-' '{print $$2"."$$3}')
FULL_VERSION := $(RPM_VERSION).$(RPM_RELEASE)
TARFILE = $(RPM_DIR)/SOURCES/scoutfs-kmod-$(FULL_VERSION).tar
.PHONY: .FORCE
all: module
module:
make $(SCOUTFS_ARGS)
$(SP) make C=2 CF="-D__CHECK_ENDIAN__" $(SCOUTFS_ARGS)
modules_install:
make $(SCOUTFS_ARGS) modules_install
# remake this each time..
$(RPM_DIR): .FORCE
@echo "## Clean up on isle $(RPM_DIR)..."
rm -frv $(RPM_DIR)/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
mkdir -p $(RPM_DIR)/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
%.spec: %.spec.in .FORCE
sed -e 's/@@VERSION@@/$(RPM_VERSION)/g' \
-e s'/@@TAR_VERSION@@/$(FULL_VERSION)/g' \
-e s'/@@RELEASE@@/$(RPM_RELEASE)/g' < $< > $@+
mv $@+ $@
# NOTE: Both tar & rpm are capable of being built natively on Linux, provided
# you have a local install of rpmbuild.sh for the rpm target.
# Normal exection is to use docker, as that pulls our canned image and tooling for the user.
# ./indocker.sh make tar
# ./indocker.sh make rpm
#
tar: $(RPM_DIR) scoutfs-kmod.spec
git archive --format=tar --prefix scoutfs-$(FULL_VERSION)/ HEAD^{tree} > $(TARFILE)
@ tar rf $(TARFILE) --transform="s@\(.*\)@scoutfs-$(FULL_VERSION)/\1@" scoutfs-kmod.spec
gzip -f -9 $(TARFILE)
$(TARFILE).gz: tar
rpm: $(TARFILE).gz scoutfs-kmod.spec
rpmbuild.sh $(TARFILE).gz
clean:
make $(SCOUTFS_ARGS) clean

72
kmod/scoutfs-kmod.spec.in Normal file
View File

@@ -0,0 +1,72 @@
%define kmod_name scoutfs
#%%trace
%define _tar_version @@TAR_VERSION@@
# official builds set this to 1, we use 0 for internal/dev-test
%{!?_release: %global _release 0}
Name: %{kmod_name}
Summary: %{kmod_name} kernel module
Version: @@VERSION@@
Release: %{_release}.@@RELEASE@@%{?dist}
License: GPLv2
Group: System/Kernel
URL: http://versity.com
BuildRequires: %kernel_module_package_buildreqs
ExclusiveArch: x86_64
# Sources.
Source0: scoutfs-kmod-%{_tar_version}.tar.gz
# Build only for standard kernel variant(s); for debug packages, append "debug"
# after "default" (separated by space)
%kernel_module_package default
# Disable the building of the debug package(s).
%define debug_package %{nil}
%description
%{kmod_name} - kernel module
%prep
%setup -q -n %{kmod_name}-%{_tar_version}
set -- *
mkdir source
mv "$@" source/
mkdir obj
%build
echo "Building for kernel: %{kernel_version} flavors: '%{flavors_to_build}'"
echo "Build var: kmodtool = %{kmodtool}"
echo "Build var: kverrel = %{kverrel}"
for flavor in %flavors_to_build; do
rm -rf obj/$flavor
cp -r source obj/$flavor
make SK_KSRC=%{kernel_source $flavor} -C obj/$flavor module
done
%install
export INSTALL_MOD_PATH=$RPM_BUILD_ROOT
export INSTALL_MOD_DIR=extra/%{name}
for flavor in %flavors_to_build ; do
# TODO add Makefile rule
#make SK_KSRC=%{kernel_source $flavor} -C obj/$flavor modules_install
make -C %{kernel_source $flavor} modules_install \
M=$PWD/obj/$flavor/src
done
%clean
rm -rf %{buildroot}
%changelog
* Fri Nov 17 2017 Nic Henke <nic.henke@versity.com> - 1.0
- Initial version.