2014-09-19

How to work with CentOS-5 in a CentOS-7 mock shell

So I have been spending a lot of time lately working on Extra Packages for Enterprise Linux (EPEL) as I know it is one of the undersold success stories of Fedora.

In doing so I have been focusing on EPEL-5 as it is the oldest release and something that most packagers do not actually think about (as they are usually focusing on the latest and greatest in Fedora or maybe Enterprise Linux-7). This has been a trip down memory lane as I have had to deal with things like ancient Python and a yum without the same command set or tools as 'current' ones.

One of the big things I have to remember is that EL-5 is based off Fedora 6 (zod) and so its RPM database is a different format than what is in any Fedora after version 8 (I believe). I rediscovered this format change when I was trying to see what packages in EPEL might replace 'core' packages in a bare bones CentOS-5 install. I was using mock to do this which uses the host system (in my case a EL-7 box) to populate the buildroot with packages from EL-5 tree.

I ran into this when I did a
[smooget@junk02 rpm]$ mock -r local-5-i386 --init
[smooget@junk02 rpm]$ mock -r local-5-i386 --shell
[root@junk02 /]# rpm -qa


I got an error telling me that the database type(9) was unknown. After spending some time working through various people running into this on google, I was able to piece together the following on how to work with the rpm inside the mock shell appropriately.
  1. Before entering into the shell, dump the databases with the system db_dump
    [smooget@junk02 rpm]$ mock -r local-5-i386 --install db4-utils
    [smooget@junk02 rpm]$ sudo -i
    [root@junk02 rpm]# cd /srv/mock/tree/local-5-i386/root/var/lib/rpm # this is not DEFAULT location
    [root@junk02 rpm]# for i in Basenames Conflictname Dirnames Group Installtid Name Obsoletename Packages Providename Requirename Sha1header Sigmd5 Triggername ; do echo $i; db_dump $i > $i.x; done
    Basenames
    Conflictname
    Dirnames
    Group
    Installtid
    Name
    Obsoletename
    Packages
    Providename
    Requirename
    Sha1header
    Sigmd5
    Triggername
    
  2. Now we can load all those db (really on Packages is needed but I like to be a completist)
    [smooget@junk02 rpm]$  mock -r local-5-i386 --shell
    [root@junk02 /]# cd /var/lib/rpm
    [root@junk02 /]# for i in Basenames    Conflictname    Dirnames    Group    Installtid    Name    Obsoletename    Packages    Providename    Requirename    Sha1header    Sigmd5    Triggername; do echo $i; rm -v $i; cat $i.x | db_load $i; done
    [root@junk02 /]# rpm --rebuilddb
    [root@junk02 /]# rpm -qa 
    should give you a list of packages.
    
Note once you have done this you can not use mock to install packages anymore. If you need to install more packages make sure you have installed yum before you do this.

So what does this give you if you have completed this and installed EVERY possible package (choosing one set in case of conflicts like samba/samba3)




=============================================================================================================================
 Package                          Arch                    Version                            Repository                 Size
=============================================================================================================================
Updating:
 agg                              i386                    2.5-9.el5                          extras                    147 k
 agg-devel                        i386                    2.5-9.el5                          extras                    368 k
 fribidi                          i386                    0.19.2-2.el5                       extras                     53 k
 fribidi-devel                    i386                    0.19.2-2.el5                       extras                     53 k

Transaction Summary
=============================================================================================================================
Install       0 Package(s)
Upgrade       4 Package(s)

Total size: 620 k
Is this ok [y/N]: 



So it looks like my next step will be to a) see if RHEL-5.10 updated those packages and if not have them 'removed' or something else. Also I need to figure out a better way of doing this so we can have a koji test to make sure the EPEL package doesn't ever get in the first place.