1#!/bin/sh
2# Create a symlink tree.
3#
4# Syntax: symlink-tree srcdir "ignore1 ignore2 ..."
5#
6# where srcdir is the directory to create a symlink tree to,
7# and "ignoreN" is a list of files/directories to ignore.
8
9prog=$0
10srcdir=$1
11ignore="$2"
12
13ignore_additional=". .. CVS"
14
15# If we were invoked with a relative path name, adjust ${prog} to work
16# in subdirs.
17case ${prog} in
18/*) ;;
19*) prog=../${prog} ;;
20esac
21
22# Set newsrcdir to something subdirectories can use.
23case ${srcdir} in
24/*) newsrcdir=${srcdir} ;;
25*) newsrcdir=../${srcdir} ;;
26esac
27
28for f in `ls -a ${srcdir}`; do
29  if [ -d ${srcdir}/$f ]; then
30    found=
31    for i in ${ignore} ${ignore_additional}; do
32      if [ "$f" = "$i" ]; then
33	found=yes
34      fi
35    done
36    if [ -z "${found}" ]; then
37      echo "$f		..working in"
38      if [ -d $f ]; then true; else mkdir $f; fi
39      (cd $f; ${prog} ${newsrcdir}/$f "${ignore}")
40    fi
41  else
42    echo "$f		..linked"
43    rm -f $f
44    ln -s ${srcdir}/$f .
45  fi
46done
47
48exit 0
49