1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
|
#!/bin/sh
# The tmpfile is for pathconfig editing (see below).
tmpfile=pathconfig.tmp.$$
trap 'rm -f $tmpfile; exit 1' 1 2 3 15
this=$0
here=`pwd`
cd ../..
twoup=`pwd`
cd $here
MAIN_HEAP_DIR=$twoup/bin/.heap
MAIN_LIB_DIR=$twoup/lib
MAIN_CONFIG_DIR=$twoup/config
# A function to move all stable library files to a parallel directory
# hierarchy.
# The first argument must be a simple path (no / inside), and
# the second argument must be an absolute path.
move() {
if [ -d $1 ] ; then
if [ ! -d $2 ] ; then
if [ -f $2 ] ; then
echo $this: $2 exists as a non-directory.
exit 1
fi
mkdir $2
fi
cd $1
for i in * .[a-zA-Z0-9]* ; do
move $i $2/$i
done
cd ..
elif [ -f $1 ] ; then
rm -f $2
mv $1 $2
fi
}
#
# Parse command line
#
if test x"$1" = x-clean ; then
shift
CLEAN=true
else
CLEAN=false
fi
if [ $# -gt 0 ] ; then
STEM=$1
else
STEM=sml
fi
if [ -f $twoup/bin/.arch-n-opsys ]; then
ARCH_N_OPSYS=`$twoup/bin/.arch-n-opsys`
if [ "$?" = "0" ]; then
eval $ARCH_N_OPSYS
else
echo "$this: Cannot determine architecture/os."
exit 1
fi
fi
HEAP_FILE=$STEM.$HEAP_SUFFIX
LIB_DIR=$STEM.lib
if [ ! -f $HEAP_FILE ] ; then
echo "$this: The heap file $HEAP_FILE is missing."
exit 1
fi
if [ ! -d $LIB_DIR ] ; then
echo "$this: The library directory $LIB_DIR is missing."
exit 1
fi
if $CLEAN ; then
echo "cleaning $twoup/lib and $MAIN_HEAP_DIR"
rm -rf $twoup/lib/* $MAIN_HEAP_DIR/*
fi
#
# create heap and lib directories, if necessary
#
if test ! -d $MAIN_HEAP_DIR ; then
mkdir -p $MAIN_HEAP_DIR
fi
if test ! -d $MAIN_LIB_DIR ; then
mkdir -p $MAIN_LIB_DIR
fi
# Moving the heap image to its place
mv $HEAP_FILE $MAIN_HEAP_DIR/sml.$HEAP_SUFFIX
# Moving each individual library...
cd $LIB_DIR
for anchor in * ; do
if [ -d $anchor ] ; then
move $anchor $MAIN_LIB_DIR/$anchor
fi
done
cd ..
# Update the pathconfig file in $MAIN_LIB_DIR
# The awk script below replaces the original binding in $pcfile
# with its fresh counterpart should there be one. Other bindings
# are retained and brand new ones are added.
pcfile=$MAIN_LIB_DIR/pathconfig
if [ -f $pcfile ] ; then
cp $pcfile $tmpfile
fi
rm -f $pcfile
cat $LIB_DIR/pathconfig >>$tmpfile
if [ -f $MAIN_CONFIG_DIR/extrapathconfig ] ; then
cat $MAIN_CONFIG_DIR/extrapathconfig >>$tmpfile
fi
awk <$tmpfile 'NF == 2 { mapping[$1] = $2 }
NF != 2 { print $0 }
END { for (i in mapping) print i, mapping[i] }' \
| sort >$pcfile
rm -r $LIB_DIR
rm -f $tmpfile
|