## Delete the old debuginfo remnants
##
-echo "Deleting samba-debuginfo and /usr/src/redhat/BUILD/samba*"
-echo "Press Control-C if you want to quit"
-sleep 10
-echo "That was your chance... :-)"
-rpm -e samba-debuginfo
-rm -rf /usr/src/redhat/BUILD/samba*
+if rpm -qa | grep -q samba-debuginfo || test -n "$(echo /usr/src/redhat/BUILD/samba* | grep -v \*)" ; then
+ echo "Removing debuginfo remnants to fix debuginfo build:"
+ if rpm -qa | grep -q samba-debuginfo ; then
+ echo "Uninstalling the samba-debuginfo RPM"
+ echo -n "Press Control-C if you want to quit (you have 10 seconds)"
+ for count in $(seq 1 10) ; do
+ echo -n "."
+ sleep 1
+ done
+ echo
+ echo "That was your chance... :-)"
+ rpm -e samba-debuginfo
+ fi
+ if test -n "$(echo /usr/src/redhat/BUILD/samba* | grep -v \*)" ; then
+ echo "Deleting /usr/src/redhat/BUILD/samba*"
+ echo -n "Press Control-C if you want to quit (you have 10 seconds)"
+ for count in $(seq 1 10) ; do
+ echo -n "."
+ sleep 1
+ done
+ echo
+ echo "That was your chance... :-)"
+ rm -rf /usr/src/redhat/BUILD/samba*
+ fi
+fi
##
## determine the samba version and create the SPEC file