4 Building rootfs tarballs
Liam Waldron edited this page 2022-10-06 12:54:38 -04:00

Rootfs tarballs allow us to quickly deploy systems, as opposed to building source code locally through the ELIF.

Step 1 - Prepare the environment

Building an Everest rootfs tarball requires a proper environment to be set up.

To take the easy way out, download and run setup-env.sh

To do everything manually, do the following:

1 - Create a workspace directory (preferrably /mnt/everest)

3 - Create an environment variable for ease of use

$ export EVEREST=/mnt/everest # replace /mnt/everest with the path to your workspace

4 - Change permissions of the workspace

# chmod 777 ${EVEREST}

5 - Create a sources directory to store packages $ mkdir -v ${EVEREST}/sources

6 - Reference for programs in use - binutils - busybox - everest-bootscripts - gcc - gmp - iana-etc - linux - mpc - mpfr - musl

Syntax may differ between versions. The following versions were used for this guide: - binutils 2.33.1 - busybox 1.24.2 - everest-bootscripts git - gcc 9.4.0 - gmp 6.1.2 - iana-etc 2.30 - linux 4.19.88 - mpc 1.1.0 - mpfr 4.0.2 - musl 1.2.3

7 - Download the following patch for iana-etc: http://patches.clfs.org/embedded-dev/iana-etc-2.30-update-2.patch

8 - Ensure the EVEREST environment variable is set up properly

$ echo ${EVEREST}

9 - Create the build user

# groupadd everest
# useradd -s /bin/bash -g everest -m -k /dev/null everest
# passwd everest
# chown -Rv everest ${EVEREST}

10 - Login as the new user

$ su - everest

11 - Create a new bash profile

$ cat > ~/.bash_profile << "EOF"
exec env -i HOME=${HOME} TERM=${TERM} PS1='\u:\w\$ ' /bin/bash
EOF

12 - Create a new bashrc

$ cat > ~/.bashrc << "EOF"
set +h
umask 022
EVEREST=/mnt/everest
LC_ALL=POSIX
PATH=${EVEREST}/cross-tools/bin:/bin:/usr/bin
export EVEREST LC_ALL PATH
EOF

13 - Source the new bash profile

$ source ~/.bash_profile

14 - Disable CFLAGS, which will cause problems with cross-compilation tools.

$ unset CFLAGS
$ echo unset CFLAGS >> ~/.bashrc

15 - Set host, target, CPU type, and architecture. This guide assumes you are building for a k8 cpu and x86 target.

$ export EVEREST=$(echo ${MACHTYPE} | sed "s/-[^-]*/-cross/")
$ export EVEREST_TARGET="x86_64-linux-musl"
$ export EVEREST_CPU="k8"
$ export EVEREST_ARCH="x86"

16 - Add the following variables to the build user's ~/.bashrc

$ echo export EVEREST_HOST=\""${EVEREST_HOST}\"" >> ~/.bashrc
$ echo export EVEREST_TARGET=\""${EVEREST_TARGET}\"" >> ~/.bashrc
$ echo export EVEREST_ARCH=\""${EVEREST_ARCH}\"" >> ~/.bashrc
$ echo export EVEREST_CPU=\""${EVEREST_CPU}\"" >> ~/.bashrc

17 - Create the cross tools directory

$ mkdir -p ${EVEREST}/cross-tools/${EVEREST_TARGET}

18 - Build the cross-toolchain

$ cd ${EVEREST}/sources
$ git clone https://git.everestlinux.org/EverestLinux/musl-cross-make
$ cd musl-cross-make
$ make
$ make install
#Note: to speed up this process, prefix both make commands with -jX, replacing X with your CPU's cores + threads

19 - Install