diff options
author | David Howells <dhowells@redhat.com> | 2011-11-30 10:47:05 +0000 |
---|---|---|
committer | David Howells <dhowells@redhat.com> | 2011-11-30 10:47:05 +0000 |
commit | 6a0a8d0183ffe016fe3022f0d704cc7e288a2d4d (patch) | |
tree | 2f4ceeac462a5b3f3fa5c79c720c566f3af947f8 | |
parent | bdec8ccc6bbb2298489216ea55661ab1b10d9a7d (diff) | |
download | cachefilesd-6a0a8d0183ffe016fe3022f0d704cc7e288a2d4d.tar.gz |
Build: Provide rules to build tarballs and RPMs
Provide make rules to build tarballs (make tarball) and RPMs (make rpm) from
the GIT tree.
The local build ID can be set whilst building an RPM:
make rpm BUILDID=.foo
This is incorporated into the RPM names after the release number.
Signed-off-by: David Howells <dhowells@redhat.com>
-rw-r--r-- | Makefile | 84 | ||||
-rw-r--r-- | redhat/cachefilesd.spec | 4 |
2 files changed, 83 insertions, 5 deletions
@@ -1,13 +1,28 @@ CFLAGS := -g -O2 -Wall INSTALL := install DESTDIR := -BUILDFOR := ETCDIR := /etc BINDIR := /bin SBINDIR := /sbin +SPECFILE := redhat/cachefilesd.spec LNS := ln -sf +############################################################################### +# +# Determine the current package version from the specfile +# +############################################################################### +VERSION := $(word 2,$(shell grep "^Version:" $(SPECFILE))) +TARBALL := cachefilesd-$(VERSION).tar.bz2 + +############################################################################### +# +# Guess at the appropriate word size +# +############################################################################### +BUILDFOR := $(shell file /usr/bin/make | sed -e 's!.*ELF \(32\|64\)-bit.*!\1!')-bit + ifeq ($(BUILDFOR),32-bit) CFLAGS += -m32 else @@ -16,17 +31,21 @@ CFLAGS += -m64 endif endif +############################################################################### # -# building +# Build stuff # +############################################################################### all: cachefilesd cachefilesd: cachefilesd.c Makefile $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< +############################################################################### # -# installation +# Install everything # +############################################################################### MAN5 := $(DESTDIR)/usr/share/man/man5 MAN8 := $(DESTDIR)/usr/share/man/man8 @@ -36,10 +55,67 @@ install: all $(INSTALL) -D -m 0644 cachefilesd.conf.5 $(MAN5)/cachefilesd.conf.5 $(INSTALL) -D -m 0644 cachefilesd.8 $(MAN8)/cachefilesd.8 +############################################################################### # -# clean up +# Clean up # +############################################################################### clean: $(RM) cachefilesd $(RM) *.o *~ $(RM) debugfiles.list debugsources.list + +distclean: clean + $(RM) -r rpmbuild $(TARBALL) + +############################################################################### +# +# Generate a tarball +# +############################################################################### +$(TARBALL): + git archive --prefix=cachefilesd-$(VERSION)/ --format tar -o $(TARBALL) HEAD + +tarball: $(TARBALL) + +############################################################################### +# +# Generate an RPM +# +############################################################################### +SRCBALL := rpmbuild/SOURCES/$(TARBALL) + +BUILDID := .local +dist := $(word 2,$(shell grep "%dist" /etc/rpm/macros.dist)) +release := $(word 2,$(shell grep ^Release: $(SPECFILE))) +release := $(subst %{?dist},$(dist),$(release)) +release := $(subst %{?buildid},$(BUILDID),$(release)) +rpmver := $(VERSION)-$(release) +SRPM := rpmbuild/SRPMS/cachefilesd-$(rpmver).src.rpm + +RPMBUILDDIRS := \ + --define "_srcrpmdir $(CURDIR)/rpmbuild/SRPMS" \ + --define "_rpmdir $(CURDIR)/rpmbuild/RPMS" \ + --define "_sourcedir $(CURDIR)/rpmbuild/SOURCES" \ + --define "_specdir $(CURDIR)/rpmbuild/SPECS" \ + --define "_builddir $(CURDIR)/rpmbuild/BUILD" \ + --define "_buildrootdir $(CURDIR)/rpmbuild/BUILDROOT" + +RPMFLAGS := \ + --define "buildid $(BUILDID)" + +rpm: + mkdir -p rpmbuild/{SPECS,SOURCES,BUILD,BUILDROOT,RPMS,SRPMS} + git archive --prefix=cachefilesd-$(VERSION)/ --format tar -o $(SRCBALL) HEAD + rpmbuild -ts $(SRCBALL) --define "_srcrpmdir rpmbuild/SRPMS" $(RPMFLAGS) + rpmbuild --rebuild $(SRPM) $(RPMBUILDDIRS) $(RPMFLAGS) + +############################################################################### +# +# Build debugging +# +############################################################################### +show_vars: + @echo VERSION=$(VERSION) + @echo TARBALL=$(TARBALL) + @echo BUILDFOR=$(BUILDFOR) diff --git a/redhat/cachefilesd.spec b/redhat/cachefilesd.spec index 8854370..6c207ac 100644 --- a/redhat/cachefilesd.spec +++ b/redhat/cachefilesd.spec @@ -1,6 +1,8 @@ +# % define buildid .local + Name: cachefilesd Version: 0.10.2 -Release: 1%{?dist} +Release: 1%{?dist}%{?buildid} Summary: CacheFiles userspace management daemon Group: System Environment/Daemons License: GPL |