Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#4389 closed task (wontfix)

Implement and document how to run Sugar in a Chroot environment.

Reported by: danielfrancis Owned by: danielfrancis
Priority: Unspecified by Maintainer Milestone:
Component: Sugar Version: Git as of bugdate
Severity: Minor Keywords:
Cc: dnarvaez Distribution/OS: Ubuntu
Bug Status: Assigned

Description

Sugar is supported in up-to-date GNU/Linux distributions. When a distribution has old packages, it doesn't use package managers, or other reasons to don't support it in sugar-build, the way I found to build and run Sugar is installing a supported distribution in another disk partition and using chroot to run commands as in the supported distribution.

The procedure I'm using to mount and chroot (all as root):

The command xchroot is this script: http://www.elstel.com/xchroot/xchroot-v2.1
It does easier the way to run X applications.

$ su
# mount /dev/sda1 /mnt/ubuntu
# mount /dev/sda5 /mnt/ubuntu/home
# cd /mnt/ubuntu
# mount --bind /dev dev
# mount --bind /proc proc
# # Sometimes you need to copy /etc/resolv.conf to etc
# xchroot .
# su sdf # Ubuntu user which has built Sugar
$ cd ~/sugar-build
$ make shell
[$] sugar-emulator


sugar-emulator works for me, but I get an error when using make run and sugar-runner.

The log was:
http://people.sugarlabs.org/francis/logs/sugar-run.log

I'll be testing and trying to document the procedure. Also I'll attach some patches to sugar-runner to allow to run correctly in a chroot environment.

Attachments (1)

0001-Document-how-to-build-in-a-Chroot-environment.patch (1.5 KB) - added by danielfrancis 11 years ago.
Documentation patch

Download all attachments as: .zip

Change History (23)

comment:1 Changed 11 years ago by danielfrancis

  • Cc dnarvaez added

comment:2 Changed 11 years ago by dnarvaez

Another use case would be to build nightly os images with a build snapshot on it. I've been playing with that but only on the os side.

comment:3 follow-up: Changed 11 years ago by dnarvaez

git://github.com/dnarvaez/sugar-os.git

Just fyi, very initial work.

comment:4 in reply to: ↑ 3 Changed 11 years ago by danielfrancis

Replying to dnarvaez:

git://github.com/dnarvaez/sugar-os.git

Sounds good.

I see that you are using the pacman package manager. ArchLinux doesn't look as the perfect distro to run the development version of a Python project.

https://www.archlinux.org/news/python-is-now-python-3/

This is a good example of a distribution which can't be supported before a migration to Python 3.

Changed 11 years ago by danielfrancis

Documentation patch

comment:5 Changed 11 years ago by danielfrancis

After some tests and changing the procedure, I didn't need to patch the scripts.
A patch to the Sugar docs is attached.

comment:6 Changed 11 years ago by dnarvaez

The problem I see with this is that the most important part is to actually install the chrooted distribution and I can't think of any way to document that part in a distro independent way. It depends on both the distributions involved which makes documenting (and maintaining the documentation) really complicated.

comment:7 Changed 11 years ago by dnarvaez

Perhaps we could document it using debbootstrap (I suppose that's what you are using?). It seems like it would cover old fedora, debian, Ubuntu and archlinux at least.

comment:8 Changed 11 years ago by dnarvaez

To clarify, we could document how to install Ubuntu 12.10 in a chroot under any distro which packages debbootstrap.

comment:9 Changed 11 years ago by danielfrancis

+1

I'm not using debbootstrap, I had set up dual-booting for Ubuntu and Arch. I used Ubuntu to run Sugar build and now I mount the partition, chroot it and use Sugar Build without having to switch between systems.

I'll try the procedure with debbootstrap and make new version of the patch.
Also, I think that would be better to make a shellscript instead of many commands in the documentation.

comment:10 Changed 11 years ago by dnarvaez

Agree about the script

comment:11 Changed 11 years ago by danielfrancis

I worked in a script to create a virtual environment with debootstrap, install the necessary packages to run Sugar Build, create a user, allow it to run Sudo, clone Sugar Build and build it.

http://git.sugarlabs.org/sugar-devel-env/sugar-devel-env

It's documentation is in the README. I'm planning to improve it and do it more confortable in the future, but it's a good start.

If you agree, the only update to the Sugar Docs would be after the list of supported distributions, a link to the repository.

comment:12 follow-up: Changed 11 years ago by dnarvaez

First of all, this is awesome!

Then some suggestions:

  • I think it needs a more specific name, like sugar-build-chroot, sugar-chroot-env or if you really hate chroot in the name maybe sugar-virtual-env. The current name doesn't make it very clear what the project is about (I would wonder how it is different from sugar-build for example).
  • Maybe before creating a user, print some text about what is going on? It was a bit surprising to me and I know how the chroot stuff works so it's probably going to surprise others more. (It asks for your passwords and you wonder what it is about).
  • I think documentation in the README make sense for now, but you should consider adding it to sugar-docs once this is more stable/tested. Just so that readers don't need to jump through and can read in a consistent format.
  • I'm not sure why there is a dependency on a running X server, but if it's possible to remove it, it would be nice. sugar-build itself doesn't require one.
  • Announce it on the mailing list! :)

