Setting up the build environment in a chroot: Difference between revisions

From Alpine Linux
(Minor changes)
Line 3: Line 3:
You will need a few Gigabytes to have enough pace for kernel compiling and storing all the binary packages and iso image.
You will need a few Gigabytes to have enough pace for kernel compiling and storing all the binary packages and iso image.


= Create a build environment =
= Create a build environment =
We are setting up our [[#Create a build environment|BE]] in chroot.<BR>


'''Note:''' The variables below:
We are setting up our [[#Create_a_build_environment|BE]] in chroot.<br>
* '''${build_dir}''' = You can name it whatever you like.
* '''${mirror}''' = Should be replaced with one of the available alpine-mirrors:
{{Mirrors}}


'''Note:''' The variables below:
*'''${build_dir}''' = You can name it whatever you like.
*'''${mirror}''' = Should be replaced with one of the available alpine-mirrors:
{{Mirrors}}
<br> Lets start by geting the latest apk static binary:


Lets start by geting the latest apk static binary:
  wget ${mirror}/apk.static
  wget ${mirror}/apk.static
  chmod +x ./apk.static
  chmod +x ./apk.static


We are setting up a basic chroot:
We are setting up a basic chroot:  
 
  mkdir ${build_dir}
  mkdir ${build_dir}
  ./apk.static --repo ${mirror}/packages/core --root $PWD/${build_dir} add --initdb build-base git abuildv
  ./apk.static --repo ${mirror}/v1.9/packages/core --root $PWD/${build_dir} add --initdb build-base git abuild
  mkdir -p ./${build_dir}/proc
  mkdir -p ./${build_dir}/proc
  mount --bind /proc ./${build_dir}/proc
  mount --bind /proc ./${build_dir}/proc


Lets setup our needed devices:
Lets setup our needed devices:  
 
  mknod -m 666 ./${build_dir}/dev/full c 1 7
  mknod -m 666 ./${build_dir}/dev/full c 1 7
  mknod -m 777 ./${build_dir}/dev/null c 1 3
  mknod -m 777 ./${build_dir}/dev/null c 1 3
Line 31: Line 36:
  mknod -m 666 ./${build_dir}/dev/tty c 5 0
  mknod -m 666 ./${build_dir}/dev/tty c 5 0


We need or dns servers and root dir:
We need or dns servers and root dir:  
 
  cp /etc/resolv.conf ./${build_dir}/etc/
  cp /etc/resolv.conf ./${build_dir}/etc/
  mkdir -p ./${build_dir}/root
  mkdir -p ./${build_dir}/root


We are setting up apk mirrors:
We are setting up apk mirrors:  
 
  mkdir -p ./${build_dir}/etc/apk
  mkdir -p ./${build_dir}/etc/apk
  echo "${mirror}/v1.9/packages/core" > ./${build_dir}/etc/apk/repositories
  echo "${mirror}/v1.9/packages/core" &gt; ./${build_dir}/etc/apk/repositories
  echo "${mirror}/v1.9/packages/extra" >> ./${build_dir}/etc/apk/repositories
  echo "${mirror}/v1.9/packages/extra" &gt;&gt; ./${build_dir}/etc/apk/repositories
 
At this point you should be able to enter your chroot:


At this point you should be able to enter your chroot:
  chroot ./${build_dir} /bin/sh
  chroot ./${build_dir} /bin/sh


= Update a existing environment =
= Update a existing environment =

Revision as of 20:02, 18 February 2009

Introduction

The Build Environment will be called BE from now on.
You will need a few Gigabytes to have enough pace for kernel compiling and storing all the binary packages and iso image.

Create a build environment

We are setting up our BE in chroot.

Note: The variables below:

  • ${build_dir} = You can name it whatever you like.
  • ${mirror} = Should be replaced with one of the available alpine-mirrors:



Lets start by geting the latest apk static binary:

wget ${mirror}/apk.static
chmod +x ./apk.static

We are setting up a basic chroot:

mkdir ${build_dir}
./apk.static --repo ${mirror}/v1.9/packages/core --root $PWD/${build_dir} add --initdb build-base git abuild
mkdir -p ./${build_dir}/proc
mount --bind /proc ./${build_dir}/proc

Lets setup our needed devices:

mknod -m 666 ./${build_dir}/dev/full c 1 7
mknod -m 777 ./${build_dir}/dev/null c 1 3
mknod -m 666 ./${build_dir}/dev/ptmx c 5 2
mknod -m 644 ./${build_dir}/dev/random c 1 8
mknod -m 644 ./${build_dir}/dev/urandom c 1 9
mknod -m 666 ./${build_dir}/dev/zero c 1 5
mknod -m 666 ./${build_dir}/dev/tty c 5 0

We need or dns servers and root dir:

cp /etc/resolv.conf ./${build_dir}/etc/
mkdir -p ./${build_dir}/root

We are setting up apk mirrors:

mkdir -p ./${build_dir}/etc/apk
echo "${mirror}/v1.9/packages/core" > ./${build_dir}/etc/apk/repositories
echo "${mirror}/v1.9/packages/extra" >> ./${build_dir}/etc/apk/repositories

At this point you should be able to enter your chroot:

chroot ./${build_dir} /bin/sh

Update a existing environment