#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# This shell script uncompresses and installs files archived in
# old-style WOS packages using the utilities cpio and compress. It
# looks in the PKGSRC directory for the archives which may be called
# out in one of eight ways :
#
# reloc.cpio.Z relocatable paths, less old style
# root.cpio.Z absolute paths, less old style
# reloc.cpio relocatable paths less old style, not compressed
# root.cpio absolute paths, less old style, not compressed
# reloc.Z relocatable paths, old style, compressed
# root.Z absolute paths, old style, compressed
# reloc relocatable paths, old style, not compressed
# root absolute paths, old style, not compressed
#
# stdin carries the source directory as the first entry followed by the
# paths of the files to be installed as indicated in the pkgmap. Since
# all operations take place from the declared base directory, both relative
# and absolute paths will install correctly. There are three methods and
# since speed is of the essence, we skip straight to the right one :
#
# If it's an initial install
# do a full cpio for each archive
# else
# If there's only the reloc archive
# make a file list, rm executables, do a selective cpio
# else
# rm executables, do a full cpio for each archive
#
# Since the old-style archives contain no execute permissions, this
# script saves the executables it requires so it can clean up after
# package, no cleanup will be possible (nothing will run) so we clean
# up first and then unload the entire archive without a file list.
#
IR=${PKG_INSTALL_ROOT:-/}
count=0
Reloc_Arch=""
Root_Arch=""
# critical archived dynamic libraries and executables
Spcl_lib=0
Movelist=""
Ld_Preload=""
# Set up the default paths
rm_cpio=0
rm_ln=0
rm_zcat=0
rm_nawk=0
rm_rm=0
rm_mv=0
# Functions
#
# This creates the temporary directory for holding the old dynamic
# libraries and executables.
#
if [ ! -d $Tmp_xpath ]; then
if [ $? -ne 0 ]; then
exit 1
fi
fi
}
#
# Test a path to see if it represents a dynamic library or executable that
# we use in this script. If it is, deal with the special case.
#
if [ $local_install -eq 1 ]; then
case $1 in
$Libintl) Spcl_lib=1; file=libintl.so.1;;
$Libmalloc) Spcl_lib=1; file=libmapmalloc.so.1;;
esac
if [ $no_select -eq 1 ]; then
if [ $Rm_alt_sav -eq 1 ]; then
fi
return 1
if [ $Tmp_Creat -eq 0 ]; then
fi
if [ $Spcl_init -eq 0 ]; then
export LD_LIBRARY_PATH
fi
export LD_PRELOAD
$LN_cmd -s ../..$Tmp_xpath/$file $1
Spcl_lib=0
elif [ $Spcl_exec -eq 1 ]; then
if [ $Tmp_Creat -eq 0 ]; then
fi
$LN_cmd -s ../..$Tmp_xpath/cpio $1
CPIO_cmd="$Tmp_xpath/cpio"
rm_cpio=0
$Tmp_xpath/ln -s ../..$Tmp_xpath/ln $1
LN_cmd="$Tmp_xpath/ln"
rm_ln=0
$LN_cmd -s ../..$Tmp_xpath/nawk $1
NAWK_cmd="$Tmp_xpath/nawk"
rm_nawk=0
$LN_cmd -s ../..$Tmp_xpath/zcat $1
ZCAT_cmd="$Tmp_xpath/zcat"
rm_zcat=0
$LN_cmd -s ../..$Tmp_xpath/rm $1
RM_cmd="$Tmp_xpath/rm"
rm_rm=0
$LN_cmd -s ../..$Tmp_xpath/mv $1
MV_cmd="$Tmp_xpath/mv"
rm_mv=0
fi
fi
fi
return 0
}
#
# Clean up the libraries and executables that were moved.
#
if [ ! -z "${Movelist}" ]; then
{ split ($0, line)
for (n=1; n <= NF; n++) {
print line[n]
}
}' | while read path; do
read file
if [ -h $path ]; then # If it's our slink
# then put the original back
if [ $1 -eq 0 ]; then
fi
else # if the archive put something down
# remove the temporary copy
fi
done
if [ -x $path ]; then
esac
fi
done
Movelist=""
if [ $Tmp_Creat -eq 1 ]; then
fi
fi
}
#
# Figure out what kind of package this is
#
# Any archive, whether compressed or not needs to be handled
# the same. i.e. reloc.cpio.Z and root.cpio.Z should cause
# the global is_an_archive to be set to 1.
read path
fi
if [ -r $PKGSRC/reloc.cpio.Z ]; then
fi
if [ -r $PKGSRC/root.cpio.Z ]; then
fi
if [ -r $PKGSRC/reloc.cpio ]; then
fi
fi
fi
fi
fi
fi
else
exit 0 # empty pipe, we're done
fi
}
#
# main
#
if [ $BD = "/" ]; then
Client_BD=""
else
fi
exit 1
fi
if [ ! -d $PKGSAV ]; then
if [ ! -d $PKGSAV ]; then
fi
if [ $? -eq 0 ]; then
else
exit 1
fi
fi
if [ -f $FILELIST ]; then
fi
cd $BD
# If there's one old-style archive and it is relocatable and this is
# not an initial install then make a file list for extraction.
fi
# If this is not an initial install then clear out potentially executing
# files and libraries for cpio and create an extraction list if necessary
# If extraction list is desired, create it
while read path
do
full_path=`echo $Client_BD/$path | sed s@//@/@g`
if [ $? -eq 1 ]; then
break
fi
fi
done
# If there's a path containing a '$' then we can't
# use the extraction list because of the shell
if [ ! -z "${s}" ]; then
fi
fi
else # No extraction list is desired
while read path
do
full_path=`echo $Client_BD/$path | sed s@//@/@g`
if [ $? -eq 1 ]; then
break
fi
fi
done
fi # $mk_filelist -eq 1
else # ! ($local_install -eq 1)
# If extraction list is desired, create it
while read path
do
done
# If there's a path containing a '$' then we can't
# use the extraction list because of the shell
if [ ! -z "${s}" ]; then
fi
fi
fi # $mk_filelist -eq 1
fi # $local_install -eq 1
fi # ${PKG_INIT_INSTALL:-null} = null
# Now extract the data from the archive(s)
# extract compressed cpio relocatable archive
cd $BD
if [ $? -ne 0 ]; then
exit 1
fi
fi
else
fi
fi
# extract compressed cpio absolute archive
cd $IR
if [ $? -ne 0 ]; then
exit 1
fi
fi
# extract cpio relocatable archive
cd $BD
if [ $? -ne 0 ]; then
exit 1
fi
fi
else
fi
fi
# extract cpio absolute archive
cd $IR
if [ $? -ne 0 ]; then
exit 1
fi
fi
if [ -f $FILELIST ]; then
fi
fi
fi
export LD_LIBRARY_PATH
fi
exit 0