#!/usr/bin/env bash

cd src

# Apply patches
for patch in ../patches/*.patch; do
    [ -r "$patch" ] || continue  # Skip non-existing or non-readable patches
    patch -p1 <"$patch"
    if [ $? -ne 0 ]; then
        echo >&2 "Error applying '$patch'"
        exit 1
    fi
done

$PIP_INSTALL .

if [ $? -ne 0 ]; then
    echo "Error installing pexpect"
    exit 1
fi
