Skip to content

Commit

Permalink
Build.sh: work around Git for Windows' lack of stat(1)
Browse files Browse the repository at this point in the history
The Git for Windows installer does not install the stat(1) utility. But
it has GNU date(1). And that version of date(1) has the -r option
which we can use instead of stat(1) to get at the mtime of a file.

Noticed by Olexandra Ovsiy in bug 628.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  • Loading branch information
dscho committed Jul 8, 2013
1 parent 949cfd9 commit e21dac7
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions Build.sh
Expand Up @@ -176,28 +176,31 @@ fi
PATH="$PATH:$(get_java_home)/bin:$(get_java_home)/../bin"
export PATH

# Thanks, MacOSX (or for that matter, BSD), and Windows, for easy, standard
# ways to get the mtime of a file.

get_mtime () {
stat -c %Y "$1"
}

# JAVA_HOME needs to be a DOS path for Windows from here on
case "$UNAME_S" in
MINGW*)
export JAVA_HOME="$(cd "$JAVA_HOME" && pwd -W)"
get_mtime () {
date -r "$1" +%s
}
;;
CYGWIN*)
export JAVA_HOME="$(cygpath -d "$JAVA_HOME")"
;;
Darwin*)
get_mtime () {
stat -f %m "$1"
}
;;
esac

# Thanks, MacOSX (or for that matter, BSD)

get_mtime () {
stat -c %Y "$1"
}
if test Darwin = "$(uname -s 2> /dev/null)"
then
get_mtime () {
stat -f %m "$1"
}
fi

# Figure out whether $2 (the destination) is newer than $1 (the source).
# If $2 is a SNAPSHOT .jar, must not be older than a day, either.
#
Expand Down

0 comments on commit e21dac7

Please sign in to comment.