relocatable.sh 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. set -e
  18. usage() {
  19. echo "
  20. Make a Hue installation relocatable. Run this in the installation
  21. directory created by 'make install', before you relocate it.
  22. Usage:
  23. $0
  24. "
  25. exit 1
  26. }
  27. if [ $# != 0 ] ; then
  28. usage
  29. fi
  30. # We're in <hue_root>/tools
  31. CURR_DIR="$(dirname $0)"
  32. HUE_ROOT="$CURR_DIR/.."
  33. ENV_PYTHON="$HUE_ROOT/build/env/bin/python"
  34. VIRTUAL_BOOTSTRAP="$CURR_DIR/virtual-bootstrap/virtual-bootstrap.py"
  35. source $HUE_ROOT/tools/enable-python27.sh
  36. export PATH=$(dirname $ENV_PYTHON):$PATH
  37. # Step 1. Fix virtualenv
  38. $ENV_PYTHON $VIRTUAL_BOOTSTRAP --relocatable "$HUE_ROOT/build/env"
  39. # Step 1b. Fix any broken lib64 directory
  40. LIB64="$HUE_ROOT/build/env/lib64"
  41. if [ -L "$LIB64" -a ! -e "$LIB64" ] ; then
  42. rm "$LIB64"
  43. ln -s lib "$LIB64"
  44. fi
  45. # Step 2. Fix .ini symlinks for all apps (make them relative)
  46. for app in $HUE_ROOT/apps/* ; do
  47. if [ -d "$app/conf" ] ; then
  48. appname=$(basename $app)
  49. pushd "$HUE_ROOT/desktop/conf"
  50. ln -sfv ../../apps/$appname/conf/*.ini .
  51. popd
  52. fi
  53. done
  54. # Step 3. Clean up any old .pyc files
  55. find "$HUE_ROOT" . -name "*.pyc" -exec rm -f {} \;