Gentoo Archives: gentoo-dev

From: Francesco R <vivo@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] lights on internals
Date: Mon, 31 Oct 2011 03:56:24
Message-Id: 4340FC94.8090101@gentoo.org
In Reply to: Re: [gentoo-dev] lights on internals by Brian Harring
1 Brian Harring wrote:
2
3 >On Sun, Oct 02, 2005 at 11:07:13PM +0200, Francesco R wrote:
4 >
5 >
6 >>The ready to cut ebuild at the bottom print it's environment (variable
7 >>and functions) to a bunch of files into /var/tmp/fakebuild/.
8 >>May be useful for who want to have a look at "what" and "when" is
9 >>avaible during the various emerge phases (but not limited to).
10 >>print_env() {
11 >> local fakebuild_output_dir="/var/tmp/fakebuild"
12 >> mkdir -p "${fakebuild_output_dir}" || die
13 >>
14 >> [[ -z "${fakebuild_progr}" ]] && fakebuild_progr=100
15 >> fakebuild_progr=$(( $fakebuild_progr +1 ))
16 >> export fakebuild_progr
17 >>
18 >> local fakebuild_ext="${1}.${fakebuild_progr}"
19 >>
20 >> # not sorting, break multiline vars
21 >> einfo "${fakebuild_output_dir}/env_${fakebuild_ext}"
22 >> env \
23 >> &> "${fakebuild_output_dir}/env_${fakebuild_ext}"
24 >>
25 >> # Remove egrep and sort to see the source of every fx
26 >> einfo "${fakebuild_output_dir}/fxlist_${fakebuild_ext}"
27 >> typeset \
28 >> | egrep '^\b.* \(\)' \
29 >> | sort \
30 >> &> "${fakebuild_output_dir}/fxlist_${fakebuild_ext}"
31 >>}
32 >>
33 >>
34 >
35 >This won't work as you expect. Env is a binary, it only gets
36 >the exported env.
37 >
38 >
39 >
40 Got the point (maybe), "typeset" is a Bash built-in.
41 The first part of the "typeset" output command give the variable list
42 *and* it's different from the output of "env" binary.
43 The output is different in two ways, first the vars are differently
44 formatted, missing apices " ' " for example.
45 env also is missing all .bashrc defined vars (speaking of a normal
46 environment not of a portage/emerge one).
47
48 ==> the "env" command should be replaced by
49 typeset &> tmpfile
50 tmpfile | grep -B10000 "$(egrep "^\b.* \(\)" tmpfile | head -n 1)" |
51 head -n '-1'
52
53 (basically the output of typeset cutted at first function)
54
55 >Elaborate on the "what and when" bit also, since the env that's dumped
56 >to ebuild.sh varies depending on a lot of things.
57 >~harring
58 >
59 >
60 >
61
62 The environment is changing between the various predefined functions and
63 in the global scope of an ebuild, at the moment only for vars, not for
64 functions.
65 example of variable vars are:
66
67 SANDBOX_*
68 PORTAGE_RESTRICT
69 TMP
70 EBUILD_PHASE
71 TMPDIR
72 PWORKDIR
73 DISTCC_DIR
74 LD_PRELOAD
75
76 All variables that must stay readonly, or not readed at all, inside an
77 ebuild but may explain at the human that's writing one, what's happening
78 and when.
79
80 better ?
81 --
82 gentoo-dev@g.o mailing list