Alpine Linux in a chroot: Difference between revisions
Clandmeter (talk | contribs) |
m (cmd macro added) |
||
Line 20: | Line 20: | ||
<br> Lets start by geting the latest apk static binary: | <br> Lets start by geting the latest apk static binary: | ||
{{Cmd|wget ${mirror}/v1.9/apk.static | |||
chmod +x ./apk.static | ^^chmod +x ./apk.static}} | ||
Verify you have apk-tools 2.0_rc1 or later: | Verify you have apk-tools 2.0_rc1 or later: | ||
{{Cmd|./apk.static --version | |||
apk-tools 2.0_rc1 | apk-tools 2.0_rc1}} | ||
We are setting up a basic chroot: | We are setting up a basic chroot: | ||
{{Cmd|mkdir ${build_dir} | |||
sudo ./apk.static -X ${mirror}/v1.9/packages/main -U --allow-untrusted --root ${build_dir} --initdb add alpine-base alpine-sdk | |||
mkdir -p ./${build_dir}/proc | |||
sudo mount --bind /proc ./${build_dir}/proc}} | |||
Lets setup our needed devices: | Lets setup our needed devices: | ||
{{Cmd|sudo mknod -m 666 ./${build_dir}/dev/full c 1 7 | |||
sudo mknod -m 666 ./${build_dir}/dev/ptmx c 5 2sudo 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}} | |||
seems as /dev/null is wrong | seems as /dev/null is wrong | ||
{{Cmd|sudo rm -f ./${build_dir}/dev/null && sudo mknod -m 666 ./${build_dir}/dev/null c 1 3}} | |||
We need or dns servers and root dir: | We need or dns servers and root dir: | ||
{{Cmd|sudo cp /etc/resolv.conf ./${build_dir}/etc/ | |||
mkdir -p ./${build_dir}/root}} | |||
We are setting up apk mirrors: | We are setting up apk mirrors: | ||
{{Cmd|sudo mkdir -p ./${build_dir}/etc/apk | |||
sudo su | |||
echo "${mirror}/v1.9/packages/main" > ./${build_dir}/etc/apk/repositories | |||
exit}} | |||
At this point you should be able to enter your chroot: | At this point you should be able to enter your chroot: | ||
{{Cmd|sudo chroot ./${build_dir} /bin/sh -l}} | |||
If you are using Alpine as a Native build system you will have to make sure that chroot can run chmod. Add following to /etc/sysctl.conf | If you are using Alpine as a Native build system you will have to make sure that chroot can run chmod. Add following to /etc/sysctl.conf | ||
kernel.grsecurity.chroot_deny_chmod = 0 | kernel.grsecurity.chroot_deny_chmod = 0 | ||
Then run the following command | Then run the following command | ||
{{Cmd|sysctl -p}} | |||
Now you can move on to [[Creating_an_Alpine_package|creating packages for Alpine.]] | Now you can move on to [[Creating_an_Alpine_package|creating packages for Alpine.]] |
Revision as of 08:05, 17 June 2011
Setting up a 'edge' build environment in a chroot
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:
- http://dl-cdn.alpinelinux.org/alpine/
- http://nl.alpinelinux.org/alpine/
- http://dl-2.alpinelinux.org/alpine/
- http://dl-3.alpinelinux.org/alpine/
- http://dl-4.alpinelinux.org/alpine/
- http://dl-5.alpinelinux.org/alpine/
- http://dl-6.alpinelinux.org/alpine/
- http://dl-8.alpinelinux.org/alpine/
- http://distrib-coffee.ipsl.jussieu.fr/pub/linux/alpine/alpine/
- http://mirror.yandex.ru/mirrors/alpine/
- http://mirrors.gigenet.com/alpinelinux/
- http://mirror1.hs-esslingen.de/pub/Mirrors/alpine/
- http://liskamm.alpinelinux.uk/
- http://mirrors.2f30.org/alpine/
- http://mirror.leaseweb.com/alpine/
- http://repository.fit.cvut.cz/mirrors/alpine/
- http://alpine.mirror.far.fi/
- http://lasca.ic.unicamp.br/pub/alpine/
- http://alpinelinux.c3sl.ufpr.br/
- http://mirrors.cug.edu.cn/alpine/
- http://mirrors.cicku.me/alpine/
Lets start by geting the latest apk static binary:
wget ${mirror}/v1.9/apk.static ^^chmod +x ./apk.static
Verify you have apk-tools 2.0_rc1 or later:
./apk.static --version apk-tools 2.0_rc1
We are setting up a basic chroot:
mkdir ${build_dir} sudo ./apk.static -X ${mirror}/v1.9/packages/main -U --allow-untrusted --root ${build_dir} --initdb add alpine-base alpine-sdk 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 666 ./${build_dir}/dev/ptmx c 5 2sudo 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
seems as /dev/null is wrong
sudo rm -f ./${build_dir}/dev/null && sudo mknod -m 666 ./${build_dir}/dev/null c 1 3
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 sudo 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
If you are using Alpine as a Native build system you will have to make sure that chroot can run chmod. Add following to /etc/sysctl.conf
kernel.grsecurity.chroot_deny_chmod = 0
Then run the following command
sysctl -p
Now you can move on to creating packages for Alpine.