relocatable.sh 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. # Step 1. Fix virtualenv
  36. $ENV_PYTHON $VIRTUAL_BOOTSTRAP --relocatable "$HUE_ROOT/build/env"
  37. # Step 1b. Fix any broken lib64 directory
  38. LIB64="$HUE_ROOT/build/env/lib64"
  39. if [ -L "$LIB64" -a ! -e "$LIB64" ] ; then
  40. rm "$LIB64"
  41. ln -s lib "$LIB64"
  42. fi
  43. # Step 2. Fix .ini symlinks for all apps (make them relative)
  44. for app in $HUE_ROOT/apps/* ; do
  45. if [ -d "$app/conf" ] ; then
  46. appname=$(basename $app)
  47. pushd "$HUE_ROOT/desktop/conf"
  48. ln -sfv ../../apps/$appname/conf/*.ini .
  49. popd
  50. fi
  51. done
  52. # Step 3. Clean up any old .pyc files
  53. find "$HUE_ROOT" . -name "*.pyc" -exec rm -f {} \;