3 # fixlinks - make symlinks in the bush source tree so that there is
4 # exactly one version of any given source file.
6 # Copyright (C) 1996-2002 Free Software Foundation, Inc.
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
23 while [ $# -gt 0 ]; do
25 -s) shift; SRCDIR
=$1 ;;
28 -*) echo "$0: $1: bad option" 1>&2
29 echo "$0: usage: $0 [-hu] [-s srcdir] [linkmap]" 1>&2
36 if [ ! -d $SRCDIR/builtins
]; then
37 echo "$0: must be run with valid -s argument or from source directory" 1>&2
42 linkfile
=$SRCDIR/support
/SYMLINKS
47 if [ ! -f "$linkfile" ]; then
48 echo "$0: symlink map file \`$linkfile' does not exist"
53 LINKTEMP
=`mktemp -t linktmp.XXXXXXXX 2>/dev/null`
54 if [ -z "$LINKTEMP" ]; then
56 LINKTEMP
=${TMPDIR}/linktmp.$$
60 $rm_ltmp && rm -f ${LINKTEMP}
61 # if the user specified hard links, then do that. otherwise, try to use
62 # symlinks if they're present
63 if [ -n "$hardlinks" ]; then
65 elif (ln -s /dev
/null
${LINKTEMP}) >/dev
/null
2>&1; then
72 while read name target
80 yes) dirname=`expr "$name" ':' '^\(.*\)/[^/]*'`
81 [ -z "$dirname" ] && dirname=.
82 cp $dirname/$target $name
83 echo $target copied to
$name ;;
84 *) $LN $target $name ; echo "$name -> $target" ;;