Add BSD license file
[platform/upstream/db4.git] / dist / s_je2db
1 #!/bin/sh -
2
3 # The examples must be hand-edited after they are copied:
4 # - add EnvironmentConfig.setInitializeCache(true), setInitializeLocking(true)
5 # - add DatabaseConfig.setType(DatabaseType.BTREE)
6 # - add null databaseName param to openDatabase() and openSecondaryDatabase()
7
8 COPY_EXAMPLES=0
9
10 JEDIR=$1
11 if [ $# -eq 1 ] ; then
12     DBDIR=..
13 else
14     DBDIR=$2
15 fi
16
17 if [ ! -d "$DBDIR/dbinc" -o ! -f "$JEDIR/build.xml" ] ; then
18         echo >&2 "Usage $0 /path/to/je [ /path/to/db ]"
19         exit 1
20 fi
21
22 JEDIR=$(cd "$JEDIR" ; /bin/pwd)
23 DBDIR=$(cd "$DBDIR" ; /bin/pwd)
24
25 JESRC="$JEDIR/src"
26 JETEST="$JEDIR/test"
27 JEEXAMPLES="$JEDIR/examples"
28 DBSRC="$DBDIR/java/src"
29 DBTEST="$DBDIR/test/scr024/src"
30 DBEXAMPLES="$DBDIR/examples_java/src"
31 DIRMATCH="com/sleepycat/\(\(asm\)\|\(bind\)\|\(collections\)\|\(persist\)\|\(util\)\)"
32 EXAMPLESMATCH="^\./\(\(collections\)\|\(persist\)\)"
33
34 cd "$JESRC"
35 for d in `find . -type d | grep -v CVS | grep $DIRMATCH` ; do
36     #echo "$DBSRC/$d"
37     mkdir -p "$DBSRC/$d"
38 done
39 cd "$JETEST"
40 for d in `find . -type d | grep -v CVS | grep $DIRMATCH` ; do
41     #echo "$DBTEST/$d"
42     mkdir -p "$DBTEST/$d"
43 done
44 if [ $COPY_EXAMPLES -eq 1 ] ; then
45     cd "$JEEXAMPLES"
46     for d in `find . -type d | grep -v CVS | grep $EXAMPLESMATCH` ; do
47         #echo "$DBEXAMPLES/$d"
48         mkdir -p "$DBEXAMPLES/$d"
49     done
50 fi
51
52 E1='s/com\.sleepycat\.je/com.sleepycat.db/g'
53 E2='/<!-- begin JE only -->/,/<!-- end JE only -->/d'
54 E3='s/LockConflictException/DeadlockException/g'
55 E4='s/$Id:.*\$/$Id$/'
56 E5='s/TransactionGettingStarted/gsg_txn\/JAVA/'
57 EXCLUDESRC="\(\(DeletedClassException\)\|\(IncompatibleClassException\)\|\(StoreExistsException\)\|\(StoreNotFoundException\)\)"
58 #EXCLUDESRC="\(\(ClassEnhancerTask\)\|\(DeletedClassException\)\|\(IncompatibleClassException\)\|\(StoreExistsException\)\|\(StoreNotFoundException\)\)"
59 EXCLUDETESTS="\(\(ConvertAndAddTest\)\|\(DevolutionTest\)\|\(TestVersionCompatibility\)\|\(XACollectionTest\)\)"
60
61 cd "$JESRC"
62 for f in `find . -name '*.java' -o -name "package.html" | grep $DIRMATCH | grep -v $EXCLUDESRC` ; do
63     #echo $DBSRC/$f
64     sed -e "$E1" -e "$E2" -e "$E3" -e "$E4" -e "$E5" < $f \
65         > $DBSRC/$f.sed.out
66     diff -q -I "\$\Id:" $DBSRC/$f $DBSRC/$f.sed.out || \
67         mv -f $DBSRC/$f.sed.out $DBSRC/$f
68     rm -f $DBSRC/$f.sed.out
69 done
70
71 cd "$JETEST"
72 for f in `find . -name '*.java' -o -name "*.java.original" | grep $DIRMATCH | grep -v $EXCLUDETESTS` \
73         ; do
74     #echo $DBTEST/$f
75     sed -e "$E1" -e "$E2" -e "$E3" -e "$E4" -e "$E5" < $f \
76         > $DBTEST/$f.sed.out
77     diff -q -I "\$\Id:" $DBTEST/$f $DBTEST/$f.sed.out || \
78         mv -f $DBTEST/$f.sed.out $DBTEST/$f
79     rm -f $DBTEST/$f.sed.out
80 done
81
82 if [ $COPY_EXAMPLES -eq 1 ] ; then
83     cd "$JEEXAMPLES"
84     for f in `find . -name '*.java' | grep $EXAMPLESMATCH` ; do
85         #echo $DBEXAMPLES/$f
86         sed -e "$E1" -e "$E2" -e "$E3" -e "$E4" -e "$E5" < $f \
87             > $DBEXAMPLES/$f.sed.out
88         diff -q -I "\$\Id:" $DBEXAMPLES/$f $DBEXAMPLES/$f.sed.out || \
89             mv -f $DBEXAMPLES/$f.sed.out $DBEXAMPLES/$f
90         rm -f $DBEXAMPLES/$f.sed.out
91     done
92 fi
93
94 exit 0