User:Ncopa/buildserver

From Alpine Linux
Jump to: navigation, search

This is how to set up a new build server.

# Create the container
lxc-create -n build-3-1-x86 -t alpine -- --arch x86 --release edge

# Make it autostart
ln -s lxc /etc/init.d/lxc.build-3-1-x86 && rc-update add lxc.build-3-1-x86

# setup ip forward for ssh
iptables -t nat -A PREROUTING -d 91.220.88.21/32 -p tcp -m tcp --dport 22031 -j DNAT --to-destination 192.168.8.31:22
/etc/init.d/iptables save
lbu commit

# Create missing dir
mkdir /var/lib/lxc/build-3-1-x86/rootfs/var/cache/distfiles

# copy authorized_keys:
cp -a /var/lib/lxc/build-3-0-x86/rootfs/root/.ssh /var/lib/lxc/build-3-1-x86/rootfs/root/

# set up network:
vi /var/lib/lxc/build-3-1-x86/rootfs/etc/network/interfaces

Contents of /etc/network/interfaces

auto lo iface lo inet loopback auto eth0 iface eth0 inet static address 192.168.8.31 netmask 255.255.255.0 gateway 192.168.8.1
# Start container
/etc/init.d/lxc.build-3-1-x86 start

# log in as root
lxc-console -n build-3-1-x86

# make netowrking autostart
rc-update add networking

# install and set up ssh
apk add openssh
rc-update add sshd
/etc/init.d/sshd start
mkdir /root/.ssh
cat > /root/.ssh/authorized_keys
# paste the ssh keys and ctrl-d

# logout
exit

#and detach from console: ctrl-a q

Log in via ssh.

# install alpine-sdk, sudo and aports-build
apk add alpine-sdk sudo aports-build

# make users in %wheel group rin commands without passwd
visudo

# create buildozer user (with good passwd)
adduser buildozer
addgroup buildozer abuild

From host, copy over buildozer keys from other build server:

cp -a /var/lib/lxc/build-3-0-x86/rootfs/home/buildozer/.abuild /var/lib/lxc/build-3-1-x86/rootfs/home/buildozer/ cp -a /var/lib/lxc/build-3-0-x86/rootfs/home/buildozer/.ssh /var/lib/lxc/build-3-1-x86/rootfs/home/buildozer/

You should now be able to log in via ssh as buildozer.

# clone aports and alpine-iso
git clone git://git.alpinelinux.org/aports
git clone git://git.alpinelinux.org/alpine-iso

# setup alpine-iso previous:
echo "3.0.0" > alpine-iso/previous


sudo vi /etc/abuild.conf

export JOBS=24                          
export MAKEFLAGS="-j$JOBS -l$JOBS"
#USE_COLORS=1
SRCDEST=/var/cache/distfiles/v3.1
PACKAGER="Buildozer <alpine-devel@lists.alpinelinux.org>"


# as buildozer, bootstrap the toolchain:
cd ~/aports/main
for i in $(ap recursdeps musl binutils gcc make patch | xargs ap builddirs); do (cd $i && abuild -r)||break; done


# set up repositories to only use selfbuilt packages:
echo "/home/buildozer/packages/main" > /etc/apk/repositories

# replace toolchain
sudo apk upgrade -U -a

# config aports build:
vi /etc/conf.d/mqtt-exec.aports-build

upload_release=v3.1
release_formats="iso"
# not all builds on musl, keep going
buildrepo="buildrepo -p -s -k -l /var/cache/distfiles/buildlogs/$(hostname)"

# create dir for buildlogs
mkdir -p /var/cache/distfiles/buildlogs/build-3-1-x86

# make sure ssh works to rsync.alpinelinux.org and that the dirs exists there:
ssh rsync.alpinelinux.org
cd alpine/v3.1
mkdir -p main/x86 main/x86_64 main/armhf releases/x86 releases/x86_64 releases/armhf
exit

# make sure aports-build autostarts and start it
rc-update add mqtt-exec.aports-build
/etc/init.d/mqtt-exec.aports-build start