Merge pull request #47 from goyox86/goyox86/macos-fixes

Detecting find and stat from Homebrew/MacPorts on macOS
This commit is contained in:
Jeremy Soller 2017-07-13 16:08:38 -06:00 committed by GitHub
commit 53653625f3
2 changed files with 24 additions and 5 deletions

View File

@ -9,3 +9,22 @@ ROOT="$(cd `dirname "$0"` && pwd)"
REPO="$ROOT/repo/$TARGET"
export CC="x86_64-elf-redox-gcc"
export XARGO_HOME="$ROOT/xargo"
if [[ "$OSTYPE" == "darwin"* ]]; then
# GNU find
FIND="gfind";
# GNU stat from Homebrew or MacPorts
if [ ! -z "$(which brew)" ]; then
STAT="$(brew --prefix)/opt/coreutils/libexec/gnubin/stat";
elif [ ! -z "$(which port)" ]; then
# TODO: find a programatic way of asking MacPorts for it's root dir.
STAT="/opt/local/opt/coreutils/libexec/gnubin/stat";
else
echo "Please install either Homebrew or MacPorts and run the boostrap script."
exit 1
fi
else
FIND="find"
STAT="stat";
fi

10
repo.sh
View File

@ -24,8 +24,8 @@ do
echo -e "\033[01;38;5;155mrepo - preparing $recipe\033[0m" >&2
./cook.sh "$recipe" prepare
else
TIME_SOURCE="$(find recipes/$recipe/source -type f -not -path '*/.git*' -printf "%Ts\n" | sort -nr | head -n 1)"
TIME_BUILD="$(find recipes/$recipe/build -type f -not -path '*/.git*' -printf "%Ts\n" | sort -nr | head -n 1)"
TIME_SOURCE="$($FIND recipes/$recipe/source -type f -not -path '*/.git*' -printf "%Ts\n" | sort -nr | head -n 1)"
TIME_BUILD="$($FIND recipes/$recipe/build -type f -not -path '*/.git*' -printf "%Ts\n" | sort -nr | head -n 1)"
if [ "$TIME_SOURCE" -gt "$TIME_BUILD" ]
then
echo -e "\033[01;38;5;155mrepo - repreparing $recipe\033[0m" >&2
@ -38,9 +38,9 @@ do
echo -e "\033[01;38;5;155mrepo - building $recipe\033[0m" >&2
./cook.sh "$recipe" update build stage tar
else
TIME_BUILD="$(find recipes/$recipe/build -type f -not -path '*/.git*' -printf "%Ts\n" | sort -nr | head -n 1)"
TIME_STAGE="$(stat -c "%Y" recipes/$recipe/stage.tar.gz)"
TIME_RECIPE="$(find recipes/$recipe/{recipe.sh,*.patch} -printf '%Ts\n' | sort -nr | head -n 1)"
TIME_BUILD="$($FIND recipes/$recipe/build -type f -not -path '*/.git*' -printf "%Ts\n" | sort -nr | head -n 1)"
TIME_STAGE="$($STAT -c "%Y" recipes/$recipe/stage.tar.gz)"
TIME_RECIPE="$($FIND recipes/$recipe/{recipe.sh,*.patch} -printf '%Ts\n' | sort -nr | head -n 1)"
if [ "$TIME_BUILD" -gt "$TIME_STAGE" -o "$TIME_RECIPE" -gt "$TIME_STAGE" ]
then
echo -e "\033[01;38;5;155mrepo - rebuilding $recipe\033[0m" >&2