2001-06-12 22:05:57 +00:00
|
|
|
#!/usr/bin/qsh
|
2003-06-03 06:44:40 +00:00
|
|
|
# Copyright (C) 2000-2003, International Business Machines
|
|
|
|
# Corporation and others. All Rights Reserved.
|
2001-06-12 22:05:57 +00:00
|
|
|
#
|
|
|
|
# Authors:
|
|
|
|
# Ami Fixler
|
2002-06-04 21:52:34 +00:00
|
|
|
# Barry Novinger
|
2001-06-12 22:05:57 +00:00
|
|
|
# Steven R. Loomis <srl@jtcsv.com>
|
|
|
|
# George Rhoten
|
|
|
|
#
|
|
|
|
# Shell script to unpax ICU and convert the files to an EBCDIC codepage.
|
|
|
|
# After extracting to EBCDIC, binary files are re-extracted without the
|
|
|
|
# EBCDIC conversion, thus restoring them to original codepage.
|
|
|
|
#
|
|
|
|
# Set the following variable to the list of binary file suffixes (extensions)
|
|
|
|
|
2001-08-10 16:36:50 +00:00
|
|
|
#binary_suffixes='ico ICO bmp BMP jpg JPG gif GIF brk BRK'
|
|
|
|
#ICU specific binary files
|
2003-12-05 00:18:26 +00:00
|
|
|
binary_suffixes='brk BRK bin BIN res RES cnv CNV dat DAT icu ICU spp SPP'
|
2004-05-13 22:08:27 +00:00
|
|
|
data_files='icu/source/data/brkitr/* icu/source/data/locales/* icu/source/data/coll/* icu/source/data/mappings/* icu/source/data/misc/* icu/source/data/translit/* icu/source/data/unidata/* icu/source/test/testdata/*'
|
2001-06-12 22:05:57 +00:00
|
|
|
|
|
|
|
usage()
|
|
|
|
{
|
|
|
|
echo "Enter archive filename as a parameter: $0 icu-archive.tar [strip]"
|
|
|
|
echo "(strip is an option to remove hex '0D' carraige returns)"
|
|
|
|
}
|
|
|
|
# first make sure we at least one arg and it's a file we can read
|
|
|
|
if [ $# -eq 0 ]; then
|
|
|
|
usage
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
if [ ! -r $1 ]; then
|
|
|
|
echo "$1 does not exist or cannot be read."
|
|
|
|
usage
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
# set up a few variables
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
echo "Extracting from $1 ..."
|
|
|
|
echo ""
|
2001-08-10 16:36:50 +00:00
|
|
|
# extract everything as iso-8859-1 except these directories
|
2002-06-04 21:52:34 +00:00
|
|
|
pax -C 819 -rcvf $1 $data_files
|
2001-06-12 22:05:57 +00:00
|
|
|
|
|
|
|
# extract files while converting them to EBCDIC
|
|
|
|
echo ""
|
|
|
|
echo "Extracting files which must be in ibm-37 ..."
|
|
|
|
echo ""
|
2002-06-04 21:52:34 +00:00
|
|
|
pax -C 37 -rvf $1 $data_files
|
2001-06-12 22:05:57 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
<$i >@@@icu@tmp
|
|
|
|
chmod +w $i
|
|
|
|
rm $i
|
|
|
|
mv @@@icu@tmp $i
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
echo "Determining binary files ..."
|
|
|
|
echo ""
|
|
|
|
|
2001-08-10 16:36:50 +00:00
|
|
|
#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 -n 1 $file|\
|
|
|
|
od -t x1|\
|
|
|
|
head -n 1|\
|
|
|
|
sed 's/ */ /g'|\
|
|
|
|
cut -f2-4 -d ' '|\
|
|
|
|
tr 'A-Z' 'a-z'`;
|
|
|
|
# echo "bom8 is" $bom8 "for" $file
|
|
|
|
# bom8=`head -c 3 $file|od -t x1|head -n 1|cut -d ' ' -f2-4`;
|
|
|
|
#Find a converted UTF-8 BOM
|
2003-06-06 17:46:51 +00:00
|
|
|
if [ "$bom8" = "057 08b 0ab" -o "$bom8" = "57 8b ab" ]
|
2001-08-10 16:36:50 +00:00
|
|
|
then
|
|
|
|
binary_files="$binary_files `echo $file | cut -d / -f2-`";
|
2001-06-12 22:05:57 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2001-08-10 16:36:50 +00:00
|
|
|
#echo $binary_files
|
|
|
|
|
2001-06-12 22:05:57 +00:00
|
|
|
for i in $(pax -f $1 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
|
|
|
|
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."
|
|
|
|
else
|
|
|
|
echo "Restoring binary files ..."
|
|
|
|
echo ""
|
2001-08-10 16:36:50 +00:00
|
|
|
rm $binary_files
|
2001-06-12 22:05:57 +00:00
|
|
|
pax -C 819 -rvf $1 $binary_files
|
|
|
|
fi
|
|
|
|
echo ""
|
|
|
|
echo "$0 has completed extracting ICU from $1."
|