2011年2月16日星期三

Fedora Chroot Bootstrap at Ubuntu 10.10

Ubuntu has febootstrap utilities to build up the Fedora Bootstrap project. It can download everything from Fedora Project. But when you chroot into new installed Fedora folder. You will find that it miss yum (apt-get like utilities) and no rpm packages are installed. (Although the packages are installed).

  • yum package is not installed
  • rpm database are not located at /var/lib/rpm
  • rpm under /home/$USER/.rpmdb may not compatible with your Fedora RPM version
So you have to reinstall the fedora packages again when you chroot. I have written a script to do everything.

#!/bin/sh
#

# Fedora Release

DISTRO=fedora
RELEASE=9
ARCH=i386
FOLDER=${DISTRO}-${RELEASE}
BOOTSTRAP_PATH=${PWD}/${FOLDER}
MIRROR=`curl -s "http://mirrors.fedoraproject.org/mirrorlist?repo=${DISTRO}-${RELEASE}&arch=i386" | grep http[\:] | head -1`

echo 'Mirror from Fedora Project ' ${MIRROR}

febootstrap --noclean --install="fedora-release" --install="yum" ${RELEASE} ${BOOTSTRAP_PATH} ${MIRROR}

cp /etc/resolv.conf ${FOLDER}/etc/
mount -t proc none ${FOLDER}/proc

cd ${FOLDER}
RPM_PKG=`find var -type f | grep rpm-[0-9] | grep rpm$`
FEDORA_PKG=`find var -type f | grep fedora-release-[0-9] | grep rpm$`
cd ..

chroot ${BOOTSTRAP_PATH} /bin/rpm --initdb
chroot ${BOOTSTRAP_PATH} /bin/rpm -ivh --nodeps ${RPM_PKG}
chroot ${BOOTSTRAP_PATH} /bin/rpm -ivh --nodeps ${FEDORA_PKG}
chroot ${BOOTSTRAP_PATH} yum -y check-update
chroot ${BOOTSTRAP_PATH} yum -y install yum rpm fedora-release
chroot ${BOOTSTRAP_PATH} yum -y update
chroot ${BOOTSTRAP_PATH} yum -y groupinstall core buildsys-build
# you can simply duplicate the previous line to install more packages automatically
chroot ${BOOTSTRAP_PATH} yum clean all

umount ${FOLDER}/proc


You can simply copy & paste into a bootstrap.sh. Please modify the shell script. Edit RELEASE and ARCH to suit your needs.

Before running this script, please install the packages at your Ubuntu 10.10 environment.

apt-get install yum rpm curl febootstrap

Happy Hacking!

2010年10月19日星期二

重新寫Blog

好久沒寫Blog,因為Server問題,沒有把舊文章取回來.唯有重新來過!現在都想寫一些技術文章,方便自己記錄一下,IT這一行就是這樣,天天都有新事物,學不盡,十年學Java,今年的J2EE已經不同,往事寫PHP/JSP/ASP去產生網頁,今天有GWT去做Ajax,HTML 5又要發佈,只要過幾年,很多人都不寫桌面軟件.

現在都集中在Embedded Linux跟Java這兩面發展,無奈都是老板的要求,從Driver到GUI到Backend,通通都要你去寫... :D 這就是工作吧,唯有把它看成自己的興趣,否則做不下去..