Bug 48950 - econf should include || die in ebuilds
Bug#: 48950 Product:  Gentoo Linux Version: 1.4_rc4 Platform: All
OS/Version: All Status: RESOLVED Severity: minor Priority: P2
Resolution: FIXED Assigned To: qa@gentoo.org Reported By: agriffis@gentoo.org
Component: Unspecified
URL: 
Summary: econf should include || die in ebuilds
Keywords:  
Status Whiteboard: 
Opened: 2004-04-25 09:43 0000
Description:   Opened: 2004-04-25 09:43 0000
resently the econf function in /usr/sbin/ebuild.sh calls die on its
own.  This is unfortunate, because die is designed to tell you at what
line, with a custom message, an ebuild failed.  When functions in
ebuild.sh call die directly, then both those features are thwarted.
The line number is useless (we don't _care_ where it died in
ebuild.sh) and the message is hard-coded.

It would be really good to (1) educate developers to never assume that
die() is called automatically from ebuild.sh, (2) fix the ebuilds to
call die when econf fails, (3) remove the automatic die from econf()

------- Comment #1 From Aron Griffis (RETIRED) 2004-04-25 09:44:46 0000 -------
Created an attachment (id=30018) [details]
list of offending ebuilds

------- Comment #2 From Aron Griffis (RETIRED) 2004-04-25 09:48:25 0000 -------
Created an attachment (id=30019) [details]
updated attachment to fix false hits

find . -name \*.ebuild | xargs perl -0777 -ne 's/\\\n/ /g; s/\n\s*assert\b/ ||
die/g; s/\beconf\b.*\bdie\b//g; s/#.*econf//g; /^.*\beconf\b.*$/m && print
"$ARGV: $&\n"' > econf-no-die.txt

------- Comment #3 From Aron Griffis (RETIRED) 2004-04-25 09:55:28 0000 -------
Created an attachment (id=30021) [details]
sorted list

find . -name \*.ebuild | xargs perl -0777 -ne 's/\\\n/ /g; s/\n\s*assert\b/ ||
die/g; s/\beconf\b.*\bdie\b//g; s/#.*econf//g; while (/^.*\beconf\b.*$/mg) {
print "$ARGV: $&\n" }' | sort > econf-no-die.txt

------- Comment #4 From Aron Griffis (RETIRED) 2004-04-25 14:27:43 0000 -------
Created an attachment (id=30039) [details]
remove more false positives

find . -name \*.ebuild | xargs perl -0777 -ne 's/\\\n/ /g; s/\n\s*assert\b/ ||
die/g; s/^.*\beconf\b.*\bdie\b.*//gm; s/#.*econf.*//g; while
(/^.*\beconf\b.*$/mg) { print "$ARGV: $&\n" }' | sort > econf-no-die.txt 

------- Comment #5 From Aron Griffis (RETIRED) 2004-04-26 13:05:25 0000 -------
Ok, I finished #2, now for #1 and #3

------- Comment #6 From Aron Griffis (RETIRED) 2004-04-26 13:18:37 0000 -------
Here is what I did for #2, btw

$ sed -e 's/^..//; s|/[^/]*:.*||;' econf-no-die.txt | sort -u | while read p; do pushd $p; rm *.ebuild .#* ChangeLog; cvs up; echo "**** $p **************************************"; perl -0777 -i -pe 's/^[^#\n]*\beconf\b(?:.*?[^\\\n])*?(?=\n)/($t = $&) =~ m{\bdie\b} ? $t : $t . " || die \"econf failed\""/mges' *.ebuild; cvs diff || { read -p "Look good?" yesno </dev/tty; if [[ $yesno != [nN]* ]]; then echangelog "Add die following econf for bug 48950"; rc; else xterm; fi; }; popd; done

rc is a bash function that runs repoman commit with the most recent ChangeLog entry as the commit message.  This bash one-liner let me verify each cvs diff before hitting <enter> to make the commit.

I'm just posting this for interest's sake, and for future reference.

------- Comment #7 From Mr. Bones. 2004-04-26 13:28:06 0000 -------
How about adding rc as an attachment for completion?

------- Comment #8 From Aron Griffis (RETIRED) 2004-04-26 13:53:56 0000 -------
I don't think it needs to be an attachment.  Here is rc() and er().  I didn't
use er() in this exercise, but it is useful in other cases.  Most developers
would need to modify the list of architectures in rc().  I develop for alpha,
ia64 and x86, so I ignore repoman's complaining if it is made up of entirely
other-architecture-specific problems.  Of course, this means that I refrain
from using rc() in situations where I might have actually broken something
related to another architecture.

# repoman commit with the message from the ChangeLog
rc ()  
{
  local msg=`perl <ChangeLog -00 -ne \
    's/^  \d{2} \w{3} \d{4};.*?:\n  //s and chomp, s/\s+/ /g, print($_), exit'`
  if [[ -z "$msg" ]]; then
      echo "no ChangeLog message found" 1>&2
      return 1
  fi  
  local out=`repoman commit -m "$msg" "$@" | tee /dev/tty`
  echo "$out" | grep -Eq 'CVS commit complete' && return 0
  echo "$out" | grep -Eq 'alpha|ia64|x86' && return 1
  repoman commit -m "$msg" --ignore-other-arches "$@"
}   

# echangelog and repoman combined
er() {
  rm -f ChangeLog
  cvs up ChangeLog || return 1
  echangelog "$*" || return 1
  rc
}

------- Comment #9 From Aron Griffis (RETIRED) 2004-05-25 12:10:01 0000 -------
testing bugzilla ... ignore this comment

------- Comment #10 From Alec Warner 2007-03-26 07:00:54 0000 -------
Can probably close this, die has supported tracebacks for nearly 12 months.  It
should no longer matter if econf has || die after it or not.