Skip to content

Commit e902dc4

Browse files
sarutakpwendell
authored andcommitted
[SPARK-5188][BUILD] make-distribution.sh should support curl, not only wget to get Tachyon
When we use `make-distribution.sh` with `--with-tachyon` option, Tachyon will be downloaded by `wget` command but some systems don't have `wget` by default (MacOS X doesn't have). Other scripts like build/mvn, build/sbt support not only `wget` but also `curl` so `make-distribution.sh` should support `curl` too. Author: Kousuke Saruta <[email protected]> Closes apache#3988 from sarutak/SPARK-5188 and squashes the following commits: 0f546e0 [Kousuke Saruta] Merge branch 'master' of git://git.apache.org/spark into SPARK-5188 010e884 [Kousuke Saruta] Merge branch 'SPARK-5188' of github.com:sarutak/spark into SPARK-5188 163687e [Kousuke Saruta] Fixed a merge conflict e24e01b [Kousuke Saruta] Merge branch 'master' of git://git.apache.org/spark into SPARK-5188 3daf1f1 [Kousuke Saruta] Merge branch 'master' of git://git.apache.org/spark into SPARK-5188 3caa4cb [Kousuke Saruta] Merge branch 'master' of git://git.apache.org/spark into SPARK-5188 7cc8255 [Kousuke Saruta] Fix to use \$MVN instead of mvn a3e908b [Kousuke Saruta] Fixed style 2db9fbf [Kousuke Saruta] Removed redirection from the logic which checks the existence of commands 1e4c7e0 [Kousuke Saruta] Used "command" command instead of "type" command 83b49b5 [Kousuke Saruta] Modified make-distribution.sh so that we use curl, not only wget to get tachyon
1 parent 406f6d3 commit e902dc4

File tree

4 files changed

+36
-25
lines changed

4 files changed

+36
-25
lines changed

