How to create a chroot environment for your team
Jing, mqjing@gmail.com
ETA: 20 mins
On-line Version: (view)
Chroot redefines the "ROOT" directory or "/" for a program or login session. Basically, everything outside of the directory you use chroot on doesn't exist as far a program or shell is concerned.
Quick Guide
Step 1: Host Utility Installation
# java (for Jenkins slave connection)
$ sudo vi /etc/apt/sources.list
/etc/apt/sources.list
$ sudo apt-get update
$ sudo apt-get install sun-java6-jdk
2. copy repo to /usr/local/bin/repo
# git (for pull the code)
$ sudo apt-get install git-core
$ git config --global user.name "autobuild"
| |||
Step 2: schroot/chroot configuration
# proxy
$ sudo vi /etc/profile
/etc/profile
# install schroot & debootstrap
sudo apt-get install schroot debootstrap
# install the ubuntu 10.04
# create a folder for chroot env.
mkdir chroot
sudo http_proxy=http://1.2.3.4:8080 debootstrap --variant=buildd --arch amd64 lucid /home/autobuild/chroot/chroot-amd64-ubuntu10.04/ http://free.nchc.org.tw/ubuntu/
# setup the chroot configuration
/etc/schroot/schroot.conf
# check the permission in the env
Note: the system files permission should be root.
# test the env
$ schroot -l
android-lucid
# [optional] setup the pseudo-terminal slave/master, related system information for chroot env.
Optional
| |||
Step 3: Guest (chroot env) Utility Installation
# Update time-zone (You are in the host env)
sudo cp /usr/share/zoneinfo/Asia/Taipei
/home/jing/chroot/chroot-amd64-ubuntu10.04/etc/localtime
# install repo (for build script that would like to repo code)
sudo cp /usr/local/bin/repo
/home/jing/chroot/chroot-amd64-ubuntu10.04/usr/local/bin/repo
# Enter chroot environment (for install the utility in chroot env)
$ sudo chroot /home/jing/chroot/chroot-amd64-ubuntu10.04(Please note: sudo chroot. NOT schroot -c xxx)
# [optional] setup locale
Optional
# set up proxy for apt-get
export http_proxy=http://1.2.3.4:8080
# add apt source (You are in chroot env)
# Note: If you doesnot add the following source, you will get ia32-lib missing
# error message
/etc/apt/sources.list
or
apt-get update
# java for Android build (you are in chroot env)
# apt-get install sun-java6-jdk
# basic tool-chain (you are in chroot env)
apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev libc6-dev lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown libxml2-utils xsltproc
# Now, common platform ready
You are ready to go!
Test
schroot -c sqm-android-lucid --
Optional Utility
|
Test Build on Jenkins
- build shell:
$ export http_proxy=http://1.2.3.4:8080
$ export https_proxy=https://1.2.3.4:8080
build.sh
How to pack thebuild environment for your team?
# pack the environment:
sudo tar -pczf env.tgz ./chroot/chroot-amd64-ubuntu10.04/
# unpack the environment: using root
sudo tar -xzf env.tgz
Note: Use root privilege to do the pack/unpack procedure otherwise you will get error message: tar: Exiting with failure status due to previous errors.
|
Note:
- Close all chroot sessions before you pack the environment