public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] lights on internals
@ 2005-10-02 21:07 Francesco R
  2005-10-03  6:42 ` Brian Harring
  0 siblings, 1 reply; 3+ messages in thread
From: Francesco R @ 2005-10-02 21:07 UTC (permalink / raw
  To: gentoo-dev

The ready to cut ebuild at the bottom print it's environment (variable
and functions) to a bunch of files into /var/tmp/fakebuild/.
May be useful for who want to have a look at "what" and "when" is
avaible during the various emerge phases (but not limited to).

usage:
# env -i \
PORTDIR_OVERLAY=/the/path/ \
fakebuild_progr=100 \
ebuild fakebuild-1.ebuild digest

# env -i \
fakebuild_progr=200 \
PORTDIR_OVERLAY=/the/path/ \
emerge --buildpkgonly =fakebuild-1

hint: try also the following:
- remove the egrep, sort after "typeset" to have also the sorce code of
the functions
- remove "{pkg,src}*" functions  (after the previous step) to have a
look at the predefined functions.


--- app-misc/fakebuild --
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

DESCRIPTION="fake ebuild to test environment"
HOMEPAGE="http://dev.gentoo.org/~vivo/"
SRC_URI=""

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~x86"

print_env() {
    local fakebuild_output_dir="/var/tmp/fakebuild"
    mkdir -p "${fakebuild_output_dir}" || die

    [[ -z "${fakebuild_progr}" ]] && fakebuild_progr=100
    fakebuild_progr=$(( $fakebuild_progr +1 ))
    export fakebuild_progr

    local fakebuild_ext="${1}.${fakebuild_progr}"

    # not sorting, break multiline vars
    einfo "${fakebuild_output_dir}/env_${fakebuild_ext}"
    env \
        &> "${fakebuild_output_dir}/env_${fakebuild_ext}"

    # Remove egrep and sort to see the source of every fx
    einfo "${fakebuild_output_dir}/fxlist_${fakebuild_ext}"
    typeset \
        | egrep '^\b.* \(\)' \
        | sort \
        &> "${fakebuild_output_dir}/fxlist_${fakebuild_ext}"
}

print_env "global_scope"

pkg_setup()    { print_env "pkg_setup" ; }
src_unpack()   { print_env "src_unpack" ; }
src_compile()  { print_env "src_compile" ; }
src_test()     { print_env "src_test" ; }
src_install()  { print_env "src_install" ; }
pkg_preinst()  { print_env "pkg_preinst" ; }
pkg_postinst() { print_env "pkg_postinst" ; }
--- app-misc/fakebuild --

-- 
   ________ ___  _    _ ____ _____ ___ ____ ____     ___
  / ___/_  \_  \/ \  / / ___/ ___/  _ / ___/ _  \   /_  \
 / __/   _/__  / \ \/ / /__/ _/_ _\ \/ /__/ / / /  /   _/
/_/ /_/\_\/_/_/_/ \__/\___/____//___ \___/\____/  / /\_\o
 
Simultaneous breaking of databases and backups since '90s.
World wide since 2005.0

-- 
gentoo-dev@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [gentoo-dev] lights on internals
  2005-10-02 21:07 [gentoo-dev] lights on internals Francesco R
@ 2005-10-03  6:42 ` Brian Harring
  2005-10-03  9:40   ` Francesco R
  0 siblings, 1 reply; 3+ messages in thread
From: Brian Harring @ 2005-10-03  6:42 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 1332 bytes --]

On Sun, Oct 02, 2005 at 11:07:13PM +0200, Francesco R wrote:
> The ready to cut ebuild at the bottom print it's environment (variable
> and functions) to a bunch of files into /var/tmp/fakebuild/.
> May be useful for who want to have a look at "what" and "when" is
> avaible during the various emerge phases (but not limited to).
> print_env() {
>     local fakebuild_output_dir="/var/tmp/fakebuild"
>     mkdir -p "${fakebuild_output_dir}" || die
> 
>     [[ -z "${fakebuild_progr}" ]] && fakebuild_progr=100
>     fakebuild_progr=$(( $fakebuild_progr +1 ))
>     export fakebuild_progr
> 
>     local fakebuild_ext="${1}.${fakebuild_progr}"
> 
>     # not sorting, break multiline vars
>     einfo "${fakebuild_output_dir}/env_${fakebuild_ext}"
>     env \
>         &> "${fakebuild_output_dir}/env_${fakebuild_ext}"
> 
>     # Remove egrep and sort to see the source of every fx
>     einfo "${fakebuild_output_dir}/fxlist_${fakebuild_ext}"
>     typeset \
>         | egrep '^\b.* \(\)' \
>         | sort \
>         &> "${fakebuild_output_dir}/fxlist_${fakebuild_ext}"
> }

This won't work as you expect.  Env is a binary, it only gets 
the exported env.

Elaborate on the "what and when" bit also, since the env that's dumped 
to ebuild.sh varies depending on a lot of things.
~harring

	

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [gentoo-dev] lights on internals
  2005-10-03  6:42 ` Brian Harring
