(→Chrooting into a loopback image) |
(→Chrooting into a loopback image) |
||
| Line 81: | Line 81: | ||
grep -q -s MeeGo ${MEEGO_ROOT}/root/.bashrc | grep -q -s MeeGo ${MEEGO_ROOT}/root/.bashrc | ||
if [ "$?" -ne "0" ]; then | if [ "$?" -ne "0" ]; then | ||
| - | echo "# MeeGo" >> ${MEEGO_ROOT}/ | + | echo "# MeeGo" >> ${MEEGO_ROOT}/root/.bashrc |
| - | echo "source /tmp/session_bus_address.user | + | echo "source /tmp/session_bus_address.user >> ${MEEGO_ROOT}/root/.bashrc |
# Change the prompt - this is optional | # Change the prompt - this is optional | ||
Under construction
One issue with a chroot installation is finding space for it. The SD card and Mydocs have plenty of space but they use FAT32 as a file system, so they can't be used directly. A solution is to mount loopback images. The easiest way to get started is to use a prebuilt loopback image.
If a prebuilt loopback image is not yet available, you can create it from a tarball.
Create 2GB image file
dd if=/dev/zero of=/home/user/MyDocs/meego-image bs=1024 count=2097152
Create filesystem on image file
mkfs.ext3 /home/user/MyDocs/meego-image
Create mount point and loopback mount the image
export MEEGO_ROOT="/mnt/meego_root" mkdir $MEEGO_ROOT mount -o loop /home/user/MyDocs/meego-image $MEEGO_ROOT
Unpack Meego rootfs image there. You might get an error about invalid tar magic. There's some problem between GNU tar and Busybox tar. Solution is to install GNU tar from Maemo Extras (package name is tar-gnu)
tar xzf <meego-image> -C $MEEGO_ROOT
Umount the image
umount $MEEGO_ROOT
You now have a loopback image ready to be chrooted into
Using a script to chroot into an image makes the process faster and safer.
Copy the code below to a meego_chroot.sh script and remember to chmod +x it.
Usage: ./meego_chroot.sh <path_to_meego-arm-n900-loop.img>
You may always execute the commands below manually if you like. Changing the prompt is optional and you only need to do it once per image.
#!/bin/sh
GRAPHICS_LIBS="\
/usr/lib/libIMGegl.so \
/usr/lib/libglslcompiler.so \
/usr/lib/libpvrPVR2D_DRI2WSEGL.so \
/usr/lib/libsrv_um.so \
/usr/lib/libOpenVGU.so \
/usr/lib/libpvrPVR2D_BLITWSEGL.so \
/usr/lib/libpvrPVR2D_FRONTWSEGL.so \
/usr/lib/libpvrPVR2D_FLIPWSEGL.so \
/usr/lib/libpvrPVR2D_X11WSEGL.so \
/usr/lib/libOpenVG.so \
/usr/lib/libEGL.so \
/usr/lib/libPVRScopeServices.so \
/usr/lib/libpvr2d.so \
/usr/lib/libGLESv2.so"
### Prepare and mount the image ###
MEEGO_IMAGE=$1
MEEGO_ROOT=/mnt/meego_root
mkdir -p ${MEEGO_ROOT}
mount -o loop ${MEEGO_IMAGE} ${MEEGO_ROOT}
### Mount system directories ###
echo "Mounting system directories inside the chroot environment..."
mount -o bind /proc ${MEEGO_ROOT}/proc
mount -o bind /sys ${MEEGO_ROOT}/sys
mount -o bind /dev ${MEEGO_ROOT}/dev
mount -o bind /dev/pts ${MEEGO_ROOT}/dev/pts/
mount -o bind /var/lib/dbus/ ${MEEGO_ROOT}/var/lib/dbus/
mount -o bind /usr/share/fonts ${MEEGO_ROOT}/usr/share/fonts
mount -o bind /tmp ${MEEGO_ROOT}/tmp
mount -o bind /var/run ${MEEGO_ROOT}/var/run
### Setup ###
rm -f ${MEEGO_ROOT}/etc/resolv.conf
cp /etc/resolv.conf ${MEEGO_ROOT}/etc/resolv.conf
rm -f ${MEEGO_ROOT}/etc/mtab
ln -s /proc/mounts ${MEEGO_ROOT}/etc/mtab
# Prepare .bashrc for setupping chroot environment
grep -q -s MeeGo ${MEEGO_ROOT}/root/.bashrc
if [ "$?" -ne "0" ]; then
echo "# MeeGo" >> ${MEEGO_ROOT}/root/.bashrc
echo "source /tmp/session_bus_address.user >> ${MEEGO_ROOT}/root/.bashrc
# Change the prompt - this is optional
echo "export PS1=MeeGo-chroot:\\\w\\\\\$" >> ${MEEGO_ROOT}/root/.bashrc
fi
# Setup .bashrc for cases when sudo is used
grep -q -s MeeGo ${MEEGO_ROOT}/home/user/.bashrc
if [ "$?" -ne "0" ]; then
echo "# MeeGo" >> ${MEEGO_ROOT}/home/user/.bashrc
echo "source /tmp/session_bus_address.user" >> ${MEEGO_ROOT}/home/user/.bashrc
# Change the prompt - this is optional
echo "export PS1=MeeGo-chroot:\\\w\\\\\$" >> ${MEEGO_ROOT}/home/user/.bashrc
fi
# Copy graphics libraries from host
for lib in ${GRAPHICS_LIBS}; do
cp ${lib} ${MEEGO_ROOT}/usr/lib/
done
# Copy pulseaudio files from host
cp /usr/lib/libpulse* ${MEEGO_ROOT}/usr/lib/
cp /var/run/pulse/.pulse-cookie ${MEEGO_ROOT}/etc/pulse-cookie
### Start your engines ###
echo -e "chrooting to ${MEEGO_ROOT}...\n"
cd ${MEEGO_ROOT}
chroot ${MEEGO_ROOT} /bin/bash
### Cleanup ###
echo "Cleaning mounts..."
cd ~
umount ${MEEGO_ROOT}/dev/pts
umount ${MEEGO_ROOT}/dev
umount ${MEEGO_ROOT}/sys
umount ${MEEGO_ROOT}/proc
umount ${MEEGO_ROOT}/var/lib/dbus/
umount ${MEEGO_ROOT}/usr/share/fonts
umount ${MEEGO_ROOT}/tmp
umount ${MEEGO_ROOT}/var/run
umount ${MEEGO_ROOT}
echo