324 lines
9.4 KiB
Bash
324 lines
9.4 KiB
Bash
#!/root/bin/ksh -p
|
|
# This version is used in the miniroot; uses the real root's ksh,
|
|
# and make sure that the real root's bin dirs are in our path.
|
|
# this command will fail if /root isn't present, which is what
|
|
# we want, anyway.
|
|
# The flag is:
|
|
# -p privileged (skips . $ENV)
|
|
|
|
# coffcheck
|
|
# Use: "coffcheck -help" for help.
|
|
#
|
|
# Finds COFF executable files on local file systems.
|
|
# Useful when upgrading to IRIX 6.5, which no longer supports COFF.
|
|
#
|
|
# Best to run as root, to avoid errors due to unreadable files or directories.
|
|
#
|
|
# Does a "find" command over all local file systems -- could take a while
|
|
# on systems with large local disk storage.
|
|
#
|
|
# Input:
|
|
# Your local file systems and inst history.
|
|
#
|
|
# Output:
|
|
# /usr/tmp/Coff.files.list:
|
|
# List of executable COFF files found on local file systems.
|
|
# (Files known to be installed using inst are intentionally
|
|
# excluded from this list -- see the next list.)
|
|
# /usr/tmp/Coff.inst_subsystems.list:
|
|
# List of inst subsystems that contain one more currently
|
|
# installed executable COFF files. These subsystems should
|
|
# be removed or upgraded when IRIX 6.5 is installed.
|
|
# /usr/tmp/Coff.files+libs.list:
|
|
# Same as Coff.files.list, but includes the shared libs each uses.
|
|
# inst'ed subsystems are excluded.
|
|
# /usr/tmp/Coff.libs.list:
|
|
# Sorted list of all COFF shared libraries referenced by files
|
|
# in Coff.files.list. inst'ed subsystems are excluded.
|
|
# /usr/tmp/Coff.errs:
|
|
# Error output produced by this script's internals.
|
|
#
|
|
# The above files are not produced if their output would be empty.
|
|
|
|
|
|
#########
|
|
# Step 1:
|
|
# Establish a safe environment and temporary workarea in /usr/tmp/coffcheck.$$
|
|
|
|
export TMPDIR=${TMPDIR:=/usr/tmp}
|
|
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/bsd:/etc:/usr/etc:/root/bin:/root/sbin:/root/usr/bin:/root/usr/sbin:/root/usr/bsd:/root/etc:/root/usr/etc
|
|
# this is needed because sort will be picked up from real root, and it's o32,
|
|
# and we don't have o32 libw.so in the miniroot. Need to set the n32 and 64
|
|
# to avoid rld warning messages when LD_LIBRARY_PATH is the only one of the
|
|
# 3 set, even though that's all we need. We shouldn't need the internal
|
|
# libs dirs from the real root, but we'll be paranoid
|
|
export LD_LIBRARY_PATH=/usr/lib:/usr/lib/internal:/lib:/root/usr/lib:/root/usr/lib/internal:/root/lib
|
|
export LD_LIBRARYN32_PATH=/usr/lib32:/usr/lib32/internal:/lib32:/root/usr/lib32:/root/usr/lib32/internal:/root/lib32
|
|
export LD_LIBRARY64_PATH=/usr/lib64:/usr/lib64/internal:/lib64:/root/usr/lib64:/root/usr/lib64/internal:/root/lib64
|
|
|
|
# Where output list and errors go, if not empty.
|
|
|
|
coff_file_list=$TMPDIR/Coff.files.list
|
|
coff_lib_list=$TMPDIR/Coff.libs.list
|
|
coff_file_lib_list=$TMPDIR/Coff.file+libs.list
|
|
coff_subsys_list=$TMPDIR/Coff.inst_subsystems.list
|
|
errlist=$TMPDIR/Coff.errs
|
|
|
|
if [ $# -gt 0 ] # help
|
|
then echo '
|
|
This command accepts no options. It checks all files on your
|
|
local filesystems for COFF executable programs. This is the
|
|
object file format from IRIX 4.0.5 and earlier releases.
|
|
These programs will no longer execute under IRIX 6.2 and later
|
|
IRIX releases.
|
|
|
|
This program will create two output files, containing a list of
|
|
subsystems installed with "inst" that contain COFF executables
|
|
(so you know which subsystems must be upgraded to be fully
|
|
functional under IRIX 6.5 ), and also a list of COFF executables
|
|
on your system that do not appear to have been installed by
|
|
"inst". Such programs are either locally built, copied from
|
|
other systems, or part of third party packages. You will need to
|
|
build or otherwise get replacements for these programs, if you
|
|
will need the functions that they provide, once you have upgraded
|
|
to IRIX 6.5. The default names of these output files are
|
|
'$coff_subsys_list and $coff_file_list',
|
|
respectively.
|
|
|
|
If you are currently running irix 4.0.x, almost all substems
|
|
installed by "inst" will be listed. A few subsystems shipped
|
|
with IRIX 5 and IRIX 6.0.1 and 6.1 still contain COFF executables
|
|
also.
|
|
'
|
|
exit 0
|
|
fi
|
|
|
|
if test ! -w /etc/passwd
|
|
then
|
|
echo You do not appear to be running this as super user.
|
|
echo Some errors may occur due to unreadable files or directories as a result.\\n
|
|
fi
|
|
|
|
tmpdir=$TMPDIR/coffcheck.$$
|
|
exitval=1
|
|
trap 'cd /; rm -fr $tmpdir; trap 0; exit $exitval' 0 1 2 3 15
|
|
mkdir $tmpdir
|
|
|
|
cd $tmpdir # Create tmp files in this temporary directory
|
|
|
|
exec 2>coffcheck.errs
|
|
|
|
#########
|
|
# Step 2:
|
|
# If someone under a different uid has already run this script,
|
|
# we won't be able to write the output files -- add a unique
|
|
# numeric suffix so we can write them:
|
|
|
|
mkunique()
|
|
{
|
|
(rm -f $1; ls -ld $1) 1>&- 2>&- || {
|
|
eval $2=$1
|
|
return
|
|
}
|
|
|
|
n=1
|
|
while (rm -f $1.$n; ls -ld $1.$n) 1>&- 2>&-
|
|
do
|
|
let n=n+1
|
|
done
|
|
eval $2=$1.$n
|
|
}
|
|
|
|
mkunique $coff_file_list coff_file_list
|
|
mkunique $coff_subsys_list coff_subsys_list
|
|
mkunique $errlist errlist
|
|
|
|
#########
|
|
# Step 3:
|
|
# Find all COFF files on local file systems.
|
|
|
|
echo Searching local filesystems for COFF executable files ... '\c'
|
|
|
|
# anything in the /stand dir is ommitted, as some of these must remain COFF
|
|
# on many systems in order for the PROM to be able to execute them.
|
|
# the first sed is in case filenames have embedded spaces or tabs
|
|
# also don't list /unix* or /root/unix*
|
|
find / -local -type f \( -perm -100 -o -perm -10 -o -perm -1 \) -print |
|
|
sed 's/[ ]/\\&/g' |
|
|
xargs file |
|
|
egrep 'MIPSEB.*COFF| mipseb ' |
|
|
sed -e 's/: .*//' -e '/^\/stand\//d' -e '/^\/root\/stand\//d' \
|
|
-e '/^\/unix/d' -e '/^\/root\/unix/d' |
|
|
sort -u > find.list
|
|
|
|
echo '\n'Preparing results ... '\c'
|
|
|
|
#########
|
|
# Step 4:
|
|
# Compile realpath - used to canonicalize 'versions long' output pathnames.
|
|
# If unable to compile, realpath defaults to a no-op command.
|
|
# A second field is expected on each line, and passed through unchanged.
|
|
|
|
export TOOLROOT=/
|
|
[ -d /usr/sysgen/root/usr/bin ] && TOOLROOT=/usr/sysgen/root
|
|
[ -d /usr/cpu/sysgen/root/usr/bin ] && TOOLROOT=/usr/cpu/sysgen/root
|
|
|
|
PATH=$TOOLROOT/usr/bin:$PATH
|
|
|
|
cat <<!! > realpath.c
|
|
char buf1[1024], buf2[1024], buf3[1024], buf4[1024];
|
|
|
|
/*
|
|
* input: two fields per line (1) pathname, (2) string (inst subsys)
|
|
* output: two fields per line (1) realpath of pathname, (2) same string
|
|
*/
|
|
|
|
main()
|
|
{
|
|
while (gets (buf1) != 0) {
|
|
sscanf (buf1, "%s %s", buf2, buf3);
|
|
realpath (buf2, buf4);
|
|
printf ("%s %s\n", buf4, buf3);
|
|
}
|
|
return 0;
|
|
}
|
|
!!
|
|
|
|
cc -o realpath realpath.c 2>/dev/null || echo cat > realpath
|
|
chmod +x realpath
|
|
|
|
#########
|
|
# Step 5:
|
|
# Obtain list of inst'd files from "versions long".
|
|
# Canonicalize these pathnames using realpath.
|
|
# Feed that stream to two command pipes (via two named pipes).
|
|
# The two command pipes calculate (1) the COFF files that
|
|
# weren't installed via inst, and (2) the inst subsystems
|
|
# which have one or more COFF files installed.
|
|
|
|
mknod pipe1 p # named pipe to feed first command pipe
|
|
mknod pipe2 p # named pipe to feed second command pipe
|
|
|
|
#############
|
|
# SubStep 5a:
|
|
# First command pipe.
|
|
# Calculate list of COFF files that were not inst'd.
|
|
|
|
< pipe1 awk '{print $1}' |
|
|
sort -u |
|
|
comm -23 find.list - > coff.file.list &
|
|
|
|
#############
|
|
# SubStep 5b:
|
|
# Second command pipe.
|
|
# Calculate list of inst subsystems having one or more COFF files.
|
|
|
|
< pipe2 sort -u |
|
|
join -j 1 -o 1.2 - find.list |
|
|
sort -u > coff.subsys.list &
|
|
|
|
#############
|
|
# SubStep 5c:
|
|
# Common source for the two command pipes.
|
|
# Obtain list of inst'd files from "versions long",
|
|
# and feed to the above two command pipes.
|
|
|
|
versions long |
|
|
awk '$1 == "f" {print "/" $NF, $4}' |
|
|
./realpath |
|
|
tee pipe1 > pipe2
|
|
|
|
wait
|
|
|
|
#########
|
|
# Step 6:
|
|
# build the list of static shared libs in use, if odump is on system
|
|
# in the standard place
|
|
if [ -s coff.file.list -a -x /usr/bin/odump ]
|
|
then
|
|
|
|
# delete everything up to the first line with a : at the end
|
|
# then save the filename, and for the lib lines (if any), delete
|
|
# everything after the libname, then join all the libnames together
|
|
# then concatenate with the filename
|
|
cat > $tmpdir/coff.sed.$$ << \EOF
|
|
/:$/ b j
|
|
d
|
|
: j
|
|
N
|
|
/:$/ {
|
|
h
|
|
s/,/ /g
|
|
s/: *\n/: STATIC\
|
|
/
|
|
s/\n.*//p
|
|
x
|
|
s/.*\n//
|
|
b j
|
|
}
|
|
/\n[ ]/ {
|
|
s/\n[ ]*/,/
|
|
s/[ ].*//
|
|
b j
|
|
}
|
|
s/,/ /g
|
|
s/: *$/: static/
|
|
p
|
|
EOF
|
|
|
|
xargs /usr/bin/odump -L < coff.file.list | \
|
|
sed -n -f $tmpdir/coff.sed.$$ > coff.file.lib.list 2>/dev/null
|
|
|
|
if [ -s coff.file.lib.list ]; then
|
|
sed -e '/: *STATIC$/d' -e 's/^[^ ]*//' -e 's/ /\
|
|
/g' coff.file.lib.list | sort -u -o coff.lib.list
|
|
fi
|
|
fi
|
|
|
|
|
|
#########
|
|
# Step 7:
|
|
# Present results to user.
|
|
|
|
echo '\n'
|
|
|
|
if [ -s coff.file.list ]
|
|
then
|
|
mv coff.file.list $coff_file_list
|
|
# build list of coff shared libs used also
|
|
echo List of files that won\'t run under IRIX 6.5 is in:
|
|
echo '\t'$coff_file_list
|
|
if [ -s coff.file.lib.list ]
|
|
then
|
|
mv coff.file.lib.list $coff_file_lib_list
|
|
echo List of files with libraries that won\'t run under IRIX 6.5 is in:
|
|
echo '\t'$coff_file_lib_list
|
|
fi
|
|
if [ -s coff.lib.list ]
|
|
then
|
|
mv coff.lib.list $coff_lib_list
|
|
echo List of COFF shared libraries that won\'t run under IRIX 6.5 is in:
|
|
echo '\t'$coff_lib_list
|
|
fi
|
|
else
|
|
echo There are apparently no files on this system that won\'t run under IRIX 6.5
|
|
fi
|
|
|
|
if [ -s coff.subsys.list ]
|
|
then
|
|
mv coff.subsys.list $coff_subsys_list
|
|
echo List of inst subsystems containing files that won\'t run under IRIX 6.5 is in:
|
|
echo '\t'$coff_subsys_list
|
|
else
|
|
echo There are no inst subsystems containing files that won\'t run under IRIX 6.5
|
|
fi
|
|
|
|
if [ -s coffcheck.errs ]
|
|
then
|
|
mv coffcheck.errs $errlist
|
|
echo Some errors occurred during check, they are in:
|
|
echo '\t'$errlist
|
|
fi
|
|
|
|
exitval=0
|