1
##########################################################################
2
# Build an RPM from the current spec file and subversion directory tree. #
4
# Note: The RPM and Makefile are set up to GENERATE RPMS as a non-root #
5
# user in the user's home directory. Of course to INSTALL the resulting #
6
# binary RPM the user has to log in as root. #
7
##########################################################################
9
SVN_TOP_DIR := $(shell pwd)/../../..
11
SPECFILE := subversion.spec
12
VERSION_FILE := $(SVN_TOP_DIR)/subversion/include/svn_version.h
16
NAME := $(shell grep '^Name:' < $(SPECFILE) | sed -e 's/^Name: //')
17
SVN_VERSION_MAJOR := $(shell grep 'define SVN_VER_MAJOR' < $(VERSION_FILE) | (read one two three; echo $$three) )
18
SVN_VERSION_MINOR := $(shell grep 'define SVN_VER_MINOR' < $(VERSION_FILE) | (read one two three; echo $$three) )
19
SVN_VERSION_MICRO := $(shell grep 'define SVN_VER_PATCH' < $(VERSION_FILE) | (read one two three; echo $$three) )
20
VERSION := $(SVN_VERSION_MAJOR).$(SVN_VERSION_MINOR).$(SVN_VERSION_MICRO)
21
RELEASE := $(shell svn st -v $(SPECFILE) | cut -b 10- | ( read one two ; echo $$one ) )
22
OSREL := $(shell ./find-osrel | ( read one two ; echo $$one ))
24
SOURCE_RPM_DIR := $(HOME)/$(RPMDIR)/sources/$(NAME)-$(VERSION)-$(RELEASE)
28
$(HOME)/$(RPMDIR)/build \
29
$(HOME)/$(RPMDIR)/rpms \
30
$(HOME)/$(RPMDIR)/rpms/i386 \
31
$(HOME)/$(RPMDIR)/rpms/i486 \
32
$(HOME)/$(RPMDIR)/rpms/i586 \
33
$(HOME)/$(RPMDIR)/rpms/i686 \
34
$(HOME)/$(RPMDIR)/rpms/noarch \
35
$(HOME)/$(RPMDIR)/rpms/ppc \
36
$(HOME)/$(RPMDIR)/rpms/sparc \
37
$(HOME)/$(RPMDIR)/sources \
38
$(HOME)/$(RPMDIR)/srpms \
43
subversion rpm : check_release build_srpm_files build_rpm_files brand_files
46
@if [ "$(RELEASE)"x = "x" ]; \
48
echo "Please specifiy RELEASE with 'make RELEASE=<number>'"; \
53
@echo "Making $(NAME)-$(VERSION)-$(RELEASE) (S)RPM for $(OSREL) ..."
55
build_rpm_files : build_srpm_files
56
cd $(SOURCE_RPM_DIR); rpmbuild -ba $(SPECFILE)
59
cd $(SOURCE_RPM_DIR)/../../rpms/i386; for oldfile in *$(RELEASE)*; do newfile=`echo $${oldfile} | sed -e "s/-$(VERSION)-$(RELEASE).i386.rpm/-$(VERSION)-$(RELEASE).$(OSREL).i386.rpm/"`; echo Moving $${oldfile} to $${newfile}; mv -f $${oldfile} $${newfile}; done
60
cd $(SOURCE_RPM_DIR)/../../srpms; for oldfile in *$(RELEASE)*; do newfile=`echo $${oldfile} | sed -e "s/-$(VERSION)-$(RELEASE).src.rpm/-$(VERSION)-$(RELEASE).$(OSREL).src.rpm/"`; echo Moving $${oldfile} to $${newfile}; mv -f $${oldfile} $${newfile}; done
62
build_srpm_files : $(HOME)/.rpmmacros $(HOME)/$(RPMDIR) subversion.spec
63
rm -rf $(SOURCE_RPM_DIR)
64
mkdir -p $(SOURCE_RPM_DIR)
65
cp * $(SOURCE_RPM_DIR)
66
sed -e 's/@RELEASE@/$(RELEASE)/' \
67
-e 's/@VERSION@/$(VERSION)/' \
68
< $(SPECFILE) > $(SOURCE_RPM_DIR)/$(SPECFILE)
69
cd $(SOURCE_RPM_DIR); cp -r $(SVN_TOP_DIR) $(NAME)-$(VERSION); \
70
tar cfz $(NAME)-$(VERSION)-$(RELEASE).tar.gz $(NAME)-$(VERSION) --exclude=.svn; \
71
rm -rf $(NAME)-$(VERSION)
73
$(HOME)/.rpmmacros : .rpmmacros
74
@if [ ! -f $(HOME)/.rpmmacros ]; \
76
echo "Creating $(HOME)/.rpmmacros"; \
77
sed -e 's;@RPMSDIR@;$(HOME)/$(RPMDIR);' < .rpmmacros > $(HOME)/.rpmmacros; \
81
@if [ ! -d $(HOME)/$(RPMDIR) ]; \
83
for i in $(RPMDIRS); \
85
echo "Making directory $$i"; \