]>
Commit | Line | Data |
---|---|---|
28e9041c | 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 | ||
9 | prog=$0 | |
10 | srcdir=$1 | |
11 | ignore="$2" | |
12 | ||
13 | ignore_additional=". .. CVS" | |
14 | ||
15 | # If we were invoked with a relative path name, adjust ${prog} to work | |
16 | # in subdirs. | |
17 | case ${prog} in | |
18 | /*) ;; | |
19 | *) prog=../${prog} ;; | |
20 | esac | |
21 | ||
22 | # Set newsrcdir to something subdirectories can use. | |
23 | case ${srcdir} in | |
24 | /*) newsrcdir=${srcdir} ;; | |
25 | *) newsrcdir=../${srcdir} ;; | |
26 | esac | |
27 | ||
28 | for 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 | |
46 | done | |
47 | ||
48 | exit 0 |