Changeset - cf4f965e2938
[Not reviewed]
0 0 3
x - 10 months ago 2024-07-14 20:43:33
xbr@c3l.lu
Add scripts for automation of building and build machine setup

This allows us to use a powerful Hetzner VM for not very long to
build our firmware in almost no time.
3 files changed with 151 insertions and 0 deletions:
0 comments (0 inline, 0 general)
build_script/build.sh
Show inline comments
 
new file 100755
 
#!/usr/bin/env bash
 
USER_DIR=/home/user
 

	
 
GLUON_DIR=$USER_DIR/gluon
 
SITE_DIR=$USER_DIR/Firmware-building/site_config
 

	
 
EXPERIMENTAL_SITE=$SITE_DIR/experimental/site
 
BETA_SITE=$SITE_DIR/beta/site
 
STABLE_SITE=$SITE_DIR/stable/site
 

	
 
# $1: site directory
 
set_site_directory() {
 
    pushd $GLUON_DIR
 

	
 
    # if site file exists, remove it
 
    if [ -a site ]; then
 
        unlink site
 
    fi
 
    ln -s $1
 

	
 
    popd $GLUON_DIR
 
}
 

	
 
build() {
 
    pushd $GLUON_DIR
 

	
 
    for TARGET in $(make list-targets); do
 
        make -j16 GLUON_TARGET=$TARGET
 
    done
 

	
 
    popd
 
}
 

	
 
# $1: autoupdater branch
 
move_output_images() {
 
    pushd $GLUON_DIR
 

	
 
    mv output/images output-images-$1
 

	
 
    popd
 
}
 

	
 
#unset multiple env vars
 
unset BUILD_EXPERIMENTAL BUILD_BETA BUILD_STABLE
 

	
 
case $1 in
 
    exp)
 
        BUILD_EXPERIMENTAL=1
 
        ;;
 

	
 
    beta)
 
        BUILD_BETA=1
 
        ;;
 

	
 
    stable)
 
        BUILD_STABLE=1
 
        ;;
 

	
 
    all)
 
        BUILD_EXPERIMENTAL=1
 
        BUILD_BETA=1
 
        BUILD_STABLE=1
 
        ;;
 

	
 
    *)
 
        echo "fflux firmware building script"
 
        echo "Usage: build.sh <all|exp|beta|stable>"
 
        exit 1
 
        ;;
 
esac
 

	
 
pushd $GLUON_DIR
 

	
 
if [ -d $GLUON_DIR/output/images ]; then
 
    echo "Error: output images directory contains images. Please remove them before building."
 
    echo "Delete `gluon/output/images` directory and try again."
 
    exit 1
 
fi
 

	
 
set_site_directory() {
 
    echo "Linking $1"
 
}
 

	
 
build() {
 
    echo "Building images"
 
}
 

	
 
move_output_images() {
 
    echo "Moving output images to output-images-$1"
 
}
 

	
 
if [ -n $BUILD_EXPERIMENTAL ]; then
 
    set_site_directory $EXPERIMENTAL_SITE
 
    build
 
    move_output_images experimental
 
fi
 

	
 
if [ -n $BUILD_BETA ]; then
 
    set_site_directory $BETA_SITE
 
    build
 
    move_output_images beta
 
fi
 

	
 
if [ -n $BUILD_STABLE ]; then
 
    set_site_directory $STABLE_SITE
 
    build
 
    move_output_images stable
 
fi
 

	
 
popd
 
\ No newline at end of file
build_script/freifunk_root.sh
Show inline comments
 
new file 100755
 
#!/usr/bin/env bash
 
# Installing QoL packages and then (after build-essential incl.) dependencies
 
apt update && apt install -y htop tmux vim sudo mosh build-essential git python3 python-is-python3 python3-distutils ecdsautils gawk unzip libncurses5-dev zlib1g-dev libssl-dev libelf-dev wget rsync time qemu-utils
 

	
 
# Create `user` user with `sudo` group
 
useradd -ms /bin/bash -G sudo user
 
# `sudo` group w/o password
 
sed -i /etc/sudoers -re 's/^%sudo.*/%sudo ALL=(ALL:ALL) NOPASSWD: ALL/g'
 

	
 
mkdir -v /home/user/.ssh
 
# my public key
 
echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOLFCOqpPOTZEQiWcY9TyVQnMoc5bCYlxLaRKhiB/uxo xbr 2024-06-16" >> /home/user/.ssh/authorized_keys
 
# projects.c3l.lu public key
 
echo "|1|X2M4bHKf8E+plhJ6KoDZzCfw5LI=|EpHLDWOmOq4SLelYTGd8SH+7hvU= ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIXfRmGmfbxPoErs5lpTnz+PZRQdh0QvPGTiswxFkXOx" >> /home/user/.ssh/known_hosts
 
chown -vR user:user /home/user/.ssh
 
chmod -v 700 /home/user/.ssh
 
chmod -v 600 /home/user/.ssh/*
 
chmod -v 644 /home/user/.ssh/known_hosts
 
# make a key to have access to projects.c3l.lu
 
sudo -u user ssh-keygen -t ed25519 -N '' -C 'freifunk-hetzner-builder' -f /home/user/.ssh/id_ed25519 <<<n
 
echo ""
 
echo "The ssh key is the following: "
 
cat /home/user/.ssh/id_ed25519.pub
build_script/freifunk_user.sh
Show inline comments
 
new file 100755
 
#!/usr/bin/env bash
 
BRANCH=$1
 
EXPERIMENTAL="experimental"
 
AUTOUPDATER_VER=${2:-$EXPERIMENTAL}
 
if [ -z $BRANCH ]; then
 
	echo "Usage: freifunk_user.sh [branch] (updater_version)"
 
	echo ""
 
	echo "branch: gluon release branch"
 
	echo "updater_version: experimental, beta, stable. defaults to experimental"
 
	exit 1
 
fi
 
git clone ssh://kallithea@projects.c3l.lu/freifunk/Firmware-building
 
git clone https://github.com/freifunk-gluon/gluon.git gluon -b "$BRANCH"
 
ln -vs /home/user/Firmware-building/site_config/"${AUTOUPDATER_VER}"/site /home/user/gluon/site
 
pushd /home/user/gluon/
 
make update
 
popd
 

	
0 comments (0 inline, 0 general)