distribution/scripts/build_distro

110 lines
2.8 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 DEVICE_ROOT is defined and not the device being built, make sure that the
# build folder is a link to root rather than a folder.
if [ -n "${DEVICE_ROOT}" ]
then
if [ ! "${DEVICE_ROOT}" = "${DEVICE}" ]
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
if [ ! -d "build.${DISTRO}-${DEVICE_ROOT}.${ARCH}" ]
then
echo "Building the device root (${DEVICE_ROOT})."
make ${DEVICE_ROOT}
fi
# Link back to the DEVICE_ROOT so we can re-use the build directory to save space.
if [ ! -L "build.${DISTRO}-${DEVICE}.${ARCH}" ]
then
ln -sf build.${DISTRO}-${DEVICE_ROOT}.${ARCH} build.${DISTRO}-${DEVICE}.${ARCH}
fi
fi
# If DEVICE_ROOT is defined, take additional clean steps to ensure everything is built
# properly for all devices including the root device.
CLEAN_OS="system-utils busybox linux grub u-boot SDL2 retroarch mesa"
CLEAN_EMUS="mupen64plus-nx mupen64plus flycast_libretro dosbox-pure \
gpsp PPSSPPSDL mupen64plussa-core mupen64plussa-input-sdl \
duckstationsa"
CLEAN_UI="emulationstation"
CLEAN_TOOLS="gamecontrollerdb moonlight"
fi
# Clean necessary packages.
PKG_CLEAN="${CLEAN_OS} ${CLEAN_EMUS} ${CLEAN_UI} ${CLEAN_TOOLS} ${PKG_CLEAN} lib32 initramfs modules autostart splash jelos"
if [ ! -n "${DIRTY}" ]
then
if [ -d "build.${DISTRO}-${DEVICE_ROOT}.${ARCH}/initramfs" ]
then
rm -rf build.${DISTRO}-${DEVICE_ROOT}.${ARCH}/initramfs
fi
# 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
fi
# 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
case ${ARCH} in
arm)
[ "${BASE_ONLY}" == "true" ] && exit 0
export PKG_BUILD_PERF=no
scripts/build_compat arm
scripts/install arm
;;
i686)
[ "${BASE_ONLY}" == "true" ] && exit 0
export PKG_BUILD_PERF=no
scripts/build_compat x86
scripts/install x86
;;
*)
make image
esac
if [ ! $? == 0 ]
then
echo "Build failed..exiting."
exit 1
fi