|
1 #!/bin/bash |
|
2 |
|
3 OPTIND=1 |
|
4 TOP_DIR=$(pwd) |
|
5 |
|
6 # Define default options. |
|
7 PACKAGE="standard" |
|
8 ACTION="build" |
|
9 SOURCE="false" |
|
10 VERSION="" |
|
11 CONCURRENCY=8 |
|
12 |
|
13 # Read command line options. |
|
14 while getopts ":h?fusv:c:" opt; do |
|
15 case "$opt" in |
|
16 h|\?) |
|
17 echo "Usage: `basename $0` [-h] [-f] [-u] [-s] [-v version] [-c concurrency]" |
|
18 exit 1 |
|
19 ;; |
|
20 f) |
|
21 PACKAGE="full" |
|
22 ;; |
|
23 u) |
|
24 ACTION="upgrade" |
|
25 ;; |
|
26 s) |
|
27 SOURCE=true |
|
28 ;; |
|
29 v) |
|
30 VERSION="?h=$OPTARG" |
|
31 ;; |
|
32 c) |
|
33 CONCURRENCY=$OPTARG |
|
34 ;; |
|
35 esac |
|
36 done |
|
37 |
|
38 # Global Settings |
|
39 # =============== |
|
40 |
|
41 MAKE_OPTIONS="--concurrency=$CONCURRENCY --contrib-destination=profiles/drustack --no-cache --force-complete" |
|
42 MAKE_FILE="http://cgit.drupalcode.org/drustack/plain/makes/$PACKAGE.make$VERSION" |
|
43 MAKE_PATH="." |
|
44 |
|
45 |
|
46 # Global Functions |
|
47 # ================ |
|
48 |
|
49 function pre_build() |
|
50 { |
|
51 if [[ $ACTION == 'build' ]]; then |
|
52 MAKE_OPTIONS="$MAKE_OPTIONS --prepare-install" |
|
53 fi |
|
54 } |
|
55 |
|
56 function pre_upgrade() |
|
57 { |
|
58 if [[ $ACTION == 'upgrade' ]]; then |
|
59 chmod a+w sites/* |
|
60 rm -rf profiles/drustack |
|
61 fi |
|
62 } |
|
63 |
|
64 function pre_source() |
|
65 { |
|
66 if [[ "$SOURCE" == true ]]; then |
|
67 MAKE_OPTIONS="$MAKE_OPTIONS --no-gitinfofile --working-copy" |
|
68 fi |
|
69 } |
|
70 |
|
71 function post_upgrade() |
|
72 { |
|
73 if [[ $ACTION == 'upgrade' ]]; then |
|
74 chmod a-w sites/* |
|
75 fi |
|
76 } |
|
77 |
|
78 function post_package() |
|
79 { |
|
80 if [[ "$SOURCE" == false ]]; then |
|
81 rm -rf profiles/drustack/.gitignore |
|
82 |
|
83 find profiles/drustack/*/contrib/ -type f -name '*.info' | |
|
84 xargs grep -l 'project = "drustack"' | |
|
85 while read DATA; do |
|
86 TMP=`mktemp` |
|
87 head -n -6 $DATA > $TMP |
|
88 mv $TMP $DATA |
|
89 done |
|
90 fi |
|
91 } |
|
92 |
|
93 function post_source() |
|
94 { |
|
95 if [[ "$SOURCE" == true ]]; then |
|
96 find $TOP_DIR -type d -name '.git' | |
|
97 while read DATA; do |
|
98 PROJECT=`echo $DATA | sed "s/^.*\/\([^\/]*\)\/\.git/\1/g"` |
|
99 cd $DATA/../ |
|
100 git remote set-url --push origin `whoami`@git.drupal.org:project/$PROJECT.git |
|
101 git fetch |
|
102 git status |
|
103 git remote -v |
|
104 done |
|
105 fi |
|
106 } |
|
107 |
|
108 |
|
109 # Install Packages |
|
110 # ================ |
|
111 |
|
112 set -o xtrace |
|
113 |
|
114 cd $TOP_DIR |
|
115 |
|
116 pre_build |
|
117 pre_upgrade |
|
118 |
|
119 #pre_package |
|
120 pre_source |
|
121 |
|
122 drush -y make $MAKE_OPTIONS $MAKE_FILE $MAKE_PATH |
|
123 |
|
124 #post_build |
|
125 post_upgrade |
|
126 |
|
127 post_package |
|
128 post_source |