Files
ForceArchCTBuilder/buildCT.sh
Bram Prieshof bd9c653a69 Added Temp variant for buildng apk PKGS
Added x86_64 to Alpine Arch list
Added jenkinsAPKbuilder to alpine with the following:
* Packages required for Jenkins-agent
* Packages required for Alpine package development
* Added BuildNode public ssh key
2023-10-02 01:52:27 +02:00

104 lines
2.5 KiB
Bash

#!/bin/bash
#Help menu
usage() {
echo "Usage: $0 [OPTIONS]"
echo "Options:"
echo " -h Display this help message"
echo " -i Use interactive mode, ignores other flags"
echo ""
echo " -a <Arch> Set architecture"
echo " -d <Distro> Set distribution"
echo " -v <Variant> Set variant "
exit 1
}
#Prepare var
interactive=false
runws=false
#Check if any parameter/option is passed
if (( $# == 0 )); then echo "No options were passed";usage; fi
#Process options
while getopts hia:d:v: flag
do
case "${flag}" in
h) usage;;
i) interactive=true;;
a) Arch=${OPTARG};;
d) Distro=${OPTARG};;
v) Variant=${OPTARG};;
?) usage
esac
done
#Go to project folder
cd "$( cd "$( dirname "$0" )" &> /dev/null && pwd )"
#Interactive mode
if $interactive;then
echo Entering interactive mode...
#Set lists for menu
variantList=("minimal" "default" "jenkinsAPKbuilder")
archListAlpine=("aarch64" "armhf" "armv7" "x86_64")
archListDebian=("arm64" "armhf" "armel")
archListRasPiOS=("armhf")
#Geneate list of availible distro's
declare -a distroList
cd ./distros/
for file in *.yaml;do
distroList+=("${file/.yaml/}")
done
#Adding quit option to menu
distroList+=("Quit")
cd ..
#Distro menu
echo "Select Distro:"
select Distro in "${distroList[@]}"; do
case $Distro in
"Quit") echo Exiting ; exit;;
"") echo 'Invalid choice' >&2 ;;
*) break
esac
done
#Architecture menu
declare -n archList=archList"$(printf '%s' "$Distro" | tr -d '0123456789')"
echo "Select architecture :"
select Arch in "${archList[@]}"; do
case $Arch in
"") echo 'Invalid choice' >&2 ;;
*) break
esac
done
#Variant menu
echo "Select variant:"
select Variant in "${variantList[@]}"; do
case $Variant in
"") echo 'Invalid choice' >&2 ;;
*) break
esac
done
read -p "Do you want to serve image files on local webserver? (yes/No) " runws
elif [ -z "$Arch" ] || [ -z "$Distro" ] || [ -z "$Variant" ]; then
#Check if all paramaters are set
echo "Not all required options were passed"
usage
fi
./distrobuilder build-lxc ./distros/$Distro.yaml -o image.variant=$Variant -o image.architecture_mapped=$Arch
rm -f meta.tar.xz
mv ./rootfs.tar.xz ./out/"$Distro-$Arch-$Variant".tar.xz
if [[ $runws == y* || $runws == Y* ]]; then
cd ./out
echo "Availible ip addresses"
ip -4 -o a
echo ""
echo "List images on: http://<IP>:8000/"
echo ""
echo "To stop the webserver press ctrl + c"
python3 -m http.server >/dev/null
fi