Difference between revisions of "Development Team/Chroot"

From Sugar Labs
Jump to navigation Jump to search
m
m (moved Walter is a wanker 12/Chroot to Development Team/Chroot over redirect: revert)
 
(29 intermediate revisions by 7 users not shown)
Line 1: Line 1:
Sugar is now somewhat runnable from chroots. Jaunty and Squeeze have been tested recently; Fedora has not. --[[User:Mstone|Michael Stone]] 22:21, 23 May 2009 (UTC)
+
=== Status ===
  
=== Chroot Construction ===
+
* sugar-chroot-0.1 released: see [http://dev.laptop.org/git/users/mstone/sugar-chroot sugar-chroot]
  
There are lots of ways to create appropriate chroots; e.g. by hand, with debootstrap, with mock, etc.
+
=== Purpose ===
  
Here are some ideas to help you get started:
+
''You want to hack sugar. You don't want to fuss around. '''You want sugar-chroot.'''''
  
==== Ubuntu jaunty chroot ====
+
=== Usage ===
With ''recent'' versions of debootstrap, in order to get a working chroot, you want something like:
 
  
export CHROOT=`pwd`/jaunty-root
+
As excerpted from the '''[http://dev.laptop.org/git/users/mstone/sugar-chroot/plain/README README]''':
sudo debootstrap --arch i386 jaunty $CHROOT http://ubuntu.media.mit.edu/ubuntu/
 
sudo chroot $CHROOT /bin/bash -l
 
mount -t proc proc /proc
 
mount -t devpts devpts /dev/pts
 
  
==== Debian squeeze chroot ====
+
sugar-chroot consists of simple scripts. Download and unpack them like so:
With debootstrap, in order to get a working chroot, you want something like:  
 
  
  export CHROOT=`pwd`/sid-root
+
  NV=sugar-chroot-0.1
  sudo debootstrap --arch i386 squeeze $CHROOT http://debian.lcs.mit.edu/debian
+
  curl http://dev.laptop.org/~mstone/releases/SOURCES/$NV.tar.xz | tar Zxf $NV.tar.xz
sudo chroot $CHROOT /bin/bash -l
+
  cd $NV
# and some of the following:
 
mount -t tmpfs tmpfs $CHROOT/tmp
 
mount -t proc proc $CHROOT/proc
 
mount -t devpts devpts $CHROOT/dev/pts
 
  mount -t selinuxfs selinux $CHROOT/selinux
 
  
''Reference: http://www.debian.org/doc/manuals/reference/ch-tips.en.html ''
+
To use them, pick a supported distro:
  
==== Fedora rawhide chroot ====
+
DISTRO=debian
With mock, it would be more like:
+
DISTRO=fedora
  
mock -r fedora-devel-i386 --init
+
To configure:
mock -r fedora-devel-i386 --install yum
 
mock -r fedora-devel-i386 --shell
 
  
=== Sugar Installation ===
+
echo $DISTRO > conf/distro
 +
$EDITOR conf/$DISTRO.mk
  
==== jaunty chroot ====
+
Then run
  
  sed -ie "s/main/main universe/" /etc/apt/sources.list
+
  sudo make r/distro
apt-get update
 
 
apt-get install locales
 
locale-gen "$LANG"
 
dpkg-reconfigure tzdata
 
 
apt-get install sugar sugar-activities
 
 
# install your development tools here
 
 
 
# patch (hopefully temporary) bugs
 
sed -ie '114i\\        if not favorites_settings.layout: favorites_settings.layout = favoriteslayout.RingLayout.key' /usr/lib/python2.6/dist-packages/jarabe/desktop/favoritesview.py
 
  
==== squeeze chroot ====
+
to install your chroot.
  
apt-get update
+
=== History ===
apt-get install locales
 
dpkg-reconfigure locales
 
 
# edit /etc/hosts
 
  
apt-get install education-desktop-sugar
+
See http://wiki.sugarlabs.org/index.php?title=Development_Team/Chroot&oldid=36911 for the manual instructions which sugar-chroot automates.
 
# install your development tools here
 
 
# fix broken hippocanvas
 
echo "deb-src http://debian.lcs.mit.edu/debian squeeze main" >> /etc/apt/sources.list
 
apt-get update
 
apt-get install apt-src devscripts
 
apt-src install python-hippocanvas
 
cd *hippo*
 
DEB_BUILD_OPTIONS=nostrip debuild -us -uc
 
cd ..
 
dpkg -i *hippo*.deb
 
 
 
=== User Accounts ===
 
 
 
For stupid reasons, it's necessary that Sugar run under a uid inside the chroot which exists as a real account outside the chroot. (Talk to the DBus people.)
 
 
 
Consequently, ''as root'', run something like this ''both'' inside and outside the chroot:
 
 
 
groupadd -g 64002 sugar
 
useradd -m -u 64002 -g sugar -s /bin/bash sugar
 
 
 
=== D-Bus ===
 
 
 
Sugar wants to be able to use global state stored in both HAL and NetworkManager, both of which live on the system bus. Consequently, ''outside the chroot'', we need to
 
 
 
sudo mount --bind /var/run/dbus $CHROOT/var/run/dbus
 
 
 
before entering the chroot. (Mock uses unshare() to enter a new mount-point namespace since this makes garbage collection of mountpoints much easier.)
 
 
 
=== X11 ===
 
 
 
We need to point Sugar at an X server. One easy (but insecure) way to do this is to make a nested X server like so, ''outside the chroot'':
 
 
 
Xephyr -ac :1 -screen 800x600x24 # 1024x768x24
 
 
 
See the talk page for more secure alternatives.
 
 
 
=== Running Sugar ===
 
 
 
Then, inside the chroot, you can happily run sugar as user 'sugar' with something like
 
 
 
sudo chroot $CHROOT /bin/bash -l
 
su sugar -
 
export DISPLAY=localhost:1
 
export DBUS_SESSION_BUS_ADDRESS=$(dbus-daemon --session --print-address --fork)
 
sugar
 
 
 
Then pull up the frame, switch to the home view, and launch some activities!
 
 
 
=== Cleaning Up ===
 
 
 
To correctly delete a chroot that you no longer need, kill all processes running in the chroot, and
 
 
 
sudo killall -u sugar
 
export CHROOT=/path/to/my/chroot  # important!
 
umount $CHROOT/var/run/dbus
 
umount $CHROOT/proc
 
umount $CHROOT/dev/pts
 
umount $CHROOT/tmp
 
rm -rf $CHROOT
 

Latest revision as of 20:33, 23 February 2010

Status

Purpose

You want to hack sugar. You don't want to fuss around. You want sugar-chroot.

Usage

As excerpted from the README:

sugar-chroot consists of simple scripts. Download and unpack them like so:

NV=sugar-chroot-0.1
curl http://dev.laptop.org/~mstone/releases/SOURCES/$NV.tar.xz | tar Zxf $NV.tar.xz
cd $NV

To use them, pick a supported distro:

DISTRO=debian
DISTRO=fedora

To configure:

echo $DISTRO > conf/distro
$EDITOR conf/$DISTRO.mk

Then run

sudo make r/distro

to install your chroot.

History

See http://wiki.sugarlabs.org/index.php?title=Development_Team/Chroot&oldid=36911 for the manual instructions which sugar-chroot automates.