distribution/scripts/build_distro

85 lines
2.3 KiB
Bash
Executable file

#!/bin/bash
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2020-present Fewtarius
###
### Simple script to build JELOS
###
if [ !"${ARCH}" == true ]
then
echo "export ARCH before building."
exit 1
fi
### Remember to make this more dynamic.
export DISTRO="JELOS"
export OS_VERSION=$(date +%Y%m%d)
export BUILD_DATE=$(date)
echo "Building ${DISTRO} for ${DEVICE}"
# If ROOT is defined make sure that the build folder is a link to root rather than
# a folder and take additional clean steps to ensure everything is built properly.
if [ -n "${ROOT}" ]
then
# Ensure there isn't a left over build directory.
if [ -d "build.${DISTRO}-${DEVICE}.${ARCH}" ]
then
echo "Removing stale build root."
rm -rf build.${DISTRO}-${DEVICE}.${ARCH}
fi
# Link back to the ROOT so we can re-use the build directory to save space.
if [ ! -L "build.${DISTRO}-${DEVICE}.${ARCH}" ]
then
ln -sf build.${DISTRO}-${ROOT}.${ARCH} build.${DISTRO}-${DEVICE}.${ARCH}
fi
# Clean packages that have device specific configurations.
PKG_CLEAN="${PKG_CLEAN} mupen64plus-nx mupen64plus flycast_libretro dosbox-pure parallel-n64_glide64 \
parallel-n64_gln64 parallel-n64_rice pcsx_rearmed pcsx_rearmed gpsp raze amiberry lzdoom \
PPSSPPSDL gzdoom mupen64plussa-core mupen64plussa-input-sdl 351files libgo2 \
gamecontrollerdb"
# Clean additional packages to ensure the OS is properly built for this device
PKG_CLEAN="${PKG_CLEAN} plymouth-lite initramfs busybox kernel grub u-boot SDL2"
fi
# If this variable exists in the environment, expand it and clean those packages too.
PKG_CLEAN="${PKG_CLEAN} modules emulationstation retroarch lib32 jelos"
# Clean a few packages to ensure the build date and version are updated
for package in ${PKG_CLEAN}
do
echo "Clean: ${package}"
./scripts/clean ${package}
done
# Clean out old builds before starting the new one.
echo "Prune old releases: ${DISTRO}-${DEVICE}.${ARCH}-*"
rm -f ./release/${DISTRO}-${DEVICE}.${ARCH}-*
# Remove the image root as it should be regenerated for every build.
rm -rf ./build.${DISTRO}-${DEVICE}.${ARCH}/image
if [ "${ARCH}" == "arm" ]
then
if [ "${BASE_ONLY}" == true ]
then
echo "Skipping 32bit."
exit 0
fi
scripts/build_compat
scripts/install arm32
else
make image
fi
if [ ! $? == 0 ]
then
echo "Build failed..exiting."
exit 1
fi