1 #!/bin/sh 2 3 THISDIR=`dirname "$0"` 4 DIRNAME=`realpath "$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 # Copy (or remove) each of the objects. 44 45 if [ "$2" = '--clean' ] ; then 46 CLEAN=$2 47 else 48 CLEAN= 49 fi 50 51 for OBJTYPE in 'conf' 'pkg' ; do 52 OBJDIR=`realpath "$L4DIR"`/$OBJTYPE 53 54 for OBJECT in "$DIRNAME/$OBJTYPE/"* ; do 55 OBJNAME=`basename "$OBJECT"` 56 ORIGIN=`realpath "$OBJECT"` 57 TARGET="$OBJDIR/$OBJNAME" 58 59 if [ "$CLEAN" ] ; then 60 if [ -d "$TARGET" ]; then 61 rm -r --one-file-system "$TARGET" 62 else 63 rm "$TARGET" 64 fi 65 else 66 if [ -d "$ORIGIN" ]; then 67 cp -R "$ORIGIN" "$TARGET" 68 else 69 cp "$ORIGIN" "$TARGET" 70 fi 71 fi 72 done 73 done