You are here

Keeping my repository up to date

The RPMs in my repository are built from a git repository. In the repository, each package is a branch. This lets me keep all of the RPMs together while keeping them separate. To build them, I have a branch named BUILD. I switch to that branch and run make.

The Makefile merges all of the other branches into the BUILD branch, builds the RPMs, copies them into a repository directory, and then rsyncs that directory to my webserver. The source for the Makefile is included at the end of this post.

This method is optimized around a single repository and only needing to enter the password for my GPG key once. The downsides are that the repository layout isn't great and all RPMs are rebuilt even if only one really needs to be. So there are probably better ways to do this. tito may be a way to do this.

Anyway, here's the Makefile:

build : clean
        # Merge branches
        for i in `git branch | grep -v BUILD` ; \
        do \
                git merge $$i ; \
        done
 
        # Build RPMs
        rpmbuild -ba --sign SPECS/*.spec
 
        # Create repositories
        mkdir -p repo/{i386,x86_64}
        cp RPMS/noarch/* repo/i386/
        cp RPMS/noarch/* repo/x86_64/
        if [ -d RPMS/i386 ] ; \
        then \
                cp RPMS/i386/* repo/i386/ ; \
        fi
        if [ -d RPMS/x86_64 ] ; \
        then \
                cp RPMS/x86_64/* repo/x86_64/ ; \
        fi
        createrepo repo/i386/
        createrepo repo/x86_64/
 
        # Push repositories to server.
        rsync -av -e ssh repo/i386 repo/x86_64 user@host:/path
 
        # Push git repos to github
        git push --all origin
 
clean :
        rm -rf repo RPMS/i386/ RPMS/x86_64/ RPMS/noarch/
Topics: 

Add new comment