Development/Howto/RPM From CVS
From Mandriva Community Wiki
[edit] Introduction
The aim of this guide is to explain how to build rpm packages for a project managed under cvs and make.
All the projects should follow this scheme to enhance the quality of our software developments.
[edit] Makefile
The Makefile must provide 2 targets to build rpm packages: make localrpm and make rpm. The localrpm target is there to build a package for testing purpose and therpm target is there for building a package to be published. The difference between the rpm and localrpm is the cvs tagging of the tree.
Here is the part of the Makefile from the rpmlint module which manages these rules:
PACKAGE=rpmlint
VERSION:=$(shell rpm -q --qf %{VERSION} --specfile $(PACKAGE).spec)
RELEASE:=$(shell rpm -q --qf %{RELEASE} --specfile $(PACKAGE).spec)
TAG := $(shell echo "V$(VERSION)''$(RELEASE)" | tr -- '-.' '''_')
FILES= rpmlint *.py INSTALL README README.CVS COPYING ChangeLog Makefile config rpmlint.spec rpmdiff
# rules to build a test rpm
localrpm: localdist buildrpm
localdist: cleandist dir localcopy tar
cleandist:
rm -rf $(PACKAGE)-$(VERSION) $(PACKAGE)-$(VERSION).tar.bz2
dir:
mkdir $(PACKAGE)-$(VERSION)
localcopy:
tar c $(FILES) | tar x -C $(PACKAGE)-$(VERSION)
tar:
tar cvf $(PACKAGE)-$(VERSION).tar $(PACKAGE)-$(VERSION)
bzip2 -9vf $(PACKAGE)-$(VERSION).tar
rm -rf $(PACKAGE)-$(VERSION)
buildrpm:
rpm -ta $(PACKAGE)-$(VERSION).tar.bz2
# rules to build a distributable rpm
rpm: changelog cvstag dist buildrpm
dist: cleandist dir export tar
export:
cvs export -d $(PACKAGE)-$(VERSION) -r $(TAG) $(PACKAGE)
cvstag:
cvs commit
cvs tag $(CVSTAGOPT) $(TAG)
changelog: ../common/username
cvs2cl -U ../common/username -I [[ChangeLog]]
rm -f [[ChangeLog]].bak
cvs commit -m "Generated by cvs2cl the ate '+%d_%b'" [[ChangeLog]]
[edit] Details
The cvs tag created using make rpm is built from version and release extracted from the spec file. If the version and release are 1.2-3mdk, the tag will be V1_2_3mdk.
The rpm target in the example builds the ChangeLog file from the commit logs by using the cvs2cl and the common cvs module which contains the association between cvs logins and email adresses.

