isar-init-build-env 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!/bin/sh
  2. # Isar Build Environment Setup Script
  3. #
  4. # Copyright (C) 2006-2011 Linux Foundation
  5. # Copyright (C) 2016 ilbers GmbH
  6. #
  7. # This program is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program; if not, write to the Free Software
  19. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. #
  21. # Normally this is called as '. ./isar-init-build-env <builddir>'
  22. #
  23. # This works in most shells (not dash), but not all of them pass the arguments
  24. # when being sourced. To workaround the shell limitation use "set <builddir>"
  25. # prior to sourcing this script.
  26. #
  27. if [ -n "$BASH_SOURCE" ]; then
  28. THIS_SCRIPT=$BASH_SOURCE
  29. elif [ -n "$ZSH_NAME" ]; then
  30. THIS_SCRIPT=$0
  31. else
  32. THIS_SCRIPT="$(pwd)/isar-init-build-env"
  33. fi
  34. if [ -n "$BBSERVER" ]; then
  35. unset BBSERVER
  36. fi
  37. if [ -z "$ZSH_NAME" ] && [ "$0" = "$THIS_SCRIPT" ]; then
  38. echo "Error: This script needs to be sourced. Please run as '. $THIS_SCRIPT'"
  39. exit 1
  40. fi
  41. if [ -z "$ISARROOT" ]; then
  42. ISARROOT=$(dirname "$THIS_SCRIPT")
  43. ISARROOT=$(readlink -f "$ISARROOT")
  44. fi
  45. unset THIS_SCRIPT
  46. ISARROOT=`readlink -f "$ISARROOT"`
  47. export ISARROOT
  48. . $ISARROOT/scripts/isar-buildenv-internal $1 && \
  49. TEMPLATECONF="$TEMPLATECONF" $ISARROOT/scripts/isar-setup-builddir || {
  50. unset ISARROOT
  51. return 1
  52. }
  53. unset ISARROOT
  54. [ -z "$BUILDDIR" ] || cd "$BUILDDIR"