Bootstrapping Centos or Fedora from Debian or Ubuntu
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 centos with fedora should work.
apt-get install yum rpm python-m2cryptoapt-get install -t experimental rpm(needed because some packages, likebash, require features not available in unstable’s rpm package — error message aboutrpmlib(BuiltinLuaScripts)).mkdir -p /tmp/centos/var/lib/rpmrpm --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. Doln -s /tmp/centos/etc/pki /etc/pki, then againyum --installroot /tmp/centos/ install yum.mount -t proc foo /tmp/centos/procmount -t sysfs foo /tmp/centos/syschroot /tmp/centos /bin/bash --logincd /var/lib/rpm && rm *(simplest way to avoid problems between db versions for Debian’s RPM and centos’ RPM)rpm --initdbyum 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!
Thomas Bliesener wrote on 09/17/09 at 3:58 pm :
That’s exactly what I needed today! :-))
But I get some problems:
> http://www.rpmfind.net
I can’t find there “centos-release”, rpm.pbone.net works.
> rpm -ivh –force-debian
Are you sure?
> yum –installroot /tmp/centos/ install yum
I get the error:
GPG key retrieval failed: [Errno 5] OSError: [Errno 2] No such file or directory: ‘/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5′
Copying /tmp/centos/etc/pki to /etc/ doesn’t make it happy:
…
Is this ok [y/N]: y
Traceback (most recent call last):
File “/usr/bin/yum”, line 29, in
yummain.user_main(sys.argv[1:], exit_code=True)
File “/usr/share/yum-cli/yummain.py”, line 236, in user_main
errcode = main(args)
File “/usr/share/yum-cli/yummain.py”, line 188, in main
base.doTransaction()
File “/usr/share/yum-cli/cli.py”, line 364, in doTransaction
if self.gpgsigcheck(downloadpkgs) != 0:
File “/usr/share/yum-cli/cli.py”, line 464, in gpgsigcheck
self.getKeyForPackage(po, lambda x, y, z: self.userconfirm())
File “/var/lib/python-support/python2.5/yum/__init__.py”, line 2571, in getKeyForPackage
misc.import_key_to_pubring(rawkey, po.repo.cachedir)
File “/var/lib/python-support/python2.5/yum/misc.py”, line 278, in import_key_to_pubring
ctx = gpgme.Context()
AttributeError: ‘module’ object has no attribute ‘Context’Is this ok [y/N]: y
Traceback (most recent call last):
File “/usr/bin/yum”, line 29, in
yummain.user_main(sys.argv[1:], exit_code=True)
File “/usr/share/yum-cli/yummain.py”, line 236, in user_main
errcode = main(args)
File “/usr/share/yum-cli/yummain.py”, line 188, in main
base.doTransaction()
File “/usr/share/yum-cli/cli.py”, line 364, in doTransaction
if self.gpgsigcheck(downloadpkgs) != 0:
File “/usr/share/yum-cli/cli.py”, line 464, in gpgsigcheck
self.getKeyForPackage(po, lambda x, y, z: self.userconfirm())
File “/var/lib/python-support/python2.5/yum/__init__.py”, line 2571, in getKeyForPackage
misc.import_key_to_pubring(rawkey, po.repo.cachedir)
File “/var/lib/python-support/python2.5/yum/misc.py”, line 278, in import_key_to_pubring
ctx = gpgme.Context()
AttributeError: ‘module’ object has no attribute ‘Context’
And here I don’t know what to do …
lucas wrote on 09/17/09 at 4:21 pm :
rpmfind works fine for fedora. I’ve changed the order in the blog so people try pbone.net first.
–force-debian: Yes, because the rpm debian package won’t let you install packages even if you use –installroot (if I remember correctly).
pki problem: oops, I missed one step when copying from my notes. post updated. You need to answer “no”, to copy or to create a symlink, and then to start yum again.
nixternal wrote on 09/17/09 at 7:20 pm :
Wish I would have had this last year when I had to work on a CentOS based distro for a company I was working for. I had to figure this out from picking pieces from here and there all over the tubes. Should have wrote something up then, but I was obviously to lazy :) Groovy write up!
Frank Lin Piat wrote on 09/17/09 at 11:01 pm :
Hi,
Could you consider posting this on the wiki, so other people can contribute directly,
Thanks,
Franklin
lucas wrote on 09/17/09 at 11:48 pm :
@Frank Lin: what do you want to contribute?
Albert wrote on 09/18/09 at 1:23 am :
I just when through this – worked great, thanks! Just had to run this after the chroot:
echo “nameserver 4.2.2.1″ > /etc/resolv.conf
Thomas Bliesener wrote on 09/18/09 at 4:08 am :
Works! THANK YOU!
Giridhar wrote on 09/18/09 at 11:17 am :
Have you considered using febootstrap or mach? Both available in Debian.
Pabs wrote on 09/18/09 at 11:03 pm :
There’s also ‘rinse’ in Debian, by Steve Kemp
I used it to bootstrap CentOS
Luca Bigliardi wrote on 10/13/09 at 12:29 am :
Hi Lucas,
I agree with you about mock, it needs some care in debian.
In the meantime I’ve managed to have a Fedora 11 chroot on
debian using mock from git. I’m adding the steps here as a
comment, maybe they can help someone..
aptitude install -t experimental rpm
aptitude install yum rpm python-peak.util
groupadd -r mock
git clone git://git.fedorahosted.org/git/mock.git mock
cd mock
./autogen.sh
./configure
make
make install
mock -r fedora-11-x86_64 –init