[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bug#580455: PATCH (lastest Sid upgrade breakes yaboot.conf and (maybe) ybin)




Here's a patch that makes ybin strip off leading and trailing whitespace and (0 or 1) leading and trailing quote marks. It also passes arguments for ofpath thru "readlink -f" before calling ofpath.

I've tested it on my PowerMac G4. It works there. I don't know if it will work in the other environments where yaboot is needed. I don't have the necessary hardware for testing that.

Others please try it.

Enjoy!

Rick


*** /usr/sbin/ybin	Sun Jul 16 07:45:35 2006
--- /tmp/ybin	Sun May  9 00:14:04 2010
***************
*** 190,196 ****
  {
  case "$1" in
      str)
!        v=`grep "^$2[\ ,=]" "$CONF"` ; echo "${v#*=}"
         ;;
      flag)
         grep "^$2\>" "$CONF" > /dev/null && echo 0 || echo 1
--- 190,209 ----
  {
  case "$1" in
      str)
! 	v=`grep "^$2[\ ,=]" "$CONF"`
! 	v="${v#*=}"
! 	# trim off leading and trailing blanks or tabs
! 	w=""
! 	while [ "$w" != "$v" ]
! 	do
! 		w="$v"
! 		v="${v##[ 	]}"
! 		v="${v%%[ 	]}"
! 	done
! 	# and zero or one leading and trailing quotes
! 	v="${v##[\'\"]}"
! 	v="${v%%[\'\"]}"
! 	echo "$v"
         ;;
      flag)
         grep "^$2\>" "$CONF" > /dev/null && echo 0 || echo 1
***************
*** 201,206 ****
--- 214,224 ----
  esac
  }
  
+ fofpath()
+ {
+ 	$OFPATH "$(readlink -f "$1")"
+ }
+ 
  ## check for existence of a configuration file, and make sure we have
  ## read permission.
  confexist()
***************
*** 611,617 ****
      ## figure out bootstrap device OF pathname if user did not supply it.
      if [ -z "$ofboot" ] ; then
  	[ "$VERBOSE" = 1 ] && echo "$PRG: Finding OpenFirmware device path to \`$boot'..."
! 	ofboot="$($OFPATH $boot)"
  	if [ $? != 0 ] ; then
  	    echo 1>&2 "$PRG: Unable to find OpenFirmware path for boot=$boot"
  	    echo 1>&2 "$PRG: Please add ofboot=<path> where <path> is the OpenFirmware path to $boot to $CONF"
--- 629,635 ----
      ## figure out bootstrap device OF pathname if user did not supply it.
      if [ -z "$ofboot" ] ; then
  	[ "$VERBOSE" = 1 ] && echo "$PRG: Finding OpenFirmware device path to \`$boot'..."
! 	ofboot="$(fofpath $boot)"
  	if [ $? != 0 ] ; then
  	    echo 1>&2 "$PRG: Unable to find OpenFirmware path for boot=$boot"
  	    echo 1>&2 "$PRG: Please add ofboot=<path> where <path> is the OpenFirmware path to $boot to $CONF"
***************
*** 626,632 ****
  	    /dev/*)
  		[ "$VERBOSE" = 1 ] && echo "$PRG: Finding OpenFirmware device path to \`$bsd'..."
  		local sbsd="$bsd"
! 		bsd="$($OFPATH $bsd)"
  		if [ $? != 0 ] ; then
  		    echo 1>&2 "$PRG: Unable to determine OpenFirmware path for bsd=$sbsd"
  		    echo 1>&2 "$PRG: Try specifying the real OpenFirmware path for bsd=$sbsd in $CONF"
--- 644,650 ----
  	    /dev/*)
  		[ "$VERBOSE" = 1 ] && echo "$PRG: Finding OpenFirmware device path to \`$bsd'..."
  		local sbsd="$bsd"
! 		bsd="$(fofpath $bsd)"
  		if [ $? != 0 ] ; then
  		    echo 1>&2 "$PRG: Unable to determine OpenFirmware path for bsd=$sbsd"
  		    echo 1>&2 "$PRG: Try specifying the real OpenFirmware path for bsd=$sbsd in $CONF"
***************
*** 645,651 ****
  	    /dev/*)
  		[ "$VERBOSE" = 1 ] && echo "$PRG: Finding OpenFirmware device path to \`$macos'..."
  		local smacos="$macos"
! 		macos="$($OFPATH $macos)"
  		if [ $? != 0 ] ; then
  		    echo 1>&2 "$PRG: Unable to determine OpenFirmware path for macos=$smacos"
  		    echo 1>&2 "$PRG: Try specifying the real OpenFirmware path for macos=$smacos in $CONF"
--- 663,669 ----
  	    /dev/*)
  		[ "$VERBOSE" = 1 ] && echo "$PRG: Finding OpenFirmware device path to \`$macos'..."
  		local smacos="$macos"
! 		macos="$(fofpath $macos)"
  		if [ $? != 0 ] ; then
  		    echo 1>&2 "$PRG: Unable to determine OpenFirmware path for macos=$smacos"
  		    echo 1>&2 "$PRG: Try specifying the real OpenFirmware path for macos=$smacos in $CONF"
***************
*** 664,670 ****
  	    /dev/*)
  		[ "$VERBOSE" = 1 ] && echo "$PRG: Finding OpenFirmware device path to \`$macosx'..."
  		local smacosx="$macosx"
! 		macosx="$($OFPATH $macosx)"
  		if [ $? != 0 ] ; then
  		    echo 1>&2 "$PRG: Unable to determine OpenFirmware path for macosx=$smacosx"
  		    echo 1>&2 "$PRG: Try specifying the real OpenFirmware path for macosx=$smacosx in $CONF"
--- 682,688 ----
  	    /dev/*)
  		[ "$VERBOSE" = 1 ] && echo "$PRG: Finding OpenFirmware device path to \`$macosx'..."
  		local smacosx="$macosx"
! 		macosx="$(fofpath $macosx)"
  		if [ $? != 0 ] ; then
  		    echo 1>&2 "$PRG: Unable to determine OpenFirmware path for macosx=$smacosx"
  		    echo 1>&2 "$PRG: Try specifying the real OpenFirmware path for macosx=$smacosx in $CONF"
***************
*** 683,689 ****
  	    /dev/*)
  		[ "$VERBOSE" = 1 ] && echo "$PRG: Finding OpenFirmware device path to \`$darwin'..."
  		local sdarwin="$darwin"
! 		darwin="$($OFPATH $darwin)"
  		if [ $? != 0 ] ; then
  		    echo 1>&2 "$PRG: Unable to determine OpenFirmware path for darwin=$sdarwin"
  		    echo 1>&2 "$PRG: Try specifying the real OpenFirmware path for darwin=$sdarwin in $CONF"
--- 701,707 ----
  	    /dev/*)
  		[ "$VERBOSE" = 1 ] && echo "$PRG: Finding OpenFirmware device path to \`$darwin'..."
  		local sdarwin="$darwin"
! 		darwin="$(fofpath $darwin)"
  		if [ $? != 0 ] ; then
  		    echo 1>&2 "$PRG: Unable to determine OpenFirmware path for darwin=$sdarwin"
  		    echo 1>&2 "$PRG: Try specifying the real OpenFirmware path for darwin=$sdarwin in $CONF"

Reply to: