You are here

build.sh in Open Atrium 7.2

#!/bin/sh
# Script to build OpenAtrium 2.x
# Make sure the correct number of args was passed from the command line
if [ $# -eq 0 ]; then
  echo "Usage $0 [-d] target_build_dir"
  exit 1
fi
DEV_BUILD=0
PANOPOLY_DEV=0
while getopts ":dp" opt; do
  case $opt in
    d) # dev arguments
      DEV_BUILD=1
      ;;
    p) # use panopoly-dev
      PANOPOLY_DEV=1
      ;;
    r) # release arg
      ;;
    \?)
      echo "Invalid option: -$OPTARG" >&2
      ;;
  esac
done
shift $((OPTIND-1))
TARGET=$1

if [ "$ATRIUM_BUILD" = "dev" ]; then
  DEV_BUILD=1
  PANOPOLY_DEV=1
  echo "In DEV"
fi

# Make sure we have a target directory
if [ -z "$TARGET" ]; then
  echo "Usage $0 target_build_dir"
  exit 2
fi
CURDIR=`pwd -P`
ORIG_TARGET=$TARGET
TARGET=$TARGET"__build"
CALLPATH=`dirname "$0"`
ABS_CALLPATH=`cd "$CALLPATH"; pwd -P`

echo '_______      ___'
echo '| ___ |     /  |'
echo '| | | |    /   |'
echo '| |_| |   / /| |'
echo '|____ |  / / | |'
echo '   OpenAtrium   '
echo '================'

set -e
if [ $DEV_BUILD -eq 1 ]; then
  echo "*** DEVELOPMENT BUILD ***"
fi
echo "Building to build dir: $TARGET"
echo 'Verifying make...'
drush verify-makefile
# Remove current drupal dir
if [ -e "$TARGET" ]; then
  echo 'Removing old build directory...'
  rm -rf "$TARGET"
fi
# Do the build
if [ $DEV_BUILD -eq 1 ]; then
# Dev version
  DRUSH_OPTS='--working-copy --no-gitinfofile --no-cache'
  # first build core
  MAKEFILE='drupal-org-core.make'
  echo "Building Drupal core..."
  drush make --prepare-install $DRUSH_OPTS "$ABS_CALLPATH/$MAKEFILE" "$TARGET"
  # now get the latest profile distro
  # now build the dev version
  cd "$TARGET"
  MAKEFILE='scripts/oa-drush-dev.make'
  if [ $PANOPOLY_DEV -eq 1 ]; then
    MAKEFILE='scripts/oa-drush-panopoly-dev.make'
  fi
  echo "Building the profile -dev version..."
  # Patch to add github remotes instead of drupal.
  drush make --yes --no-core $DRUSH_OPTS "$ABS_CALLPATH/$MAKEFILE" --contrib-destination=profiles/openatrium
  # Remove drupal remotes.
  if [ -e "profiles/openatrium" ]; then
    cd "profiles/openatrium"
    echo "Downloading latest profile..."
    git init .
    git remote add --track 7.x-2.x origin http://git.drupal.org/project/openatrium.git
    git fetch
    git checkout 7.x-2.x
  fi
  cd $CURDIR
else
# Release version
  MAKEFILE='build-openatrium.make'
  DRUSH_OPTS='--no-cache --prepare-install'
  echo 'Running drush make...'
  drush make $DRUSH_OPTS "$ABS_CALLPATH/$MAKEFILE" "$TARGET"
