QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1611|回复: 1

一个lndir 的shell脚本

[复制链接]
发表于 2006-5-16 17:27:06 | 显示全部楼层 |阅读模式
[code:1]
#! /bin/sh

# lndir - create shadow link tree
#
# $XConsortium: lndir.sh,v 1.8 91/04/15 17:55:03 rws Exp $
#
# Used to create a copy of the a directory tree that has links for all
# non- directories (except those named RCS or SCCS).  If you are
# building the distribution on more than one machine, you should use
# this script.
#
# If your master sources are located in /usr/local/src/X and you would like
# your link tree to be in /usr/local/src/new-X, do the following:
#
#         %  mkdir /usr/local/src/new-X
#        %  cd /usr/local/src/new-X
#         %  lndir ../X

USAGE="Usage: $0 fromdir [todir]"

if [ $# -lt 1 -o $# -gt 2 ]
then
        echo "$USAGE"
        exit 1
fi

DIRFROM=$1

if [ $# -eq 2 ];
then
        DIRTO=$2
else
        DIRTO=.
fi

if [ ! -d $DIRTO ]
then
        echo "$0: $DIRTO is not a directory"
        echo "$USAGE"
        exit 2
fi

cd $DIRTO

if [ ! -d $DIRFROM ]
then
        echo "$0: $DIRFROM is not a directory"
        echo "$USAGE"
        exit 2
fi

pwd=`pwd`

if [ `(cd $DIRFROM; pwd)` = $pwd ]
then
        echo "$pwd: FROM and TO are identical!"
        exit 1
fi

for file in `ls -af $DIRFROM`
do
    if [ ! -d $DIRFROM/$file ]
    then
            ln -s $DIRFROM/$file .
    else
            if [ $file != RCS -a $file != SCCS -a $file != . -a $file != .. ]
            then
                    echo $file:
                    mkdir $file
                    (cd $file
                     pwd=`pwd`
                     case "$DIRFROM" in
                             /*) ;;
                             *)  DIRFROM=../$DIRFROM ;;
                     esac
                     if [ `(cd $DIRFROM/$file; pwd)` = $pwd ]
                     then
                            echo "$pwd: FROM and TO are identical!"
                            exit 1
                     fi
                     $0 $DIRFROM/$file
                    )
            fi
    fi
done[/code:1][/code]
 楼主| 发表于 2006-5-16 17:29:31 | 显示全部楼层
BTW:
kernel的编译选项:
make O=/home/your/linux-o
将编译的后目标文件放在你想要的目录.

这样不会破坏源代码目录.

这两种方法都很好.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-11-2 16:32 , Processed in 0.042902 second(s), 16 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表