-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.sh
executable file
·143 lines (136 loc) · 3.86 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/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
DRUSH_OPTS='--working-copy --no-gitinfofile --no-cache'
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
# 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
# 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!'
else
echo 'Error in build.'
exit 2
fi