Ports: Fix compatiblity issues with running package.sh on Serenity

This commit is contained in:
Peter Elliott 2022-10-21 20:53:50 -06:00 committed by Jelle Raaijmakers
parent 18d72ed3fd
commit d844829de4
Notes: sideshowbarker 2024-07-17 11:30:54 +09:00

View file

@ -30,14 +30,16 @@ buildstep_intro() {
echo -e "\x1b[1;32m=> $@\x1b[0m"
}
maybe_source() {
if [ -f "$1" ]; then
. "$1"
fi
}
target_env() {
maybe_source "${SCRIPT}/.hosted_defs.sh"
if [ -f "${SCRIPT}/.hosted_defs.sh" ]; then
. "${SCRIPT}/.hosted_defs.sh"
elif [ "$(uname -s)" = "SerenityOS" ]; then
export SERENITY_ARCH="$(uname -m)"
export SERENITY_INSTALL_ROOT=""
else
>&2 echo "Error: .hosted_defs.sh is missing and we are not running on Serenity."
exit 1
fi
}
target_env
@ -107,7 +109,12 @@ shift
: "${workdir:=$port-$version}"
PORT_META_DIR="$(pwd)"
PORT_BUILD_DIR="${SERENITY_BUILD_DIR}/Ports/${port}"
if [[ -z ${SERENITY_BUILD_DIR:-} ]]; then
PORT_BUILD_DIR="${PORT_META_DIR}"
else
PORT_BUILD_DIR="${SERENITY_BUILD_DIR}/Ports/${port}"
fi
mkdir -p "${PORT_BUILD_DIR}"
cd "${PORT_BUILD_DIR}"
@ -455,7 +462,11 @@ func_defined pre_configure || pre_configure() {
}
func_defined configure || configure() {
chmod +x "${workdir}"/"$configscript"
run ./"$configscript" --host="${SERENITY_ARCH}-pc-serenity" "${configopts[@]}"
if [[ -n "${SERENITY_SOURCE_DIR:-}" ]]; then
run ./"$configscript" --host="${SERENITY_ARCH}-pc-serenity" "${configopts[@]}"
else
run ./"$configscript" --build="${SERENITY_ARCH}-pc-serenity" "${configopts[@]}"
fi
}
func_defined post_configure || post_configure() {
: