Landfall

tools/install.sh

129:152c4fc0a967
2021-01-16 Paul Boddie Added missing Makefiles.
     1 #!/bin/sh     2      3 THISDIR=`dirname "$0"`     4 DIRNAME=`readlink -f "$THISDIR/.."`     5 PROGNAME=`basename "$0"`     6      7 if [ "$1" = '--help' ]; then     8     cat 1>&2 <<EOF     9 Usage: $PROGNAME <l4-directory> [ --clean ]    10     11 Copy the distributed packages into the "pkg" hierarchy found within the    12 specified directory. Also copy the distributed configuration examples into the    13 "conf" hierarchy.    14     15 The indicated directory need not be called "l4", but it must at least have a    16 "conf" directory and a "pkg" directory inside it.    17     18 Specifying --clean removes copied objects.    19 EOF    20     exit 1    21 fi    22     23 # Test for a directory argument and whether it exists.    24     25 if [ ! "$1" ] || [ ! -e "$1" ] ; then    26     cat 1>&2 <<EOF    27 Please indicate the l4 directory containing a pkg directory hierarchy.    28 EOF    29     exit 1    30 fi    31     32 # Test for an appropriate directory.    33     34 if [ ! -e "$1/pkg" ] ; then    35     cat 1>&2 <<EOF    36 The indicated directory does not appear to contain a pkg directory hierarchy.    37 EOF    38     exit 1    39 fi    40     41 L4DIR=$1    42     43 # Determine the mode.    44     45 if [ "$2" = '--clean' ] ; then    46     CLEAN=$2    47 else    48     CLEAN=    49 fi    50     51 # Check the configuration, if possible.    52     53 "$THISDIR/checkconfig.sh" -q "$L4DIR"    54     55 # Generate binaries if appropriate.    56     57 if [ ! "$CLEAN" ] ; then    58     if ! "$THISDIR/makefonts.sh" -q ; then    59         cat 1>&2 <<EOF    60     61 Install halted due to font generation problem.    62 EOF    63         exit 1    64     fi    65 fi    66     67 # Copy (or remove) each of the objects.    68     69 for OBJTYPE in 'conf' 'pkg' ; do    70     TARGETDIR=`readlink -f "$L4DIR"`/$OBJTYPE    71     SOURCEDIR="$DIRNAME/$OBJTYPE"    72     73     # If cleaning, remove all objects.    74     75     if [ "$CLEAN" ] ; then    76         for OBJECT in "$SOURCEDIR/"* ; do    77             OBJNAME=`basename "$OBJECT"`    78             ORIGIN=`readlink -f "$OBJECT"`    79             TARGET="$TARGETDIR/$OBJNAME"    80     81             if [ -d "$TARGET" ] ; then    82                 rm -r --one-file-system "$TARGET"    83             else    84                 rm "$TARGET"    85             fi    86         done    87     88         continue    89     fi    90     91     # Make directories.    92     93     for OBJECT in `find "$SOURCEDIR" -type d -print` ; do    94         ORIGIN=`readlink -f "$OBJECT"`    95         RELPATH=${ORIGIN#$SOURCEDIR/}    96     97         # Skip top-level directories.    98     99         if [ "$RELPATH" = "$ORIGIN" ]; then   100             continue   101         fi   102    103         TARGET="$TARGETDIR/$RELPATH"   104    105         if [ ! -e "$TARGET" ]; then   106             mkdir "$TARGET"   107         fi   108     done   109    110     # Copy new files.   111    112     for OBJECT in `find "$SOURCEDIR" -type f -not -name '.*' -not -name '*.orig' -not -name '*.rej' -print` ; do   113         ORIGIN=`readlink -f "$OBJECT"`   114         RELPATH=${ORIGIN#$SOURCEDIR/}   115         TARGET="$TARGETDIR/$RELPATH"   116    117         if [ ! -e "$TARGET" ] || [ "$ORIGIN" -nt "$TARGET" ] ; then   118             cp "$ORIGIN" "$TARGET"   119         fi   120     done   121    122     # Remove obsolete files.   123    124     for OBJECT in "$SOURCEDIR/"* ; do   125         OBJNAME=`basename "$OBJECT"`   126         ORIGIN=`readlink -f "$OBJECT"`   127    128         # Examine the target object directory for files that are not provided   129         # by the distribution.   130    131         TARGET="$TARGETDIR/$OBJNAME"   132    133         for FILENAME in `find "$TARGET" -type f -not -name '.*' -not -name '*.orig' -not -name '*.rej' -print` ; do   134             PATHNAME=`readlink -f "$FILENAME"`   135             RELPATH=${PATHNAME#$TARGET}   136             SOURCE="$ORIGIN/$RELPATH"   137    138             if [ ! -e "$SOURCE" ] ; then   139                 rm "$PATHNAME"   140             fi   141         done   142    143         # Remove obsolete directories.   144    145         for FILENAME in `find "$TARGET" -depth -type d -print` ; do   146             PATHNAME=`readlink -f "$FILENAME"`   147             RELPATH=${PATHNAME#$TARGET}   148             SOURCE="$ORIGIN/$RELPATH"   149    150             if [ ! -e "$SOURCE" ] ; then   151                 rmdir "$PATHNAME"   152             fi   153         done   154     done   155 done