Commit 8189a222 by Richard Kenner

Fix problems with symlinks to ".".

From-SVN: r13516
parent af3e86c2
#! /bin/sh #! /bin/sh
# Install modified versions of certain ANSI-incompatible # Install modified versions of certain ANSI-incompatible
# native System V Release 4 system include files. # native System V Release 4 system include files.
# Copyright (C) 1994, 1996 Free Software Foundation, Inc. # Copyright (C) 1994, 1996, 1997 Free Software Foundation, Inc.
# Contributed by Ron Guilmette (rfg@monkeys.com). # Contributed by Ron Guilmette (rfg@monkeys.com).
# #
# This file is part of GNU CC. # This file is part of GNU CC.
...@@ -73,7 +73,7 @@ fi ...@@ -73,7 +73,7 @@ fi
echo 'Making directories:' echo 'Making directories:'
cd ${INPUT} cd ${INPUT}
if $LINKS; then if $LINKS; then
files=`ls -LR | sed -n s/:$//p` files=`find . -follow -type d -print 2>/dev/null | sed '/^.$/d'`
else else
files=`find . -type d -print | sed '/^.$/d'` files=`find . -type d -print | sed '/^.$/d'`
fi fi
...@@ -98,6 +98,7 @@ if $LINKS; then ...@@ -98,6 +98,7 @@ if $LINKS; then
# In case $dest is relative, get to $file's dir first. # In case $dest is relative, get to $file's dir first.
cd ${INPUT} cd ${INPUT}
cd `echo ./$file | sed -n 's&[^/]*$&&p'` cd `echo ./$file | sed -n 's&[^/]*$&&p'`
rwd=`pwd`
# Check that the target directory exists. # Check that the target directory exists.
# Redirections changed to avoid bug in sh on Ultrix. # Redirections changed to avoid bug in sh on Ultrix.
(cd $dest) > /dev/null 2>&1 (cd $dest) > /dev/null 2>&1
...@@ -107,7 +108,11 @@ if $LINKS; then ...@@ -107,7 +108,11 @@ if $LINKS; then
x=`pwd` x=`pwd`
# If link leads back into ${INPUT}, # If link leads back into ${INPUT},
# make a similar link here. # make a similar link here.
if expr $x : "${INPUT}/.*" > /dev/null; then if expr "$dest" : '[^/][^/]*' >/dev/null && [ ! -h $dest ]; then
echo $file '->' $dest': Making link'
rm -fr ${LIB}/$file > /dev/null 2>&1
ln -s $dest ${LIB}/$file > /dev/null 2>&1
elif expr $x : "${INPUT}/.*" > /dev/null; then
# Y gets the actual target dir name, relative to ${INPUT}. # Y gets the actual target dir name, relative to ${INPUT}.
y=`echo $x | sed -n "s&${INPUT}/&&p"` y=`echo $x | sed -n "s&${INPUT}/&&p"`
# DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}. # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
...@@ -116,6 +121,15 @@ if $LINKS; then ...@@ -116,6 +121,15 @@ if $LINKS; then
echo $file '->' $dots$y ': Making link' echo $file '->' $dots$y ': Making link'
rm -fr ${LIB}/$file > /dev/null 2>&1 rm -fr ${LIB}/$file > /dev/null 2>&1
ln -s $dots$y ${LIB}/$file > /dev/null 2>&1 ln -s $dots$y ${LIB}/$file > /dev/null 2>&1
elif expr $x : "${rwd}/.*" > /dev/null; then
# Y gets the actual target dir name, relative to the directory where the link is.
y=`echo $x | sed -n "s&${rwd}/&&p"`
# DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
dots=`echo "$file" |
sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
echo $file '->' $dots$y ': Making link'
rm -fr ${LIB}/$file > /dev/null 2>&1
ln -s $dots$y ${LIB}/$file > /dev/null 2>&1
else else
# If the link is to outside ${INPUT}, # If the link is to outside ${INPUT},
# treat this directory as if it actually contained the files. # treat this directory as if it actually contained the files.
...@@ -1526,7 +1540,7 @@ if $LINKS; then ...@@ -1526,7 +1540,7 @@ if $LINKS; then
for file in $files; do for file in $files; do
dest=`ls -ld $file | sed -n 's/.*-> //p'` dest=`ls -ld $file | sed -n 's/.*-> //p'`
if expr "$dest" : '[^/].*' > /dev/null; then if expr "$dest" : '[^/].*' > /dev/null; then
target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"` target=${LIB}/`echo $file | sed "s|[^/]*\$|$dest|"`
if [ -f $target ]; then if [ -f $target ]; then
ln -s $dest ${LIB}/$file >/dev/null 2>&1 ln -s $dest ${LIB}/$file >/dev/null 2>&1
fi fi
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment