symlink-tree revision 89857
133965Sjdp#!/bin/sh
233965Sjdp# Create a symlink tree.
333965Sjdp#
433965Sjdp# Syntax: symlink-tree srcdir "ignore1 ignore2 ..."
533965Sjdp#
633965Sjdp# where srcdir is the directory to create a symlink tree to,
733965Sjdp# and "ignoreN" is a list of files/directories to ignore.
833965Sjdp
933965Sjdpprog=$0
1033965Sjdpsrcdir=$1
1133965Sjdpignore="$2"
1233965Sjdp
1377298Sobrienif test $# -lt 1; then
1477298Sobrien  echo "symlink-tree error:  Usage: symlink-tree srcdir \"ignore1 ignore2 ...\""
1577298Sobrien  exit 1
1677298Sobrienfi
1777298Sobrien
1833965Sjdpignore_additional=". .. CVS"
1933965Sjdp
2033965Sjdp# If we were invoked with a relative path name, adjust ${prog} to work
2133965Sjdp# in subdirs.
2233965Sjdpcase ${prog} in
2389857Sobrien/* | [A-Za-z]:[\\/]*) ;;
2433965Sjdp*) prog=../${prog} ;;
2533965Sjdpesac
2633965Sjdp
2733965Sjdp# Set newsrcdir to something subdirectories can use.
2833965Sjdpcase ${srcdir} in
2989857Sobrien/* | [A-Za-z]:[\\/]*) newsrcdir=${srcdir} ;;
3033965Sjdp*) newsrcdir=../${srcdir} ;;
3133965Sjdpesac
3233965Sjdp
3333965Sjdpfor f in `ls -a ${srcdir}`; do
3433965Sjdp  if [ -d ${srcdir}/$f ]; then
3533965Sjdp    found=
3633965Sjdp    for i in ${ignore} ${ignore_additional}; do
3733965Sjdp      if [ "$f" = "$i" ]; then
3833965Sjdp	found=yes
3933965Sjdp      fi
4033965Sjdp    done
4133965Sjdp    if [ -z "${found}" ]; then
4238889Sjdp      echo "$f		..working in"
4333965Sjdp      if [ -d $f ]; then true; else mkdir $f; fi
4433965Sjdp      (cd $f; ${prog} ${newsrcdir}/$f "${ignore}")
4533965Sjdp    fi
4633965Sjdp  else
4738889Sjdp    echo "$f		..linked"
4833965Sjdp    rm -f $f
4933965Sjdp    ln -s ${srcdir}/$f .
5033965Sjdp  fi
5133965Sjdpdone
5233965Sjdp
5333965Sjdpexit 0
54