1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298
|
#!/bin/bash
#
# Bourne Shell Script
#
# Description:
# Convert Tritonus 1.81 java source code
# so that it work with Java Development Kit 1.1.7 and
# the Collections API for JDK 1.1
#
# Author:
# Peter Pilgrim
# Wed Jan 05 21:15:56 GMT 2000
#
# ********************************************************************************
PrintUsage()
# ********************************************************************************
{
cat << EOF
USAGE: $myname
[ --classpath (-cp) <CLASSPATH> ]
[ --dryrun (-dr) ] [ --force ]
[ --verbose (-v) | --noverbose (+v) ]
[ --help (-h) | --usage (-u) ]
OPTIONS:
'--dryrun' dry run and test the configuration, do not configure the
'-dr' the run-time stub file.
'--verbose' generates verbose output also.
'-v'
'--help' produces this brief text and exits gracefully.
'-h' '-u'
DESCRIPTION:
This program '$myname' converts Tritonus 1.81
Java source code so that it compiles with Java Development Kit 1.1.7
and the Collections API for JDK 1.1 The Collections API for JDK1.1 can
be found on the Javasoft web pages under the InfoBus product line.
Peter Pilgrim Wed Jan 05 21:18:41 GMT 2000
EOF
echo '$RCSfile: ConvertJDK117,v $ $Revision: 1.1.1.1 $ $Author: pfisterer $ $Date: 2000/04/13 19:13:57 $'
exit 0
}
# ********************************************************************************
BackupFile ()
# ********************************************************************************
{
# Backup a file by renaming it.
ThisFile=$1
if [ -f ${ThisFile} ]; then
if [ -f ${ThisFile}.bak ]; then
(set $VerboseOpt; ${PrefixCmd} /bin/rm -f ${ThisFile}.bak )
fi
(set $VerboseOpt; ${PrefixCmd} mv ${ThisFile} ${ThisFile}.bak )
fi
}
# ********************************************************************************
SysWarn()
# ********************************************************************************
{
# Log an message string to the standard out and do NOT exit
echo "$myname: *WARNING* : $1" 1>&2
}
# ********************************************************************************
SysError()
# ********************************************************************************
{
# Log an message string to the standard error and exit
echo "$myname: *ERROR* : $1" 1>&2
exit 1
}
# ********************************************************************************
SignalCatcher()
# ********************************************************************************
{
# A generic signal handler for the shell script.
echo
echo "$myname: Got Signal $1"
exit 3
}
# ********************************************************************************
CleanUp ()
# ********************************************************************************
{
echo "$myname:Finished (total:$total, errors:$errors, cmpltd:$cmpltd, ignored:$ignored, counter:$counter )"
/bin/rm -f DUMMY_FILE $TempFile1 $TempFile2
}
# ********************************************************************************
# MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN
# ********************************************************************************
myname=`basename $0`
debug=
verbose=
silent=
VerboseOpt="+x"
PrefixCmd=""
DryRunFlag=0
cmpltd=0
errors=0
total=0
ignored=0
counter=0
#
# Interpret the command line arguments (the GNU way!)
#
while [ $# -gt 0 ]
do
#
# Interpret cli argument
#
case $1 in
# **** The standard CLI options begin here ****
-silent | -quiet | \
--silence | --silenc | --silenc | --silen | --sile | --sil | \
--quiet | --quie | --qui | --qu | --q | -q )
silent=yes
verbose=
VerboseOpt="+x"
;;
-verbose | --verbose | --verbos | --verbo | --verb | \
--ver | --ve | --v | -v )
verbose=yes
VerboseOpt="-x"
;;
--debug | --debu | --deb | -debug | -debu | -deb )
debug=yes
;;
--dryrun | --dryru | --dryr | --dry | --dr | -dr | \
-dryrun | -dryru | -dryr | -dry | -dr | -dr )
PrefixCmd="echo =>"
DryRunFlag=1
;;
--help | --hel | --he | --h | -help | -hel | -he | -h | \
--usage | --usag | --usa | --us | --u | \
-usage | -usag | -usa | -us | -u )
PrintUsage
exit 0
;;
--* | -*)
SysError "unknown cli option: '$1'. Try '--help' for more info"
break;;
*) break;;
esac
shift
done
#
# Trap any signals
#
trap 'CleanUp "Cleaning"' 0
trap 'SignalCatcher "(SIGHUP)"' 1
trap 'SignalCatcher "(SIGINT)"' 2
trap 'SignalCatcher "(SIGQUIT)"' 3
trap 'SignalCatcher "(SIGTERM)"' 15
echo "$myname: converting to JDK 1.1.7 and compatible Collections API"
JavaSourceFiles=`find . -name "*.java" -print`
# Create a `sed(1)' file to replace
SedFile=collections.sed
/bin/rm -f $SedFile
# List of Collections API
ReplaceClassList="
Collection
Comparable
Comparator
Iterator
List
ListIterator
Map
Set
SortedMap
SortedSet
AbstractCollection
AbstractList
AbstractMap
AbstractSequentialList
AbstractSet
ArrayList
Arrays
Collections
HashMap
HashSet
Hashtable
LinkedList
Random
SubList
TreeMap
TreeSet
Vector
ConcurrentModificationException
NoSuchElementException
UnsupportedOperationException"
# Create the sed script file
for Class in $ReplaceClassList
do
## ============================================================
## WARNING EMBEDDED TABS HERE!!!
## ============================================================
echo "s/ java.util.$Class/ com.sun.java.util.collections.$Class/g" >> $SedFile
echo "s/ java.util.$Class/ com.sun.java.util.collections.$Class/g" >> $SedFile
## ============================================================
## added to convert ConcurrentModificationException,
## NoSuchElementException and UnsupportedOperationException
## MP20000326
## ============================================================
echo "s/ java.lang.$Class/ com.sun.java.util.collections.$Class/g" >> $SedFile
echo "s/ java.lang.$Class/ com.sun.java.util.collections.$Class/g" >> $SedFile
done
# find all java source file and run sed script through them
for SrcFile in $JavaSourceFiles
do
let total=total+1
temp=`grep "java.util." $SrcFile`
if [ "x$temp" != "x" ]; then
echo -n " [$counter] $SrcFile "
NewFile=${SrcFile}.new
BackFile=${SrcFile}.bak
[ -f $NewFile ] && /bin/rm -f $NewFile
sed -f $SedFile $SrcFile > $NewFile
status=$?
let counter=counter+1
if [ $DryRunFlag -ne 0 ]; then
echo "*DRYRUN*"
continue
fi
if [ $status -eq 0 ]; then
# backup the original original
[ -f $BackFile ] && /bin/rm -f $BackFile
mv $SrcFile $BackFile; status=$?
if [ $status -ne 0 ]; then
let errors=errors+1
echo "*FAILED*"
SysError "command failed mv $SrcFile $BackFile (status:$status)"
fi
# the output sed file becomes the new Java source file
mv $NewFile $SrcFile; status=$?
if [ $status -ne 0 ]; then
let errors=errors+1
echo "*FAILED*"
SysError "command failed mv $NewFile $SrcFile (status:$status)"
fi
let cmpltd=cmpltd+1
echo "*DONE*"
else
let errors=errors+1
echo "*FAILED*"
fi
## echo "**** DEATH 69 ****"; exit 69
else
let ignored=ignored+1
fi
done
if [ $DryRunFlag -ne 0 ]; then
echo "*DRYRUN*"
continue
fi
if [ $errors -eq 0 ]; then
cat <<XEOF
There were apparently no errors detected. It looks like the conversion
process worked. You should be able to compile again with JDK 1.1.7
BTW: You do have a backup of the ORIGINAL distribution. Dont you?
XEOF
fi
# fini
|