2019-05-28 01:02:29 +03:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# This script contains common helpers for all ports.
|
|
|
|
set -e
|
|
|
|
|
|
|
|
if [ -z "$MAKEOPTS" ]; then
|
|
|
|
MAKEOPTS="-j $(nproc)"
|
|
|
|
fi
|
|
|
|
if [ -z "$INSTALLOPTS" ]; then
|
2019-05-28 11:25:10 +03:00
|
|
|
INSTALLOPTS=""
|
2019-05-28 01:02:29 +03:00
|
|
|
fi
|
|
|
|
if [ -z "$SERENITY_ROOT" ]; then
|
|
|
|
echo "You must have source'd UseIt.sh to build any ports!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$PORT_DIR" ]; then
|
|
|
|
echo "Must set PORT_DIR to where the source should be cloned."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-05-28 02:25:29 +03:00
|
|
|
function run_command() {
|
|
|
|
echo "+ $@"
|
|
|
|
(cd "$PORT_DIR" && "$@")
|
|
|
|
echo "+ FINISHED: $@"
|
|
|
|
}
|
|
|
|
|
2019-05-28 03:58:36 +03:00
|
|
|
function run_command_nocd() {
|
|
|
|
echo "+ $@ (nocd)"
|
|
|
|
("$@")
|
|
|
|
echo "+ FINISHED (nocd): $@"
|
|
|
|
}
|
|
|
|
|
2019-05-28 01:02:29 +03:00
|
|
|
function run_fetch_git() {
|
|
|
|
if [ -d "$PORT_DIR/.git" ]; then
|
2019-05-28 02:25:29 +03:00
|
|
|
run_command git fetch
|
|
|
|
run_command git reset --hard FETCH_HEAD
|
2019-05-28 14:48:06 +03:00
|
|
|
run_command git clean -fx
|
2019-05-28 01:02:29 +03:00
|
|
|
else
|
2019-05-28 03:58:36 +03:00
|
|
|
run_command_nocd git clone "$1" "$PORT_DIR"
|
2019-05-28 01:02:29 +03:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2019-05-28 11:25:39 +03:00
|
|
|
function run_replace_in_file() {
|
|
|
|
run_command perl -p -i -e "$1" $2
|
|
|
|
}
|
|
|
|
|
2019-05-28 02:25:29 +03:00
|
|
|
function run_patch() {
|
|
|
|
echo "+ Applying patch $1"
|
|
|
|
run_command patch "$2" < "$1"
|
|
|
|
}
|
|
|
|
|
2019-05-28 01:02:29 +03:00
|
|
|
function run_configure_cmake() {
|
2019-05-28 02:25:29 +03:00
|
|
|
run_command cmake -DCMAKE_TOOLCHAIN_FILE="$SERENITY_ROOT/Toolchain/CMakeToolchain.txt" .
|
2019-05-28 01:02:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function run_configure_autotools() {
|
2019-05-28 02:25:29 +03:00
|
|
|
run_command ./configure --host=i686-pc-serenity "$@"
|
2019-05-28 01:02:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function run_make() {
|
2019-05-28 02:25:29 +03:00
|
|
|
run_command make $MAKEOPTS "$@"
|
2019-05-28 01:02:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function run_make_install() {
|
2019-05-28 02:25:29 +03:00
|
|
|
run_command make $INSTALLOPTS install "$@"
|
2019-05-28 01:02:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if [ -z "$1" ]; then
|
2019-05-28 02:25:29 +03:00
|
|
|
echo "+ Fetching..."
|
2019-05-28 01:02:29 +03:00
|
|
|
fetch
|
2019-05-28 02:25:29 +03:00
|
|
|
echo "+ Configuring..."
|
2019-05-28 01:02:29 +03:00
|
|
|
configure
|
2019-05-28 02:25:29 +03:00
|
|
|
echo "+ Building..."
|
2019-05-28 01:02:29 +03:00
|
|
|
build
|
2019-05-28 02:25:29 +03:00
|
|
|
echo "+ Installing..."
|
2019-05-28 01:02:29 +03:00
|
|
|
install
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$1" == "fetch" ]; then
|
2019-05-28 02:25:29 +03:00
|
|
|
echo "+ Fetching..."
|
2019-05-28 01:02:29 +03:00
|
|
|
fetch
|
|
|
|
elif [ "$1" == "configure" ]; then
|
2019-05-28 02:25:29 +03:00
|
|
|
echo "+ Configuring..."
|
2019-05-28 01:02:29 +03:00
|
|
|
configure
|
|
|
|
elif [ "$1" == "build" ]; then
|
2019-05-28 02:25:29 +03:00
|
|
|
echo "+ Building..."
|
2019-05-28 01:02:29 +03:00
|
|
|
build
|
|
|
|
elif [ "$1" == "install" ]; then
|
2019-05-28 02:25:29 +03:00
|
|
|
echo "+ Installing..."
|
2019-05-28 01:02:29 +03:00
|
|
|
install
|
|
|
|
else
|
|
|
|
echo "Unknown verb: $1"
|
|
|
|
echo "Supported: (one of) fetch configure build install"
|
|
|
|
exit 1
|
|
|
|
fi
|