home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 March / PCWELT_3_2006.ISO / base / 05_common.mo / usr / bin / flea < prev    next >
Encoding:
Text File  |  2004-02-24  |  6.9 KB  |  312 lines

  1. #!/bin/sh
  2.  
  3. #
  4. #     File a bug against the Mutt mail user agent.
  5. #
  6.  
  7. #     $Id: muttbug.sh.in,v 2.18 2001/10/10 09:56:51 roessler Exp $
  8. #
  9.  
  10. #
  11. #     Copyright (c) 2000 Thomas Roessler <roessler@guug.de>
  12. #
  13. #
  14. #     This program is free software; you can redistribute it and/or modify
  15. #     it under the terms of the GNU General Public License as published by
  16. #     the Free Software Foundation; either version 2 of the License, or
  17. #     (at your option) any later version.
  18. #     This program is distributed in the hope that it will be useful,
  19. #     but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. #     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21. #     GNU General Public License for more details.
  22. #     You should have received a copy of the GNU General Public License
  23. #     along with this program; if not, write to the Free Software
  24. #     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  25. #
  26.  
  27. SUBMIT="submit@bugs.guug.de"
  28. DEBIAN_SUBMIT="submit@bugs.debian.org"
  29.  
  30. prefix=/usr
  31.  
  32. DEBUGGER=/usr/bin/gdb
  33. SENDMAIL=/usr/sbin/sendmail
  34. sysconfdir=/etc/mutt
  35. pkgdatadir=@pkgdatadir@
  36.  
  37. include_file ()
  38. {
  39.     echo
  40.     echo "--- Begin $1"
  41.     sed -e 's/^-/- -/' $1 | egrep -v '^[     ]*(#|$)'
  42.     echo "--- End $1"
  43.     echo
  44. }
  45.  
  46. debug_gdb ()
  47. {
  48.     cat << EOF > $SCRATCH/gdb.rc
  49. bt
  50. list
  51. quit
  52. EOF
  53.     $DEBUGGER -n -x $SCRATCH/gdb.rc -c $CORE mutt
  54. }
  55.  
  56. debug_dbx ()
  57. {
  58.     cat << EOF > $SCRATCH/dbx.rc
  59. where
  60. list
  61. quit
  62. EOF
  63.     $DEBUGGER -s $SCRATCH/dbx.rc mutt $CORE
  64. }
  65.  
  66. debug_sdb ()
  67. {
  68.     cat << EOF > $SCRATCH/sdb.rc
  69. t
  70. w
  71. q
  72. EOF
  73.     $DEBUGGER mutt $CORE < $SCRATCH/sdb.rc
  74. }
  75.  
  76. case `echo -n` in
  77. "") n=-n; c=   ;;
  78.  *) n=; c='\c' ;;
  79. esac
  80.  
  81.  
  82. exec > /dev/tty
  83. exec < /dev/tty
  84.  
  85. SCRATCH=${TMPDIR-/tmp}/`basename $0`.`hostname`.$$
  86.  
  87. mkdir ${SCRATCH} || \
  88.     echo "`basename $0`: Can't create temporary directory." >& 2 ; 
  89.     exit 1 ; 
  90. }
  91.  
  92. trap "rm -r -f ${SCRATCH} ; trap '' 0 ; exit" 0 1 2
  93.  
  94. TEMPLATE=${SCRATCH}/template.txt
  95.  
  96. echo "Please enter a one-line description of the problem you experience:"
  97. echo $n "> $c"
  98. read SUBJECT
  99.  
  100. cat <<EOF  
  101. What should the severity for this bug report be?
  102.  
  103.        0) Feature request, or maybe a bug which is very difficult to
  104.        fix due to major design considerations.
  105.  
  106.        1) The package fails to perform correctly in some conditions,
  107.        or on some systems, or fails to comply with current policy
  108.        documents. Most bugs are in this category.
  109.  
  110.        2) This bug makes this version of the package unsuitable for
  111.        a stable release.
  112.  
  113.        3) Dangerous bug. Makes the package in question unusable by
  114.        anyone or mostly so, or causes data loss, or introduces a
  115.        security hole allowing access to the accounts of users who
  116.        use the package.
  117.  
  118.        4) Critical bug. Makes unrelated software on the system (or
  119.        the whole system) break, or causes serious data loss, or
  120.        introduces a security hole on systems where you install the
  121.        package.
  122.  
  123. EOF
  124. echo $n "Severity? [01234] $c"
  125. read severity
  126. case "$severity" in
  127. 0|[Ww]) severity=wishlist  ;;
  128. 2|[Ii]) severity=important ;;
  129. 3|[Gg]) severity=grave     ;;
  130. 4|[Cc]) severity=critical  ;;
  131.      *) severity=normal    ;;
  132. esac
  133.  
  134. if test -x $DEBUGGER ; then
  135.     test -f core && CORE=core
  136.     echo "If mutt has crashed, it may have saved some program state in"
  137.     echo "a file named core.  We can include this information with the bug"
  138.     echo "report if you wish so."
  139.     echo "Do you want to include information gathered from a core file?"
  140.     echo "If yes, please enter the path - otherwise just say no: [$CORE]"
  141.     echo $n "> $c"
  142.     read _CORE
  143.     test "$_CORE" && CORE="$_CORE"
  144. fi
  145.  
  146. echo $n "Do you want to include your personal mutt configuration files? [Y|n] $c"
  147. read personal
  148. case "$personal" in
  149. [nN]*)  personal=no  ;;
  150.     *)  personal=yes ;;
  151. esac
  152.  
  153. echo $n "Do you want to include your system's global mutt configuration file? [Y|n] $c"
  154. read global
  155. case "$global" in
  156. [nN]*)  global=no  ;;
  157.     *)    global=yes ;;
  158. esac
  159.  
  160. if test -f /etc/debian_version ; then
  161.     DEBIAN=yes
  162.     echo $n "Checking whether mutt has been installed as a package... $c"
  163.     DEBIANVERSION="`dpkg -l mutt | grep '^[ih]' | awk '{print $3}'`" 2> /dev/null
  164.     if test "$DEBIANVERSION" ; then
  165.         DPKG=yes
  166.     else
  167.         DPKG=no
  168.         unset DEBIANVERSION
  169.     fi
  170.     echo "$DPKG"
  171.     echo $n "File this bug with Debian? [Y|n] $c"
  172.     read DPKG
  173.     case "$DPKG" in
  174.     [nN])    DPKG=no ;;
  175.     *)    DPKG=yes ;;
  176.     esac
  177. else
  178.     DEBIAN=no
  179.     DPKG=no
  180. fi
  181.  
  182. MUTTVERSION="`mutt -v | head -1 | awk '{print $2}'`"
  183. test "$DPKG" = "yes" && SUBMIT="$SUBMIT, $DEBIAN_SUBMIT"
  184.  
  185. exec > ${TEMPLATE}
  186.  
  187. test "$EMAIL"        && echo "From: $EMAIL"
  188. test "$REPLYTO"      && echo "Reply-To: $REPLYTO"
  189. test "$ORGANIZATION" && echo "Organization: $ORGANIZATION"
  190.  
  191. echo "Subject: mutt-$MUTTVERSION: $SUBJECT"
  192. echo "To: $SUBMIT"
  193. echo "Bcc: ${EMAIL-$LOGNAME}"
  194. echo
  195. echo "Package: mutt"
  196. echo "Version: ${DEBIANVERSION-$MUTTVERSION}"
  197. echo "Severity: $severity"
  198. echo 
  199. echo "-- Please type your report below this line"
  200. echo
  201. echo
  202. echo
  203.  
  204. if test "$DEBIAN" = "yes" ; then
  205.     echo "Obtaining Debian-specific information..." > /dev/tty
  206.     bug -p -s dummy mutt |                                 \
  207.         sed -n -e "/^-- System Information/,/^---/p" | \
  208.         grep -v '^---'
  209. fi
  210.  
  211. echo 
  212. echo "-- Build environment information"
  213. echo
  214. echo "(Note: This is the build environment installed on the system"
  215. echo "muttbug is run on.  Information may or may not match the environment"
  216. echo "used to build mutt.)"
  217. echo
  218. echo "- gcc version information"
  219. echo "gcc"
  220. gcc -v 2>&1
  221. echo
  222. echo "- CFLAGS"
  223. echo -Wall -pedantic -O2 -march=i486 -mcpu=i686
  224.  
  225.  
  226. echo
  227. echo "-- Mutt Version Information"
  228. echo
  229. mutt -v
  230.  
  231. if test "$CORE" && test -f "$CORE" ; then
  232.     echo 
  233.     echo "-- Core Dump Analysis Output"
  234.     echo
  235.  
  236.     case "$DEBUGGER" in
  237.         *sdb) debug_sdb $CORE ;;
  238.         *dbx) debug_dbx $CORE ;;
  239.         *gdb) debug_gdb $CORE ;;
  240.     esac
  241.     
  242.     echo
  243. fi
  244.  
  245. if test "$personal" = "yes" ; then
  246.     CANDIDATES=".muttrc-${MUTTVERSION} .muttrc .mutt/muttrc-${MUTTVERSION} .mutt/muttrc"
  247.     MATCHED="none"
  248.     for f in $CANDIDATES; do
  249.         if test -f "${HOME}/$f" ; then
  250.             MATCHED="${HOME}/$f"
  251.             break
  252.             fi
  253.     done
  254.     
  255.     if test "$MATCHED" = "none" ; then
  256.         echo "Warning: Can't find your personal .muttrc." >&2
  257.     else
  258.         include_file $MATCHED
  259.     fi
  260. fi
  261.  
  262.  
  263. if test "$global" = "yes" ; then
  264.     CANDIDATES="Muttrc-${MUTTVERSION} Muttrc"
  265.     DIRECTORIES="$sysconfdir $pkgdatadir"
  266.     MATCHED="none"
  267.     for d in $DIRECTORIES ; do
  268.         for f in $CANDIDATES; do
  269.             if test -f $d/$f ; then
  270.                 MATCHED="$d/$f"
  271.                 break
  272.             fi
  273.         done
  274.         test "$MATCHED" = "none" || break
  275.     done
  276.     
  277.     if test "$MATCHED" = "none" ; then
  278.         echo "Warning: Can't find global Muttrc." >&2
  279.     else
  280.         include_file $MATCHED
  281.     fi
  282. fi
  283.  
  284. exec > /dev/tty
  285.  
  286. cp $TEMPLATE $SCRATCH/mutt-bug.txt
  287.  
  288. input="e"
  289. while : ; do
  290.     if test "$input" = "e" ; then
  291.         ${VISUAL-${EDITOR-vi}} $SCRATCH/mutt-bug.txt
  292.         if cmp $SCRATCH/mutt-bug.txt ${TEMPLATE} > /dev/null ; then
  293.             echo "Warning: Bug report was not modified!"
  294.         fi
  295.     fi
  296.     
  297.     echo $n "Submit, Edit, View, Quit? [S|e|v|q] $c"
  298.     read _input
  299.     input="`echo $_input | tr EVSQ evsq`"
  300.     case $input in
  301.     e*)    ;;
  302.     v*)    ${PAGER-more} $SCRATCH/mutt-bug.txt ;;
  303.     s*|"")    $SENDMAIL -t < $SCRATCH/mutt-bug.txt ; exit ;;
  304.     q*)    exit
  305.     esac
  306. done
  307.  
  308.