3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 USAGE
="Usage: $0 [-i | -a] [-g <dir>] [-s <dir>]\n\
16 -h Show this message\n\
17 -i Prompts the user for input\n\
18 -a Does not prompt the user. Potentially dangerous.\n\
19 -g The local location of the HBase git repository\n\
20 -s The local location of the HBase svn checkout\n\
21 Either -i or -a is required.\n\
22 Edit the script to set default Git and SVN directories."
24 if [ "$#" == "0" ]; then
34 while getopts "hiag:s:" OPTION
45 # We don't actually use this variable but require it to be
46 # set explicitly because it will commit changes without asking
58 if [ $INTERACTIVE ] && [ $AUTO ]; then
59 echo "Only one of -i or -a can be used."
64 # Set GIT_DIR and SVN_DIR to defaults if not given
65 if [ ! $GIT_DIR ]; then
68 if [ ! $SVN_DIR ]; then
69 SVN_DIR
=~
/svn
/hbase.apache.org
/trunk
72 # Check that GIT_DIR and SVN_DIR exist
73 if [ ! -d $GIT_DIR -o ! -d $SVN_DIR ]; then
74 echo "Both the GIT and SVN directories must exist."
86 # Generate the site to ~/git/hbase/target/site
87 if [ $INTERACTIVE ]; then
88 read -p "Build the site? (y/n)" yn
91 mvn clean package javadoc
:aggregate post-site site
:stage
-DskipTests
93 if [ $status -ne 0 ]; then
94 echo "The website does not build. Aborting."
99 echo "Not building the site."
103 echo "Building the site in auto mode."
104 mvn clean package javadoc
:aggregate post-site site
:stage
-DskipTests
106 if [ $status != 0 ]; then
107 echo "The website does not build. Aborting."
113 # Refresh the local copy of the live website
114 echo "Updating Subversion..."
116 # Be aware that this will restore all the files deleted a few lines down
117 # if you are debugging this script
118 # and need to run it multiple times without svn committing
119 svn update
> /dev
/null
121 # Get current size of svn directory and # files, for sanity checking before commit
122 SVN_OLD_SIZE
=`du -sm . |awk '{print $1}'`
123 SVN_OLD_NUMFILES
=`find . -type f |wc -l |awk '{print $1}'`
125 # Make a list of things that are in SVN but not the generated site
126 # and not auto-generated
127 # -- we might need to delete these
128 echo "The following directories (if any) might be stale:" |
tee /tmp
/out.txt
129 find .
-type d
! -path '*0.94*' ! -path '*apidocs*' \
130 ! -path '*xref*' ! -path '*book*' \
131 -exec ls $GIT_DIR/target
/staging
/{} \
; |
grep 'No such' |
tee -a /tmp
/out.txt
132 echo "The following files (if any) might be stale:" |
tee -a /tmp
/out.txt
133 find .
-type f
! -path '*0.94*' ! -path '*apidocs*' \
134 ! -path '*xref*' ! -path '*book*' ! -name '*.svg' \
135 -exec ls $GIT_DIR/target
/staging
/{} \
; |
grep 'No such' |
tee -a /tmp
/out.txt
137 if [ $INTERACTIVE ]; then
138 read -p "Exit to take care of them? (y/n)" yn
145 * ) echo "Please answer yes or no.";;
148 echo "Not taking care of stale directories and files in auto mode." |
tee -a /tmp
/out.txt
149 echo "If necessary, handle them in a manual commit."|
tee -a /tmp
/out.txt
152 # Delete known auto-generated content from trunk
153 echo "Deleting known auto-generated content from SVN"
154 rm -rf apidocs devapidocs xref xref-test book book.html java.html apache_hbase_reference_guide.pdf
*
156 # Copy generated site to svn -- cp takes different options on Darwin and GNU
157 echo "Copying the generated site to SVN"
158 if [ `uname` == "Darwin" ]; then
160 elif [ `uname` == "Linux" ]; then
164 cp $COPYOPTS $GIT_DIR/target
/staging
/* .
166 # Look for things we need to fix up in svn
168 echo "Untracked files: svn add"
169 svn status |
grep '?' |
sed -e "s/[[:space:]]//g"|cut
-d '?' -f 2|
while read i
; do
174 echo "Locally deleted files: svn del"
175 svn status |
grep '!' |
sed -e "s/[[:space:]]//g"|cut
-d '!' -f 2|
while read i
; do
180 # Display the proposed changes. I filtered out
181 # modified because there are so many.
182 if [ $INTERACTIVE ]; then
183 svn status |
grep -v '^M'|
less -P "Enter 'q' to exit the list."
185 echo "The following changes will be made to SVN."
189 # Get current size of svn directory, for sanity checking before commit
190 SVN_NEW_SIZE
=`du -sm . |awk '{print $1}'`
191 SVN_NEW_NUMFILES
=`find . -type f |wc -l |awk '{print $1}'`
193 # Get difference between new and old size and number of files
194 # We don't care about negatives so remove the sign
195 SVN_SIZE_DIFF
=`expr $SVN_NEW_SIZE - $SVN_OLD_SIZE|sed 's/-//g'`
196 SVN_NUM_DIFF
=`expr $SVN_NEW_NUMFILES - $SVN_OLD_NUMFILES|sed 's/-//g'`
198 # The whole site is only 500 MB so a difference of 10 MB is huge
199 # In this case, we should abort because something is wrong
200 # Leaving this commented out for now until we get some benchmarks
201 if [ $SVN_SIZE_DIFF > 10 -o $SVN_NUM_DIFF > 50 ]; then
202 echo "This commit would cause the website to change sizes by \
203 $SVN_DIFF MB and $SVN_NUM_DIFF files. There is likely a problem.
209 if [ $INTERACTIVE ]; then
210 read -p "Commit changes? This will publish the website. (y/n)" yn
213 echo "Published website using script in interactive mode. \
214 This commit changed the size of the website by $SVN_SIZE_DIFF MB \
215 and the number of files by $SVN_NUM_DIFF files." |
tee commit.txt
216 cat /tmp
/out.txt
>> /tmp
/commit.txt
217 svn commit
-F /tmp
/commit.txt
221 read -p "Revert SVN changes? (y/n)" revert
235 echo "Published website using script in auto mode. This commit \
236 changed the size of the website by $SVN_SIZE_DIFF MB and the number of files \
237 by $SVN_NUM_DIFF files." |
tee /tmp
/commit.txt
238 cat /tmp
/out.txt
>> /tmp
/commit.txt
239 svn commit
-q -F /tmp
/commit.txt