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

From Alpine Linux
m (→‎Setting up a build environment for Alpine 1.9: english grammer corrections.)
Line 1: Line 1:
= Setting up a build environment for Alpine 1.9 =
= Setting up a build environment for Alpine 1.9 =


This docuemtn explains how to set up an Alpine build environment in a chroot in a "normal" Linux distro as Ubuntu, Fedora, Gentoo or Arch linux. In this build environment you will be able to build and run alpine packages.
This document explains how to set up an Alpine build environment in a chroot under a "normal" Linux distro, such as Arch, Debian, Fedora, Gentooor Ubuntu. Once inside the chroot environment, you can build, debug and run alpine packages.


== Introduction  ==
== Introduction  ==


The Build Environment will be called [[#Create_a_build_environment|BE]] from now on.<br> 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>  
We are setting up our Build Environment in chroot.<br>  


'''Note:''' The variables below:  
'''Note:''' The variables below:  

Revision as of 05:16, 5 August 2009

Setting up a build environment for Alpine 1.9

This document explains how to set up an Alpine build environment in a chroot under a "normal" Linux distro, such as Arch, Debian, Fedora, Gentoo, or Ubuntu. Once inside the chroot environment, you can build, debug and run alpine packages.

Introduction

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 Build Environment 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}/v1.9/apk.static
chmod +x ./apk.static

We are setting up a basic chroot:

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

Lets setup our needed devices:

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

We need or dns servers and root dir:

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

We are setting up apk mirrors:

sudo mkdir -p ./${build_dir}/etc/apk
su
echo "${mirror}/v1.9/packages/main" > ./${build_dir}/etc/apk/repositories
exit

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

sudo chroot ./${build_dir} /bin/sh -l