Module Name: src Committed By: uebayasi Date: Fri Dec 11 12:57:39 UTC 2009
Modified Files: src/distrib/sets: sets.subr Log Message: Replace many "if [ -f $x ]; then echo $x; fi" instances with function. To generate a diff of this commit: cvs rdiff -u -r1.109 -r1.110 src/distrib/sets/sets.subr Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/distrib/sets/sets.subr diff -u src/distrib/sets/sets.subr:1.109 src/distrib/sets/sets.subr:1.110 --- src/distrib/sets/sets.subr:1.109 Fri Dec 11 12:07:58 2009 +++ src/distrib/sets/sets.subr Fri Dec 11 12:57:39 2009 @@ -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} + 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 - if [ "$shlib" != "no" -a \ - -f $setdir/ad.${MACHINE_CPU}.shl ]; then - echo $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,