Build the programs

Building programs is made using a independant environment.

Independant build environment

The indenpendant environement is basically a folder you can chroot in and compile programs from. The build toolchain is located in an non standard location (/tools in our case), in oder to copy compiled programs in standard locations (/bin, /usr/bin, etc).

Chroot folder

The Wakes independant build environment (the toolchain) is widely based on the LFS 7.5 temporary system. In addition to it, the following programs were added:

ksh
zlib
iproute2
openssl
openssh
vi
wget
procps
libtar
libarchive
libcurl

Docker image

The goal is to create a docker image instead of using a basic chroot script to enter the image. Once the toolchain folder is ready, create the docker image:

tar -C /toolchain -c . | docker import - toolchain

Then you can start a container from this image:

docker run -d -p 2222:22 -it toolchain /tools/sbin/sshd -D

and enter the image using ssh:

ssh -p 2222 root@0

Adjusted toolchain

todo: compile glibc, wkpkg, make the wakes prep

Compile wkpkg

wkpkg: wkpkg.o
	gcc -o wkpkg -Wall -g -lm -lrt -ldl wkpkg.o /tools/lib/libtar.a  \
        /tools/lib/libz.a /tools/lib/libarchive.a /tools/lib/libbz2.a    \
        /tools/lib/libcurl.a /tools/lib/libssl.a /tools/lib/libcrypto.a

wkpkg.o: wkpkg.c
	gcc -Wall -g -c wkpkg.c

clean:
	rm wkpkg.o wkpkg

Wakes preparation

cat <<EOF > /etc/wkpkg.conf

# Default network depot
http://www.gnuwakes.org/depot main

#usb://depot main

#ftp://www.gnuwakes.org/depot main
#cdrom://depot    main

#disk://var/wkpkg/rep main

EOF

cat <<EOF > /etc/wakes_version
1.0
EOF

mkdir /var/wkpkg/{cat,rep,db,mnt,run}
mkdir /var/wkpkg/mnt/{cdrom,usb}

Adjust the toolchain

# install linux header and glibc
wkpkg -i linux-headers-4.1.1
wkpkg -i glibc

# ld
mv -v /tools/bin/{ld,ld-old}
mv -v /tools/$(gcc -dumpmachine)/bin/{ld,ld-old}
mv -v /tools/bin/{ld-new,ld}
ln -sv /tools/bin/ld /tools/$(gcc -dumpmachine)/bin/ld

# gcc
gcc -dumpspecs | sed -e 's@/tools@@g'                   \
    -e '/\*startfile_prefix_spec:/{n;s@.*@/usr/lib/ @}' \
    -e '/\*cpp:/{n;s@$@ -isystem /usr/include@}' >      \
    `dirname $(gcc --print-libgcc-file-name)`/specs

Make the docker image

commit change from the running container to a new one:

# id: from docker ps
docker commit id toolchain-wakes-adjusted

run the adjusted container:

docker run -d -p 2223:22 -it toolchain-wakes-adjusted /tools/sbin/sshd -D

enter the adjusted container:

ssh -p 2223 root@0