Imported Upstream version 5.3.21
[platform/upstream/libdb.git] / dist / buildpkg
1 #!/bin/sh
2 # $Id: $
3 #
4 die()
5 {
6         echo >&2 "$@"
7         exit 1
8 }
9
10 # Build the distribution package.
11 . ./RELEASE || die "Can't read the RELEASE file"
12
13 CSHARP_DOC_SRC=""
14 # 0 is none, 1 is local dir, 2 is remote dir
15 CSHARP_DOC_LOCATION=0
16 test_run=0
17
18 while [ $# -gt 0 ]
19 do
20         case "$1" in
21         -n)
22                 nodocs=true;;
23         -csharp_doc_src)
24                 shift
25                 if [ ! $# -gt 0 ]; then
26                         die "csharp_doc_dir param requires argument."
27                 fi
28                 CSHARP_DOC_SRC=$1
29                 CSHARP_DOC_LOCATION=1
30                 if [ ! -f $CSHARP_DOC_SRC ]; then
31                         die "CSharp doc archive must exist."
32                 fi;;
33         -csharp_doc_url)
34                 shift
35                 if [ ! $# -gt 0 ]; then
36                         die "csharp_doc_dir param requires argument."
37                 fi
38                 CSHARP_DOC_SRC=$1
39                 CSHARP_DOC_LOCATION=2;;
40         -test)
41                 echo "Doing a test run - this may contain changes that aren't\
42 reflected in a tag, so the package won't be reproducible."
43                 test_run=1;;
44         esac
45         shift
46 done
47
48 # A version string can be specified on the command line (e.g., "20080219").
49 # Otherwise, use the standard X.X.X format.
50 VERSION=${1:-${DB_VERSION_MAJOR}.${DB_VERSION_MINOR}.${DB_VERSION_PATCH}}
51
52 # Use "ustar" as the archiver
53 TAR=ustar
54
55 # Set root directory where we do the work, can be anywhere.
56 START_DIR=`pwd`
57 D=`pwd`/../release
58 R="$D/db-${VERSION}"
59 RNC="$D/db-$VERSION.NC"
60 DOCS=`pwd`/../../docs_books-5.3
61 DB_ADDONS=`pwd`/../../db_addons-5.3
62
63 if [ ! -d $DB_ADDONS ]; then
64         echo "buildpkg requires a db_addons repository at the same level as the db repository."
65         exit 1
66 fi
67
68 # Create directory, remove any previous release tree.
69 rm -rf $R $RNC
70 mkdir -p $R
71
72 echo "Removed old release build from $R"
73
74 # Copy the files in the current tip to $R
75 hg archive $R
76
77 # If doing a test run, apply any local changes to the new tree.
78 if [ $test_run != 0 ]; then
79         hg diff | patch -p1 -d $R
80 fi
81
82 echo "Created hg archive in $R"
83
84 if [ "$nodocs" = true ] ; then
85         rm -rf $R/docs
86 else
87         [ -d $DOCS ] || die "buildpkg requires a docs_books repository at the same level as the db repository."
88
89         # Check that the doc repo is up to date, and create a tag if necessary.
90         cd $DOCS
91         hg pull -u
92         if [ $? != 0 ]; then
93                 rm -rf $R
94                 die "Failed updating the docs_books repository."
95         fi
96         has_tag=`hg tags | grep "db-${VERSION}"`
97         if [ "$has_tag" = "" ]; then
98                 hg tag "db-${VERSION}"
99                 TAG_CREATED="true"
100         else
101                 hg up -r "db-${VERSION}"
102         fi
103
104         # Build a copy of the documentation in the release tree.
105         cd $R/dist
106         sh s_docs db-${VERSION} $DOCS
107
108         if [ $? != 0 ]; then
109                 rm -rf $R
110                 die "Failed generating documentation."
111         fi
112
113         # Copy in the C sharp doc.
114         if [ $CSHARP_DOC_LOCATION -eq 2 ]; then
115                 scp $CSHARP_DOC_SRC .
116                 CSHARP_DOC_SRC="csharp_docs.tgz"
117                 if [ ! -f $CSHARP_DOC_SRC ]; then
118                         echo "WARNING: Invalid csharp doc file - csharp_docs.tgz expected."
119                 fi
120         fi
121         if [ $CSHARP_DOC_LOCATION -eq 0 -o ! -f $CSHARP_DOC_SRC ]; then
122                 echo "WARNING: No csharp docs, skipping."
123                 CSHARP_DOC_LOCATION=0
124         fi
125         if [ $CSHARP_DOC_LOCATION != 0 ]; then
126                 rm -rf $R/docs/csharp
127                 mkdir -p $R/docs/csharp
128                 $TAR zxf $CSHARP_DOC_SRC -C $R/docs/csharp
129         fi
130
131         # Build the Java documentation.
132         cd $R/dist && sh s_javadoc
133 fi
134
135 # Pull a copy of the JDBC and ODBC libraries into the package.
136 # Build the ADO.NET package, including moving the ADO.NET doc built above
137 # into that package.
138 # Tell the script where to look for packages.
139 cd $R/dist && sh s_sql_drivers ../../../..
140 # Warn if s_sql_drivers didn't move its docs.
141 if [ -e "$R/docs/bdb-sql-ado" ]; then
142         echo "WARNING: ADO.NET doc is still in the non ADO.NET package."
143 fi
144
145 cd $START_DIR
146
147 # Pull a copy of the bfile directory into the package.
148 cd $DB_ADDONS
149 hg pull -u
150 if [ $? != 0 ]; then
151         echo "Failed updating the db_addons repository. Exiting."
152         rm -rf $R
153         exit 1
154 fi
155
156 cd $START_DIR
157 SQL_EXT_DIR=$R/lang/sql/sqlite/ext
158 if [ ! -d $SQL_EXT_DIR ]; then
159         mkdir -p $SQL_EXT_DIR
160 fi
161 if [ -d $SQL_EXT_DIR/bfile ]; then
162         rm -rf $SQL_EXT_DIR/bfile
163 fi
164 cp -rp $DB_ADDONS/bfile $SQL_EXT_DIR
165
166 # Remove source directories we don't distribute.
167 cd $R && rm -rf test/tcl/TODO test/upgrade test/scr036 test/erlang
168 cd $R && rm -rf test/perf test/purify test/repmgr
169 cd $R && rm -rf test/server test/stl test/vxworks
170 cd $R && find . -name '.hg*' | xargs rm -f
171 cd $R && find . -name 'tags' | xargs rm -f
172
173 # Create symbolic links and cscope output, fix permissions.
174 #cd $R/dist && sh s_perm
175 #cd $R/dist && sh s_cscope
176
177 # Build a regular version and smoke test.
178 ### cd $R && rm -rf build_run && mkdir build_run
179 ### cd $R/build_run && ../dist/configure && make >& mklog
180 ### cd $R/build_run && make ex_access && echo "test" | ./ex_access
181 # Check the install
182 ### cd $R/build_run && make prefix=`pwd`/BDB install
183
184 # Build a small-footprint version and smoke test.
185 ### cd $R && rm -rf build_run && mkdir build_run
186 ### cd $R/build_run && ../dist/configure --enable-smallbuild && make >& mklog
187 ### cd $R/build_run && make ex_access && echo "test" | ./ex_access
188
189 # Remove the build directory
190 ### cd $R && rm -rf build_run
191
192 (cd $R/dist && ./s_perm)
193
194 # Check for file names differing only in case.
195 cd $R && find . | sort -f | uniq -ic | sed '/1 /d'
196
197 # Create the crypto tar archive release.
198 T="$D/db-$VERSION.tar.gz"
199 rm -f $T
200 cd $D || die "Can't find $D"
201 # Move package files in db-$VERSION/release to current directory so that
202 # regular packages won't includes generated package twice.
203 if [ -d "db-$VERSION/release" ]; then
204         mv db-$VERSION/release/* .
205         rm -rf db-$VERSION/release
206 fi
207 $TAR czf $T -find db-$VERSION -chown 100 -chgrp 100
208 chmod 444 $T
209
210 # Create the non-crypto tree.
211 cd $D && mv -i db-$VERSION $RNC && $TAR xzf $T
212 cd $RNC/dist && sh s_crypto
213
214 (cd $RNC/dist && ./s_perm)
215
216 # Create the non-crypto tar archive release.
217 T="$D/db-$VERSION.NC.tar.gz"
218 rm -f $T
219 cd $RNC/.. && $TAR czf $T -find db-$VERSION.NC -chown 100 -chgrp 100
220 chmod 444 $T
221
222 t=__tmp
223 cd $R && awk '{print $0 "\r"}' < LICENSE > $t && rm -f LICENSE && cp $t LICENSE
224 cd $R && awk '{print $0 "\r"}' < README > $t && rm -f README && cp $t README && rm $t
225 cd $RNC && awk '{print $0 "\r"}' < LICENSE > $t && rm -f LICENSE && cp $t LICENSE
226 cd $RNC && awk '{print $0 "\r"}' < README > $t && rm -f README && cp $t README && rm $t
227
228 # Create the crypto zip archive release.
229 T="$D/db-$VERSION.zip"
230 rm -f $T
231 cd $R/.. && rm -f $T && zip -q -r $T db-$VERSION
232 chmod 444 $T
233
234 # Create the non-crypto zip archive release.
235 T="$D/db-$VERSION.NC.zip"
236 rm -f $T
237 cd $RNC/.. && rm -f $T && zip -q -r $T db-$VERSION.NC 
238 chmod 444 $T
239
240 rm -rf $R $RNC
241
242 if [ "$TAG_CREATED" = "true" ]; then
243         echo "Created a tag in docs_books repository. Please push."
244 fi