build/mvn

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ install_app() {
4848
# check if we already have the tarball
4949
# check if we have curl installed
5050
# download application
51-
[ ! -f "${local_tarball}" ] && [ -n "`which curl 2>/dev/null`" ] && \
51+
[ ! -f "${local_tarball}" ] && [ $(command -v curl) ] && \
5252
echo "exec: curl ${curl_opts} ${remote_tarball}" && \
5353
curl ${curl_opts} "${remote_tarball}" > "${local_tarball}"
5454
# if the file still doesn't exist, lets try `wget` and cross our fingers
55-
[ ! -f "${local_tarball}" ] && [ -n "`which wget 2>/dev/null`" ] && \
55+
[ ! -f "${local_tarball}" ] && [ $(command -v wget) ] && \
5656
echo "exec: wget ${wget_opts} ${remote_tarball}" && \
5757
wget ${wget_opts} -O "${local_tarball}" "${remote_tarball}"
5858
# if both were unsuccessful, exit

build/sbt-launch-lib.bash

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ acquire_sbt_jar () {
5050
# Download
5151
printf "Attempting to fetch sbt\n"
5252
JAR_DL="${JAR}.part"
53-
if hash curl 2>/dev/null; then
53+
if [ $(command -v curl) ]; then
5454
(curl --silent ${URL1} > "${JAR_DL}" || curl --silent ${URL2} > "${JAR_DL}") && mv "${JAR_DL}" "${JAR}"
55-
elif hash wget 2>/dev/null; then
55+
elif [ $(command -v wget) ]; then
5656
(wget --quiet ${URL1} -O "${JAR_DL}" || wget --quiet ${URL2} -O "${JAR_DL}") && mv "${JAR_DL}" "${JAR}"
5757
else
5858
printf "You do not have curl or wget installed, please install sbt manually from http://www.scala-sbt.org/\n"

dev/check-license

+11-11
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@ acquire_rat_jar () {
2727
if [[ ! -f "$rat_jar" ]]; then
2828
# Download rat launch jar if it hasn't been downloaded yet
2929
if [ ! -f "$JAR" ]; then
30-
# Download
31-
printf "Attempting to fetch rat\n"
32-
JAR_DL="${JAR}.part"
33-
if hash curl 2>/dev/null; then
34-
curl --silent "${URL}" > "$JAR_DL" && mv "$JAR_DL" "$JAR"
35-
elif hash wget 2>/dev/null; then
36-
wget --quiet ${URL} -O "$JAR_DL" && mv "$JAR_DL" "$JAR"
37-
else
38-
printf "You do not have curl or wget installed, please install rat manually.\n"
39-
exit -1
40-
fi
30+
# Download
31+
printf "Attempting to fetch rat\n"
32+
JAR_DL="${JAR}.part"
33+
if [ $(command -v curl) ]; then
34+
curl --silent "${URL}" > "$JAR_DL" && mv "$JAR_DL" "$JAR"
35+
elif [ $(command -v wget) ]; then
36+
wget --quiet ${URL} -O "$JAR_DL" && mv "$JAR_DL" "$JAR"
37+
else
38+
printf "You do not have curl or wget installed, please install rat manually.\n"
39+
exit -1
40+
fi
4141
fi
4242

4343
unzip -tq $JAR &> /dev/null

make-distribution.sh

+21-10
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ SPARK_HOME="$(cd "`dirname "$0"`"; pwd)"
3232
DISTDIR="$SPARK_HOME/dist"
3333

3434
SPARK_TACHYON=false
35+
TACHYON_VERSION="0.5.0"
36+
TACHYON_TGZ="tachyon-${TACHYON_VERSION}-bin.tar.gz"
37+
TACHYON_URL="https://github.com/amplab/tachyon/releases/download/v${TACHYON_VERSION}/${TACHYON_TGZ}"
38+
3539
MAKE_TGZ=false
3640
NAME=none
3741
MVN="$SPARK_HOME/build/mvn"
@@ -93,7 +97,7 @@ done
9397

9498
if [ -z "$JAVA_HOME" ]; then
9599
# Fall back on JAVA_HOME from rpm, if found
96-
if which rpm &>/dev/null; then
100+
if [ $(command -v rpm) ]; then
97101
RPM_JAVA_HOME=$(rpm -E %java_home 2>/dev/null)
98102
if [ "$RPM_JAVA_HOME" != "%java_home" ]; then
99103
JAVA_HOME=$RPM_JAVA_HOME
@@ -107,22 +111,23 @@ if [ -z "$JAVA_HOME" ]; then
107111
exit -1
108112
fi
109113

110-
if which git &>/dev/null; then
114+
if [ $(command -v git) ]; then
111115
GITREV=$(git rev-parse --short HEAD 2>/dev/null || :)
112116
if [ ! -z $GITREV ]; then
113117
GITREVSTRING=" (git revision $GITREV)"
114118
fi
115119
unset GITREV
116120
fi
117121

118-
if ! which "$MVN" &>/dev/null; then
122+
123+
if [ ! $(command -v $MVN) ] ; then
119124
echo -e "Could not locate Maven command: '$MVN'."
120125
echo -e "Specify the Maven command with the --mvn flag"
121126
exit -1;
122127
fi
123128

124-
VERSION=$(mvn help:evaluate -Dexpression=project.version 2>/dev/null | grep -v "INFO" | tail -n 1)
125-
SPARK_HADOOP_VERSION=$(mvn help:evaluate -Dexpression=hadoop.version $@ 2>/dev/null\
129+
VERSION=$($MVN help:evaluate -Dexpression=project.version 2>/dev/null | grep -v "INFO" | tail -n 1)
130+
SPARK_HADOOP_VERSION=$($MVN help:evaluate -Dexpression=hadoop.version $@ 2>/dev/null\
126131
| grep -v "INFO"\
127132
| tail -n 1)
128133
SPARK_HIVE=$($MVN help:evaluate -Dexpression=project.activeProfiles -pl sql/hive $@ 2>/dev/null\
@@ -225,16 +230,22 @@ cp -r "$SPARK_HOME/ec2" "$DISTDIR"
225230

226231
# Download and copy in tachyon, if requested
227232
if [ "$SPARK_TACHYON" == "true" ]; then
228-
TACHYON_VERSION="0.5.0"
229-
TACHYON_URL="https://github.com/amplab/tachyon/releases/download/v${TACHYON_VERSION}/tachyon-${TACHYON_VERSION}-bin.tar.gz"
230-
231233
TMPD=`mktemp -d 2>/dev/null || mktemp -d -t 'disttmp'`
232234

233235
pushd $TMPD > /dev/null
234236
echo "Fetching tachyon tgz"
235-
wget "$TACHYON_URL"
236237

237-
tar xf "tachyon-${TACHYON_VERSION}-bin.tar.gz"
238+
TACHYON_DL="${TACHYON_TGZ}.part"
239+
if [ $(command -v curl) ]; then
240+
curl --silent -k -L "${TACHYON_URL}" > "${TACHYON_DL}" && mv "${TACHYON_DL}" "${TACHYON_TGZ}"
241+
elif [ $(command -v wget) ]; then
242+
wget --quiet "${TACHYON_URL}" -O "${TACHYON_DL}" && mv "${TACHYON_DL}" "${TACHYON_TGZ}"
243+
else
244+
printf "You do not have curl or wget installed. please install Tachyon manually.\n"
245+
exit -1
246+
fi
247+
248+
tar xzf "${TACHYON_TGZ}"
238249
cp "tachyon-${TACHYON_VERSION}/core/target/tachyon-${TACHYON_VERSION}-jar-with-dependencies.jar" "$DISTDIR/lib"
239250
mkdir -p "$DISTDIR/tachyon/src/main/java/tachyon/web"
240251
cp -r "tachyon-${TACHYON_VERSION}"/{bin,conf,libexec} "$DISTDIR/tachyon"

0 commit comments

Comments
 (0)