为何uboot中会使用 rm -f来删除目录?

系统安装、升级讨论
版面规则
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
回复
mobilefzb
帖子: 224
注册时间: 2010-05-18 22:23

为何uboot中会使用 rm -f来删除目录?

#1

帖子 mobilefzb » 2010-07-21 14:03

我搞不懂为何uboot就能通过…………
请帮我解答下下面红色的部分

#!/bin/sh -e

# Script to create header files and links to configure
# U-Boot for a specific board.
#
# Parameters: Target Architecture CPU Board [VENDOR] [SOC]
#
# (C) 2002-2006 DENX Software Engineering, Wolfgang Denk <wd@denx.de>
#

APPEND=no # Default: Create new config file
BOARD_NAME="" # Name to print in make output
TARGETS=""

while [ $# -gt 0 ] ; do
case "$1" in
--) shift ; break ;;
-a) shift ; APPEND=yes ;;
-n) shift ; BOARD_NAME="${1%%_config}" ; shift ;;
-t) shift ; TARGETS="`echo $1 | sed 's:_: :g'` ${TARGETS}" ; shift ;;
*) break ;;
esac
done

[ "${BOARD_NAME}" ] || BOARD_NAME="$1"

[ $# -lt 4 ] && exit 1
[ $# -gt 6 ] && exit 1

if [ "${ARCH}" -a "${ARCH}" != "$2" ]; then
echo "Failed: \$ARCH=${ARCH}, should be '$2' for ${BOARD_NAME}" 1>&2
exit 1
fi

echo "Configuring for ${BOARD_NAME} board..."

#
# Create link to architecture specific headers
#
if [ "$SRCTREE" != "$OBJTREE" ] ; then
mkdir -p ${OBJTREE}/include
mkdir -p ${OBJTREE}/include2
cd ${OBJTREE}/include2
rm -f asm
ln -s ${SRCTREE}/arch/$2/include/asm asm
LNPREFIX=${SRCTREE}/arch/$2/include/asm/
cd ../include
rm -f asm
ln -s ${SRCTREE}/arch/$2/include/asm asm
else
cd ./include
rm -f asm
ln -s ../arch/$2/include/asm asm
fi

rm -f asm/arch

if [ -z "$6" -o "$6" = "NULL" ] ; then
ln -s ${LNPREFIX}arch-$3 asm/arch
else
ln -s ${LNPREFIX}arch-$6 asm/arch
fi

if [ "$2" = "arm" ] ; then
rm -f asm/proc
ln -s ${LNPREFIX}proc-armv asm/proc
fi

#
# Create include file for Make
#
echo "ARCH = $2" > config.mk
echo "CPU = $3" >> config.mk
echo "BOARD = $4" >> config.mk

[ "$5" ] && [ "$5" != "NULL" ] && echo "VENDOR = $5" >> config.mk

[ "$6" ] && [ "$6" != "NULL" ] && echo "SOC = $6" >> config.mk

# Assign board directory to BOARDIR variable
if [ -z "$5" -o "$5" = "NULL" ] ; then
BOARDDIR=$4
else
BOARDDIR=$5/$4
fi

#
# Create board specific header file
#
if [ "$APPEND" = "yes" ] # Append to existing config file
then
echo >> config.h
else
> config.h # Create new config file
fi
echo "/* Automatically generated - do not edit */" >>config.h

for i in ${TARGETS} ; do
echo "#define CONFIG_MK_${i} 1" >>config.h ;
done

cat << EOF >> config.h
#define CONFIG_BOARDDIR board/$BOARDDIR
#include <config_defaults.h>
#include <configs/$1.h>
#include <asm/config.h>
EOF

exit 0

恳求解答,小弟我感激不尽
thorne
帖子: 660
注册时间: 2008-10-08 22:01

Re: 为何uboot中会使用 rm -f来删除目录?

#2

帖子 thorne » 2010-07-21 14:20

rmdir命令只能够删除空的目录
要删除非空目录
需用
rm -f

代码: 全选

其实我是个Debian GNU/Linux用户
Octave script :http://forum.ubuntu.org.cn/viewtopic.php?f=35&t=254511
Octave中文:http://forum.ubuntu.org.cn/viewtopic.php?f=35&t=318969
mobilefzb
帖子: 224
注册时间: 2010-05-18 22:23

Re: 为何uboot中会使用 rm -f来删除目录?

#3

帖子 mobilefzb » 2010-07-21 14:35

但是如果自己输入命令 rm -f 目录 是不会删除目录的,rm的帮助文档也说明了,如果要删除路径 需要 -r的参数

但是uboot里面运行这些却不会出错?这是为何?

楼上的意思看的不是很懂,这个和rmdir有啥关系?
恳求解答
thorne
帖子: 660
注册时间: 2008-10-08 22:01

Re: 为何uboot中会使用 rm -f来删除目录?

#4

帖子 thorne » 2010-07-21 14:40

哦 搞错了
确定那个uboot删除的是目录么?
是不是它用了 alias的?
关于rmdir什么的 当我没说

代码: 全选

其实我是个Debian GNU/Linux用户
Octave script :http://forum.ubuntu.org.cn/viewtopic.php?f=35&t=254511
Octave中文:http://forum.ubuntu.org.cn/viewtopic.php?f=35&t=318969
回复