+
+ # expand bconds from ~/.bcondrc
+ # The file structure is like gentoo's package.use:
+ # ---
+ # * -selinux
+ # samba -mysql -pgsql
+ # w32codec-installer license_agreement
+ # php +mysqli
+ # ---
+ if [ "${BCOND_VERSION}" != "NONE" ] && ( [ -f $HOME/.bcondrc ] || ( [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] ) ) ; then
+ # This takes package name, first defined in spec.
+ # so consider that when defining flags for package.
+ PN=`$RPM -q --qf '%{NAME}\n' --specfile $SPECFILE | head -n 1`
+ AVAIL=`$RPMBUILD --bcond $SPECFILE`
+
+ 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" = "$PN" ]; then
+ for flag in $flags; do
+ opt=${flag#[+-]}
+
+ # use only flags which are in this package.
+ if [[ $AVAIL = *${opt}* ]]; then
+ if [[ $flag = -* ]]; then
+ BCOND="$BCOND --without $opt"
+ else
+ BCOND="$BCOND --with $opt"
+ fi
+ fi
+ done
+ fi
+ done < $BCONDRC
+ fi
+