Debian Codegraph @

dist/s_sql_drivers

raw symbols SCIP
1 #!/bin/sh
2 #
3 # This script pulls below SQL Drivers into a Berkeley DB
4 # source tree:
5 # 1. ch-werner ODBC
6 # 2. ch-werner JDBC
7 # 3. ADO.NET
8
9 # javasqlite-<date>.tar.gz, sqliteodbc-X.XX.tar.gz, and ADO.NET packages must
10 # be in the parent of this repository/source tree.
11
12 # The packages can be downloaded from (update to current version):
13 # http://www.ch-werner.de/sqliteodbc/sqliteodbc-0.86.tar.gz
14 # http://www.ch-werner.de/javasqlite/javasqlite-20100727.tar.gz
15 # http://system.data.sqlite.org/index.html
16
17 . ./RELEASE
18
19 die()
20 {
21 echo >&2 "$@"
22 exit 1
23 }
24
25 START_DIR=`pwd`
26 if [ "x$1" != "x" ]; then
27 PKG_ROOT=$1
28 else
29 PKG_ROOT=../..
30 fi
31
32 DB_ADDONS_REPO=$PKG_ROOT/db_addons-5.3
33 update_repo()
34 {
35 if [ ! -d $DB_ADDONS_REPO ]; then
36 die "db_addons repository doesn't exist."
37 fi
38 hg up -R $DB_ADDONS_REPO -r `hg branch` || \
39 die "Failed updating db_addons - likely contains local updates."
40 hg pull -R $DB_ADDONS_REPO -u
41 if [ $? != 0 ]; then
42 die "Failed updating the db_addons repository."
43 fi
44 }
45 update_repo
46
47 cd $START_DIR
48 ODBC_PACKAGE=`ls $DB_ADDONS_REPO/thirdparty/sql/sqliteodbc-*.tar.gz | tail -1`
49 JDBC_PACKAGE=`ls $DB_ADDONS_REPO/thirdparty/sql/javasqlite-*.tar.gz | tail -1`
50 ADO_PACKAGE=`ls $DB_ADDONS_REPO/thirdparty/sql/sqlite-dotnetsrc*.zip | tail -1`
51 HOMEDIR=`pwd`
52
53 SQL_DIR=../lang/sql/
54 ODBC_DIR=$SQL_DIR/odbc
55 JDBC_DIR=$SQL_DIR/jdbc
56 ADO_DIR=$PKG_ROOT/adodotnet
57 rm -rf "$ODBC_DIR" && mkdir -p $ODBC_DIR
58 rm -rf "$JDBC_DIR" && mkdir -p $JDBC_DIR
59 rm -rf "$ADO_DIR" && mkdir -p $ADO_DIR
60
61
62 ##############################################################################
63 # ODBC Driver
64 ##############################################################################
65 s_sql_odbc()
66 {
67 cd $START_DIR
68 if [ ! -e $ODBC_PACKAGE ]; then
69 echo "No ODBC package found, can't continue."
70 echo "Download it from: http://www.ch-werner.de/sqliteodbc"
71 return 1
72 fi
73
74 # Don't assume GNU tar
75 dir=`basename $ODBC_PACKAGE .tar.gz`
76 gzip -c -d $ODBC_PACKAGE | tar xf -
77 mv $dir/* $ODBC_DIR || exit $?
78
79 # Apply patches
80 PATCH='odbc/odbc.patch'
81 ( cd $ODBC_DIR && patch -p1 -i $START_DIR/$PATCH )
82 if [ $? -ne 0 ]; then
83 die "Can not apply patch $PATCH"
84 fi
85
86 # Remove unnecessary files from packages.
87
88 # There is a symbolic link in the ODBC package: that can't go into a
89 # zip file.
90 rm -f $ODBC_DIR/source
91
92 # TCC has a conflicting license, so we can't ship it.
93 rm -rf $ODBC_DIR/tcc* $ODBC_DIR/sqlite+tcc.c $ODBC_DIR/README.sqlite+tcc
94
95 # Generate the resource3.h file needed by ODBC on Windows.
96 VERS=`cat $ODBC_DIR/VERSION`
97 VERS_C=`echo $VERS | sed -e 's/\([0-9]\+\)[.]\([0-9]\+\).*/\1,\2/g'`
98 cat $ODBC_DIR/resource.h.in | \
99 sed -e "s/--VERS_C--/$VERS_C/g" \
100 -e "s/--VERS--/$VERS/g" > $ODBC_DIR/resource3.h
101
102 # Let sqlite3odb.rc include "$SQL_DIR/generated/sqlite3.h" instead of sqlite3.h
103 mv $ODBC_DIR/sqlite3odbc.rc $ODBC_DIR/sqlite3odbc.rc.in
104 cat $ODBC_DIR/sqlite3odbc.rc.in | \
105 sed -e 's/sqlite3.h/..\/..\/lang\/sql\/generated\/sqlite3.h/g' \
106 > $ODBC_DIR/sqlite3odbc.rc
107 }
108
109 ##############################################################################
110 # JDBC Driver
111 ##############################################################################
112 s_sql_jdbc()
113 {
114 cd $START_DIR
115 if [ ! -e $JDBC_PACKAGE ]; then
116 echo "No JDBC package found, can't continue."
117 echo "Download it from: http://www.ch-werner.de/javasqlite"
118 return 1
119 fi
120
121 # Don't assume GNU tar
122 dir=`basename $JDBC_PACKAGE .tar.gz`
123 gzip -c -d $JDBC_PACKAGE | tar xf -
124 mv $dir/* $JDBC_DIR || exit $?
125
126 #
127 # Remove unnecessary files from packages.
128 #
129 # Remove useless makefiles, they create confusion.
130 for f in `ls $JDBC_DIR/*mak`; do
131 # TODO: It would be nice to pull this release number from the
132 # SQL code in the repository.
133 if [ `basename $f` = "sqlite-3.6.22.mak" ]; then
134 continue;
135 fi
136 rm -f $f
137 done
138
139 # Remove some SQLite format databases from the package.
140 rm -f $JDBC_DIR/db $JDBC_DIR/db2 $JDBC_DIR/db3
141
142 # Remove other bits and pieces that aren't relevant.
143 rm -rf $JDBC_DIR/debian $ODBC_DIR/*ming* $ODBC_DIR/README.* $ODBC_DIR/*mak
144
145 # Patch the JDBC build files for autoconf, so the Berkeley DB library
146 # can be added to the link command.
147 mv $JDBC_DIR/Makefile.in $JDBC_DIR/Makefile.in.tmp
148 # 1. Define BDB_LIB for Makefile
149 # 2. Add LD_LIBRARY_PATH for runing native/mkconst in JDBC configuration
150 cat $JDBC_DIR/Makefile.in.tmp | \
151 sed -e '/native\/mkconst > SQLite\/Constants.java/ i \\t\LD_LIBRARY_PATH=\"\$\$LD_LIBRARY_PATH:\$(PWD)\/..\/.libs\" \\' \
152 -e '/^LIBS=/s/$/ @BDB_LIB@/' > $JDBC_DIR/Makefile.in
153 rm -f $JDBC_DIR/Makefile.in.tmp
154
155 # Generate Constants.java needed by JDBC on Windows
156 gcc -DHAVE_SQLITE3 -I$SQL_DIR/generated -o mkconst $JDBC_DIR/native/mkconst.c
157 ./mkconst > $JDBC_DIR/SQLite/Constants.java
158
159 # Add the wildcard below since gcc on Windows appends a .exe
160 rm -f mkconst*
161 }
162
163
164 ##############################################################################
165 # ADO.NET
166 #
167 # This function integrate SQLite ADO.NET and BDB SQL to generate a new
168 # all-in-one package under package root
169 #
170 # Note: If you run into XQuery issue when executing the script, you may need to
171 # upgrade the XQilla version to at lease 2.2
172 ##############################################################################
173 s_sql_adodotnet()
174 {
175 cd $START_DIR
176 ADO_DIR_ORIG=`basename $ADO_PACKAGE .zip`
177 ADO_DIR="dbsql-adodotnet-${DB_VERSION_MAJOR}.${DB_VERSION_MINOR}.${DB_VERSION_PATCH}"
178 TMP_FILE='temp_file'
179
180 # Detect package
181 if [ ! -e $ADO_PACKAGE ]; then
182 echo "No ADO.NET package found, can't continue."
183 echo "Download it from: http://system.data.sqlite.org/index.html"
184 return 1
185 fi
186
187 # Detect XQilla
188 which xqilla > /dev/null 2>&1
189 if [ $? -ne 0 ]; then
190 echo "Can not find xqilla command."
191 exit 1
192 fi
193
194 # Copy files of driver.
195 rm -rf "$ADO_DIR_ORIG"
196 rm -rf "$ADO_DIR"
197 unzip $ADO_PACKAGE > /dev/null
198 mv $ADO_DIR_ORIG $ADO_DIR
199 cd $ADO_DIR || die "Can not unpack the SQLite ADO.NET package"
200
201 #
202 # Copy BDB files
203 #
204 BDB_ROOT="db-${DB_VERSION_MAJOR}.${DB_VERSION_MINOR}.${DB_VERSION_PATCH}"
205 BDB_PATH4SED=`echo $BDB_ROOT | sed -e 's/\//\\\\\//g'`
206 mkdir -p $BDB_ROOT
207 cp -r $START_DIR/../src $BDB_ROOT
208
209 # Copy files from build_windows directory.
210 reserved_projects="db_sql_shell db_sql db"
211 reserved_solutions="Berkeley_DB.sln Berkeley_DB_vs2010.sln"
212 mkdir $BDB_ROOT/build_windows
213 mkdir $BDB_ROOT/build_windows/VS8
214 mkdir $BDB_ROOT/build_windows/VS10
215 for f in $reserved_solutions *.h *.src *.rc *.def
216 do
217 cp $START_DIR/../build_windows/$f $BDB_ROOT/build_windows
218 done
219 for f in $reserved_projects
220 do
221 cp $START_DIR/../build_windows/VS8/$f.vcproj $BDB_ROOT/build_windows/VS8
222 cp $START_DIR/../build_windows/VS10/$f.vcxproj \
223 $BDB_ROOT/build_windows/VS10
224 done
225 cp $START_DIR/../build_windows/VS10/*.props $BDB_ROOT/build_windows/VS10/
226
227 # Cleanup solution files
228 for sln_name in $reserved_solutions
229 do
230 sln=$BDB_ROOT/build_windows/$sln_name
231 cp $sln ${sln}.tmp
232 grep ^Project $sln | awk -F '"' '{print $4}' | while read project
233 do
234 found="false"
235 for s in $reserved_projects
236 do
237 if [ "$s" = "$project" ]; then
238 found="true"
239 break
240 fi
241 done
242
243 [ "$found" = "true" ] && continue
244
245 guid=`grep "^Project.*\"$project\"" ${sln}.tmp | \
246 head -n 1 | awk -F '[{}]' '{print $4}'`
247 if [ "$guid" != "" ]; then
248 sed -e "/^Project.*\"$project\"/,/^EndProject/d" \
249 -e "/$guid/d" ${sln}.tmp > $TMP_FILE
250 cp $TMP_FILE ${sln}.tmp
251 fi
252 done
253
254 # Change to dos format -- VisualStudio solution files must be dos format
255 sed -e 's/ //g' -e 's/$/ /' ${sln}.tmp > $sln
256
257 rm -f $TMP_FILE
258 rm -f ${sln}.tmp
259 done
260
261 # Copy wince files
262 cp -r $START_DIR/../build_wince $BDB_ROOT
263 # Move docs
264 if [ -e "$START_DIR/../docs/bdb-sql-ado" ]; then
265 mv "$START_DIR/../docs/bdb-sql-ado" Doc/
266 echo "Berkeley DB specific documentation is included in the package \
267 at <pkgroot>/Doc/bdb-sql-ado/index.htm" > README
268 echo "Or at <pkgroot>/Doc/bdb-sql-ado/BDB-SQL-ADO-Guide.pdf" >> README
269 fi
270
271 # Copy lang/ for DB/DBSQL projects
272 mkdir -p $BDB_ROOT/lang
273 for dir in dbm hsearch sql cxx
274 do
275 cp -r $START_DIR/../lang/$dir $BDB_ROOT/lang
276 done
277 mkdir $BDB_ROOT/examples
278 for dir in sql cxx
279 do
280 cp -r $START_DIR/../examples/$dir $BDB_ROOT/examples
281 done
282
283 # Replace SQLite source code with DBSQL source code
284 cp -f $START_DIR/../lang/sql/generated/* SQLite.Interop/src/core/
285 cp -f $START_DIR/adodotnet/testce.2008.csproj testce/
286
287 # Apply patches
288 PATCH='adodotnet/adodotnet.patch'
289 patch -p0 -i $START_DIR/$PATCH
290 if [ $? -ne 0 ]; then
291 die "Can not apply patch $PATCH"
292 fi
293
294 #
295 # Generate WinCE projects
296 #
297 WINDOWS_VCPROJ="SQLite.Interop/SQLite.Interop.2008.vcproj"
298 WINDOWS_2010_VCPROJ="SQLite.Interop/SQLite.Interop.2010.vcxproj"
299 WINCE_VCPROJ_NAME="SQLite.Interop.2008.WinCE"
300 WINCE_VCPROJ="SQLite.Interop/${WINCE_VCPROJ_NAME}.vcproj"
301 XQ_COMMON="$START_DIR/adodotnet/adapt_common.xq.in"
302
303 # Define WINCE_PLATFORM_NAME
304 # Use the most common project name for WinCE project file.
305 WINCE_PLATFORM_NAME='Pocket PC 2003 (ARMV4)'
306 WINCE_PROJECT_GUID='A7895F70-6FD5-11E0-A1F0-0800200C9A66'
307 XQ='gen_wince_project.xq'
308 XQ_IN="${XQ}.in"
309 XQ_IN_SRC="$START_DIR/adodotnet/${XQ_IN}"
310 # Generate XQuery script
311 cp $XQ_COMMON $XQ_IN
312 cat $XQ_IN_SRC >> $XQ_IN
313 sed -e "s/@DB_VERSION_MAJOR@/$DB_VERSION_MAJOR/g" \
314 -e "s/@DB_VERSION_MINOR@/$DB_VERSION_MINOR/g" \
315 -e "s/@PROJECT_GUID@/$WINCE_PROJECT_GUID/g" \
316 -e "s/@PLATFORM_NAME@/$WINCE_PLATFORM_NAME/g" \
317 -e "s/@PROJECT_FILE@/$WINCE_VCPROJ_NAME/g" \
318 -e "s/@BDB_PATH@/$BDB_PATH4SED/g" \
319 -e "s/@BDB_NAME@/$BDB_ROOT/g" \
320 < $XQ_IN >> $XQ
321
322 cp $WINDOWS_VCPROJ $WINCE_VCPROJ
323 xqilla -u -i $WINCE_VCPROJ $XQ
324 rm -f $XQ
325 rm -f $XQ_IN
326
327 #
328 # Change SQLite.Interop/SQLite.Interop.2010.vcproj for Win32/x64
329 #
330 XQ='adapt_SQLite.Interop.2010.xq'
331 XQ_IN="${XQ}.in"
332 XQ_IN_SRC="$START_DIR/adodotnet/${XQ_IN}"
333 # Generate XQuery script
334 namespace="http://schemas.microsoft.com/developer/msbuild/2003";
335 echo "declare namespace msbuild='$namespace';" > $XQ_IN
336 echo "declare default element namespace '$namespace';" >> $XQ_IN
337 cat $XQ_COMMON >> $XQ_IN
338 cat $XQ_IN_SRC >> $XQ_IN
339 sed -e "s/@DB_VERSION_MAJOR@/$DB_VERSION_MAJOR/g" \
340 -e "s/@DB_VERSION_MINOR@/$DB_VERSION_MINOR/g" \
341 -e "s/@WINCE_PLATFORM_NAME@/$WINCE_PLATFORM_NAME/g" \
342 -e "s/@BDB_PATH@/$BDB_PATH4SED/g" \
343 -e "s/@BDB_NAME@/$BDB_ROOT/g" \
344 < $XQ_IN >> $XQ
345
346 # Change File list for vcproject file
347 xqilla -u -i $WINDOWS_2010_VCPROJ $XQ
348 rm -f $XQ
349 rm -f $XQ_IN
350
351 #
352 # Change SQLite.Interop/SQLite.Interop.2008.vcproj for Win32/x64
353 #
354 XQ='adapt_SQLite.Interop.2008.xq'
355 XQ_IN="${XQ}.in"
356 XQ_IN_SRC="$START_DIR/adodotnet/${XQ_IN}"
357 # Generate XQuery script
358 cp $XQ_COMMON $XQ_IN
359 cat $XQ_IN_SRC >> $XQ_IN
360 sed -e "s/@DB_VERSION_MAJOR@/$DB_VERSION_MAJOR/g" \
361 -e "s/@DB_VERSION_MINOR@/$DB_VERSION_MINOR/g" \
362 -e "s/@WINCE_PLATFORM_NAME@/$WINCE_PLATFORM_NAME/g" \
363 -e "s/@BDB_PATH@/$BDB_PATH4SED/g" \
364 -e "s/@BDB_NAME@/$BDB_ROOT/g" \
365 < $XQ_IN >> $XQ
366
367 # Change File list for vcproject file
368 xqilla -u -i $WINDOWS_VCPROJ $XQ
369 xqilla -u -i $WINCE_VCPROJ $XQ
370 rm -f $XQ
371 rm -f $XQ_IN
372
373 #
374 # Use sed to do below changes:
375 # 1. Change xml version to 1.0, otherwise Visual Studio can not open it
376 # 2. Remove unnecessary xmlns in VS2010 project file
377 #
378 for f in $WINDOWS_VCPROJ $WINCE_VCPROJ $WINDOWS_2010_VCPROJ
379 do
380 forward="cat"
381 which tidy > /dev/null 2>&1
382 if [ $? -eq 0 ]; then
383 # If we can find tidy command, use it to tidy the project file
384 forward='tidy -w 1000 -xml -i -q -utf8 -n'
385
386 # Rename _ProjectFileVersion for now, othwerwise the tidy command
387 # might fails
388 sed -e 's/_ProjectFileVersion/tempProjectFileVersion/g' $f > $TMP_FILE
389 else
390 echo "Warning: can not find tidy command to format the project file"
391 fi
392
393 sed -e '1s/xml version="1.1"/xml version="1.0"/' \
394 -e 's/<ItemGroup xmlns.*/<ItemGroup>/g' \
395 $TMP_FILE | $forward > ${f}.tmp
396
397 sed -e 's/tempProjectFileVersion/_ProjectFileVersion/g' ${f}.tmp > $f
398 rm ${f}.tmp
399 done
400
401 #
402 # Don't build Designer and Linq by default -- users can build them
403 # as needed.
404 for sln in `ls *.sln`
405 do
406 # Dos to unix
407 sed 's/$\r//' $sln > ${sln}.tmp
408
409 # Remove the projects from default building list
410 for project_name in "SQLite.Designer" "System.Data.SQLite.Linq"
411 do
412 project_id=`cat ${sln}.tmp | grep $project_name | head -n 1 | \
413 awk -F '[{}]' '{print $4}'`
414 if [ "$project_id" != "" ]; then
415 sed -e "/{$project_id}\./d" ${sln}.tmp > ${sln}
416 cp ${sln} ${sln}.tmp
417 fi
418 done
419
420 # Change to dos format -- VisualStudio solution files must be dos format
421 sed -e 's/ //g' -e 's/$/ /' ${sln}.tmp > $sln
422
423 rm ${sln}.tmp
424 done
425
426 #
427 # Generate WinCE edition for Solution files
428 #
429 # Skip *.MSBuild.sln and *.2010.sln since they don't include CompactFramework
430 # components
431 #
432 for sln in SQLite.NET.2008.sln
433 do
434 dst=`echo $sln | sed -e 's/2008/2008.WinCE/g'`
435
436 # Dos to unix
437 sed 's/$\r//' $sln > ${sln}.tmp
438 rm -f $TMP_FILE
439
440 # Change Win32 projects to WinCE projects
441 sed -e "s/|Win32/|$WINCE_PLATFORM_NAME/g" ${sln}.tmp > $TMP_FILE
442 sed -e "s/SQLite.Interop.2008/SQLite.Interop.2008.WinCE/g" $TMP_FILE > ${sln}.tmp
443 # Remove x64 platform -- WinCE projects doesn't require it
444 sed -e "/|x64/d" ${sln}.tmp > $TMP_FILE
445
446 # Remove SQLite.Designer, since it's not for Windows mobile/CE
447 guid=`grep 'SQLite.Designer' $TMP_FILE | head -n 1 | awk -F '[{}]' '{print $4}'`
448 if [ "$guid" != "" ]; then
449 sed -e '/SQLite.Designer/,/EndProject/d' \
450 -e "/$guid/d" $TMP_FILE > ${sln}.tmp
451 else
452 cp $TMP_FILE ${sln}.tmp
453 fi
454
455 # Change test.2008 to testce.2008 for WinCE testing
456 testceProj="$START_DIR/adodotnet/testce.2008.csproj"
457 test_GUID=`cat ${sln}.tmp | grep test\.2008 | awk -F "[{}]" '{print $4}'`
458 testce_GUID=`cat $testceProj | grep ProjectGuid | awk -F "[{}]" '{print $2}'`
459
460 # Change test project name and UID
461 sed -e "s/test\\\/testce\\\/g" \
462 -e "s/$test_GUID/$testce_GUID/g" \
463 -e "s/test\.2008/testce\.2008/g" \
464 ${sln}.tmp > $TMP_FILE
465
466 # Change to dos format -- VisualStudio solution files must be dos format
467 sed -e 's/ //g' -e 's/$/ /' $TMP_FILE > $dst
468
469 rm -f ${sln}.tmp
470 done
471
472 #
473 # SQLITE_MEMDEBUG only suit (Tcl) testfixture. Disable it.
474 #
475 cd $START_DIR/$ADO_DIR
476 for f in SQLite.Interop/props/sqlite3.props SQLite.Interop/props/sqlite3.vsprops
477 do
478 sed -e "s/SQLITE_MEMDEBUG=1//g" $f > $TMP_FILE
479 cat $TMP_FILE > $f
480 done
481
482 #
483 # Set Working directory for debugging with IDE
484 #
485 cp $START_DIR/adodotnet/test.2008.csproj.user test
486
487 #
488 # Clean Env
489 #
490 rm -f $TMP_FILE
491 cd $START_DIR
492
493 #
494 # Generate Package
495 #
496 rm -f ${ADO_DIR}.zip
497 zip -r ${ADO_DIR}.zip $ADO_DIR > /dev/null
498 if [ $? -eq 0 ]; then
499 dst_dir="../release"
500 [ ! -d "$dst_dir" ] && mkdir -p $dst_dir
501 mv ${ADO_DIR}.zip $dst_dir
502 echo "Package is generated successfully. File: $dst_dir/${ADO_DIR}.zip"
503 fi
504
505 # Clean environment
506 rm -r $ADO_DIR
507 }
508
509
510 s_sql_odbc
511 s_sql_jdbc
512 s_sql_adodotnet
513