Back to home page

OSCL-LXR

 
 

    


0001 #!/bin/bash
0002 
0003 #
0004 # Licensed to the Apache Software Foundation (ASF) under one or more
0005 # contributor license agreements.  See the NOTICE file distributed with
0006 # this work for additional information regarding copyright ownership.
0007 # The ASF licenses this file to You under the Apache License, Version 2.0
0008 # (the "License"); you may not use this file except in compliance with
0009 # the License.  You may obtain a copy of the License at
0010 #
0011 #    http://www.apache.org/licenses/LICENSE-2.0
0012 #
0013 # Unless required by applicable law or agreed to in writing, software
0014 # distributed under the License is distributed on an "AS IS" BASIS,
0015 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0016 # See the License for the specific language governing permissions and
0017 # limitations under the License.
0018 #
0019 
0020 # This scripts packages the SparkR source files (R and C files) and
0021 # creates a package that can be loaded in R. The package is by default installed to
0022 # $FWDIR/lib and the package can be loaded by using the following command in R:
0023 #
0024 #   library(SparkR, lib.loc="$FWDIR/lib")
0025 #
0026 # NOTE(shivaram): Right now we use $SPARK_HOME/R/lib to be the installation directory
0027 # to load the SparkR package on the worker nodes.
0028 
0029 set -o pipefail
0030 set -e
0031 
0032 FWDIR="$(cd "`dirname "${BASH_SOURCE[0]}"`"; pwd)"
0033 pushd "$FWDIR" > /dev/null
0034 . "$FWDIR/find-r.sh"
0035 
0036 if [ -z "$VERSION" ]; then
0037   VERSION=`grep Version "$FWDIR/pkg/DESCRIPTION" | awk '{print $NF}'`
0038 fi
0039 
0040 if [ ! -f "$FWDIR/SparkR_$VERSION.tar.gz" ]; then
0041   echo -e "R source package file '$FWDIR/SparkR_$VERSION.tar.gz' is not found."
0042   echo -e "Please build R source package with check-cran.sh"
0043   exit -1;
0044 fi
0045 
0046 echo "Removing lib path and installing from source package"
0047 LIB_DIR="$FWDIR/lib"
0048 rm -rf "$LIB_DIR"
0049 mkdir -p "$LIB_DIR"
0050 "$R_SCRIPT_PATH/R" CMD INSTALL "SparkR_$VERSION.tar.gz" --library="$LIB_DIR"
0051 
0052 # Zip the SparkR package so that it can be distributed to worker nodes on YARN
0053 pushd "$LIB_DIR" > /dev/null
0054 jar cfM "$LIB_DIR/sparkr.zip" SparkR
0055 popd > /dev/null
0056 
0057 popd