build-functions 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. #!/bin/bash
  2. # Licensed to Cloudera, Inc. under one
  3. # or more contributor license agreements. See the NOTICE file
  4. # distributed with this work for additional information
  5. # regarding copyright ownership. Cloudera, Inc. licenses this file
  6. # to you under the Apache License, Version 2.0 (the
  7. # "License"); you may not use this file except in compliance
  8. # with the License. You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. # Common functions for hudson build scripts
  18. if [ ! -e $HOME/.hue_cache ]; then
  19. mkdir -p $HOME/.hue_cache
  20. fi;
  21. check_mtime() {
  22. MTIME_FILE=${1}
  23. MTIME=$( curl -Is ${2} | awk 'BEGIN {FS=":"} { if ($1 == "Last-Modified") { print substr($2,2) } }' )
  24. if echo "${MTIME}" | diff ${MTIME_FILE} - > /dev/null; then
  25. return 0
  26. else
  27. echo ${MTIME} > ${MTIME_FILE}
  28. return 1
  29. fi;
  30. }
  31. ##########
  32. #
  33. # Use $CDH_URL to control where to download Hadoop.
  34. # If not specified, it uses the $CDH variable to select an archive location.
  35. #
  36. CDH_URL=${CDH_URL:-http://nightly.cloudera.com/cdh4/cdh/4/hadoop-2.0.0-cdh4.5.0-SNAPSHOT.tar.gz}
  37. CDH_TGZ=$(basename $CDH_URL)
  38. CDH_VERSION=${CDH_TGZ/.tar.gz/}
  39. CDH_CACHE="$HOME/.hue_cache/${CDH_TGZ}"
  40. CDH_MTIME_FILE="$HOME/.hue_cache/.cdh_mtime"
  41. build_hadoop() {
  42. if ! check_mtime ${CDH_MTIME_FILE} ${CDH_URL} || [ ! -f $CDH_CACHE ]; then
  43. echo "Downloading $CDH_URL..."
  44. wget $CDH_URL -O $CDH_CACHE
  45. fi
  46. HADOOP_DIR=$HUE_ROOT/ext/hadoop
  47. export HADOOP_HDFS_HOME="$HADOOP_DIR/${CDH_VERSION}/share/hadoop/hdfs"
  48. export HADOOP_BIN="$HADOOP_DIR/${CDH_VERSION}/bin/hadoop"
  49. export HADOOP_MR1_HOME="$HADOOP_DIR/${CDH_VERSION}/share/hadoop/mapreduce1"
  50. export HADOOP_MR1_BIN="$HADOOP_DIR/${CDH_VERSION}/bin-mapreduce1/hadoop"
  51. mkdir -p $HADOOP_DIR
  52. rm -rf "$HADOOP_DIR/${CDH_VERSION}"
  53. echo "Unpacking $CDH_CACHE to $HADOOP_DIR"
  54. tar -C $HADOOP_DIR -xzf $CDH_CACHE
  55. # For Hive
  56. ln -s "$HADOOP_DIR/${CDH_VERSION}/bin-mapreduce1" $HADOOP_MR1_HOME/bin
  57. # For MR1
  58. rm -f "$HADOOP_DIR/${CDH_VERSION}/share/hadoop/mapreduce"
  59. ln -sf "mapreduce1" "$HADOOP_DIR/${CDH_VERSION}/share/hadoop/mapreduce"
  60. ln -s $HADOOP_DIR/${CDH_VERSION} $HADOOP_DIR/hadoop
  61. }
  62. ##########
  63. HIVE_URL=${HIVE_URL:-http://nightly.cloudera.com/cdh4/cdh/4/hive-0.10.0-cdh4.5.0-SNAPSHOT.tar.gz}
  64. HIVE_TGZ=$(basename $HIVE_URL)
  65. HIVE_VERSION=${HIVE_TGZ/.tar.gz/}
  66. HIVE_CACHE="$HOME/.hue_cache/${HIVE_TGZ}"
  67. HIVE_MTIME_FILE="$HOME/.hue_cache/.hive_mtime"
  68. build_hive() {
  69. if ! check_mtime ${HIVE_MTIME_FILE} ${HIVE_URL} || [ ! -f $HIVE_CACHE ]; then
  70. echo "Downloading $HIVE_URL..."
  71. wget $HIVE_URL -O $HIVE_CACHE
  72. fi
  73. HIVE_DIR=$HUE_ROOT/ext/hive
  74. export HIVE_HOME="$HIVE_DIR/${HIVE_VERSION}"
  75. mkdir -p $HIVE_DIR
  76. rm -rf $HIVE_HOME
  77. echo "Unpacking $HIVE_CACHE to $HIVE_DIR"
  78. tar -C $HIVE_DIR -xzf $HIVE_CACHE
  79. ln -s $HIVE_DIR/${HIVE_VERSION} $HIVE_DIR/hive
  80. export HIVE_CONF_DIR=$HIVE_HOME/conf
  81. }
  82. ##########
  83. OOZIE_URL=${OOZIE_URL:-http://nightly.cloudera.com/cdh4/cdh/4/oozie-3.3.2-cdh4.5.0-SNAPSHOT.tar.gz}
  84. OOZIE_TGZ=$(basename $OOZIE_URL)
  85. OOZIE_VERSION=${OOZIE_TGZ/.tar.gz/}
  86. OOZIE_CACHE="$HOME/.hue_cache/${OOZIE_TGZ}"
  87. OOZIE_MTIME_FILE="$HOME/.hue_cache/.oozie_mtime"
  88. build_oozie() {
  89. if ! check_mtime ${OOZIE_MTIME_FILE} ${OOZIE_URL} || [ ! -f $OOZIE_CACHE ]; then
  90. echo "Downloading $OOZIE_URL..."
  91. wget $OOZIE_URL -O $OOZIE_CACHE
  92. fi
  93. OOZIE_DIR=$HUE_ROOT/ext/oozie
  94. export OOZIE_HOME="$OOZIE_DIR/${OOZIE_VERSION}"
  95. mkdir -p $OOZIE_DIR
  96. rm -rf $OOZIE_HOME
  97. echo "Unpacking $OOZIE_CACHE to $OOZIE_DIR"
  98. tar -C $OOZIE_DIR -xzf $OOZIE_CACHE
  99. export OOZIE_CONF_DIR=$OOZIE_HOME/conf
  100. rm -rf $OOZIE_DIR/oozie
  101. ln -s $OOZIE_DIR/${OOZIE_VERSION} $OOZIE_DIR/oozie
  102. mkdir -p $OOZIE_HOME/libext
  103. tar -C $OOZIE_HOME/libext -zxvf $OOZIE_HOME/oozie-hadooplibs-*-cdh*.tar.gz
  104. cp $OOZIE_HOME/libext/oozie-*/hadooplibs/hadooplib-*-mr1-cdh*/*jar $OOZIE_HOME/libext/
  105. tar -C $OOZIE_HOME -zxvf $OOZIE_HOME/oozie-examples.tar.gz
  106. tar -C $OOZIE_HOME -zxvf $OOZIE_HOME/oozie-sharelib-*SNAPSHOT.tar.gz
  107. $OOZIE_HOME/bin/oozie-setup.sh prepare-war
  108. $OOZIE_HOME/bin/ooziedb.sh create -sqlfile oozie.sql -run
  109. }