[editor's note: the author of this software is Michael Beach ] INTRODUCTION This is a first attempt at documentation for the CVS to RPM conversion program (it's so new, it doesn't even have a name yet!). Apart from the source code itself, this file is the definitive documentation. The large block comments in the source code may be of some use, but reflect more my thoughts as I was hacking together the program, rather than its finished state. WHAT IS IT MEANT TO DO? It is meant to make it easier to generate source and binary rpms fit for distribution (ie not ugly unreadable abominations) from source archives held under CVS. It will create tarballs, patch files and a spec file in nominated locations, typically those will be the same locations that RPM uses. It is then simply a case of issuing rpm -ba against the generated spec file in order to build binary and source RPMs. It allows for the generation of RPMs by other than the original author of the program being packaged, through the use of CVSs vendor branch mechanism. If desired, a tarball will be generated for the vendor branch (the pristine sources) and a patchfile which includes all local (packager introduced) changes. It is also intended to allow reproducibility; at any later time it should be possible to rebuild an RPM from the repository. Of course this is only possible as far as the configuration of the build machine permits. HOW DOES IT DO IT? Essentially the program is a macro-mangling engine that knows how to invoke CVS and tar. It relies upon the CVS tags used to label the sources to be incorporated in the RPM to contain the relevant version information. It extracts this using regular expressions and then allows it to be substituted into the names of the tarballs and the directories within them, and into the template spec file and its name. Along the way if invokes CVS and tar to build the tarballs and patch files. HOW DO I USE IT? In order to use this program, you will need to have sources under CVS that you want to package with RPM. You will also need for each source RPM (ie for each spec file) you intend to create, a description file and a release file. The description file contains information about what CVS modules are used in the RPM, how to extract version information from the tags used in these CVS modules, how to name the patch files and the tarballs and the directories within the tarballs, and of course a template spec file. The description file is itself kept under CVS, so that changes in the RPM's meta information (spec file contents, file names etc) can be maintained. The release file is used to describe each RPM generated. It specifies the tags to be used for extracting the source for each CVS module, which description file to be used (including version number) and the release number to be used. Both the description file and the release file consist of s-expressions. For non Lisp-heads this simply means that clauses in these files are delimited by an opening and a closing parenthesis. It also means that you can use Emacs to do cute indenting automatically. Example description and release files are included, named kernel.descr and rpmrel respectively. These are files I use for building RPMs for the Linux kernel from a CVS repository. The description file should contain the three s-expressions given following. No particular order is required, but the order given below seems to make sense. (srpm-name "name of the spec file") This defines the name of the spec file to be generated. The string will typically contain macros that will be expanded. (cvs-modules ...) This s-expression will contain a sequence of other s-expressions, each of which describes one of the CVS modules which contributes to the RPM. Each of these s-expressions, in turn, is a sequence of the following types of s-expression. (name "shorthand name for CVS module") This gives an arbitrary name to the CVS module. It should be unique among the CVS modules used in this RPM. It is how CVS modules are referred to in macros. (cvs-name "cvs/module/name") This is the name under which to find the module in the CVS repository. (tag-to-version-id-re "regexp" "subst string") This s-expression specifies how to generate a version identifier from the CVS tag used to identify the source version in the repository. The regexp matches the CVS tag, and is one of the 'Henry Spencer' style regexps that most packages seem to use. Parenthesised expressions in the regexp are captured and numbered from 1 upwards (0 is the string matched by the entire regexp). Then every occurrence of @n in the subst string is replaced with parenthesised expression n from the regexp. The value resulting from this substitution is then available as the version-id macro for this CVS module. (tag-to-patch-id-re "regexp" "subst string") Similar to the tag-to-version-id-re s-expression described above, this one generates a macro called patch-id from the CVS tag used to identify the local changes to sources. This is only of significance if the sources under CVS are from a 3rd party, and the CVS vendor branch mechanism is used. (tarball-name "name") (dir-name "name") (patch-name "name") These describe the names to be used when the tarball (and optionally patchfile) for the module are to be generated. tarball-name gives the actual name for the tar file, dir-name gives the name for the top level directory in the tarball (the name from the CVS module may not be what you want) and the patch-name gives the name of the patch file to be generated (if required). Each of the strings will typically contain macros to be substituted, usually either the version-id or the patch-id. The format for such macros is @{macro-name}, eg @{version-id} or @{patch-id}. After the (cvs-modules ...) s-expression, comes the (spec-file-template ...) s-expression. What comes after the spec-file-template keyword is simply a string which contains the spec file template. However, to avoid hairy quoting hassles, it is easiest to use a scsh feature called a here string, rather than using "...". This works just like a Bourne shell style here document, just start it with #<