diff options
author | imp <imp@FreeBSD.org> | 2014-08-01 00:00:46 +0000 |
---|---|---|
committer | imp <imp@FreeBSD.org> | 2014-08-01 00:00:46 +0000 |
commit | 9776427d41e08427506e63f477dbe386f05063f0 (patch) | |
tree | 1a86c31c3a1dd4e7a42c4df9ea54dcd909284018 /tools | |
parent | e8c9682c95273549ee3b01c5e94150c8080dfd51 (diff) | |
download | FreeBSD-src-9776427d41e08427506e63f477dbe386f05063f0.zip FreeBSD-src-9776427d41e08427506e63f477dbe386f05063f0.tar.gz |
Use rm -x only on FreeBSD 10 and newer. Many people still build from
older hosts, which still works, so don't break that gratuitously.
MFC After: 3 days
Diffstat (limited to 'tools')
-rw-r--r-- | tools/tools/nanobsd/nanobsd.sh | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/tools/tools/nanobsd/nanobsd.sh b/tools/tools/nanobsd/nanobsd.sh index 600d112..745ea1a 100644 --- a/tools/tools/nanobsd/nanobsd.sh +++ b/tools/tools/nanobsd/nanobsd.sh @@ -178,6 +178,15 @@ SRCCONF=${SRCCONF:=/dev/null} # ####################################################################### +# rm doesn't know -x prior to FreeBSD 10, so cope with a variety of build +# hosts for now. +nano_rm ( ) { + case $(uname -r) in + 7*|8*|9*) rm $* ;; + *) rm -x $* ;; + esac +} + # run in the world chroot, errors fatal CR() { @@ -200,9 +209,9 @@ nano_cleanup ( ) ( clean_build ( ) ( pprint 2 "Clean and create object directory (${MAKEOBJDIRPREFIX})" - if ! rm -xrf ${MAKEOBJDIRPREFIX}/ > /dev/null 2>&1 ; then + if ! nano_rm -rf ${MAKEOBJDIRPREFIX}/ > /dev/null 2>&1 ; then chflags -R noschg ${MAKEOBJDIRPREFIX}/ - rm -xr ${MAKEOBJDIRPREFIX}/ + nano_rm -r ${MAKEOBJDIRPREFIX}/ fi mkdir -p ${MAKEOBJDIRPREFIX} printenv > ${MAKEOBJDIRPREFIX}/_.env @@ -256,17 +265,17 @@ build_kernel ( ) ( clean_world ( ) ( if [ "${NANO_OBJ}" != "${MAKEOBJDIRPREFIX}" ]; then pprint 2 "Clean and create object directory (${NANO_OBJ})" - if ! rm -rxf ${NANO_OBJ}/ > /dev/null 2>&1 ; then + if ! nano_rm -rf ${NANO_OBJ}/ > /dev/null 2>&1 ; then chflags -R noschg ${NANO_OBJ} - rm -xr ${NANO_OBJ}/ + nano_rm -r ${NANO_OBJ}/ fi mkdir -p ${NANO_OBJ} ${NANO_WORLDDIR} printenv > ${NANO_OBJ}/_.env else pprint 2 "Clean and create world directory (${NANO_WORLDDIR})" - if ! rm -rxf ${NANO_WORLDDIR}/ > /dev/null 2>&1 ; then + if ! nano_rm -rf ${NANO_WORLDDIR}/ > /dev/null 2>&1 ; then chflags -R noschg ${NANO_WORLDDIR} - rm -rxf ${NANO_WORLDDIR}/ + nano_rm -rf ${NANO_WORLDDIR}/ fi mkdir -p ${NANO_WORLDDIR} fi @@ -378,7 +387,7 @@ setup_nanobsd ( ) ( cd usr/local/etc find . -print | cpio -dumpl ../../../etc/local cd .. - rm -rf etc + nano_rm -rf etc ln -s ../../etc/local etc ) fi @@ -400,7 +409,7 @@ setup_nanobsd ( ) ( echo "mount -o ro /dev/${NANO_DRIVE}s3" > conf/default/etc/remount # Put /tmp on the /var ramdisk (could be symlink already) - test -d tmp && rmdir tmp || rm -f tmp + test -d tmp && rmdir tmp || nano_rm -f tmp ln -s var/tmp tmp ) > ${NANO_OBJ}/_.dl 2>&1 @@ -560,7 +569,7 @@ create_i386_diskimage ( ) ( -y ${NANO_HEADS}` else echo "Creating md backing file..." - rm -f ${IMG} + nano_rm -f ${IMG} dd if=/dev/zero of=${IMG} seek=${NANO_MEDIASIZE} count=0 MD=`mdconfig -a -t vnode -f ${IMG} -x ${NANO_SECTS} \ -y ${NANO_HEADS}` @@ -785,7 +794,7 @@ cust_pkg () ( exit 2 fi done - rm -rxf ${NANO_WORLDDIR}/Pkg + nano_rm -rf ${NANO_WORLDDIR}/Pkg ) cust_pkgng () ( @@ -820,7 +829,7 @@ cust_pkgng () ( echo "FAILED: pkg bootstrapping faied" exit 2 fi - rm -f ${NANO_WORLDDIR}/Pkg/pkg-* + nano_rm -f ${NANO_WORLDDIR}/Pkg/pkg-* # Count & report how many we have to install todo=`ls ${NANO_WORLDDIR}/Pkg | /usr/bin/wc -l` @@ -849,7 +858,7 @@ cust_pkgng () ( exit 2 fi done - rm -rxf ${NANO_WORLDDIR}/Pkg + nano_rm -rf ${NANO_WORLDDIR}/Pkg ) ####################################################################### |