From d844829de47c0ad1bb898512c12759d044b416e1 Mon Sep 17 00:00:00 2001 From: Peter Elliott Date: Fri, 21 Oct 2022 20:53:50 -0600 Subject: [PATCH] Ports: Fix compatiblity issues with running package.sh on Serenity --- Ports/.port_include.sh | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/Ports/.port_include.sh b/Ports/.port_include.sh index e7984fc4357..c24c0c1f162 100755 --- a/Ports/.port_include.sh +++ b/Ports/.port_include.sh @@ -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() { :