fi
set +e
# check to see if drush make was successful by checking for oa_core module
if [ -e "$TARGET/profiles/openatrium/modules/contrib/oa_core" ]; then
  # Restore previous sites folder if build was successful
  if [ -e "$ORIG_TARGET/sites" ]; then
    echo "Restoring sites folder from: $ORIG_TARGET/sites"
    rm -rf "$TARGET/sites"
    mv "$ORIG_TARGET/sites" "$TARGET/sites"
  fi

  echo "Moving files to: $ORIG_TARGET"
  if [ -e "$ORIG_TARGET" ]; then
    rm -rf "$ORIG_TARGET"
  fi
  if [ -e "$ORIG_TARGET" ]; then
    echo "Error removing old files.  Please fix permissions."
    exit 1
  fi
  mv $TARGET $ORIG_TARGET
  DRUPAL=`cd "$ORIG_TARGET"; pwd -P`

  echo "Active site now in: $DRUPAL"

  # Copy libraries from profile into site libraries
  # Modules properly using Library API don't need this, but many modules
  # don't support libraries in the profile (like WYSIWYG)
  echo "Copying library files."
  rsync -r $DRUPAL/profiles/openatrium/libraries/ $DRUPAL/sites/all/libraries/

  if [ ! -e "$DRUPAL/sites/default/settings.php" ]; then
    echo "No settings.php file found"
    echo "Please run the install.php script to install Drupal and Open Atrium"
    exit 1
  fi

  DRUPAL_DB=`drush status --fields=db-hostname`
  if [ ! -z "$DRUPAL_DB" ]; then
    # Clear caches and Run updates
    cd "$DRUPAL"
    echo 'Running updates...'
    drush updb -y;
    # @TODO Figure out why this cc all is needed
    drush cc drush;
    echo 'Reverting all features...'
    drush fra -y;
    echo 'Clearing caches...'
    drush cc all;
    echo 'Build completed successfully!'
  fi
else
  echo 'Error in build.'
  exit 2
fi

File

