Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/distrib/sets Replace many "if [ -f $x ]; then echo $x; fi" i...
details: https://anonhg.NetBSD.org/src/rev/17e90e5cd56c
branches: trunk
changeset: 749854:17e90e5cd56c
user: uebayasi <uebayasi%NetBSD.org@localhost>
date: Fri Dec 11 12:57:39 2009 +0000
description:
Replace many "if [ -f $x ]; then echo $x; fi" instances with function.
diffstat:
distrib/sets/sets.subr | 109 ++++++++++++++++++------------------------------
1 files changed, 42 insertions(+), 67 deletions(-)
diffs (157 lines):
diff -r 6b424db6a56c -r 17e90e5cd56c distrib/sets/sets.subr
--- a/distrib/sets/sets.subr Fri Dec 11 12:07:58 2009 +0000
+++ b/distrib/sets/sets.subr Fri Dec 11 12:57:39 2009 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: sets.subr,v 1.109 2009/12/11 12:07:58 he Exp $
+# $NetBSD: sets.subr,v 1.110 2009/12/11 12:57:39 uebayasi Exp $
#
#
@@ -178,7 +178,7 @@
# In each file, a record consists of a path and a System Package name,
# separated by whitespace. E.g.,
#
-# # $NetBSD: sets.subr,v 1.109 2009/12/11 12:07:58 he Exp $
+# # $NetBSD: sets.subr,v 1.110 2009/12/11 12:57:39 uebayasi Exp $
# . base-sys-root [keyword[,...]]
# ./altroot base-sys-root
# ./bin base-sys-root
@@ -386,98 +386,73 @@
setname=$1
setdir=$setsdir/lists/$setname
+
echo $setdir/mi
- for _extsrc_pkg in ${EXTSRCS}; do
- if [ -f $setdir/mi.ext.${_extsrc_pkg} ]; then
- echo $setdir/mi.ext.${_extsrc_pkg}
- fi
- done
+
if [ "${MACHINE}" != "${MACHINE_ARCH}" ]; then
# Prefer an ad.${MACHINE_ARCH} over an ad.${MACHINE_CPU},
# since the arch-specific one will be more specific than
# the cpu-specific one.
- if [ -f $setdir/ad.${MACHINE_ARCH} ]; then
- echo $setdir/ad.${MACHINE_ARCH}
- elif [ -f $setdir/ad.${MACHINE_CPU} ]; then
- echo $setdir/ad.${MACHINE_CPU}
- fi
- if [ "$shlib" != "no" -a \
- -f $setdir/ad.${MACHINE_CPU}.shl ]; then
- echo $setdir/ad.${MACHINE_CPU}.shl
+ echo_if_exist $setdir/ad.${MACHINE_ARCH} || \
+ echo_if_exist $setdir/ad.${MACHINE_CPU}
+ if [ "$shlib" != "no" ]; then
+ echo_if_exist $setdir/ad.${MACHINE_CPU}.shl
fi
fi
- if [ -f $setdir/md.${MACHINE}.${MACHINE_ARCH} ]; then
- echo $setdir/md.${MACHINE}.${MACHINE_ARCH}
- elif [ -f $setdir/md.${MACHINE} ]; then
- echo $setdir/md.${MACHINE}
- fi
- if [ -f $setdir/stl.mi ]; then
- echo $setdir/stl.mi
- fi
- if [ -f $setdir/stl.${stlib} ]; then
- echo $setdir/stl.${stlib}
- fi
+
+ echo_if_exist $setdir/md.${MACHINE}.${MACHINE_ARCH} || \
+ echo_if_exist $setdir/md.${MACHINE}
+
+ echo_if_exist $setdir/stl.mi
+ echo_if_exist $setdir/stl.${stlib}
+
if [ "$shlib" != "no" ]; then
- if [ -f $setdir/shl.mi ]; then
- echo $setdir/shl.mi
- fi
- for _extsrc_pkg in ${EXTSRCS}; do
- if [ -f $setdir/shl.mi.ext.${_extsrc_pkg} ]; then
- echo $setdir/shl.mi.ext.${_extsrc_pkg}
- fi
- done
- if [ -f $setdir/shl.${shlib} ]; then
- echo $setdir/shl.${shlib}
- fi
- for _extsrc_pkg in ${EXTSRCS}; do
- if [ -f $setdir/shl.${shlib}.ext.${_extsrc_pkg} ]; then
- echo $setdir/shl.${shlib}.ext.${_extsrc_pkg}
- fi
- done
+ echo_if_exist $setdir/shl.mi
+ echo_if_exist $setdir/shl.${shlib}
fi
+
if [ "$module" != "no" ]; then
- if [ -f $setdir/module.mi ]; then
- echo $setdir/module.mi
- fi
- if [ -f $setdir/module.${MACHINE} ]; then
- echo $setdir/module.${MACHINE}
- fi
+ echo_if_exist $setdir/module.mi
+ echo_if_exist $setdir/module.${MACHINE}
if [ "${MACHINE}" != "${MACHINE_ARCH}" ]; then
# Prefer a module.ad.${MACHINE_ARCH} over a
# module.ad.${MACHINE_CPU}, since the arch-
# specific one will be more specific than the
# cpu-specific one.
- if [ -f $setdir/module.ad.${MACHINE_ARCH} ]; then
- echo $setdir/module.ad.${MACHINE_ARCH}
- elif [ -f $setdir/module.ad.${MACHINE_CPU} ]; then
- echo $setdir/module.ad.${MACHINE_CPU}
- fi
+ echo_if_exist $setdir/module.ad.${MACHINE_ARCH} || \
+ echo_if_exist $setdir/module.ad.${MACHINE_CPU}
fi
fi
- if [ -f $setdir/rescue.mi ]; then
- echo $setdir/rescue.mi
- fi
- if [ -f $setdir/rescue.${MACHINE} ]; then
- echo $setdir/rescue.${MACHINE}
- fi
+ echo_if_exist $setdir/rescue.mi
+ echo_if_exist $setdir/rescue.${MACHINE}
if [ "${MACHINE}" != "${MACHINE_ARCH}" ]; then
# Prefer a rescue.ad.${MACHINE_ARCH} over a
# rescue.ad.${MACHINE_CPU}, since the arch-
# specific one will be more specific than the
# cpu-specific one.
- if [ -f $setdir/rescue.ad.${MACHINE_ARCH} ]; then
- echo $setdir/rescue.ad.${MACHINE_ARCH}
- elif [ -f $setdir/rescue.ad.${MACHINE_CPU} ]; then
- echo $setdir/rescue.ad.${MACHINE_CPU}
- fi
- if [ "$shlib" != "no" -a \
- -f $setdir/rescue.ad.${MACHINE_CPU}.shl ]; then
- echo $setdir/rescue.ad.${MACHINE_CPU}.shl
+ echo_if_exist $setdir/rescue.ad.${MACHINE_ARCH} || \
+ echo_if_exist $setdir/rescue.ad.${MACHINE_CPU}
+ if [ "$shlib" != "no" ]; then
+ echo_if_exist $setdir/rescue.ad.${MACHINE_CPU}.shl
fi
fi
}
+echo_if_exist()
+{
+ [ -f $1 ] && echo $1
+ return $?
+}
+
+echo_if_exist_foreach()
+{
+ local _list=$1; shift
+ for _suffix in $@; do
+ echo_if_exist ${_list}.${_suffix}
+ done
+}
+
# arch_to_cpu mach
#
# Print the ${MACHINE_CPU} for ${MACHINE_ARCH}=mach,
Home |
Main Index |
Thread Index |
Old Index