Module Name:    src
Committed By:   uebayasi
Date:           Fri Dec 11 13:30:11 UTC 2009

Modified Files:
        src/distrib/sets: sets.subr

Log Message:
list_set_lists() - Share code of handling *.ad.* set lists.


To generate a diff of this commit:
cvs rdiff -u -r1.112 -r1.113 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.112 src/distrib/sets/sets.subr:1.113
--- src/distrib/sets/sets.subr:1.112	Fri Dec 11 13:10:47 2009
+++ src/distrib/sets/sets.subr	Fri Dec 11 13:30:11 2009
@@ -1,4 +1,4 @@
-#	$NetBSD: sets.subr,v 1.112 2009/12/11 13:10:47 uebayasi Exp $
+#	$NetBSD: sets.subr,v 1.113 2009/12/11 13:30:11 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.112 2009/12/11 13:10:47 uebayasi Exp $
+# 	# $NetBSD: sets.subr,v 1.113 2009/12/11 13:30:11 uebayasi Exp $
 # 	.			base-sys-root	[keyword[,...]]
 # 	./altroot		base-sys-root
 # 	./bin			base-sys-root
@@ -386,40 +386,26 @@
 	setname=$1
 
 	list_set_lists_mi $setname
-	if [ "${MACHINE}" != "${MACHINE_ARCH}" ]; then
-		list_set_lists_ad $setname
-	fi
+	list_set_lists_ad $setname
 	list_set_lists_md $setname
 	list_set_lists_stl $setname
-	if [ "$shlib" != "no" ]; then
-		list_set_lists_shl $setname
-	fi
-	if [ "$module" != "no" ]; then
-		list_set_lists_module $setname
-	fi
+	list_set_lists_shl $setname
+	list_set_lists_module $setname
 	list_set_lists_rescue $setname
-	if [ "${MACHINE}" != "${MACHINE_ARCH}" ]; then
-		list_set_lists_rescue_ad $setname
-	fi
 }
 
 list_set_lists_mi()
 {
 	setdir=$setsdir/lists/$1
+	# always exist!
 	echo $setdir/mi
 }
 
 list_set_lists_ad()
 {
 	setdir=$setsdir/lists/$1
-	# Prefer an ad.${MACHINE_ARCH} over an ad.${MACHINE_CPU},
-	# since the arch-specific one will be more specific than
-	# the cpu-specific one.
-	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
+	[ "${MACHINE}" != "${MACHINE_ARCH}" ] && \
+	list_set_lists_common_ad $1
 }
 
 list_set_lists_md()
@@ -439,6 +425,7 @@
 list_set_lists_shl()
 {
 	setdir=$setsdir/lists/$1
+	[ "$shlib" != "no" ] || return
 	echo_if_exist $setdir/shl.mi
 	echo_if_exist $setdir/shl.${shlib}
 }
@@ -446,16 +433,12 @@
 list_set_lists_module()
 {
 	setdir=$setsdir/lists/$1
+	[ "$module" != "no" ] || return
 	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.
-		echo_if_exist $setdir/module.ad.${MACHINE_ARCH} || \
-		echo_if_exist $setdir/module.ad.${MACHINE_CPU}
-	fi
+	# XXX module never has .shl
+	[ "${MACHINE}" != "${MACHINE_ARCH}" ] && \
+	list_set_lists_common_ad $1 module
 }
 
 list_set_lists_rescue()
@@ -463,20 +446,24 @@
 	setdir=$setsdir/lists/$1
 	echo_if_exist $setdir/rescue.mi
 	echo_if_exist $setdir/rescue.${MACHINE}
+	[ "${MACHINE}" != "${MACHINE_ARCH}" ] && \
+	list_set_lists_common_ad $1 rescue
 }
 
-list_set_lists_rescue_ad()
+list_set_lists_common_ad()
 {
-	setdir=$setsdir/lists/$1
-	# Prefer a rescue.ad.${MACHINE_ARCH} over a
-	# rescue.ad.${MACHINE_CPU}, since the arch-
+	setdir=$setsdir/lists/$1; _prefix=$2
+
+	[ -n "$_prefix" ] && prefix="$_prefix".
+
+	# Prefer a <prefix>.ad.${MACHINE_ARCH} over a
+	# <prefix>.ad.${MACHINE_CPU}, since the arch-
 	# specific one will be more specific than the
 	# cpu-specific one.
-	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
+	echo_if_exist $setdir/${prefix}ad.${MACHINE_ARCH} || \
+	echo_if_exist $setdir/${prefix}ad.${MACHINE_CPU}
+	[ "$shlib" != "no" ] && \
+	echo_if_exist $setdir/${prefix}ad.${MACHINE_CPU}.shl
 }
 
 echo_if_exist()

Reply via email to