Skip to content

Setup an schroot build environment

Cecil edited this page Dec 11, 2017 · 1 revision

Setting up a schoot

Warning: schroot and debootstrap are Debian Linux creatures. Ubuntu is a Debian.

Using an schroot to create a build environment for Shoes Linux is much easier and runs faster than creating a bunch of OracleBox virtual machines and it allows for clever cross compile possibilities with qemu but we're going to stick the simple things here. If you want to build Linux Shoes for distribution instead of depending on me (aka you are forking the project or replacing me or just terribly curious), this is a the best way to build for distribution.

Can you do it in a VM installed on a Windows or OSX Virtual Machine? Yes! Just make sure your VM has plenty of disk assigned 50GB perhaps (more would be better). Just create a Ubuntu VM, install that and then you follow along. I'm not going to describe how to setup a VM or install ubuntu/debian on Window or OSX. Plenty of web info for doing that. Just make sure its a 64 bit Linux VM installed on 64 bit host. Let me me know if anyone tries that.

Everything that follows is done in Linux and you stop when you see errors and you fix them.

get debootstrap

$ sudo apt-get install debootstrap
$ sudo apt-get install schroot

Configure a schroot

Do your web searches (RTFM) before you blindly accept the following. I want a chroot with the latest Debian Wheezy (7.11?). At least, read this. That page refers to very old Linux distribution names, so we will have to replace them.

I prefer to use the /etc/schroot/chroot.d method for creating my schroot. My names and locations will have to be changed to what you want. You'll need to sudo -s to create anything in /etc or type sudo in front of every command. My chroot will be known as wzyX86 to the schroot command and the files will live in /srv/chroot/deb7-11.x86_64

ccoupe@bronco:/etc/schroot/chroot.d$ more wzyX86.conf 
[wzyX86]
description=Debian 7.11 Wheezy for x86_64
directory=/srv/chroot/deb7-11.x86_64
#personality=linux32
root-users=ccoupe
type=directory
users=ccoupe

Now we need to create the directory

sudo mkdir -p /srv/chroot/deb7-11.x86_64

Install Wheezy

ccoupe@bronco:~$ sudo debootstrap --variant=buildd --arch=amd64 wheezy /srv/chroot/deb7-11.x86_64/ http://ftp.debian.org/debian/

W: Cannot check Release signature; keyring file not available /usr/share/keyrings/debian-archive-keyring.gpg
I: Retrieving Release 
....
....
I: Configuring build-essential...
I: Base system installed successfully.
ccoupe@bronco:~$ 

Get back to a normal user if you are su'd - ^d to exit su status works well.

Update Packages

Lets login to the new chroot. $ schroot -c wzyX86 and then su. We need to edit the /etc/apt/source.list file. It only has one line inside and we need more repos. Make it look like this: (for wheezy - Debian 7.x obviously)

deb http://ftp.us.debian.org/debian/ wheezy main
deb-src http://ftp.us.debian.org/debian/ wheezy main

deb http://security.debian.org/ wheezy/updates main
deb-src http://security.debian.org/ wheezy/updates main

# wheezy-updates, previously known as 'volatile'
deb http://ftp.us.debian.org/debian/ wheezy-updates main
deb-src http://ftp.us.debian.org/debian/ wheezy-updates main
deb http://http.debian.net/debian wheezy-backports main

Now do apt-get updates and then apt-get dist-upgrade

Install Packages Shoes needs

Login and become root

ccoupe@bronco:~$ schroot -c wzyX86
(wzyX86)ccoupe@bronco:~$ su 
Password: 
(wzyX86)root@bronco:/home/ccoupe# apt-get install build-essential

Yes it should tell you it was installed. It's a test.

Continue with installing these: libgtk-3-dev libxml2-dev libxslt1-dev libcroco3-dev librsvg2-dev libjpeg-dev libgif-dev . If we need more, we know how to do it - but only if we know the package name. See troubleshooting.

Notice one other thing. Your home directory is shared is in the schroot and you can write to it.. Also notice the your PATH env variable is NOT the same. $ echo $PATH We are going to exploit that.

Ruby dependencies

Debian does not come with a Ruby installed but if it did, we would need to use one configured our way. As a normal user, we want to build Ruby 2.2.7 ( this example) . I happen to have a place in my home directory were I keep all these things cd ~/Projects/shoesdeps/src/ for me, and I have a copy of ruby-2.2.7.tar.gz in there. So we, untar it create a build script and see what else is missing. We are going to install it in the schroot's /usr/local/ because /usr/local/bin is at the front of PATH.

First, we need to install some packages that Ruby wants.

$ su
# apt-get install libgdbm-dev
# apt-get libssl-dev
# apt-get libreadline6-dev
# apt-get libyaml-dev
^d
$

Ruby build

We want a build script, 'wheezy-ruby.sh' 👍

#! /bin/bash
# copy this to the ruby dir or soft link it.
# execute it instead of ./configure
export dest="/usr/local"
export CFLAGS="-I${dest}/include"
export LDFLAGS="-L${dest}/lib"
./configure \
  --enable-shared \
  --enable-load-relative \
  --disable-install-doc \
  --without-tk --without-tcllib --without-tcltk \
  --prefix="${dest}"

Untar, cd, configure:

...$ tar xf ruby-2.2.7.tar.gz 
...$ cd ruby-2.2.7
.../ruby-2.2.7$ ../wheezy-ruby.sh
.... many lines out configure output
config.status: creating ruby-2.2.pc
.../ruby-2.2.7$

make You will want to pay attention to the configure and compile phases of the Ruby options. If you think it has all the right optional libraries then do the su and make install dance. Verify that you have a ruby 2.2.7

# ruby -v
ruby 2.2.7p470 (2017-03-28 revision 58194) [x86_64-linux]
# gem -v
2.4.5.2

rubygems

Ruby includes really old versions of rubygems when you build from source (we did)- it's kind-of easy to fix. I prefer wget instead of curl so lets install wget. You know the drill. be su and apt-get install wget. I suggest to get back to a normal user in your schoot (not root user) and your cd'd into that src/.

$ wget https://github.com/rubygems/rubygems/archive/v2.6.10.tar.gz
$ #grrr
$  mv v2.6.10.tar.gz  rubygems-2.6.10.gz
$ tar xf rubygems-2.6.10.gz
$ cd rubygems-2.6.10
$ su
# ruby setup.rb --no-rdoc --no-ri
^d
$ gem -v
2.6.10

We should be good to build Shoes inside our schroot. cd to ~Projects/shoes3 where my shoe3 source lives. rm crosscompile' if it exists. rake -T. rake linux:setup:x86_64_linuxandrake` Don't panic if it dies because it can't find something. You can fix that.

Troubleshooting

Finding package names

Fortunately, you have the tools. In your host system, there is a GUI package installer (perhaps several of them) and they usually have a search function. I happen to like synaptic. for this article, I used an older Debian 7.2 VM and it's Add/Replace Software in the menus to verify each of the above package names. There is also a command line way to search but I never remember what it is.

permissions error with minitest

This happens when you don't do a rake clean before a second rake. For reasons known only by the minitest folk they have some files with 444 permission (r--r--r--). they get copied in the the first rake but a second rake doesn't have permission to write over them. If you do a rake clean, then their are no files so the copy succeeds.

Clone this wiki locally