And a bug report:

initctl: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused
start: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused
invoke-rc.d: initscript dbus, action "start" failed.
dpkg: error processing dbus (--configure):

subprocess installed post-installation script returned error exit status 1

This is on debian wheezy (it's a sugar-build supported distribution, but still).

comment:13 follow-up: Changed 11 years ago by dnarvaez

Another thing, the failure left the mounts in place. I think it would be good to get rid of them on failures.
And a way for env.sh to get rid of those would be nice too. It's a bit annoying to manually cleanup chroot mounts.

comment:14 in reply to: ↑ 12 ; follow-up: Changed 11 years ago by danielfrancis

Replying to dnarvaez:

Then some suggestions:

  • I think it needs a more specific name

Moved the repository:
http://git.sugarlabs.org/sugar-virtual-env/sugar-virtual-env

  • Maybe before creating a user, print some text about what is going on?

That's the current behavior.
http://git.sugarlabs.org/sugar-virtual-env/sugar-virtual-env/blobs/master/sugar-env-setup.sh#line36

  • I think documentation in the README make sense for now, but you should consider adding it to sugar-docs once this is more stable/tested. Just so that readers don't need to jump through and can read in a consistent format.

Sure.

  • I'm not sure why there is a dependency on a running X server, but if it's possible to remove it, it would be nice. sugar-build itself doesn't require one.

The script runs xhost to allow the virtual system to run X applications, but it wont stop if the command fails or if it isn't installed, so you are right.

And a bug report:

dpkg: error processing dbus (--configure):

Dbus doesn't work always in all Chroot environments and Sugar has got the necessary conditionals to work without showing network information.
Does it stop the installation/build process? (That's a bug which can be fixed)

comment:15 in reply to: ↑ 13 Changed 11 years ago by danielfrancis

Replying to dnarvaez:

Another thing, the failure left the mounts in place. I think it would be good to get rid of them on failures.
And a way for env.sh to get rid of those would be nice too. It's a bit annoying to manually cleanup chroot mounts.

The chroot script unmounts all.
http://git.sugarlabs.org/sugar-virtual-env/sugar-virtual-env/blobs/master/sugar-chroot#line52

comment:16 in reply to: ↑ 14 ; follow-up: Changed 11 years ago by dnarvaez

Replying to danielfrancis:

  • Maybe before creating a user, print some text about what is going on?

That's the current behavior.
http://git.sugarlabs.org/sugar-virtual-env/sugar-virtual-env/blobs/master/sugar-env-setup.sh#line36

Oh! It might be good to make standout more, it sort of get lost in all the text, with \n around it and # or something.

And a bug report:

dpkg: error processing dbus (--configure):

Dbus doesn't work always in all Chroot environments and Sugar has got the necessary conditionals to work without showing network information.
Does it stop the installation/build process? (That's a bug which can be fixed)

It breaks when configuring debs. dbus is not configured because of that error and several dependencies also goes unconfigured because of that.

comment:17 in reply to: ↑ 16 Changed 11 years ago by danielfrancis

Replying to dnarvaez:

Oh! It might be good to make standout more, it sort of get lost in all the text, with \n around it and # or something.

Pushed.

It breaks when configuring debs. dbus is not configured because of that error and several dependencies also goes unconfigured because of that.

Happened the first time I built Sugar without mounting all the directories, then with Sugar-chroot it was fixed for me. I'm not sure about how to solve it now.

comment:18 Changed 11 years ago by dnarvaez

There is a bug about this with a lo of info

https://bugs.launchpad.net/ubuntu/+source/upstart/+bug/430224

I guess it doesn't work for me because in debian there is no upstart. Perhaps we could just replace initctl as suggested, I suppose we don't depend on running upstart services in the chroot.

comment:19 Changed 11 years ago by dnarvaez

Installation is succeeding with that approach, I should have a few patches for you in a bit.

comment:20 Changed 11 years ago by dnarvaez

  • Resolution set to wontfix
  • Status changed from new to closed

This is was done in a separate module by Daniel.

comment:21 Changed 11 years ago by dnarvaez

  • Milestone not applicable deleted

Milestone not applicable deleted

comment:22 Changed 11 years ago by dnarvaez

  • Component changed from sugar-build to Sugar
Note: See TracTickets for help on using tickets.