1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/tools/install.sh Sun May 13 01:34:16 2018 +0200
1.3 @@ -0,0 +1,73 @@
1.4 +#!/bin/sh
1.5 +
1.6 +THISDIR=`dirname "$0"`
1.7 +DIRNAME=`realpath "$THISDIR/.."`
1.8 +PROGNAME=`basename "$0"`
1.9 +
1.10 +if [ "$1" = '--help' ]; then
1.11 + cat 1>&2 <<EOF
1.12 +Usage: $PROGNAME <l4-directory> [ --clean ]
1.13 +
1.14 +Copy the distributed packages into the "pkg" hierarchy found within the
1.15 +specified directory. Also copy the distributed configuration examples into the
1.16 +"conf" hierarchy.
1.17 +
1.18 +The indicated directory need not be called "l4", but it must at least have a
1.19 +"conf" directory and a "pkg" directory inside it.
1.20 +
1.21 +Specifying --clean removes copied objects.
1.22 +EOF
1.23 + exit 1
1.24 +fi
1.25 +
1.26 +# Test for a directory argument and whether it exists.
1.27 +
1.28 +if [ ! "$1" ] || [ ! -e "$1" ] ; then
1.29 + cat 1>&2 <<EOF
1.30 +Please indicate the l4 directory containing a pkg directory hierarchy.
1.31 +EOF
1.32 + exit 1
1.33 +fi
1.34 +
1.35 +# Test for an appropriate directory.
1.36 +
1.37 +if [ ! -e "$1/pkg" ] ; then
1.38 + cat 1>&2 <<EOF
1.39 +The indicated directory does not appear to contain a pkg directory hierarchy.
1.40 +EOF
1.41 + exit 1
1.42 +fi
1.43 +
1.44 +L4DIR=$1
1.45 +
1.46 +# Copy (or remove) each of the objects.
1.47 +
1.48 +if [ "$2" = '--clean' ] ; then
1.49 + CLEAN=$2
1.50 +else
1.51 + CLEAN=
1.52 +fi
1.53 +
1.54 +for OBJTYPE in 'conf' 'pkg' ; do
1.55 + OBJDIR=`realpath "$L4DIR"`/$OBJTYPE
1.56 +
1.57 + for OBJECT in "$DIRNAME/$OBJTYPE/"* ; do
1.58 + OBJNAME=`basename "$OBJECT"`
1.59 + ORIGIN=`realpath "$OBJECT"`
1.60 + TARGET="$OBJDIR/$OBJNAME"
1.61 +
1.62 + if [ "$CLEAN" ] ; then
1.63 + if [ -d "$TARGET" ]; then
1.64 + rm -r --one-file-system "$TARGET"
1.65 + else
1.66 + rm "$TARGET"
1.67 + fi
1.68 + else
1.69 + if [ -d "$ORIGIN" ]; then
1.70 + cp -R "$ORIGIN" "$TARGET"
1.71 + else
1.72 + cp "$ORIGIN" "$TARGET"
1.73 + fi
1.74 + fi
1.75 + done
1.76 +done