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:
* This package won't build with app-editors/emacs[jit].
* Reemerge Emacs with USE=-jit
* or use "eselect emacs" to select the jit-less version.
* ERROR: app-emacs/mmxx-macros-99999999::akater failed (setup phase):
* Elisp native compilation not supported during build
*
* Call stack:
* ebuild.sh, line 136: Called pkg_setup
* ebuild.sh, line 370: Called akater-emacs-nojit_pkg_setup
* akater-emacs-nojit.eclass, line 72: Called die
* The specific snippet of code:
* die "Elisp native compilation not supported during build"
*
* If you need support, post the output of `emerge --info '=app-emacs/mmxx-macros-99999999::akater'`,
* the complete build log and the output of `emerge -pqv '=app-emacs/mmxx-macros-99999999::akater'`.
* The complete build log is located at '/var/tmp/portage/app-emacs/mmxx-macros-99999999/temp/build.log'.
* The ebuild environment file is located at '/var/tmp/portage/app-emacs/mmxx-macros-99999999/temp/die.env'.
* Working directory: '/var/tmp/portage/app-emacs/mmxx-macros-99999999/empty'
* S: '/var/tmp/portage/app-emacs/mmxx-macros-99999999/work/mmxx-macros-99999999'
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 sudo cp
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 =app-emacs/mmxx-macros-99999999
) it will create the the log files in /var/tmp/bug-prefill/$packageatom 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 /usr/bin or ~/.local/bin or whatever is in you $PATH variable.
Make executeable with
user $
chmod a+x ./bug-prefill
Example:
bug-prefill "=app-emacs/mmxx-macros-99999999" "can't compile"
Would output advice on where to find the log files like this:
*****************************************************************
*****************************************************************
once the bug is filed, please attach
/var/tmp/file-bug/app-emacs-mmxx-macros-99999999/emerge_info_app-emacs-mmxx-macros-99999999.txt
/var/tmp/file-bug/app-emacs-mmxx-macros-99999999/emerge_pqv_app-emacs-mmxx-macros-99999999.txt
/var/tmp/file-bug/app-emacs-mmxx-macros-99999999/app-emacs-mmxx-macros-99999999_build.log
And would open this prefilled webform.
Anyhow, here is the script:
#!/usr/bin/env bash
# gather package emerge infos, put them in /tmp and open a browser with a bug report template
# 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 "$@"
}
c_print() {
echo "${GREEN}${1}${RESET}"
}
main "$@"