build.sh
View source
  1. #!/bin/sh
  2. # Script to build OpenAtrium 2.x
  3. # Make sure the correct number of args was passed from the command line
  4. if [ $# -eq 0 ]; then
  5. echo "Usage $0 [-d] target_build_dir"
  6. exit 1
  7. fi
  8. DEV_BUILD=0
  9. PANOPOLY_DEV=0
  10. while getopts ":dp" opt; do
  11. case $opt in
  12. d) # dev arguments
  13. DEV_BUILD=1
  14. ;;
  15. p) # use panopoly-dev
  16. PANOPOLY_DEV=1
  17. ;;
  18. r) # release arg
  19. ;;
  20. \?)
  21. echo "Invalid option: -$OPTARG" >&2
  22. ;;
  23. esac
  24. done
  25. shift $((OPTIND-1))
  26. TARGET=$1
  27. if [ "$ATRIUM_BUILD" = "dev" ]; then
  28. DEV_BUILD=1
  29. PANOPOLY_DEV=1
  30. echo "In DEV"
  31. fi
  32. # Make sure we have a target directory
  33. if [ -z "$TARGET" ]; then
  34. echo "Usage $0 target_build_dir"
  35. exit 2
  36. fi
  37. CURDIR=`pwd -P`
  38. ORIG_TARGET=$TARGET
  39. TARGET=$TARGET"__build"
  40. CALLPATH=`dirname "$0"`
  41. ABS_CALLPATH=`cd "$CALLPATH"; pwd -P`
  42. echo '_______ ___'
  43. echo '| ___ | / |'
  44. echo '| | | | / |'
  45. echo '| |_| | / /| |'
  46. echo '|____ | / / | |'
  47. echo ' OpenAtrium '
  48. echo '================'
  49. set -e
  50. if [ $DEV_BUILD -eq 1 ]; then
  51. echo "*** DEVELOPMENT BUILD ***"
  52. fi
  53. echo "Building to build dir: $TARGET"
  54. echo 'Verifying make...'
  55. drush verify-makefile
  56. # Remove current drupal dir
  57. if [ -e "$TARGET" ]; then
  58. echo 'Removing old build directory...'
  59. rm -rf "$TARGET"
  60. fi
  61. # Do the build
  62. if [ $DEV_BUILD -eq 1 ]; then
  63. # Dev version
  64. DRUSH_OPTS='--working-copy --no-gitinfofile --no-cache'
  65. # first build core
  66. MAKEFILE='drupal-org-core.make'
  67. echo "Building Drupal core..."
  68. drush make --prepare-install $DRUSH_OPTS "$ABS_CALLPATH/$MAKEFILE" "$TARGET"
  69. # now get the latest profile distro
  70. # now build the dev version
  71. cd "$TARGET"
  72. MAKEFILE='scripts/oa-drush-dev.make'
  73. if [ $PANOPOLY_DEV -eq 1 ]; then
  74. MAKEFILE='scripts/oa-drush-panopoly-dev.make'
  75. fi
  76. echo "Building the profile -dev version..."
  77. # Patch to add github remotes instead of drupal.
  78. drush make --yes --no-core $DRUSH_OPTS "$ABS_CALLPATH/$MAKEFILE" --contrib-destination=profiles/openatrium
  79. # Remove drupal remotes.
  80. if [ -e "profiles/openatrium" ]; then
  81. cd "profiles/openatrium"
  82. echo "Downloading latest profile..."
  83. git init .
  84. git remote add --track 7.x-2.x origin http://git.drupal.org/project/openatrium.git
  85. git fetch
  86. git checkout 7.x-2.x
  87. fi
  88. cd $CURDIR
  89. else
  90. # Release version
  91. MAKEFILE='build-openatrium.make'
  92. DRUSH_OPTS='--no-cache --prepare-install'
  93. echo 'Running drush make...'
  94. drush make $DRUSH_OPTS "$ABS_CALLPATH/$MAKEFILE" "$TARGET"
  95. fi
  96. set +e
  97. # check to see if drush make was successful by checking for oa_core module
  98. if [ -e "$TARGET/profiles/openatrium/modules/contrib/oa_core" ]; then
  99. # Restore previous sites folder if build was successful
  100. if [ -e "$ORIG_TARGET/sites" ]; then
  101. echo "Restoring sites folder from: $ORIG_TARGET/sites"
  102. rm -rf "$TARGET/sites"
  103. mv "$ORIG_TARGET/sites" "$TARGET/sites"
  104. fi
  105. echo "Moving files to: $ORIG_TARGET"
  106. if [ -e "$ORIG_TARGET" ]; then
  107. rm -rf "$ORIG_TARGET"
  108. fi
  109. if [ -e "$ORIG_TARGET" ]; then
  110. echo "Error removing old files. Please fix permissions."
  111. exit 1
  112. fi
  113. mv $TARGET $ORIG_TARGET
  114. DRUPAL=`cd "$ORIG_TARGET"; pwd -P`
  115. echo "Active site now in: $DRUPAL"
  116. # Copy libraries from profile into site libraries
  117. # Modules properly using Library API don't need this, but many modules
  118. # don't support libraries in the profile (like WYSIWYG)
  119. echo "Copying library files."
  120. rsync -r $DRUPAL/profiles/openatrium/libraries/ $DRUPAL/sites/all/libraries/
  121. if [ ! -e "$DRUPAL/sites/default/settings.php" ]; then
  122. echo "No settings.php file found"
  123. echo "Please run the install.php script to install Drupal and Open Atrium"
  124. exit 1
  125. fi
  126. DRUPAL_DB=`drush status --fields=db-hostname`
  127. if [ ! -z "$DRUPAL_DB" ]; then
  128. # Clear caches and Run updates
  129. cd "$DRUPAL"
  130. echo 'Running updates...'
  131. drush updb -y;
  132. # @TODO Figure out why this cc all is needed
  133. drush cc drush;
  134. echo 'Reverting all features...'
  135. drush fra -y;
  136. echo 'Clearing caches...'
  137. drush cc all;
  138. echo 'Build completed successfully!'
  139. fi
  140. else
  141. echo 'Error in build.'
  142. exit 2
  143. fi