ICU-4869 Make it easier to use z/OS ASCII mode.

X-SVN-Rev: 19295
This commit is contained in:
George Rhoten 2006-02-27 17:25:48 +00:00
parent 5d15b21a8d
commit 20e4259d9b

View File

@ -1,10 +1,10 @@
#!/bin/sh
# Copyright (C) 2001 - 2003, International Business Machines Corporation.
# All Rights Reserved.
# Copyright (C) 2001-2006, International Business Machines
# Corporation and others. All Rights Reserved.
#
# Authors:
# Ami Fixler
# Steven R. Loomis <srl@jtcsv.com>
# Steven R. Loomis
# George Rhoten
#
# Shell script to unpax ICU and convert the files to an EBCDIC codepage.
@ -15,113 +15,104 @@
#binary_suffixes='ico ICO bmp BMP jpg JPG gif GIF brk BRK'
#ICU specific binary files
binary_suffixes='brk BRK bin BIN res RES cnv CNV dat DAT icu ICU spp SPP'
binary_suffixes='brk BRK bin BIN res RES cnv CNV dat DAT icu ICU spp SPP xml XML'
usage()
{
echo "Enter archive filename as a parameter: $0 icu-archive.tar [strip]"
echo "(strip is an option to remove hex '0D' carraige returns)"
echo "Enter archive filename as a parameter: $0 icu-archive.tar [strip]"
echo "(strip is an option to remove hex '0D' carriage returns)"
}
# first make sure we at least one arg and it's a file we can read
if [ $# -eq 0 ]; then
usage
exit
usage
exit
fi
if [ ! -r $1 ]; then
echo "$1 does not exist or cannot be read."
usage
exit
tar_file=$1
if [ ! -r $tar_file ]; then
echo "$tar_file does not exist or cannot be read."
usage
exit
fi
# set up a few variables
echo ""
echo "Extracting from $1 ..."
echo "Extracting from $tar_file ..."
echo ""
# extract files while converting them to EBCDIC
pax -rvf $1 -o to=IBM-1047,from=ISO8859-1
pax -rvf $tar_file -o to=IBM-1047,from=ISO8859-1
if [ $# -gt 1 ]; then
if [ $2 -eq strip ]; then
echo ""
echo "Stripping hex 0d characters ..."
for i in $(pax -f $1 2>/dev/null)
do
case $i in
*/)
# then this entry is a directory
;;
*)
# then this entry is NOT a directory
tr -d
if test $# -gt 1 -a "$2" = "strip" ; then
echo ""
echo "Stripping hex 0d characters ..."
for i in $(pax -f $tar_file 2>/dev/null)
do
case $i in
*/) ;; # then this entry is a directory
*) # then this entry is NOT a directory
tr -d
<$i >@@@icu@tmp
chmod +w $i
rm $i
mv @@@icu@tmp $i
;;
esac
done
fi
chmod +w $i
rm $i
mv @@@icu@tmp $i
;;
esac
done
fi
echo ""
echo "Determining binary files ..."
echo ""
#for dir in `find ./icu -type d \( -name CVS -o -print \)`; do
# if [ -f $dir/CVS/Entries ]; then
# binary_files="$binary_files`cat $dir/CVS/Entries | fgrep -- -kb \
# | cut -d / -f2 | sed -e "s%^%$dir/%" \
# | sed -e "s%^\./%%" | tr '\n' ' '`"
# fi
#done
#echo "Detecting Unicode files"
for file in `find icu \( -name \*.txt -print \)`; do
bom8=`head -c 3 $file|\
od -t x1|\
head -n 1|\
sed 's/ */ /g'|\
cut -f2-4 -d ' '|\
tr 'A-Z' 'a-z'`;
#Find a converted UTF-8 BOM
if test "$bom8" = "57 8b ab"
then
binary_files="$binary_files $file";
fi
done
# When building in ASCII mode, text files are converted as ASCII
if [ ${ICU_ENABLE_ASCII_STRINGS} -eq 1 ]; then
binary_suffixes="$binary_suffixes txt TXT ucm UCM"
else
for file in `find ./icu \( -name \*.txt -print \)`; do
bom8=`head -c 3 $file|\
od -t x1|\
head -n 1|\
sed 's/ */ /g'|\
cut -f2-4 -d ' '|\
tr 'A-Z' 'a-z'`;
#Find a converted UTF-8 BOM
if [ "$bom8" = "57 8b ab" ]
then
binary_files="$binary_files $file";
fi
done
fi
for i in $(pax -f $1 2>/dev/null)
for i in $(pax -f $tar_file 2>/dev/null)
do
case $i in
*/)
# then this entry is a directory
;;
*.*)
# then this entry has a dot in the filename
for j in $binary_suffixes
do
suf=${i#*.*}
if [ "$suf" = "$j" ]
then
binary_files="$binary_files $i"
break
fi
done
;;
*)
# then this entry does not have a dot in it
;;
esac
case $i in
*/) ;; # then this entry is a directory
*.*) # then this entry has a dot in the filename
for j in $binary_suffixes
do
# We substitute the suffix more than once
# to handle files like NormalizationTest-3.2.0.txt
suf=${i#*.*}
suf=${suf#*.*}
suf=${suf#*.*}
if [ "$suf" = "$j" ]
then
binary_files="$binary_files $i"
break
fi
done
;;
*) ;; # then this entry does not have a dot in it
esac
done
# now see if a re-extract of binary files is necessary
if [ ${#binary_files} -eq 0 ]; then
echo ""
echo "There are no binary files to restore."
echo ""
echo "There are no binary files to restore."
else
echo "Restoring binary files ..."
echo ""
rm $binary_files
pax -rvf $1 $binary_files
echo "Restoring binary files ..."
echo ""
rm $binary_files
pax -rvf $tar_file $binary_files
fi
echo ""
echo "$0 has completed extracting ICU from $1."
echo "$0 has completed extracting ICU from $tar_file."