Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 638638 - sys-apps/portage - bashrc problems introduced by update
Summary: sys-apps/portage - bashrc problems introduced by update
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Unclassified (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Portage team
Depends on:
Reported: 2017-11-23 22:36 UTC by Nick Bowler
Modified: 2017-11-25 00:52 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---

Full emerge output from failing command. (crossdev-fail.log,8.71 KB, text/plain)
2017-11-23 22:36 UTC, Nick Bowler

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Bowler 2017-11-23 22:36:06 UTC
Created attachment 506230 [details]
Full emerge output from failing command.


The recently stabilised sys-apps/portage-2.3.13-r1 broke dependency
calculation for all cross toolchains, at least when metadata is out
of date (such as after creating a new target with crossdev, or if
the metadata is removed):

  # emerge -1 cross-armv7a-hardfloat-linux-gnueabi/binutils
  * QA Notice: 'awk' called in global scope: cross-armv7a-hardfloat-linux-gnueabi/binutils-9999
*** missing command: awk
 * ERROR: cross-armv7a-hardfloat-linux-gnueabi/binutils-9999::gentoo-draconx failed (depend phase):
 *   External commands disallowed while sourcing ebuild: env
  !!! All ebuilds that could satisfy "cross-armv7a-hardfloat-linux-gnueabi/binutils" have been masked.

Dozens of these errors get spewed out on pretty much any emerge

egencache fails similarly, so I can't regenerate the metadata either.
But everything works if I generate metadata first using an older version
of portage.  Everything works OK in the previous stable version (2.3.8).

Portage 2.3.13 (python 3.4.5-final-0, default/linux/amd64/13.0, gcc-5.4.0, glibc-2.25-r9, 4.13.3 x86_64)
System uname: Linux-4.13.3-x86_64-Intel-R-_Core-TM-2_Quad_CPU_Q8300_@_2.50GHz-with-gentoo-2.4.1
KiB Mem:     4044892 total,    246164 free
KiB Swap:          0 total,         0 free
Timestamp of repository gentoo: Thu, 23 Nov 2017 00:45:01 +0000
Head commit of repository palemoon: acc476e6cfcba9d9d5a889a8e0e66c99bdb3d525

sh bash 4.3_p48-r1
ld GNU ld (Gentoo 2.28.1 p1.0) 2.28.1
distcc 3.2rc1 x86_64-pc-linux-gnu [disabled]
ccache version 3.2.4 [enabled]
app-shells/bash:          4.3_p48-r1::gentoo
dev-java/java-config:     2.2.0-r3::gentoo
dev-lang/perl:            5.24.3::gentoo
dev-lang/python:          2.7.14::gentoo, 3.4.5::gentoo
dev-util/ccache:          3.2.4::gentoo
dev-util/cmake:           3.8.2::gentoo
sys-apps/baselayout:      2.4.1-r2::gentoo
sys-apps/openrc:          0.32.1::gentoo
sys-apps/sandbox:         2.10-r4::gentoo
sys-devel/autoconf:       2.13::gentoo, 2.69::gentoo
sys-devel/automake:       1.11.6-r1::gentoo, 1.13.4::gentoo, 1.15.1-r1::gentoo
sys-devel/binutils:       2.28-r2::gentoo, 2.28.1::gentoo, 2.29.1-r1::gentoo
sys-devel/gcc:            3.4.6-r2::gentoo, 4.1.2::gentoo, 4.2.4-r1::gentoo, 4.9.4::gentoo, 5.4.0-r3::gentoo, 6.4.0::gentoo
sys-devel/gcc-config:     1.9.0::gentoo
sys-devel/libtool:        2.4.6-r3::gentoo
sys-devel/make:           4.2.1::gentoo
sys-kernel/linux-headers: 4.4::gentoo (virtual/os-headers)
sys-libs/glibc:           2.25-r9::gentoo

    location: /srv/repos/gentoo
    sync-type: webrsync
    sync-uri: rsync://
    sync-user: portage
    priority: -1000

    location: /srv/repos/gentoo-draconx
    masters: gentoo

    location: /srv/repos/gentoo-fixes
    masters: gentoo

    location: /srv/repos/palemoon
    sync-type: git
    masters: gentoo

CFLAGS="-O2 -march=core2 -pipe"
CONFIG_PROTECT="/etc /etc/stunnel/stunnel.conf /usr/share/config /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/ssl/certs/ca-certificates.crt /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-O2 -march=core2 -pipe"
EMERGE_DEFAULT_OPTS="--keep-going --quiet-build --autounmask-write=n --dynamic-deps=n --unordered-display --verbose-conflicts --with-bdeps-auto=n"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs binpkg-multi-instance ccache config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync multilib-strict news parallel-fetch preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync webrsync-gpg xattr"
FFLAGS="-O2 -pipe"
INSTALL_MASK="/usr/share/cursors/xorg-x11/default 	/usr/share/alsa/alsa.conf.d/51-pulseaudio-probe.conf 	/etc/profile.d/ 	/etc/portage/bin/post_sync"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
USE="X acl alsa amd64 berkdb bzip2 cairo cjk cli cracklib crypt cups curl cvs cxx doc dri enca exif fbcon fdt ffmpeg flac fontconfig fontforge fortran gdbm gnutls gpm graphviz gtk iconv icu idn imagemagick ipv6 jadetex jpeg jpeg2k kerberos kpathsea latex lcms libass lto mad modules mp3 mp4 multilib ncurses nls nptl ogg opengl openmp otr pam pcre perl png python readline sdl seccomp session smp ssl svg tcpd tex4ht theora threads tiff truetype unicode vim-syntax vorbis xattr xcb xft xinerama xulrunner xv zlib" ABI_X86="64" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="mmx mmxext sse sse2 sse3 sse4_1 ssse3" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" KERNEL="linux" L10N="en-CA en ja ko" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="en_CA en ja" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-6 php7-0" POSTGRES_TARGETS="postgres9_5" PYTHON_SINGLE_TARGET="python3_4" PYTHON_TARGETS="python2_7 python3_4" QEMU_SOFTMMU_TARGETS="arm i386 x86_64" QEMU_USER_TARGETS="arm mips mipsel ppc ppc64" RUBY_TARGETS="ruby22" USERLAND="GNU" VIDEO_CARDS="intel radeon" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Comment 1 Mike Gilbert gentoo-dev 2017-11-24 14:56:40 UTC
It works fine for me.

I would guess that you have either modified the binutils ebuild, or you have some weird code in /etc/portage/bashrc.
Comment 2 Nick Bowler 2017-11-24 15:45:53 UTC
(In reply to Mike Gilbert from comment #1)
> I would guess that you have either modified the binutils ebuild, or you have
> some weird code in /etc/portage/bashrc.

You are right, crossdev was a red herring.  The awk call is in my bashrc.

Not sure why bashrc is suddenly broken now but I changed it to use command -p awk and now metadata generation works again...

Assuming this change was intentional perhaps the portage documentation (e.g., man 5 portage) should note that bashrc is run with a bogus PATH.

Comment 3 Zac Medico gentoo-dev 2017-11-24 21:28:32 UTC
NOTE: It's possible to avoid having die by using [[ ${EBUILD_PHASE} != depend ]] conditionals, like this:

if [[ ${EBUILD_PHASE} != depend ]]; then
    # safely execute commands in global scope here
    echo "hello world"
Comment 4 Psi 2017-11-24 23:54:06 UTC
(In reply to Zac Medico from comment #3)
> NOTE: It's possible to avoid having die by using [[ ${EBUILD_PHASE} !=
> depend ]] conditionals, like this:
> if [[ ${EBUILD_PHASE} != depend ]]; then
>     # safely execute commands in global scope here
>     echo "hello world"
> fi

You posted just before I did, Zac. :-)  I've been doing something similar.

As long as your /etc/portage/bashrc doesn't need to be sourced during dependency resolution for some reason, you could try a variation of Zac's workaround, with reversed logic.  Just make this the fist line of code in your bashrc (outside of any functions):

[[ ${EBUILD_PHASE} != depend ]] || return 0

This line will cause the sourced bashrc to bail out safely during the "depend" phase.  It will also always return success so as to avoid frightening any callers.  Then you can safely fire away like you always have without having to change anything else.  I use return statements frequently to avoid having my package bashrc scripts executed repeatedly.

I agree with the OP that the potential side effects of disallowing commands in the global scope could use some documenting.  I think it's a good idea, just think it could have been documented.
Comment 5 Nick Bowler 2017-11-25 00:52:54 UTC
Both good suggestions, thanks.

None of my bashrc bits matter during dependency generation, so I think I will do something similar.