Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Commit

Permalink
Add flashcache.spec for rpm builds
Browse files Browse the repository at this point in the history
Pass in kernel_version, modversion, and pkgrelease, or let it use the
defaults.
  • Loading branch information
zlandau committed Nov 3, 2012
1 parent f669a07 commit 6f68bdb
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 6 deletions.
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
COMMIT_REV := $(shell git describe --always --abbrev=12)
KERNEL_TREE ?= /lib/modules/$(shell uname -r)/build
COMMIT_REV ?= $(shell git describe --always --abbrev=12)
KERNEL_SOURCE_VERSION ?= $(shell uname -r)
KERNEL_TREE ?= /lib/modules/$(KERNEL_SOURCE_VERSION)/build
export COMMIT_REV

# Check for RHEL/CentOS
Expand Down
68 changes: 68 additions & 0 deletions flashcache.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# The kernel version you are building for
%{!?kernel_version:%define kernel_version %(uname -r)}

# The version of the module,
%{!?modversion:%define modversion %(if [ -d .git ]; then git describe --abbrev=0 --tags; else 2.0; fi)}

# Which revision are we on, increment per RPM build
%{!?pkgrelease:%define pkgrelease 1}

#### You shouldn't need to set the vars below

%define kernel kernel-%{kernel_version}

# The name of the module you are supplying
%define modname flashcache

# Define git commit revision, if we're in a repo
%define commit_rev %(if [ -d .git ]; then git describe --always --abbrev=12; else ''; fi)

# The path to the module, after it is installed
%define modpath /lib/modules/%{kernel_version}/extra/flashcache/

%define make_opts %{?_smp_mflags} COMMIT_REV=%{commit_rev} RHEL5_VER=

Name: %{modname}-%{kernel_version}
Summary: %{modname} Kernel Module for the %{kernel_version} kernel
Version: %{modversion}
Release: %{pkgrelease}
Source: %{modname}-%{modversion}.tar.gz
Epoch: 0
License: GPL
Group: System Environment/Kernel
BuildRoot: %{_tmppath}/%{name}-%{version}-root
Requires: modutils kernel-devel
Provides: kernel-module-%{modname} = %{epoch}:%{version}

%description
This package provides a %{modname} kernel module for
kernel %{kernel_version}.

%prep
%setup -q -n %{modname}-%{modversion}

%build
make %{make_opts} KERNEL_SOURCE_VERSION=%{kernel_version}

%install
rm -rf %{buildroot}
cd src
make %{make_opts} DESTDIR=%{buildroot} utils_install ocf_install
install -d %{buildroot}/%{modpath}/
install -m 644 flashcache.ko %{buildroot}/%{modpath}/%{modname}.ko

%post
/sbin/depmod -a %{kernel_version}

%postun
/sbin/depmod -a %{kernel_version}

%clean
rm -rf %{buildroot}

%files
%defattr(-,root,root,-)
%doc README LICENSE
/sbin/*
%{modpath}/%{modname}.ko
/usr/lib/ocf/resource.d/%{modname}/%{modname}
9 changes: 6 additions & 3 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ utils:
.PHONY: modules_install
modules_install: modules
install -o root -g root -m 0755 -d $(DESTDIR)/lib/modules/$(KERNEL_SOURCE_VERSION)/extra/flashcache/
install -o root -g root -m 0755 flashcache.ko $(DESTDIR)/lib/modules/$(KERNEL_SOURCE_VERSION)/extra/flashcache/
depmod -a
install -o root -g root -m 0644 flashcache.ko $(DESTDIR)/lib/modules/$(KERNEL_SOURCE_VERSION)/extra/flashcache/

.PHONY: utils_install
utils_install: utils
Expand All @@ -44,8 +43,12 @@ utils_install: utils
ocf_install:
make -C ocf install

.PHONY: depmod
depmod:
depmod -a

.PHONY: install
install: modules_install utils_install ocf_install
install: modules_install utils_install ocf_install depmod

.PHONY: clean
clean:
Expand Down
2 changes: 1 addition & 1 deletion src/ocf/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
COMMIT_REV ?= $(shell git describe --always --abbrev=12)
CFLAGS +=
PROGRAMS += flashcache
INSTALL_DIR = /usr/lib/ocf/resource.d/flashcache
INSTALL_DIR = $(DESTDIR)/usr/lib/ocf/resource.d/flashcache

.PHONY:all
all: $(PROGRAMS)
Expand Down

0 comments on commit 6f68bdb

Please sign in to comment.