Difference between revisions of "Setting up the build environment in a chroot"

From Alpine Linux
Jump to: navigation, search
(Create BE on existing 2.6 kernel: Initial notes on chroot a BE)
(Fix double redirect)
(Tag: Redirect target changed)
 
(26 intermediate revisions by 9 users not shown)
Line 1: Line 1:
= Introduction =
+
#REDIRECT [[Alpine Linux in a chroot]]
You will need a few Gigabytes to have enough pace for kernel compiling and storing all the binary packages and iso image.
 
 
 
This page is divided into 2 main sections
 
* [[#Create a build environment|Create a build environment]]
 
* [[#Update a existing environment|Update a existing environment]]
 
 
 
= Create a build environment =
 
 
 
The Build Environment (called [[#Create a build environment|BE]] from now on) could be any of the following...
 
* Created on a existing 2.6 kernel
 
* A [[Native Harddisk Install|disk-based Alpine]]
 
 
 
== Create [[#Create a build environment|BE]] on existing 2.6 kernel ==
 
We are setting up our [[#Create a build environment|BE]] in chroot.
 
 
 
'''Note:''' The variables below:
 
* '''${mirror}''' = Should be replaced with one of the available alpine-mirrors.
 
* '''${build_dir}''' = You can name it whatever you like.
 
 
 
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}/packages/core --root $PWD/${build_dir} add --initdb build-base git abuildv
 
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}/packages/core" > ./${build_dir}/etc/apk/repositories
 
echo "${mirror}/packages/extra" >> ./${build_dir}/etc/apk/repositories
 
 
 
At this point you should be able to enter your chroot:
 
chroot ./${build_dir} /bin/sh
 
 
 
== Create [[#Create a build environment|BE]] on HD-based Alpine ==
 
First you need to boot a alpine-test.iso<BR>
 
Ether you do it on a standalone computer or in a virtual machine.
 
=== Preparing KVM ''(temporary notes)'' ===
 
I chose to setup a HD-based Alpine in a virtual machine on my Ubuntu 8.10.<BR>
 
('''Notes:''' This section about setting up KVM should probably be removed later on - it's mostly there to help me get started).
 
apt-get install kvm ###This installs KVM###
 
kvm-img create alpine-kvm_hd.img 5G ###Create a KVM-disk###
 
wget http://distrib-coffee.ipsl.jussieu.fr/pub/linux/alpine/alpine/v1.9/alpine-test.iso ###Download iso###
 
Before we boot our kvm-qemu we need to prepare it for networking by following the [[Running_Alpinelinux_As_a_QEMU_networked_Guest]] documents.<BR>
 
This assumes you created a file '''qemu-ifup''' according to the wiki-doc just mentioned.
 
sudo kvm -cdrom alpine-test.iso -boot d -net tap,vlan=0,ifname=tap0,script=./qemu-ifup -net nic,vlan0 alpine-kvm_hd.img
 
 
 
At this point we started a virtual machine running a clean Alpine.<BR>
 
Now we need to prepare this for networking, etc.
 
 
 
'''Temporary note:''' [[For some reason I can't get networking to work in my kvm-qemu box. Complaining about tun/tap on my host. Need to fix this.]]
 
 
 
=== Prepare the clean Alpine ===
 
At this point you should have a fresh alpine-box.<BR>
 
 
 
 
 
= Update a existing environment =
 

Latest revision as of 01:15, 2 April 2020