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