#!/usr/bin/env bash set -eu SCRIPT="$(dirname "${0}")" export SERENITY_ARCH="${SERENITY_ARCH:-i686}" HOST_CC="${CC:=cc}" HOST_CXX="${CXX:=c++}" HOST_AR="${AR:=ar}" HOST_RANLIB="${RANLIB:=ranlib}" HOST_PATH="${PATH:=}" HOST_PKG_CONFIG_DIR="${PKG_CONFIG_DIR:=}" HOST_PKG_CONFIG_SYSROOT_DIR="${PKG_CONFIG_SYSROOT_DIR:=}" HOST_PKG_CONFIG_LIBDIR="${PKG_CONFIG_LIBDIR:=}" DESTDIR="/" maybe_source() { if [ -f "$1" ]; then . "$1" fi } enable_ccache() { if command -v ccache &>/dev/null; then ccache_tooldir="${SERENITY_BUILD_DIR}/ccache" mkdir -p "$ccache_tooldir" for tool in gcc g++ c++; do ln -sf "$(command -v ccache)" "${ccache_tooldir}/${SERENITY_ARCH}-pc-serenity-${tool}" done export PATH="${ccache_tooldir}:$PATH" fi } target_env() { maybe_source "${SCRIPT}/.hosted_defs.sh" } target_env host_env() { export CC="${HOST_CC}" export CXX="${HOST_CXX}" export AR="${HOST_AR}" export RANLIB="${HOST_RANLIB}" export PATH="${HOST_PATH}" export PKG_CONFIG_DIR="${HOST_PKG_CONFIG_DIR}" export PKG_CONFIG_SYSROOT_DIR="${HOST_PKG_CONFIG_SYSROOT_DIR}" export PKG_CONFIG_LIBDIR="${HOST_PKG_CONFIG_LIBDIR}" enable_ccache } packagesdb="${DESTDIR}/usr/Ports/packages.db" . "$@" shift : "${makeopts:=-j$(nproc)}" : "${installopts:=}" : "${workdir:=$port-$version}" : "${configscript:=configure}" : "${configopts:=}" : "${useconfigure:=false}" : "${depends:=}" : "${patchlevel:=1}" : "${auth_type:=}" : "${auth_import_key:=}" : "${auth_opts:=}" : "${launcher_name:=}" : "${launcher_category:=}" : "${launcher_command:=}" run_nocd() { echo "+ $@ (nocd)" ("$@") } run() { echo "+ $@" (cd "$workdir" && "$@") } run_replace_in_file() { run perl -p -i -e "$1" $2 } ensure_build() { # Sanity check. if [ ! -f "${DESTDIR}/usr/lib/libc.so" ]; then echo "libc.so could not be found. This likely means that SerenityOS:" echo "- has not been built and/or installed yet" echo "- has been installed in an unexpected location" echo "The currently configured build directory is ${SERENITY_BUILD_DIR}. Resolve this issue and try again." exit 1 fi } install_main_launcher() { if [ -n "$launcher_name" ] && [ -n "$launcher_category" ] && [ -n "$launcher_command" ]; then install_launcher "$launcher_name" "$launcher_category" "$launcher_command" fi } install_launcher() { if [ "$#" -lt 3 ]; then echo "Syntax: install_launcher " exit 1 fi launcher_name="$1" launcher_category="$2" launcher_command="$3" launcher_filename="${launcher_name,,}" launcher_filename="${launcher_filename// /}" case "$launcher_command" in *\ *) mkdir -p $DESTDIR/usr/local/libexec launcher_executable="/usr/local/libexec/$launcher_filename" cat >"$DESTDIR/$launcher_executable" <