SPECS: builder - make --show-bconds output parseable (to be passed...

glen glen at pld-linux.org
Mon Oct 23 21:54:27 CEST 2006


Author: glen                         Date: Mon Oct 23 19:54:27 2006 GMT
Module: SPECS                         Tag: HEAD
---- Log message:
- make --show-bconds output parseable (to be passed to other programs)

---- Files affected:
SPECS:
   builder (1.458 -> 1.459) 

---- Diffs:

================================================================
Index: SPECS/builder
diff -u SPECS/builder:1.458 SPECS/builder:1.459
--- SPECS/builder:1.458	Mon Oct 23 21:53:46 2006
+++ SPECS/builder	Mon Oct 23 21:54:22 2006
@@ -1244,6 +1244,55 @@
 	}' $SPEC | LC_ALL=C sort -u
 }
 
+process_bcondrc() {
+	# expand bconds from ~/.bcondrc
+	# The file structure is like gentoo's package.use:
+	# ---
+	# * -selinux
+	# samba -mysql -pgsql
+	# w32codec-installer license_agreement
+	# php +mysqli
+	# ---
+	if ([ -f $HOME/.bcondrc ] || ([ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ])); then
+		:
+	else
+		return
+	fi
+
+	SN=${SPECFILE%%\.spec}
+
+	local bcondrc=$HOME/.bcondrc
+	[ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && bcondrc=$HOME_ETC/.bcondrc
+
+	local bcond_avail=$(find_spec_bcond $SPECFILE)
+
+	while read pkg flags; do
+		# ignore comments
+		[[ "$pkg" == \#* ]] && continue
+
+		# any package or current package?
+		if [ "$pkg" = "*" ] || [ "$pkg" = "$PACKAGE_NAME" ] || [ "$pkg" = "$SN" ]; then
+			for flag in $flags; do
+				local opt=${flag#[+-]}
+
+				# use only flags which are in this package.
+				if [[ $bcond_avail = *${opt}* ]]; then
+					if [[ $flag = -* ]]; then
+						if [[ $BCOND != *--with?${opt}* ]]; then
+							BCOND="$BCOND --without $opt"
+						fi
+					else
+						if [[ $BCOND != *--without?${opt}* ]]; then
+							BCOND="$BCOND --with $opt"
+						fi
+					fi
+				fi
+			done
+		fi
+	done < $bcondrc
+	update_shell_title "parse ~/.bcondrc: DONE!"
+}
+
 set_bconds_values()
 {
 	update_shell_title "set bcond values"
@@ -1259,47 +1308,7 @@
 	fi
 
 	local bcond_avail=$(find_spec_bcond $SPECFILE)
-
-	# expand bconds from ~/.bcondrc
-	# The file structure is like gentoo's package.use:
-	# ---
-	# * -selinux
-	# samba -mysql -pgsql
-	# w32codec-installer license_agreement
-	# php +mysqli
-	# ---
-	if ([ -f $HOME/.bcondrc ] || ([ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ])); then
-		SN=${SPECFILE%%\.spec}
-
-		local bcondrc=$HOME/.bcondrc
-		[ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && bcondrc=$HOME_ETC/.bcondrc
-
-		while read pkg flags; do
-			# ignore comments
-			[[ "$pkg" == \#* ]] && continue
-
-			# any package or current package?
-			if [ "$pkg" = "*" ] || [ "$pkg" = "$PACKAGE_NAME" ] || [ "$pkg" = "$SN" ]; then
-				for flag in $flags; do
-					local opt=${flag#[+-]}
-
-					# use only flags which are in this package.
-					if [[ $bcond_avail = *${opt}* ]]; then
-						if [[ $flag = -* ]]; then
-							if [[ $BCOND != *--with?${opt}* ]]; then
-								BCOND="$BCOND --without $opt"
-							fi
-						else
-							if [[ $BCOND != *--without?${opt}* ]]; then
-								BCOND="$BCOND --with $opt"
-							fi
-						fi
-					fi
-				done
-			fi
-		done < $bcondrc
-		update_shell_title "parse ~/.bcondrc: DONE!"
-	fi
+	process_bcondrc "$SPECFILE"
 
 	update_shell_title "parse bconds"
 	case "${BCOND_VERSION}" in
@@ -1985,16 +1994,24 @@
 
 update_shell_title "$COMMAND"
 case "$COMMAND" in
+	"show_bconds")
+		init_builder
+		if [ -n "$SPECFILE" ]; then
+			get_spec > /dev/null
+			parse_spec
+			set_bconds_values
+			echo "$BCOND"
+		fi
+		;;
 	"build" | "build-binary" | "build-source" | "build-prep" )
-		init_builder;
+		init_builder
 		if [ -n "$SPECFILE" ]; then
-			get_spec;
-			parse_spec;
-			set_bconds_values;
-			display_bconds;
-			display_branches;
-			[ X"$SHOW_BCONDS" = X"yes" ] && exit 0
-			fetch_build_requires;
+			get_spec
+			parse_spec
+			set_bconds_values
+			display_bconds
+			display_branches
+			fetch_build_requires
 			if [ "$INTEGER_RELEASE" = "yes" ]; then
 				echo "Checking release $PACKAGE_RELEASE..."
 				if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/SPECS/builder?r1=1.458&r2=1.459&f=u



More information about the pld-cvs-commit mailing list