Local yum repo for multiple versions

chris asked:

I would like to setup a local repo for rhel 5 and 6. Can this be done on 1 server, or do I need one server for each major version?

We have a valid, legal subscription with RH, but we would rather not pay for RH satellite.

My answer:


You can build packages for EL5 on an EL6 box, but the problem is that EL6 has a newer version of RPM that writes files incompatible with the version of RPM shipped with EL5. You can work around this with some arguments to rpmbuild when building your source packages, preferably in a wrapper script. Something like this will cause rpmbuild to use the older format:

#!/bin/bash
# Assumes you have an RPM environment set up in ~/rpmbuild using rpmdev-setuptree
# Argument 1: a spec file in ~/rpmbuild/SPECS
# Build the EL6 SRPM
rpmbuild -bs $1
# Build the EL5 SRPM
rpmbuild 
  --define "_source_filedigest_algorithm 1" 
  --define "_binary_filedigest_algorithm 1" 
  --define "_binary_payload w9.gzdio" 
  --define="dist .el5" 
  --define="el5 1" 
  $1

Once the SRPMs are built, you can then run mock on the EL5 and EL6 SRPMs, respectively:

for el in 5 6; do
  for package in ~/rpmbuild/SRPMS/*.el{$el}.src.rpm; do
    for arch in x86_64 i386; do
      mock -r epel-{$el}-{$arch} $package
    done
  done
done

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.