diff --git a/chocpkg/chocpkg b/chocpkg/chocpkg index ce3979d..cb541c0 100755 --- a/chocpkg/chocpkg +++ b/chocpkg/chocpkg @@ -2,16 +2,42 @@ set -eu +# set_chocpkg_root sets the CHOCPKG_ROOT environment variable based on the +# path where the script is located. +set_chocpkg_root() { + # Assume that the package root is one directory up from the script. + local script_path=$(realpath "$0") + local script_dir=$(dirname "$script_path") + CHOCPKG_ROOT=$(dirname "$script_dir") + + # Build directory must not contain a space, or bad things happen: + case "$CHOCPKG_ROOT" in + *\ *) + cat <> /dev/stderr - exit -1 + if [ -z "${CHOCPKG_ROOT:-}" ]; then + set_chocpkg_root + PATH="$CHOCPKG_ROOT/chocpkg:$CHOCPKG_ROOT/install.native/bin:$PATH" fi + INSTALL_DIR="$CHOCPKG_ROOT/install" NATIVE_INSTALL_DIR="$CHOCPKG_ROOT/install.native" PACKAGES_DIR="$CHOCPKG_ROOT/packages" BUILD_DIR="$CHOCPKG_ROOT/build" + mkdir -p "$INSTALL_DIR" "$NATIVE_INSTALL_DIR" "$PACKAGES_DIR" "$BUILD_DIR" } diff --git a/setup.sh b/setup.sh deleted file mode 100644 index c5518df..0000000 --- a/setup.sh +++ /dev/null @@ -1,24 +0,0 @@ - -CHOCPKG_ROOT=$HOME/chocolate-doom-build -export CHOCPKG_ROOT - -# Build directory must not contain a space, or bad things happen: -case "$CHOCPKG_ROOT" in -*\ *) -cat <