User:Schievel/bug-prefill

bug-prefill is a small helper script to file bugs that occured during an emerge. In this case normally emerge would prompt something like this:

Now issuing all those commands then gathering the logs is tedious. Especially because during a normal emerge the build dir is not visible for normal users, so you would have to do  to get the build.log out of there, but you have to type the path in or copy and past it, because the user can use tab completion in a directory the user can not even read. Tedious... Therefor I did this little helper. Fed with the package-atom from emerge's output (the ) it will create the the log files in  and copy the build.log into that directory, too. And also stripping the build.log from color codes and such while at it. Because it needs root rights to access the build.log, it will prompt for the sudo-password. It then opens a prefilled bug report. After that the attachments still need to be chosen manually. I would love to automate that as well, but still waiting for bugzilla to support multiple attachments on bug entry: https://bugzilla.mozilla.org/show_bug.cgi?id=278469 Put into a file called bug-prefill and save into or  or whatever is in you $PATH variable. Make executeable with

Example:

Would output advice on where to find the log files like this:

And would open this prefilled webform.

Anyhow, here is the script: {{CodeBox|lang=bash|1=
 * 1) !/usr/bin/env bash
 * 2) gather package emerge infos, put them in /tmp and open a browser with a bug report template
 * 3) dependencies: app-text/wgetpaste, app-text/ansifilter

set -e

GREEN=$'\033[0;32m' RESET=$'\033[0m'

main { pkg="${1}" strippedpkg=$(echo "$pkg" {{!}} tr / - {{!}} tr -d =) portagepkgdir=$(echo "$pkg" {{!}} tr -d =) bugdescr="${2}" tempdir="/var/tmp/file-bug/${strippedpkg}" test -f "${tempdir}" && rm "${tempdir}/"* mkdir -p "${tempdir}" c_print "*****************************************************************" c_print "Gathering information for Package: ${pkg}..." c_print "*****************************************************************" emerge --info "${pkg}" {{!}} tee "${tempdir}/emerge_info_${strippedpkg}.txt" echo c_print "*****************************************************************" echo emerge -pqv "${pkg}" {{!}} tee "${tempdir}/emerge_pqv_${strippedpkg}.txt" sudo test -f "/var/tmp/portage/${portagepkgdir}/temp/build.log" && sudo ansifilter "/var/tmp/portage/${portagepkgdir}/temp/build.log" > "${tempdir}/${strippedpkg}_build.log" echo

print_user_advice exec xdg-open "https://bugs.gentoo.org/enter_bug.cgi?product=Gentoo%20Linux&component=Current%20packages&bug_severity=normal&short_desc=$(urlencode <<<"${pkg// /, }: ${bugdescr}")&comment=Please+enter+bug+description" }

print_user_advice { c_print "*****************************************************************" c_print "*****************************************************************" echo c_print "once the bug is filed, please attach" c_print "${tempdir}/emerge_info_${strippedpkg}.txt" c_print "${tempdir}/emerge_pqv_${strippedpkg}.txt"

if -f "${tempdir}/${strippedpkg}_build.log" ; then build_log_size=$(wc -c < "${tempdir}/${strippedpkg}_build.log") if ${build_log_size} -ge 1024000 ; then wgetpaste "${tempdir}/${strippedpkg}_build.log" echo c_print "WARNING: build.log is to big to attach it to a bug on b.g.o. It was uploaded via wgetpaste instead. Please post the URL of the paste." else c_print "${tempdir}/${strippedpkg}_build.log" fi else c_print "build.log of package not found. Make sure the build ran before." fi }

c_print { echo "${GREEN}${1}${RESET}" }

main "$@"

} }}