Admin/cvs-copy
author haftmann
Mon, 06 Jun 2005 14:12:07 +0200
changeset 16301 f9f2e1643593
parent 16280 d7f8c48d5acb
permissions -rwxr-xr-x
migrated scripts to new webiste
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12721
226fc0e2e7e3 #!/usr/bin/env bash;
wenzelm
parents: 9796
diff changeset
     1
#!/usr/bin/env bash
9781
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
     2
#
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
     3
# $Id$
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
     4
#
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
     5
# cvs-copy - make copy of CVS controlled directory hierarchy
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
     6
#
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
     7
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
     8
## diagnostics
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
     9
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    10
PRG=$(basename "$0")
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    11
THIS=$(cd $(dirname "$0"); echo "$PWD")
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    12
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    13
function usage()
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    14
{
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    15
  echo
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    16
  echo "Usage: $PRG FROMDIR TODIR"
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    17
  echo
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    18
  echo "  Make copy of CVS controlled directory hierarchy"
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    19
  exit 1
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    20
}
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    21
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    22
function fail()
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    23
{
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    24
  echo "$1" >&2
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    25
  exit 2
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    26
}
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    27
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    28
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    29
## process command line
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    30
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    31
[ "$#" -ne 2 ] && usage
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    32
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    33
FROMDIR="$1"; shift
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    34
TODIR="$1"; shift
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    35
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    36
16279
4cc37b145b97 added detection for GNU cp
haftmann
parents: 12721
diff changeset
    37
## GNU cp required
4cc37b145b97 added detection for GNU cp
haftmann
parents: 12721
diff changeset
    38
4cc37b145b97 added detection for GNU cp
haftmann
parents: 12721
diff changeset
    39
CP=cp
4cc37b145b97 added detection for GNU cp
haftmann
parents: 12721
diff changeset
    40
type -path gcp >/dev/null && CP=gcp
4cc37b145b97 added detection for GNU cp
haftmann
parents: 12721
diff changeset
    41
4cc37b145b97 added detection for GNU cp
haftmann
parents: 12721
diff changeset
    42
9781
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    43
## main
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    44
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    45
function copy ()
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    46
{
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    47
  local PREFIX="$1"
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    48
  local TYPE NAME REST
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    49
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    50
  [ -d "$FROMDIR/${PREFIX}CVS" ] || fail "Bad CVS directory '$FROMDIR/${PREFIX}.'"
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    51
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    52
  { cat "$FROMDIR/${PREFIX}CVS/Entries" || \
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    53
    fail "Cannot read '$FROMDIR/${PREFIX}CVS/Entries'"; } | \
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    54
  {
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    55
    ORIG_IFS="$IFS"
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    56
    IFS="/"
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    57
    while read TYPE NAME REST
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    58
    do
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    59
      if [ -n "$NAME" ]; then
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    60
        if [ "$TYPE" = D ]; then
9796
wenzelm
parents: 9781
diff changeset
    61
          echo "X ${PREFIX}$NAME"
9781
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    62
          mkdir -p "$TODIR/${PREFIX}$NAME" || fail "Bad directory '$TODIR/${PREFIX}$NAME'"
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    63
          copy "${PREFIX}$NAME/" || return "$?"
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    64
        else
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    65
          { [ ! -d "$TODIR/${PREFIX}$NAME" ] && \
16280
d7f8c48d5acb added detection for GNU cp
haftmann
parents: 16279
diff changeset
    66
            $CP -af "$FROMDIR/${PREFIX}$NAME" "$TODIR/${PREFIX}$NAME"; } || \
9781
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    67
          fail "Cannot install '$TODIR/${PREFIX}$NAME'"
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    68
        fi
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    69
      fi
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    70
    done
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    71
    IFS="$ORIG_IFS"
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    72
  }
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    73
}
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    74
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    75
mkdir -p "$TODIR" || fail "Bad directory '$TODIR'"
32378f1c2f17 cvs-copy - make copy of CVS controlled directory hierarchy;
wenzelm
parents:
diff changeset
    76
copy ""