3
# mkbuildtree <build tree>
5
# Creates symbolic links in <build tree> for the sparse tree
6
# in the current directory.
8
# Script to determine the relative path between two directories.
9
# Copyright (c) D. J. Hawkey Jr. 2002
10
# Fixed for Xen project by K. Fraser in 2003.
15
if [ "$1" != "/" -a "${1##*[^/]}" = "/" ]; then
20
if [ "$2" != "/" -a "${2##*[^/]}" = "/" ]; then
27
[ "${1%%[^/]*}" != "/" ] && cd $1 && SRCPATH=$PWD
28
[ "${2%%[^/]*}" != "/" ] && cd $2 && DESTPATH=$PWD
29
[ "$CWD" != "$PWD" ] && cd $CWD
33
[ "$SRCPATH" = "$DESTPATH" ] && DESTPATH="." && return
34
[ "$SRCPATH" = "/" ] && DESTPATH=${DESTPATH#?} && return
36
while [ "$BASEPATH/" != "${DESTPATH%${DESTPATH#$BASEPATH/}}" ]; do
37
BASEPATH=${BASEPATH%/*}
40
SRCPATH=${SRCPATH#$BASEPATH}
41
DESTPATH=${DESTPATH#$BASEPATH}
42
DESTPATH=${DESTPATH#?}
43
while [ -n "$SRCPATH" ]; do
45
DESTPATH="../$DESTPATH"
48
[ -z "$BASEPATH" ] && BASEPATH="/"
49
[ "${DESTPATH##*[^/]}" = "/" ] && DESTPATH=${DESTPATH%?}
52
# relative_lndir <target_dir>
53
# Creates a tree of symlinks in the current working directory that mirror
54
# real files in <target_dir>. <target_dir> should be relative to the current
55
# working directory. Symlinks in <target_dir> are ignored. Source-control files
59
local SYMLINK_DIR REAL_DIR pref i j
64
for i in `find . -type d | grep -v SCCS`; do
65
[ -d $SYMLINK_DIR/$i ] || mkdir -p $SYMLINK_DIR/$i
68
pref=`echo $i | sed -e 's#/[^/]*#../#g' -e 's#^\.##'`
69
for j in `find . -type f -o -type l -maxdepth 1`; do
70
ln -sf ${pref}${REAL_DIR}/$i/$j ${SYMLINK_DIR}/$i/$j
77
[ "$1" == "" ] && { echo "Syntax: $0 <linux tree to xenify>"; exit 1; }
79
# Get absolute path to the destination directory
85
# Get absolute path to the source directory
88
# Get name of sparse directory
91
# Get path to source, relative to destination
92
abs_to_rel ${AD} ${AS}
95
# We now work from the destination directory
99
find sys -type l | while read f
101
case $(readlink $f) in
108
if [ -f ${AD}/BUILDING ]; then
109
# Create symlinks of files and directories which exist in the sparse source
110
(cd sys && relative_lndir ../${RS}/sys)
112
# Create symlinks of files and directories which exist in the sparse source