How to manage RPM packages with Git

Now I manage RPM packages like this repo. I put source and binary packages in this repo.But this way has these problems.

I'd like to change like this.

And I made the prototype of this idea like this.

mizzy/how-to-manage-rpm-packages-with-git

The file/directory strucure in this repo is like this.

|-- build.rb
|-- ffmpeg
|   |-- ffmpeg-github-0.8.2.spec
|   |-- libavformat-muxer.paperboy.patch
|   |-- libx264-superfast_firstpass.ffpreset
|   `-- libx264-veryfast_firstpass.ffpreset
|-- memcached
|   |-- memcached-1.4.15-1.el6.src.rpm
|   `-- memcached.spec
`-- ngx_openresty
    `-- ngx_openresty.spec

Build rb is the package build script, and others are directories for each package.Which files should be managed is vary from package to package, so I arrange several patterns.


Pattern 1: ngx_openresty

With this pattern, all I have to manage is spec file.In this spec file,

Source0: http://agentzh.org/misc/nginx/ngx_openresty-%{version}.tar.gz

You can see this line.Build.rb gets this file, pust under ~/rpmbuild/SOURCES and build source and binary packages.This is the simplest pattern.


Pattern2: ffpmeg

This pattern has a spec file, patch files and other files.If you need original patches and manage patch files with Git, this pattern is suitable.

Source: http://www.ffmpeg.org/releases/ffmpeg-%{version}.tar.bz2

Build.rb get this source file in spec, put this source, patches and other files under ~/rpmbuild/SOURCE and build source and binary packages.


Pattern 3: memcached

With this pattern, You'd like to change the build options of the existence source package, but the sources in spec file is like this.

Source0:        http://memcached.googlecode.com/files/%{name}-%{version}.tar.gz
Source1:        memcached.sysv

So you can't get the memcached.sysv through the network.But this file is included in the existence source package and you don't need to manage it with Git.

In this case, it's easy to put the existence source package under the Gir repo.


With any of these patterns, you can see the history of each file, total file size in the repo is minimum and all files needed to build package are found in the repo.


Package Building and Deploying

My final goal is, git clone these files, build packages with the script like this and deploy the packages to yum servers automatically.


Other featuer

Also I'd like to write git url as source in the spec file like this.

Source: git://github.com/torvalds/linux.git, ref: dfdeb

Build script will clone source files from this git url, build tar ball from these and build package.This idea is inspired by Bundler.