functions: break check_config into its constituent parts; add check_distro

Take the opportunity to cleanup the check_foobar() too.

Signed-off-by: Ian Leonard <antonlacon@gmail.com>
This commit is contained in:
Ian Leonard 2018-10-12 19:13:33 +00:00
parent 0727f4c685
commit 2a12f77b6e

View File

@ -457,16 +457,15 @@ init_package_cache() {
} }
check_path() { check_path() {
dashes="===========================" local dashes="===========================" path_err_msg
if [ "${PWD##/usr}" != "${PWD}" ]; then if [ "${PWD##/usr}" != "${PWD}" ]; then
check_pathmessage="$check_pathmessage\n $dashes$dashes$dashes" path_err_msg="\n $dashes$dashes$dashes"
check_pathmessage="$check_pathmessage\n ERROR: You try to build inside /usr" path_err_msg="${path_err_msg}\n ERROR: Detected building inside /usr"
check_pathmessage="$check_pathmessage\n $dashes$dashes$dashes" path_err_msg="${path_err_msg}\n $dashes$dashes$dashes"
check_pathmessage="$check_pathmessage\n This is not supported with our buildsystem." path_err_msg="${path_err_msg}\n This is not supported with our buildsystem."
check_pathmessage="$check_pathmessage\n Please use another dir (for example your \$HOME) to build $DISTRONAME" path_err_msg="${path_err_msg}\n Please use another dir (for example your \$HOME) to build ${DISTRONAME}"
echo -e $check_pathmessage die "${path_err_msg}"
die
fi fi
} }
@ -487,57 +486,83 @@ save_build_config() {
done done
} }
check_config() { check_distro() {
dashes="===========================" local dashes="===========================" distro_err_msg
if [ ! -d $PROJECT_DIR/$PROJECT ]; then if [ -z "${DISTRO}" -o ! -d "${DISTRO_DIR}/${DISTRO}" ]; then
check_project="$check_project\n $dashes$dashes$dashes" distro_err_msg="\n $dashes$dashes$dashes"
check_project="$check_project\n ERROR: Project not found, use a valid project or create a new config" distro_err_msg="${distro_err_msg}\n ERROR: Distro not found, use a valid distro or create a new config"
check_project="$check_project\n $dashes$dashes$dashes" distro_err_msg="${distro_err_msg}\n $dashes$dashes$dashes"
check_project="$check_project\n\n Valid projects:" distro_err_msg="${distro_err_msg}\n\n Valid distros:"
for projects in $PROJECT_DIR/*; do for distros in ${DISTRO_DIR}/*; do
check_project="$check_project\n - $(basename $projects)" distro_err_msg="${distro_err_msg}\n - ${distros##*/}"
done done
echo -e $check_project die "${distro_err_msg}"
die
fi fi
}
if [ \( -z "$DEVICE" -a -d "$PROJECT_DIR/$PROJECT/devices" \) -o \( -n "$DEVICE" -a ! -d "$PROJECT_DIR/$PROJECT/devices/$DEVICE" \) ]; then check_project() {
check_device="$check_device\n $dashes$dashes$dashes" local dashes="===========================" project_err_msg
check_device="$check_device\n ERROR: You need to specify a valid device for the $PROJECT project" if [ -z "${PROJECT}" -o ! -d "${PROJECT_DIR}/${PROJECT}" ]; then
check_device="$check_device\n $dashes$dashes$dashes" project_err_msg="\n $dashes$dashes$dashes"
check_device="$check_device\n\n Valid devices for project: $PROJECT" project_err_msg="${project_err_msg}\n ERROR: Project not found, use a valid project or create a new config"
project_err_msg="${project_err_msg}\n $dashes$dashes$dashes"
project_err_msg="${project_err_msg}\n\n Valid projects:"
for device in $PROJECT_DIR/$PROJECT/devices/*; do for projects in ${PROJECT_DIR}/*; do
check_device="$check_device\n - $(basename $device)" project_err_msg="${project_err_msg}\n - ${projects##*/}"
done done
echo -e $check_device die "${project_err_msg}"
die
fi fi
}
if [ -d $PROJECT_DIR/$PROJECT/devices/$DEVICE/linux ]; then check_device() {
linux_config_dir="$PROJECT_DIR/$PROJECT/devices/$DEVICE/linux" local dashes="===========================" device_err_msg
if [ \( -z "${DEVICE}" -a -d "${PROJECT_DIR}/${PROJECT}/devices" \) -o \
\( -n "${DEVICE}" -a ! -d "${PROJECT_DIR}/${PROJECT}/devices/${DEVICE}" \) ]; then
device_err_msg="\n $dashes$dashes$dashes"
device_err_msg="${device_err_msg}\n ERROR: You need to specify a valid device for the $PROJECT project"
device_err_msg="${device_err_msg}\n $dashes$dashes$dashes"
device_err_msg="${device_err_msg}\n\n Valid devices for project: ${PROJECT}"
for device in ${PROJECT_DIR}/${PROJECT}/devices/*; do
device_err_msg="${device_err_msg}\n - ${device##*/}"
done
die "${device_err_msg}"
fi
}
check_arch() {
local dashes="===========================" arch_err_msg linux_config_dir
if [ -d ${PROJECT_DIR}/${PROJECT}/devices/${DEVICE}/linux ]; then
linux_config_dir="${PROJECT_DIR}/${PROJECT}/devices/$DEVICE/linux"
else else
linux_config_dir="$PROJECT_DIR/$PROJECT/linux" linux_config_dir="${PROJECT_DIR}/${PROJECT}/linux"
fi fi
if [ ! -e $linux_config_dir/linux.${TARGET_PATCH_ARCH:-$TARGET_ARCH}.conf ] && if [ ! -e $linux_config_dir/linux.${TARGET_PATCH_ARCH:-$TARGET_ARCH}.conf ] &&
! ls $linux_config_dir/*/linux.${TARGET_PATCH_ARCH:-$TARGET_ARCH}.conf &>/dev/null; then ! ls $linux_config_dir/*/linux.${TARGET_PATCH_ARCH:-$TARGET_ARCH}.conf &>/dev/null; then
check_arch="$check_arch\n $dashes$dashes$dashes" arch_err_msg="\n $dashes$dashes$dashes"
check_arch="$check_arch\n ERROR: Architecture not found, use a valid Architecture" arch_err_msg="${arch_err_msg}\n ERROR: Architecture not found, use a valid Architecture"
check_arch="$check_arch\n for your project or create a new config" arch_err_msg="${arch_err_msg}\n for your project or create a new config"
check_arch="$check_arch\n $dashes$dashes$dashes" arch_err_msg="${arch_err_msg}\n $dashes$dashes$dashes"
check_arch="$check_arch\n\n Valid Architectures for your project: $PROJECT" arch_err_msg="${arch_err_msg}\n\n Valid Architectures for your project: ${PROJECT}"
for arch in $linux_config_dir/*.conf $linux_config_dir/*/linux.$TARGET_ARCH.conf; do for arch in $linux_config_dir/*.conf $linux_config_dir/*/linux.$TARGET_ARCH.conf; do
[[ ${arch} =~ .*\*.* ]] && continue #ignore unexpanded wildcard [[ ${arch} =~ .*\*.* ]] && continue #ignore unexpanded wildcard
check_arch="$check_arch\n - $(basename $arch | cut -f2 -d".")" arch_err_msg="${arch_err_msg}\n - $(basename $arch | cut -f2 -d".")"
done done
echo -e $check_arch die "${arch_err_msg}"
die
fi fi
} }
check_config() {
check_distro
check_project
check_device
check_arch
}
do_autoreconf() { do_autoreconf() {
export ACLOCAL_DIR=$SYSROOT_PREFIX/usr/share/aclocal export ACLOCAL_DIR=$SYSROOT_PREFIX/usr/share/aclocal