September 17th, 2009 by lucas
Here are some notes about bootstrapping a Centos or Fedora chroot from Debian. It should also work from Ubuntu with minor changes, but I haven’t checked. The following should really be done in a chroot, since some commands will install files in your /etc or elsewhere, ignoring the
--installroot passed to
yum. The following instructions are for Centos, but replacing all occurences of
fedora should work.
apt-get install yum rpm python-m2crypto. If at some point, you get error messages about
rpmlib(BuiltinLuaScripts), you need to install a newer rpm package (from Debian unstable, for example).
mkdir -p /tmp/centos/var/lib/rpm
rpm --root /tmp/centos --initdb
- Go to http://rpm.pbone.net or http://www.rpmfind.net, search for centos-release or fedora-release, and download the rpm for the version you want.
rpm -ivh --force-debian --nodeps --root /tmp/centos centos-release*rpm(that populates /tmp/centos/etc with information about the centos repositories)
yum --installroot /tmp/centos/ install yum. That fails because of missing GPG information in /etc/pki. Do
ln -s /tmp/centos/etc/pki /etc/pki, then again
yum --installroot /tmp/centos/ install yum.
mount -t proc foo /tmp/centos/proc
mount -t sysfs foo /tmp/centos/sys
chroot /tmp/centos /bin/bash --login
If you get errors about different DB versions between Debian’s RPM and CentOS’ RPM, you can try, in the CentOS chroot:
cd /var/lib/rpm && rm *(simplest way to avoid problems between db versions for Debian’s RPM and centos’ RPM)
yum install yum(again, to restore the rpm db)
yum install vim-minimal less
- That’s all!
Update: Jaldhar Vyas pointed me to mach, and Paul Wise to mock. Both packages are available in Debian, but use config files for each release shipped in the package. Unfortunately, both packages are out of date, and don’t include Fedora 9 or newer. Also, mock doesn’t support Centos.
Anyway, both packages could use a new maintainer. Don’t hesitate to jump in!