@ 2005-10-03  9:40   ` Francesco R
  0 siblings, 0 replies; 3+ messages in thread
From: Francesco R @ 2005-10-03  9:40 UTC (permalink / raw
  To: gentoo-dev

Brian Harring wrote:

>On Sun, Oct 02, 2005 at 11:07:13PM +0200, Francesco R wrote:
>  
>
>>The ready to cut ebuild at the bottom print it's environment (variable
>>and functions) to a bunch of files into /var/tmp/fakebuild/.
>>May be useful for who want to have a look at "what" and "when" is
>>avaible during the various emerge phases (but not limited to).
>>print_env() {
>>    local fakebuild_output_dir="/var/tmp/fakebuild"
>>    mkdir -p "${fakebuild_output_dir}" || die
>>
>>    [[ -z "${fakebuild_progr}" ]] && fakebuild_progr=100
>>    fakebuild_progr=$(( $fakebuild_progr +1 ))
>>    export fakebuild_progr
>>
>>    local fakebuild_ext="${1}.${fakebuild_progr}"
>>
>>    # not sorting, break multiline vars
>>    einfo "${fakebuild_output_dir}/env_${fakebuild_ext}"
>>    env \
>>        &> "${fakebuild_output_dir}/env_${fakebuild_ext}"
>>
>>    # Remove egrep and sort to see the source of every fx
>>    einfo "${fakebuild_output_dir}/fxlist_${fakebuild_ext}"
>>    typeset \
>>        | egrep '^\b.* \(\)' \
>>        | sort \
>>        &> "${fakebuild_output_dir}/fxlist_${fakebuild_ext}"
>>}
>>    
>>
>
>This won't work as you expect.  Env is a binary, it only gets 
>the exported env.
>
>  
>
Got the point (maybe), "typeset" is a Bash built-in.
The first part of the "typeset" output command give the variable list
*and* it's different from the output of "env" binary.
The output is different in two ways, first the vars are differently
formatted, missing apices " ' " for example.
env also is missing all .bashrc defined vars (speaking of a normal
environment not of a portage/emerge one).

==> the "env" command should be replaced by
typeset &> tmpfile
tmpfile | grep -B10000 "$(egrep "^\b.* \(\)" tmpfile | head -n 1)" |
head -n '-1'

(basically the output of typeset cutted at first function)

>Elaborate on the "what and when" bit also, since the env that's dumped 
>to ebuild.sh varies depending on a lot of things.
>~harring
>	
>  
>

The environment is changing between the various predefined functions and
in the global scope of an ebuild, at the moment only for vars, not for
functions.
example of variable vars are:

SANDBOX_*
PORTAGE_RESTRICT
TMP
EBUILD_PHASE
TMPDIR
PWORKDIR
DISTCC_DIR
LD_PRELOAD

All variables that must stay readonly, or not readed at all, inside an
ebuild but may explain at the human that's writing one, what's happening
and when.

better ?
-- 
gentoo-dev@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-10-31  3:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-02 21:07 [gentoo-dev] lights on internals Francesco R
2005-10-03  6:42 ` Brian Harring
2005-10-03  9:40   ` Francesco R

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox