#!/bin/sh
|
#!/bin/sh
|
# Create a symlink tree.
|
# Create a symlink tree.
|
#
|
#
|
# Copyright (C) 1995, 2000, 2003 Free Software Foundation, Inc.
|
# Copyright (C) 1995, 2000, 2003 Free Software Foundation, Inc.
|
#
|
#
|
# This file is free software; you can redistribute it and/or modify
|
# This file is free software; you can redistribute it and/or modify
|
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
# the Free Software Foundation; either version 2 of the License, or
|
# the Free Software Foundation; either version 2 of the License, or
|
# (at your option) any later version.
|
# (at your option) any later version.
|
#
|
#
|
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
#
|
#
|
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
# Boston, MA 02110-1301, USA.
|
# Boston, MA 02110-1301, USA.
|
#
|
#
|
# As a special exception to the GNU General Public License, if you
|
# As a special exception to the GNU General Public License, if you
|
# distribute this file as part of a program that contains a
|
# distribute this file as part of a program that contains a
|
# configuration script generated by Autoconf, you may include it under
|
# configuration script generated by Autoconf, you may include it under
|
# the same distribution terms that you use for the rest of that program.
|
# the same distribution terms that you use for the rest of that program.
|
#
|
#
|
# Please report bugs to
|
# Please report bugs to
|
# and send patches to .
|
# and send patches to .
|
|
|
# Syntax: symlink-tree srcdir "ignore1 ignore2 ..."
|
# Syntax: symlink-tree srcdir "ignore1 ignore2 ..."
|
#
|
#
|
# where srcdir is the directory to create a symlink tree to,
|
# where srcdir is the directory to create a symlink tree to,
|
# and "ignoreN" is a list of files/directories to ignore.
|
# and "ignoreN" is a list of files/directories to ignore.
|
|
|
prog=$0
|
prog=$0
|
srcdir=$1
|
srcdir=$1
|
ignore="$2"
|
ignore="$2"
|
|
|
if test $# -lt 1; then
|
if test $# -lt 1; then
|
echo "symlink-tree error: Usage: symlink-tree srcdir \"ignore1 ignore2 ...\""
|
echo "symlink-tree error: Usage: symlink-tree srcdir \"ignore1 ignore2 ...\""
|
exit 1
|
exit 1
|
fi
|
fi
|
|
|
ignore_additional=". .. CVS"
|
ignore_additional=". .. CVS"
|
|
|
# If we were invoked with a relative path name, adjust ${prog} to work
|
# If we were invoked with a relative path name, adjust ${prog} to work
|
# in subdirs.
|
# in subdirs.
|
case ${prog} in
|
case ${prog} in
|
/* | [A-Za-z]:[\\/]*) ;;
|
/* | [A-Za-z]:[\\/]*) ;;
|
*) prog=../${prog} ;;
|
*) prog=../${prog} ;;
|
esac
|
esac
|
|
|
# Set newsrcdir to something subdirectories can use.
|
# Set newsrcdir to something subdirectories can use.
|
case ${srcdir} in
|
case ${srcdir} in
|
/* | [A-Za-z]:[\\/]*) newsrcdir=${srcdir} ;;
|
/* | [A-Za-z]:[\\/]*) newsrcdir=${srcdir} ;;
|
*) newsrcdir=../${srcdir} ;;
|
*) newsrcdir=../${srcdir} ;;
|
esac
|
esac
|
|
|
for f in `ls -a ${srcdir}`; do
|
for f in `ls -a ${srcdir}`; do
|
if [ -d ${srcdir}/$f ]; then
|
if [ -d ${srcdir}/$f ]; then
|
found=
|
found=
|
for i in ${ignore} ${ignore_additional}; do
|
for i in ${ignore} ${ignore_additional}; do
|
if [ "$f" = "$i" ]; then
|
if [ "$f" = "$i" ]; then
|
found=yes
|
found=yes
|
fi
|
fi
|
done
|
done
|
if [ -z "${found}" ]; then
|
if [ -z "${found}" ]; then
|
echo "$f ..working in"
|
echo "$f ..working in"
|
if [ -d $f ]; then true; else mkdir $f; fi
|
if [ -d $f ]; then true; else mkdir $f; fi
|
(cd $f; ${prog} ${newsrcdir}/$f "${ignore}")
|
(cd $f; ${prog} ${newsrcdir}/$f "${ignore}")
|
fi
|
fi
|
else
|
else
|
echo "$f ..linked"
|
echo "$f ..linked"
|
rm -f $f
|
rm -f $f
|
ln -s ${srcdir}/$f .
|
ln -s ${srcdir}/$f .
|
fi
|
fi
|
done
|
done
|
|
|
exit 0
|
exit 0
|
|
|