Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
info when a build fails in the ebuild.(solved)
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
hedmo
Veteran
Veteran


Joined: 29 Aug 2009
Posts: 1305
Location: sweden

PostPosted: Mon Nov 23, 2020 5:19 am    Post subject: info when a build fails in the ebuild.(solved) Reply with quote

hi

i like to get some help with ebuilds . if a package fails to compile , i like to give info . like in chromium when it fails to compile and
you have FEATURES="ccache" . it will give you a info to disable ccache and retry before creating a bug.


Code:


chromium_pkg_die() {
   if [[ "${EBUILD_PHASE}" != "compile" ]]; then
      return
   fi

# ccache often causes bogus compile failures, especially when the cache gets
   # corrupted.
   if has ccache ${FEATURES}; then
      ewarn
      ewarn "You have enabled ccache. Please try disabling ccache"
      ewarn "before reporting a bug."
      ewarn
   fi


regards


Last edited by hedmo on Mon Nov 23, 2020 10:25 am; edited 1 time in total
Back to top
View user's profile Send private message
Ionen
Developer
Developer


Joined: 06 Dec 2018
Posts: 2727

PostPosted: Mon Nov 23, 2020 6:08 am    Post subject: Reply with quote

It doesn't look much documented (nor used much), but can use EBUILD_DEATH_HOOKS which I believe(?) is a portage-specific extension.

portage has a function to register those (register_die_hook()) but seems nobody use it likely to avoid failing with non-portage, and instead add it manually like below.

Gave it a try, ebuild:
Code:
# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

DESCRIPTION="Set for failure"
HOMEPAGE=""

LICENSE="freedist"
SLOT="0"
KEYWORDS="~amd64 ~x86"

has dying_message ${EBUILD_DEATH_HOOKS} || EBUILD_DEATH_HOOKS+=" dying_message"
dying_message() {
   ewarn
   ewarn "Hmmm '${EBUILD_PHASE}' sure looks empty.. I guess we can't use this."
   ewarn "But we're getting an error message anyway!"
   if has news ${FEATURES}; then
      ewarn "By the way, aren't news wonderful?"
   fi
   ewarn
}

S=${WORKDIR}
src_compile() { emake; }


Results:
Code:
# emerge useless-apps/die
Calculating dependencies... done!

>>> Verifying ebuild manifests

>>> Emerging (1 of 1) useless-apps/die-0::gentoo
>>> Unpacking source...
>>> Source unpacked in /tmp/portage/useless-apps/die-0/work
>>> Preparing source in /tmp/portage/useless-apps/die-0/work ...
>>> Source prepared.
>>> Configuring source in /tmp/portage/useless-apps/die-0/work ...
>>> Source configured.
>>> Compiling source in /tmp/portage/useless-apps/die-0/work ...
make -j11
make: *** No targets specified and no makefile found.  Stop.
 * ERROR: useless-apps/die-0::gentoo failed (compile phase):
 *   emake failed
 *
 * If you need support, post the output of `emerge --info '=useless-apps/die-0::gentoo'`,
 * the complete build log and the output of `emerge -pqv '=useless-apps/die-0::gentoo'`.
 * The complete build log is located at '/var/log/portage/useless-apps:die-0:20201123-060225.log.gz'.
 * The ebuild environment file is located at '/tmp/portage/useless-apps/die-0/temp/environment'.
 * Working directory: '/tmp/portage/useless-apps/die-0/work'
 * S: '/tmp/portage/useless-apps/die-0/work'
 *
 * Hmmm '' sure looks empty.. I guess we can't use this.
 * But we're getting an error message anyway!
 * By the way, aren't news wonderful?
 *

>>> Failed to emerge useless-apps/die-0, Log file:
[...]
Back to top
View user's profile Send private message
hedmo
Veteran
Veteran


Joined: 29 Aug 2009
Posts: 1305
Location: sweden

PostPosted: Mon Nov 23, 2020 7:24 am    Post subject: Reply with quote

Ionen wrote:
It doesn't look much documented (nor used much), but can use EBUILD_DEATH_HOOKS which I believe(?) is a portage-specific extension.

portage has a function to register those (register_die_hook()) but seems nobody use it likely to avoid failing with non-portage, and instead add it manually like below.

Gave it a try,


Ionen

thanks it worked as i wanted.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum