BuildSystem: Download correct cmake if it is not available

This commit is contained in:
Bananymous 2023-12-28 19:13:27 +02:00
parent af80bad87a
commit 5d83ab2289
4 changed files with 66 additions and 5 deletions

View File

@ -6,6 +6,11 @@ source $BANAN_SCRIPT_DIR/config.sh
FAKEROOT_FILE="$BANAN_BUILD_DIR/fakeroot-context"
if [[ -z $CMAKE_COMMAND ]]; then
echo "No usable cmake binary found" >&2
exit 1
fi
run_fakeroot() {
fakeroot -i $FAKEROOT_FILE -s $FAKEROOT_FILE -- /bin/bash -c '$@' bash $@
}
@ -66,10 +71,6 @@ if [[ $# -eq 0 ]]; then
exit 1
fi
if [[ -z $CMAKE_COMMAND ]]; then
export CMAKE_COMMAND=cmake
fi
case $1 in
toolchain)
build_toolchain

View File

@ -0,0 +1,53 @@
#!/bin/bash
CMAKE_VERSION_REQUIRED="3.26"
version_atleast() {
[ "$1" = "$(echo -e "$1\n$2" | sort -rV | head -n1)" ]
}
download_cmake() {
read -e -p "Do you want to download it [y/N]? " choice
if ! [[ "$choice" == [Yy]* ]]; then
echo "Build requirements not met" >&2
return 1
fi
CMAKE_FULL_NAME="cmake-3.26.6-linux-x86_64"
mkdir -p $BANAN_BUILD_DIR/toolchain
cd $BANAN_BUILD_DIR/toolchain
wget https://cmake.org/files/v3.26/$CMAKE_FULL_NAME.tar.gz
tar xf $CMAKE_FULL_NAME.tar.gz
cp -r $CMAKE_FULL_NAME/bin/* $BANAN_TOOLCHAIN_PREFIX/bin/
cp -r $CMAKE_FULL_NAME/share/* $BANAN_TOOLCHAIN_PREFIX/share/
export CMAKE_COMMAND="$BANAN_TOOLCHAIN_PREFIX/bin/cmake"
}
if ! type ninja &> /dev/null ; then
echo "ninja not found" >&2
return 1
fi
if [ -z "$CMAKE_COMMAND" ]; then
if [ -f $BANAN_TOOLCHAIN_PREFIX/bin/cmake ]; then
export CMAKE_COMMAND="$BANAN_TOOLCHAIN_PREFIX/bin/cmake"
else
export CMAKE_COMMAND=cmake
fi
fi
if ! type $CMAKE_COMMAND &> /dev/null ; then
echo "You don't seem to have cmake installed"
download_cmake
return 0
fi
CMAKE_VERSION=$($CMAKE_COMMAND --version | head -n1 | cut -d' ' -f3)
if ! version_atleast "$CMAKE_VERSION" "$CMAKE_VERSION_REQUIRED" ; then
echo "Your cmake version ($CMAKE_VERSION) is less than the required $CMAKE_VERSION_REQUIRED"
download_cmake
return 0
fi

View File

@ -29,3 +29,5 @@ fi
if [[ -z $BANAN_BOOTLOADER ]]; then
export BANAN_BOOTLOADER="BANAN"
fi
source $BANAN_SCRIPT_DIR/check-requirements.sh

View File

@ -15,6 +15,11 @@ fi
if [[ -z $BANAN_ROOT_DIR ]]; then
echo "You must set the BANAN_ROOT_DIR environment variable" >&2
exit 1
fi
if [[ -z $CMAKE_COMMAND ]]; then
echo "You must set the CMAKE_COMMAND environment variable" >&2
exit 1
fi
ROOT_PARTITION_INDEX=2
@ -32,7 +37,7 @@ fi
if ! [ -d $INSTALLER_BUILD_DIR ]; then
mkdir -p $INSTALLER_BUILD_DIR
cd $INSTALLER_BUILD_DIR
cmake ..
$CMAKE_COMMAND ..
fi
cd $INSTALLER_BUILD_DIR