2001-06-12 22:05:57 +00:00
|
|
|
#!/usr/bin/qsh
|
2007-08-23 03:37:11 +00:00
|
|
|
# Copyright (C) 2000-2007, International Business Machines
|
2003-06-03 06:44:40 +00:00
|
|
|
# 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
|
2006-03-01 06:26:56 +00:00
|
|
|
# Steven R. Loomis
|
2001-06-12 22:05:57 +00:00
|
|
|
# George Rhoten
|
2007-08-23 03:37:11 +00:00
|
|
|
# Jason Spieth
|
2001-06-12 22:05:57 +00:00
|
|
|
#
|
|
|
|
# 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)
|
|
|
|
|
2007-08-23 03:37:11 +00:00
|
|
|
#****************************************************************************
|
2001-08-10 16:36:50 +00:00
|
|
|
#binary_suffixes='ico ICO bmp BMP jpg JPG gif GIF brk BRK'
|
|
|
|
#ICU specific binary files
|
2007-08-23 03:37:11 +00:00
|
|
|
#****************************************************************************
|
2006-03-01 06:26:56 +00:00
|
|
|
binary_suffixes='brk BRK bin BIN res RES cnv CNV dat DAT icu ICU spp SPP xml XML'
|
2005-07-01 17:25:45 +00:00
|
|
|
data_files='icu/source/data/brkitr/* icu/source/data/locales/* icu/source/data/coll/* icu/source/data/rbnf/* 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
|
|
|
|
2007-08-23 03:37:11 +00:00
|
|
|
#****************************************************************************
|
|
|
|
# Function: usage
|
|
|
|
# Description: Prints out text that describes how to call this script
|
|
|
|
# Input: None
|
|
|
|
# Output: None
|
|
|
|
#****************************************************************************
|
2001-06-12 22:05:57 +00:00
|
|
|
usage()
|
|
|
|
{
|
2006-03-01 06:26:56 +00:00
|
|
|
echo "Enter archive filename as a parameter: $0 icu-archive.tar"
|
2001-06-12 22:05:57 +00:00
|
|
|
}
|
2007-08-23 03:37:11 +00:00
|
|
|
|
|
|
|
#****************************************************************************
|
2001-06-12 22:05:57 +00:00
|
|
|
# first make sure we at least one arg and it's a file we can read
|
2007-08-23 03:37:11 +00:00
|
|
|
#****************************************************************************
|
|
|
|
|
|
|
|
# check for no arguments
|
2001-06-12 22:05:57 +00:00
|
|
|
if [ $# -eq 0 ]; then
|
|
|
|
usage
|
|
|
|
exit
|
|
|
|
fi
|
2007-08-23 03:37:11 +00:00
|
|
|
|
|
|
|
# tar file is argument 1
|
2006-03-01 06:26:56 +00:00
|
|
|
tar_file=$1
|
2007-08-23 03:37:11 +00:00
|
|
|
|
|
|
|
# check that the file is valid
|
2006-03-01 06:26:56 +00:00
|
|
|
if [ ! -r $tar_file ]; then
|
|
|
|
echo "$tar_file does not exist or cannot be read."
|
2001-06-12 22:05:57 +00:00
|
|
|
usage
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2007-08-23 03:37:11 +00:00
|
|
|
#****************************************************************************
|
|
|
|
# Determine which directories in the data_files list
|
2005-07-01 17:25:45 +00:00
|
|
|
# are included in the provided archive
|
2007-08-23 03:37:11 +00:00
|
|
|
#****************************************************************************
|
2005-07-01 17:25:45 +00:00
|
|
|
for data_dir in $data_files
|
|
|
|
do
|
2007-08-23 03:37:11 +00:00
|
|
|
if (pax -f $tar_file $data_dir >/dev/null 2>&1)
|
|
|
|
then
|
|
|
|
ebcdic_data="$ebcdic_data `echo $data_dir`";
|
|
|
|
fi
|
2005-07-01 17:25:45 +00:00
|
|
|
done
|
|
|
|
|
2007-08-23 03:37:11 +00:00
|
|
|
#****************************************************************************
|
|
|
|
# Extract files. We do this in two passes. One pass for 819 files and a
|
|
|
|
# second pass for 37 files
|
|
|
|
#****************************************************************************
|
|
|
|
echo ""
|
|
|
|
echo "Extracting from $tar_file ..."
|
|
|
|
echo ""
|
|
|
|
|
2001-08-10 16:36:50 +00:00
|
|
|
# extract everything as iso-8859-1 except these directories
|
2006-03-01 06:26:56 +00:00
|
|
|
pax -C 819 -rcvf $tar_file $ebcdic_data
|
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 ""
|
2006-03-01 06:26:56 +00:00
|
|
|
pax -C 37 -rvf $tar_file $ebcdic_data
|
2001-06-12 22:05:57 +00:00
|
|
|
|
2007-08-23 03:37:11 +00:00
|
|
|
#****************************************************************************
|
|
|
|
# For files we have restored as CCSID 37, check the BOM to see if they
|
|
|
|
# should be processed as 819. Also handle files with special paths. Files
|
|
|
|
# that match will be added to binary files lists. The lists will in turn
|
|
|
|
# be processed to restore files as 819.
|
|
|
|
#****************************************************************************
|
2001-06-12 22:05:57 +00:00
|
|
|
echo ""
|
|
|
|
echo "Determining binary files ..."
|
|
|
|
echo ""
|
|
|
|
|
2007-08-23 03:37:11 +00:00
|
|
|
# Process BOMs
|
2001-08-10 16:36:50 +00:00
|
|
|
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'`;
|
|
|
|
#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
|
2007-08-23 03:37:11 +00:00
|
|
|
file="`echo $file | cut -d / -f2-`"
|
|
|
|
|
2007-09-13 20:17:02 +00:00
|
|
|
if [ `echo $binary_files | wc -w` -lt 200 ]
|
2007-08-23 03:37:11 +00:00
|
|
|
then
|
2007-09-13 20:17:02 +00:00
|
|
|
binary_files="$binary_files $file";
|
2004-11-15 19:35:13 +00:00
|
|
|
else
|
2007-09-13 20:17:02 +00:00
|
|
|
echo "Restoring binary files ..."
|
|
|
|
rm $binary_files;
|
|
|
|
pax -C 819 -rvf $tar_file $binary_files;
|
|
|
|
echo "Determining binary files ..."
|
|
|
|
binary_files="$file";
|
2004-11-15 19:35:13 +00:00
|
|
|
fi
|
2001-06-12 22:05:57 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2007-08-23 03:37:11 +00:00
|
|
|
# Process special paths
|
2006-03-01 06:26:56 +00:00
|
|
|
for i in $(pax -f $tar_file 2>/dev/null)
|
2001-06-12 22:05:57 +00:00
|
|
|
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
|
2007-09-13 20:17:02 +00:00
|
|
|
|
|
|
|
if [ `echo $binary_files | wc -w` -lt 200 ]
|
|
|
|
then
|
|
|
|
binary_files="$binary_files $i";
|
|
|
|
else
|
|
|
|
echo "Restoring binary files ..."
|
|
|
|
rm $binary_files;
|
|
|
|
pax -C 819 -rvf $tar_file $binary_files;
|
|
|
|
echo "Determining binary files ..."
|
|
|
|
binary_files="$i";
|
|
|
|
fi
|
2001-06-12 22:05:57 +00:00
|
|
|
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
|
2007-09-13 20:17:02 +00:00
|
|
|
if [ `echo $binary_files | wc -w` -gt 0 ]
|
2007-08-23 03:37:11 +00:00
|
|
|
then
|
2001-06-12 22:05:57 +00:00
|
|
|
echo "Restoring binary files ..."
|
2007-09-13 20:17:02 +00:00
|
|
|
rm $binary_files
|
|
|
|
pax -C 819 -rvf $tar_file $binary_files
|
2001-06-12 22:05:57 +00:00
|
|
|
fi
|
2006-05-16 16:25:42 +00:00
|
|
|
|
2007-08-23 03:37:11 +00:00
|
|
|
#****************************************************************************
|
|
|
|
# Generate and run the configure script
|
|
|
|
#****************************************************************************
|
|
|
|
|
2006-05-16 16:25:42 +00:00
|
|
|
echo ""
|
|
|
|
echo "Generating qsh compatible configure ..."
|
|
|
|
echo ""
|
|
|
|
|
2006-08-22 16:29:48 +00:00
|
|
|
sed -f icu/as_is/os400/convertConfigure.sed icu/source/configure > icu/source/configureTemp
|
2006-05-16 16:25:42 +00:00
|
|
|
del -f icu/source/configure
|
|
|
|
mv icu/source/configureTemp icu/source/configure
|
|
|
|
chmod 755 icu/source/configure
|
|
|
|
|
2001-06-12 22:05:57 +00:00
|
|
|
echo ""
|
2006-03-01 06:26:56 +00:00
|
|
|
echo "$0 has completed extracting ICU from $tar_file."
|
2007-08-23 03:37:11 +00:00
|
|
|
|