| 1 | <?xml version="1.0" encoding="utf-8" ?> |
1 | <?xml version="1.0" encoding="utf-8" ?> |
| 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 3 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
3 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
| 4 | <!-- |
4 | |
| 5 | This HTML is auto-generated. DO NOT EDIT THIS FILE! If you are writing a new |
|
|
| 6 | PEP, see http://www.python.org/peps/pep-0001.html for instructions and links |
|
|
| 7 | to templates. DO NOT USE THIS HTML FILE AS YOUR TEMPLATE! |
|
|
| 8 | --> |
|
|
| 9 | <head> |
5 | <head> |
| 10 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
6 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| 11 | <meta name="generator" content="Docutils 0.3.5: http://docutils.sourceforge.net/" /> |
7 | <meta name="generator" content="Docutils 0.4: http://docutils.sourceforge.net/" /> |
| 12 | <title>GLEP 47 -- Creating 'safe' environment variables</title> |
8 | <title>GLEP 47 -- Creating 'safe' environment variables</title> |
| 13 | <link rel="stylesheet" href="tools/glep.css" type="text/css" /> |
9 | <link rel="stylesheet" href="tools/glep.css" type="text/css" /> |
| 14 | </head> |
10 | </head> |
| 15 | <body bgcolor="white"> |
11 | <body bgcolor="white"> |
| 16 | <table class="navigation" cellpadding="0" cellspacing="0" |
12 | <table class="navigation" cellpadding="0" cellspacing="0" |
| … | |
… | |
| 20 | <img src="http://www.gentoo.org/images/gentoo-new.gif" alt="[Gentoo]" |
16 | <img src="http://www.gentoo.org/images/gentoo-new.gif" alt="[Gentoo]" |
| 21 | border="0" width="150" height="35" /></a></td> |
17 | border="0" width="150" height="35" /></a></td> |
| 22 | <td class="textlinks" align="left"> |
18 | <td class="textlinks" align="left"> |
| 23 | [<b><a href="http://www.gentoo.org/">Gentoo Linux Home</a></b>] |
19 | [<b><a href="http://www.gentoo.org/">Gentoo Linux Home</a></b>] |
| 24 | [<b><a href="http://www.gentoo.org/proj/en/glep">GLEP Index</a></b>] |
20 | [<b><a href="http://www.gentoo.org/proj/en/glep">GLEP Index</a></b>] |
| 25 | [<b><a href="./glep-0047.txt">GLEP Source</a></b>] |
21 | [<b><a href="http://www.gentoo.org/proj/en/glep/glep-0047.txt">GLEP Source</a></b>] |
| 26 | </td></tr></table> |
22 | </td></tr></table> |
| 27 | <div class="document"> |
|
|
| 28 | <table class="rfc2822 field-list" frame="void" rules="none"> |
23 | <table class="rfc2822 docutils field-list" frame="void" rules="none"> |
| 29 | <col class="field-name" /> |
24 | <col class="field-name" /> |
| 30 | <col class="field-body" /> |
25 | <col class="field-body" /> |
| 31 | <tbody valign="top"> |
26 | <tbody valign="top"> |
| 32 | <tr class="field"><th class="field-name">GLEP:</th><td class="field-body">47</td> |
27 | <tr class="field"><th class="field-name">GLEP:</th><td class="field-body">47</td> |
| 33 | </tr> |
28 | </tr> |
| 34 | <tr class="field"><th class="field-name">Title:</th><td class="field-body">Creating 'safe' environment variables</td> |
29 | <tr class="field"><th class="field-name">Title:</th><td class="field-body">Creating 'safe' environment variables</td> |
| 35 | </tr> |
30 | </tr> |
| 36 | <tr class="field"><th class="field-name">Version:</th><td class="field-body">1.2</td> |
31 | <tr class="field"><th class="field-name">Version:</th><td class="field-body">1.6</td> |
| 37 | </tr> |
32 | </tr> |
| 38 | <tr class="field"><th class="field-name">Last-Modified:</th><td class="field-body"><a class="reference" href="http://www.gentoo.org/cgi-bin/viewcvs/xml/htdocs/proj/en/glep/glep-0047.txt?cvsroot=gentoo">2006/02/11 21:43:14</a></td> |
33 | <tr class="field"><th class="field-name">Last-Modified:</th><td class="field-body"><a class="reference" href="http://www.gentoo.org/cgi-bin/viewcvs.cgi/xml/htdocs/proj/en/glep/glep-0047.txt?cvsroot=gentoo">2007/07/22 10:03:18</a></td> |
| 39 | </tr> |
34 | </tr> |
| 40 | <tr class="field"><th class="field-name">Author:</th><td class="field-body">Diego Pettenò, Fabian Groffen</td> |
35 | <tr class="field"><th class="field-name">Author:</th><td class="field-body">Diego Pettenò, Fabian Groffen</td> |
| 41 | </tr> |
36 | </tr> |
| 42 | <tr class="field"><th class="field-name">Status:</th><td class="field-body">Draft</td> |
37 | <tr class="field"><th class="field-name">Status:</th><td class="field-body">Rejected</td> |
| 43 | </tr> |
38 | </tr> |
| 44 | <tr class="field"><th class="field-name">Type:</th><td class="field-body">Standards Track</td> |
39 | <tr class="field"><th class="field-name">Type:</th><td class="field-body">Standards Track</td> |
| 45 | </tr> |
40 | </tr> |
| 46 | <tr class="field"><th class="field-name">Content-Type:</th><td class="field-body"><a class="reference" href="glep-0012.html">text/x-rst</a></td> |
41 | <tr class="field"><th class="field-name">Content-Type:</th><td class="field-body"><a class="reference" href="glep-0002.html">text/x-rst</a></td> |
| 47 | </tr> |
42 | </tr> |
| 48 | <tr class="field"><th class="field-name">Created:</th><td class="field-body">14-Oct-2005</td> |
43 | <tr class="field"><th class="field-name">Created:</th><td class="field-body">14-Oct-2005</td> |
| 49 | </tr> |
44 | </tr> |
| 50 | <tr class="field"><th class="field-name">Post-History:</th><td class="field-body">09-Feb-2006</td> |
45 | <tr class="field"><th class="field-name">Post-History:</th><td class="field-body">09-Feb-2006</td> |
| 51 | </tr> |
46 | </tr> |
| 52 | </tbody> |
47 | </tbody> |
| 53 | </table> |
48 | </table> |
| 54 | <hr /> |
49 | <hr /> |
| 55 | <div class="contents topic" id="contents"> |
50 | <div class="contents topic"> |
| 56 | <p class="topic-title first"><a name="contents">Contents</a></p> |
51 | <p class="topic-title first"><a id="contents" name="contents">Contents</a></p> |
| 57 | <ul class="simple"> |
52 | <ul class="simple"> |
| 58 | <li><a class="reference" href="#credits" id="id5" name="id5">Credits</a></li> |
53 | <li><a class="reference" href="#credits" id="id5" name="id5">Credits</a></li> |
| 59 | <li><a class="reference" href="#abstract" id="id6" name="id6">Abstract</a></li> |
54 | <li><a class="reference" href="#abstract" id="id6" name="id6">Abstract</a></li> |
| 60 | <li><a class="reference" href="#motivation" id="id7" name="id7">Motivation</a></li> |
55 | <li><a class="reference" href="#motivation" id="id7" name="id7">Motivation</a></li> |
| 61 | <li><a class="reference" href="#rationale" id="id8" name="id8">Rationale</a></li> |
56 | <li><a class="reference" href="#rationale" id="id8" name="id8">Rationale</a></li> |
| … | |
… | |
| 66 | </li> |
61 | </li> |
| 67 | <li><a class="reference" href="#references" id="id12" name="id12">References</a></li> |
62 | <li><a class="reference" href="#references" id="id12" name="id12">References</a></li> |
| 68 | <li><a class="reference" href="#copyright" id="id13" name="id13">Copyright</a></li> |
63 | <li><a class="reference" href="#copyright" id="id13" name="id13">Copyright</a></li> |
| 69 | </ul> |
64 | </ul> |
| 70 | </div> |
65 | </div> |
| 71 | <div class="section" id="credits"> |
66 | <div class="section"> |
| 72 | <h1><a class="toc-backref" href="#id5" name="credits">Credits</a></h1> |
67 | <h1><a class="toc-backref" href="#id5" id="credits" name="credits">Credits</a></h1> |
| 73 | <p>The text of this GLEP is a result of a discussion and input of the |
68 | <p>The text of this GLEP is a result of a discussion and input of the |
| 74 | following persons, in no particular order: Mike Frysinger, Diego |
69 | following persons, in no particular order: Mike Frysinger, Diego |
| 75 | Pettenò, Fabian Groffen and Finn Thain.</p> |
70 | Pettenò, Fabian Groffen and Finn Thain.</p> |
| 76 | </div> |
71 | </div> |
| 77 | <div class="section" id="abstract"> |
72 | <div class="section"> |
| 78 | <h1><a class="toc-backref" href="#id6" name="abstract">Abstract</a></h1> |
73 | <h1><a class="toc-backref" href="#id6" id="abstract" name="abstract">Abstract</a></h1> |
| 79 | <p>In order for ebuilds and eclasses to be able to make host specific |
74 | <p>In order for ebuilds and eclasses to be able to make host specific |
| 80 | decisions, it is necessary to have a number of environmental variables |
75 | decisions, it is necessary to have a number of environmental variables |
| 81 | which allow for such decisions. This GLEP introduces some measures that |
76 | which allow for such decisions. This GLEP introduces some measures that |
| 82 | need to be made to make these decisions 'safe', by making sure the |
77 | need to be made to make these decisions 'safe', by making sure the |
| 83 | variables the decisions are based on are 'safe'. A small overlap with |
78 | variables the decisions are based on are 'safe'. A small overlap with |
| 84 | GLEP 22 <a class="footnote-reference" href="#id3" id="id1" name="id1">[1]</a> is being handled in this GLEP where the use of 2-tuple |
79 | GLEP 22 <a class="footnote-reference" href="#id3" id="id1" name="id1">[1]</a> is being handled in this GLEP where the use of 2-tuple |
| 85 | keywords are being kept instead of 4-tuple keywords. Additionally, the |
80 | keywords are being kept instead of 4-tuple keywords. Additionally, the |
| 86 | <tt class="literal"><span class="pre">ELIBC</span></tt>, <tt class="literal"><span class="pre">KERNEL</span></tt> and <tt class="literal"><span class="pre">ARCH</span></tt> get auto filled starting from |
81 | <tt class="docutils literal"><span class="pre">ELIBC</span></tt>, <tt class="docutils literal"><span class="pre">KERNEL</span></tt> and <tt class="docutils literal"><span class="pre">ARCH</span></tt> get auto filled starting from |
| 87 | <tt class="literal"><span class="pre">CHOST</span></tt> and the 2-tuple keyword, instead of solely from they 4-tuple |
82 | <tt class="docutils literal"><span class="pre">CHOST</span></tt> and the 2-tuple keyword, instead of solely from they 4-tuple |
| 88 | keyword as proposed in GLEP 22.</p> |
83 | keyword as proposed in GLEP 22.</p> |
| 89 | <p>The destiny of the <tt class="literal"><span class="pre">USERLAND</span></tt> variable is out of the scope of this |
84 | <p>The destiny of the <tt class="docutils literal"><span class="pre">USERLAND</span></tt> variable is out of the scope of this |
| 90 | GLEP. Depending on its presence in the tree, it may be decided to set |
85 | GLEP. Depending on its presence in the tree, it may be decided to set |
| 91 | this variable the same way we propose to set <tt class="literal"><span class="pre">ELIBC</span></tt>, <tt class="literal"><span class="pre">KERNEL</span></tt> and |
86 | this variable the same way we propose to set <tt class="docutils literal"><span class="pre">ELIBC</span></tt>, <tt class="docutils literal"><span class="pre">KERNEL</span></tt> and |
| 92 | <tt class="literal"><span class="pre">ARCH</span></tt>, or alternatively, e.g. via the profiles.</p> |
87 | <tt class="docutils literal"><span class="pre">ARCH</span></tt>, or alternatively, e.g. via the profiles.</p> |
| 93 | </div> |
88 | </div> |
| 94 | <div class="section" id="motivation"> |
89 | <div class="section"> |
| 95 | <h1><a class="toc-backref" href="#id7" name="motivation">Motivation</a></h1> |
90 | <h1><a class="toc-backref" href="#id7" id="motivation" name="motivation">Motivation</a></h1> |
| 96 | <p>The Gentoo/Alt project is in an emerging state to get ready to serve a |
91 | <p>The Gentoo/Alt project is in an emerging state to get ready to serve a |
| 97 | plethora of 'alternative' configurations such as FreeBSD, NetBSD, |
92 | plethora of 'alternative' configurations such as FreeBSD, NetBSD, |
| 98 | DragonflyBSD, GNU/kFreeBSD, Mac OS X, (Open)Darwin, (Open)Solaris and so |
93 | DragonflyBSD, GNU/kFreeBSD, Mac OS X, (Open)Darwin, (Open)Solaris and so |
| 99 | on. As such, the project is in need for a better grip on the actual |
94 | on. As such, the project is in need for a better grip on the actual |
| 100 | host being built on. This information on the host environment is |
95 | host being built on. This information on the host environment is |
| 101 | necessary to make proper (automated) decisions on settings that are |
96 | necessary to make proper (automated) decisions on settings that are |
| 102 | highly dependant on the build environment, such as platform or C-library |
97 | highly dependant on the build environment, such as platform or C-library |
| 103 | implementation.</p> |
98 | implementation.</p> |
| 104 | </div> |
99 | </div> |
| 105 | <div class="section" id="rationale"> |
100 | <div class="section"> |
| 106 | <h1><a class="toc-backref" href="#id8" name="rationale">Rationale</a></h1> |
101 | <h1><a class="toc-backref" href="#id8" id="rationale" name="rationale">Rationale</a></h1> |
| 107 | <p>Gentoo's unique Portage system allows easy installation of applications |
102 | <p>Gentoo's unique Portage system allows easy installation of applications |
| 108 | from source packages. Compiling sources is prone to many environmental |
103 | from source packages. Compiling sources is prone to many environmental |
| 109 | settings and availability of certain tools. Only recently the Gentoo |
104 | settings and availability of certain tools. Only recently the Gentoo |
| 110 | for FreeBSD project has started, as second Gentoo project that operates |
105 | for FreeBSD project has started, as second Gentoo project that operates |
| 111 | on a foreign host operating system using foreign (non-GNU) C-libraries |
106 | on a foreign host operating system using foreign (non-GNU) C-libraries |
| … | |
… | |
| 116 | environmental differences, information regarding it should be supplied. |
111 | environmental differences, information regarding it should be supplied. |
| 117 | Since decisions based on this information can be vital, it is of high |
112 | Since decisions based on this information can be vital, it is of high |
| 118 | importance that this information can be trusted and the values can be |
113 | importance that this information can be trusted and the values can be |
| 119 | considered 'safe' and correct.</p> |
114 | considered 'safe' and correct.</p> |
| 120 | </div> |
115 | </div> |
| 121 | <div class="section" id="backwards-compatibility"> |
116 | <div class="section"> |
| 122 | <h1><a class="toc-backref" href="#id9" name="backwards-compatibility">Backwards Compatibility</a></h1> |
117 | <h1><a class="toc-backref" href="#id9" id="backwards-compatibility" name="backwards-compatibility">Backwards Compatibility</a></h1> |
| 123 | <p>The proposed keywording scheme in this GLEP is fully compatible with the |
118 | <p>The proposed keywording scheme in this GLEP is fully compatible with the |
| 124 | current situation of the portage tree, this in contrast to GLEP 22. The |
119 | current situation of the portage tree, this in contrast to GLEP 22. The |
| 125 | variables provided by GLEP 22 can't be extracted from the new keyword, |
120 | variables provided by GLEP 22 can't be extracted from the new keyword, |
| 126 | but since GLEP 22-style keywords aren't in the tree at the moment, that |
121 | but since GLEP 22-style keywords aren't in the tree at the moment, that |
| 127 | is not a problem. The same information can be extracted from the CHOST |
122 | is not a problem. The same information can be extracted from the CHOST |
| 128 | variable, if necessary. No modifications to ebuilds will have to be |
123 | variable, if necessary. No modifications to ebuilds will have to be |
| 129 | made.</p> |
124 | made.</p> |
| 130 | </div> |
125 | </div> |
| 131 | <div class="section" id="specification"> |
126 | <div class="section"> |
| 132 | <h1><a class="toc-backref" href="#id10" name="specification">Specification</a></h1> |
127 | <h1><a class="toc-backref" href="#id10" id="specification" name="specification">Specification</a></h1> |
| 133 | <p>Unlike GLEP 22 the currently used keyword scheme is not changed. |
128 | <p>Unlike GLEP 22 the currently used keyword scheme is not changed. |
| 134 | Instead of proposing a 4-tuple <a class="footnote-reference" href="#id4" id="id2" name="id2">[2]</a> keyword, a 2-tuple keyword is chosen |
129 | Instead of proposing a 4-tuple <a class="footnote-reference" href="#id4" id="id2" name="id2">[2]</a> keyword, a 2-tuple keyword is chosen |
| 135 | for archs that require them. Archs for which a 1-tuple keyword |
130 | for archs that require them. Archs for which a 1-tuple keyword |
| 136 | suffices, can keep that keyword. Since this doesn't change anything to |
131 | suffices, can keep that keyword. Since this doesn't change anything to |
| 137 | the current situation in the tree, it is considered to be a big |
132 | the current situation in the tree, it is considered to be a big |
| 138 | advantage over the 4-tuple keyword from GLEP 22. This GLEP is an |
133 | advantage over the 4-tuple keyword from GLEP 22. This GLEP is an |
| 139 | official specification of the syntax of the keyword.</p> |
134 | official specification of the syntax of the keyword.</p> |
| 140 | <p>Keywords will consist out of two parts separated by a hyphen ('-'). The |
135 | <p>Keywords will consist out of two parts separated by a hyphen ('-'). The |
| 141 | part up to the first hyphen from the left of the keyword 2-tuple is the |
136 | part up to the first hyphen from the left of the keyword 2-tuple is the |
| 142 | architecture, such as ppc64, sparc and x86. Allowed characters for the |
137 | architecture, such as ppc64, sparc and x86. Allowed characters for the |
| 143 | architecture name are in <tt class="literal"><span class="pre">a-z0-9</span></tt>. The remaining part on the right of |
138 | architecture name are in <tt class="docutils literal"><span class="pre">a-z0-9</span></tt>. The remaining part on the right of |
| 144 | the first hyphen from the left indicates the operating system or |
139 | the first hyphen from the left indicates the operating system or |
| 145 | distribution, such as linux, macos, darwin, obsd, et-cetera. If the |
140 | distribution, such as linux, macos, darwin, obsd, et-cetera. If the |
| 146 | right hand part is omitted, it implies the operating system/distribution |
141 | right hand part is omitted, it implies the operating system/distribution |
| 147 | type is Gentoo GNU/Linux. In such case the hyphen is also omitted, and |
142 | type is Gentoo GNU/Linux. In such case the hyphen is also omitted, and |
| 148 | the keyword consists of solely the architecture. The operating system |
143 | the keyword consists of solely the architecture. The operating system |
| 149 | or distribution name can consist out of characters in <tt class="literal"><span class="pre">a-zA-Z0-9_+:-</span></tt>. |
144 | or distribution name can consist out of characters in <tt class="docutils literal"><span class="pre">a-zA-Z0-9_+:-</span></tt>. |
| 150 | Please note that the hyphen is an allowed character, and therefore the |
145 | Please note that the hyphen is an allowed character, and therefore the |
| 151 | separation of the two fields in the keyword is only determinable by |
146 | separation of the two fields in the keyword is only determinable by |
| 152 | scanning for the first hyphen character from the start of the keyword |
147 | scanning for the first hyphen character from the start of the keyword |
| 153 | string. Examples of keywords following this specification are |
148 | string. Examples of keywords following this specification are |
| 154 | ppc-darwin and x86. This is fully compatible with the current use of |
149 | ppc-darwin and x86. This is fully compatible with the current use of |
| 155 | keywords in the tree.</p> |
150 | keywords in the tree.</p> |
| 156 | <p>The variables <tt class="literal"><span class="pre">ELIBC</span></tt>, <tt class="literal"><span class="pre">KERNEL</span></tt> and <tt class="literal"><span class="pre">ARCH</span></tt> are currently set in |
151 | <p>The variables <tt class="docutils literal"><span class="pre">ELIBC</span></tt>, <tt class="docutils literal"><span class="pre">KERNEL</span></tt> and <tt class="docutils literal"><span class="pre">ARCH</span></tt> are currently set in |
| 157 | the profiles when other than their defaults for a GNU/Linux system. |
152 | the profiles when other than their defaults for a GNU/Linux system. |
| 158 | They can as such easily be overridden and defined by the user. To |
153 | They can as such easily be overridden and defined by the user. To |
| 159 | prevent this from happening, the variables should be auto filled by |
154 | prevent this from happening, the variables should be auto filled by |
| 160 | Portage itself, based on the <tt class="literal"><span class="pre">CHOST</span></tt> variable. While the <tt class="literal"><span class="pre">CHOST</span></tt> |
155 | Portage itself, based on the <tt class="docutils literal"><span class="pre">CHOST</span></tt> variable. While the <tt class="docutils literal"><span class="pre">CHOST</span></tt> |
| 161 | variable can be as easy as the others set by the user, it still is |
156 | variable can be as easy as the others set by the user, it still is |
| 162 | assumed to be 'safe'. This assumption is grounded in the fact that the |
157 | assumed to be 'safe'. This assumption is grounded in the fact that the |
| 163 | variable itself is being used in various other places with the same |
158 | variable itself is being used in various other places with the same |
| 164 | intention, and that an invalid <tt class="literal"><span class="pre">CHOST</span></tt> will cause major malfunctioning |
159 | intention, and that an invalid <tt class="docutils literal"><span class="pre">CHOST</span></tt> will cause major malfunctioning |
| 165 | of the system. A user that changes the <tt class="literal"><span class="pre">CHOST</span></tt> into something that is |
160 | of the system. A user that changes the <tt class="docutils literal"><span class="pre">CHOST</span></tt> into something that is |
| 166 | not valid for the system, is already warned that this might render the |
161 | not valid for the system, is already warned that this might render the |
| 167 | system unusable. Concluding, the 'safeness' of the <tt class="literal"><span class="pre">CHOST</span></tt> variable |
162 | system unusable. Concluding, the 'safeness' of the <tt class="docutils literal"><span class="pre">CHOST</span></tt> variable |
| 168 | is based on externally assumed 'safeness', which's discussion falls |
163 | is based on externally assumed 'safeness', which's discussion falls |
| 169 | outside this GLEP.</p> |
164 | outside this GLEP.</p> |
| 170 | <p>Current USE-expansion of the variables is being maintained, as this |
165 | <p>Current USE-expansion of the variables is being maintained, as this |
| 171 | results in full backward compatibility. Since the variables themself |
166 | results in full backward compatibility. Since the variables themself |
| 172 | don't change in what they represent, but only how they are being |
167 | don't change in what they represent, but only how they are being |
| … | |
… | |
| 181 | ... |
176 | ... |
| 182 | use elibc_FreeBSD && myconf="${myconf} -Dlibc=/usr/lib/libc.a" |
177 | use elibc_FreeBSD && myconf="${myconf} -Dlibc=/usr/lib/libc.a" |
| 183 | ... |
178 | ... |
| 184 | } |
179 | } |
| 185 | </pre> |
180 | </pre> |
| 186 | <p>Alternatively, the variables <tt class="literal"><span class="pre">ELIBC</span></tt>, <tt class="literal"><span class="pre">KERNEL</span></tt> and <tt class="literal"><span class="pre">ARCH</span></tt> |
181 | <p>Alternatively, the variables <tt class="docutils literal"><span class="pre">ELIBC</span></tt>, <tt class="docutils literal"><span class="pre">KERNEL</span></tt> and <tt class="docutils literal"><span class="pre">ARCH</span></tt> |
| 187 | are available in the ebuild evironment and they can be used instead of |
182 | are available in the ebuild evironment and they can be used instead of |
| 188 | invoking <tt class="literal"><span class="pre">xxx_Xxxx</span></tt> or in switch statements where they are actually |
183 | invoking <tt class="docutils literal"><span class="pre">xxx_Xxxx</span></tt> or in switch statements where they are actually |
| 189 | necessary.</p> |
184 | necessary.</p> |
| 190 | <p>A map file can be used to have the various <tt class="literal"><span class="pre">CHOST</span></tt> values being |
185 | <p>A map file can be used to have the various <tt class="docutils literal"><span class="pre">CHOST</span></tt> values being |
| 191 | translated to the correct values for the four variables. This change is |
186 | translated to the correct values for the four variables. This change is |
| 192 | invisible for ebuilds and eclasses, but allows to rely on these |
187 | invisible for ebuilds and eclasses, but allows to rely on these |
| 193 | variables as they are based on a 'safe' value -- the <tt class="literal"><span class="pre">CHOST</span></tt> variable. |
188 | variables as they are based on a 'safe' value -- the <tt class="docutils literal"><span class="pre">CHOST</span></tt> variable. |
| 194 | Ebuilds should not be sensitive to the keyword value, but use the |
189 | Ebuilds should not be sensitive to the keyword value, but use the |
| 195 | aforementioned four variables instead. They allow specific tests for |
190 | aforementioned four variables instead. They allow specific tests for |
| 196 | properties. If this is undesirable, the full <tt class="literal"><span class="pre">CHOST</span></tt> variable can be |
191 | properties. If this is undesirable, the full <tt class="docutils literal"><span class="pre">CHOST</span></tt> variable can be |
| 197 | used to match a complete operating system.</p> |
192 | used to match a complete operating system.</p> |
| 198 | <div class="section" id="variable-assignment"> |
193 | <div class="section"> |
| 199 | <h2><a class="toc-backref" href="#id11" name="variable-assignment">Variable Assignment</a></h2> |
194 | <h2><a class="toc-backref" href="#id11" id="variable-assignment" name="variable-assignment">Variable Assignment</a></h2> |
| 200 | <p>The <tt class="literal"><span class="pre">ELIBC</span></tt>, <tt class="literal"><span class="pre">KERNEL</span></tt>, <tt class="literal"><span class="pre">ARCH</span></tt> variables are filled from a profile |
195 | <p>The <tt class="docutils literal"><span class="pre">ELIBC</span></tt>, <tt class="docutils literal"><span class="pre">KERNEL</span></tt>, <tt class="docutils literal"><span class="pre">ARCH</span></tt> variables are filled from a profile |
| 201 | file. The file can be overlaid, such that the following entries in the |
196 | file. The file can be overlaid, such that the following entries in the |
| 202 | map file (on the left of the arrow) will result in the assigned |
197 | map file (on the left of the arrow) will result in the assigned |
| 203 | variables on the right hand side of the arrow:</p> |
198 | variables on the right hand side of the arrow:</p> |
| 204 | <pre class="literal-block"> |
199 | <pre class="literal-block"> |
| 205 | *-*-linux-* -> KERNEL="linux" |
200 | *-*-linux-* -> KERNEL="linux" |
| 206 | *-*-*-gnu -> ELIBC="glibc" |
201 | *-*-*-gnu -> ELIBC="glibc" |
| 207 | *-*-kfreebsd-gnu -> KERNEL="FreeBSD" ELIBC="glibc" |
202 | *-*-kfreebsd-gnu -> KERNEL="FreeBSD" ELIBC="glibc" |
| 208 | *-*-freebsd* -> KERNEL="FreeBSD" ELIBC="FreeBSD" |
203 | *-*-freebsd* -> KERNEL="FreeBSD" ELIBC="FreeBSD" |
| 209 | *-*-darwin* -> KERNEL="Darwin" ELIBC="Darwin" |
204 | *-*-darwin* -> KERNEL="Darwin" ELIBC="Darwin" |
| 210 | *-*-netbsd* -> KERNEL="NetBSD" ELIBC="NetBSD" |
205 | *-*-netbsd* -> KERNEL="NetBSD" ELIBC="NetBSD" |
| 211 | *-*-solaris* -> KERNEL="Solaris" ELIBC="Solaris" |
206 | *-*-solaris* -> KERNEL="Solaris" ELIBC="Solaris" |
| 212 | </pre> |
207 | </pre> |
| 213 | <p>A way to achieve this is proposed by Mike Frysinger, which |
208 | <p>A way to achieve this is proposed by Mike Frysinger, which |
| 214 | suggests to have a env-map file, for instance filled with:</p> |
209 | suggests to have an env-map file, for instance filled with:</p> |
| 215 | <pre class="literal-block"> |
210 | <pre class="literal-block"> |
| 216 | % cat env-map |
211 | % cat env-map |
| 217 | *-linux-* KERNEL=linux |
212 | *-linux-* KERNEL=linux |
| 218 | *-gnu ELIBC=glibc |
213 | *-gnu ELIBC=glibc |
| 219 | x86_64-* ARCH=amd64 |
214 | x86_64-* ARCH=amd64 |
| 220 | </pre> |
215 | </pre> |
| 221 | <p>then the following bash script can be used to set the four variables to |
216 | <p>then the following bash script can be used to set the four variables to |
| 222 | their correct values:</p> |
217 | their correct values:</p> |
| 223 | <pre class="literal-block"> |
218 | <pre class="literal-block"> |
| 224 | % cat readmap |
219 | % cat readmap |
| 225 | #!/bin/bash |
220 | #!/bin/bash |
| 226 | |
221 | |
| 227 | CBUILD=${CBUILD:-${CHOST=${CHOST:-$1}}} |
222 | CBUILD=${CBUILD:-${CHOST=${CHOST:-$1}}} |
| 228 | [[ -z ${CHOST} ]] && echo need chost |
223 | [[ -z ${CHOST} ]] && echo need chost |
| 229 | |
224 | |
| 230 | unset KERNEL ELIBC ARCH |
225 | unset KERNEL ELIBC ARCH |
| 231 | |
226 | |
| 232 | while read LINE ; do |
227 | while read LINE ; do |
| 233 | set -- ${LINE} |
228 | set -- ${LINE} |
| 234 | targ=$1 |
229 | targ=$1 |
| 235 | shift |
230 | shift |
| 236 | [[ ${CBUILD} == ${targ} ]] && eval $@ |
231 | [[ ${CBUILD} == ${targ} ]] && eval $@ |
| 237 | done < env-map |
232 | done < env-map |
| 238 | |
233 | |
| 239 | echo ARCH=${ARCH} KERNEL=${KERNEL} ELIBC=${ELIBC} |
234 | echo ARCH=${ARCH} KERNEL=${KERNEL} ELIBC=${ELIBC} |
| 240 | </pre> |
235 | </pre> |
| 241 | <p>Given the example env-map file, this script would result in:</p> |
236 | <p>Given the example env-map file, this script would result in:</p> |
| 242 | <pre class="literal-block"> |
237 | <pre class="literal-block"> |
| 243 | % ./readmap x86_64-pc-linux-gnu |
238 | % ./readmap x86_64-pc-linux-gnu |
| 244 | ARCH=amd64 KERNEL=linux ELIBC=glibc |
239 | ARCH=amd64 KERNEL=linux ELIBC=glibc |
| 245 | </pre> |
240 | </pre> |
| 246 | <p>The entries in the <tt class="literal"><span class="pre">env-map</span></tt> file will be evaluated in a forward |
241 | <p>The entries in the <tt class="docutils literal"><span class="pre">env-map</span></tt> file will be evaluated in a forward |
| 247 | linear full scan. A side-effect of this exhaustive search is that the |
242 | linear full scan. A side-effect of this exhaustive search is that the |
| 248 | variables can be re-assigned if multiple entries match the given |
243 | variables can be re-assigned if multiple entries match the given |
| 249 | <tt class="literal"><span class="pre">CHOST</span></tt>. Because of this, the order of the entries does matter. |
244 | <tt class="docutils literal"><span class="pre">CHOST</span></tt>. Because of this, the order of the entries does matter. |
| 250 | Because the <tt class="literal"><span class="pre">env-map</span></tt> file size is assumed not to exceed the block |
245 | Because the <tt class="docutils literal"><span class="pre">env-map</span></tt> file size is assumed not to exceed the block |
| 251 | size of the file system, the performance penalty of a full scan versus |
246 | size of the file system, the performance penalty of a full scan versus |
| 252 | 'first-hit-stop technique' is assumed to be minimal.</p> |
247 | 'first-hit-stop technique' is assumed to be minimal.</p> |
| 253 | <p>It should be noted, however, that the above bash script is a proof of |
248 | <p>It should be noted, however, that the above bash script is a proof of |
| 254 | concept implementation. Since Portage is largerly written in Python, it |
249 | concept implementation. Since Portage is largerly written in Python, it |
| 255 | will be more efficient to write an equivalent of this code in Python |
250 | will be more efficient to write an equivalent of this code in Python |
| 256 | also. Coding wise, this is considered to be a non-issue, but the format |
251 | also. Coding wise, this is considered to be a non-issue, but the format |
| 257 | of the <tt class="literal"><span class="pre">env-map</span></tt> file, and especially its wildcard characters, might |
252 | of the <tt class="docutils literal"><span class="pre">env-map</span></tt> file, and especially its wildcard characters, might |
| 258 | not be the best match with Python. For this purpose, the format |
253 | not be the best match with Python. For this purpose, the format |
| 259 | specification of the <tt class="literal"><span class="pre">env-map</span></tt> file is deferred to the Python |
254 | specification of the <tt class="docutils literal"><span class="pre">env-map</span></tt> file is deferred to the Python |
| 260 | implementation, and only the requirements are given here.</p> |
255 | implementation, and only the requirements are given here.</p> |
| 261 | <p>The <tt class="literal"><span class="pre">env-map</span></tt> file should be capable of encoding a <tt class="literal"><span class="pre">key</span></tt>, <tt class="literal"><span class="pre">value</span></tt> |
256 | <p>The <tt class="docutils literal"><span class="pre">env-map</span></tt> file should be capable of encoding a <tt class="docutils literal"><span class="pre">key</span></tt>, <tt class="docutils literal"><span class="pre">value</span></tt> |
| 262 | pair, where <tt class="literal"><span class="pre">key</span></tt> is a (regular) expression that matches a |
257 | pair, where <tt class="docutils literal"><span class="pre">key</span></tt> is a (regular) expression that matches a |
| 263 | chost-string, and <tt class="literal"><span class="pre">value</span></tt> contains at least one, distinct variable |
258 | chost-string, and <tt class="docutils literal"><span class="pre">value</span></tt> contains at least one, distinct variable |
| 264 | assignment for the variables <tt class="literal"><span class="pre">ARCH</span></tt>, <tt class="literal"><span class="pre">KERNEL</span></tt> and <tt class="literal"><span class="pre">ELIBC</span></tt>. The |
259 | assignment for the variables <tt class="docutils literal"><span class="pre">ARCH</span></tt>, <tt class="docutils literal"><span class="pre">KERNEL</span></tt> and <tt class="docutils literal"><span class="pre">ELIBC</span></tt>. The |
| 265 | interpreter of the <tt class="literal"><span class="pre">env-map</span></tt> file must scan the file linearly and |
260 | interpreter of the <tt class="docutils literal"><span class="pre">env-map</span></tt> file must scan the file linearly and |
| 266 | continue trying to match the <tt class="literal"><span class="pre">key</span></tt>s and assign variables if |
261 | continue trying to match the <tt class="docutils literal"><span class="pre">key</span></tt>s and assign variables if |
| 267 | appropriate until the end of file.</p> |
262 | appropriate until the end of file.</p> |
| 268 | <p>Since Portage will use the <tt class="literal"><span class="pre">env-map</span></tt> file, the location of the file is |
263 | <p>Since Portage will use the <tt class="docutils literal"><span class="pre">env-map</span></tt> file, the location of the file is |
| 269 | beyond the scope of this GLEP and up to the Portage implementors.</p> |
264 | beyond the scope of this GLEP and up to the Portage implementors.</p> |
| 270 | </div> |
265 | </div> |
| 271 | </div> |
266 | </div> |
| 272 | <div class="section" id="references"> |
267 | <div class="section"> |
| 273 | <h1><a class="toc-backref" href="#id12" name="references">References</a></h1> |
268 | <h1><a class="toc-backref" href="#id12" id="references" name="references">References</a></h1> |
| 274 | <table class="footnote" frame="void" id="id3" rules="none"> |
269 | <table class="docutils footnote" frame="void" id="id3" rules="none"> |
| 275 | <colgroup><col class="label" /><col /></colgroup> |
270 | <colgroup><col class="label" /><col /></colgroup> |
| 276 | <tbody valign="top"> |
271 | <tbody valign="top"> |
| 277 | <tr><td class="label"><a class="fn-backref" href="#id1" name="id3">[1]</a></td><td>GLEP 22, New "keyword" system to incorporate various |
272 | <tr><td class="label"><a class="fn-backref" href="#id1" name="id3">[1]</a></td><td>GLEP 22, New "keyword" system to incorporate various |
| 278 | userlands/kernels/archs, Goodyear, |
273 | userlands/kernels/archs, Goodyear, |
| 279 | (<a class="reference" href="http://glep.gentoo.org/glep-0022.html">http://glep.gentoo.org/glep-0022.html</a>)</td></tr> |
274 | (<a class="reference" href="http://glep.gentoo.org/glep-0022.html">http://glep.gentoo.org/glep-0022.html</a>)</td></tr> |
| 280 | </tbody> |
275 | </tbody> |
| 281 | </table> |
276 | </table> |
| 282 | <table class="footnote" frame="void" id="id4" rules="none"> |
277 | <table class="docutils footnote" frame="void" id="id4" rules="none"> |
| 283 | <colgroup><col class="label" /><col /></colgroup> |
278 | <colgroup><col class="label" /><col /></colgroup> |
| 284 | <tbody valign="top"> |
279 | <tbody valign="top"> |
| 285 | <tr><td class="label"><a class="fn-backref" href="#id2" name="id4">[2]</a></td><td>For the purpose of readability, we will refer to 1, 2 and |
280 | <tr><td class="label"><a class="fn-backref" href="#id2" name="id4">[2]</a></td><td>For the purpose of readability, we will refer to 1, 2 and |
| 286 | 4-tuples, even though tuple in itself suggest a field consisting of |
281 | 4-tuples, even though tuple in itself suggest a field consisting of |
| 287 | two values. For clarity: a 1-tuple describes a single value field, |
282 | two values. For clarity: a 1-tuple describes a single value field, |
| 288 | while a 4-tuple describes a field consisting out of four values.</td></tr> |
283 | while a 4-tuple describes a field consisting out of four values.</td></tr> |
| 289 | </tbody> |
284 | </tbody> |
| 290 | </table> |
285 | </table> |
| 291 | </div> |
286 | </div> |
| 292 | <div class="section" id="copyright"> |
287 | <div class="section"> |
| 293 | <h1><a class="toc-backref" href="#id13" name="copyright">Copyright</a></h1> |
288 | <h1><a class="toc-backref" href="#id13" id="copyright" name="copyright">Copyright</a></h1> |
| 294 | <p>This document has been placed in the public domain.</p> |
289 | <p>This document has been placed in the public domain.</p> |
| 295 | </div> |
290 | </div> |
| 296 | </div> |
|
|
| 297 | |
291 | |
|
|
292 | </div> |
|
|
293 | <div class="footer"> |
| 298 | <hr class="footer" /> |
294 | <hr class="footer" /> |
| 299 | <div class="footer"> |
|
|
| 300 | <a class="reference" href="glep-0047.txt">View document source</a>. |
295 | <a class="reference" href="glep-0047.txt">View document source</a>. |
| 301 | Generated on: 2006-02-12 19:57 UTC. |
296 | Generated on: 2007-10-13 13:39 UTC. |
| 302 | Generated by <a class="reference" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source. |
297 | Generated by <a class="reference" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source. |
|
|
298 | |
| 303 | </div> |
299 | </div> |
| 304 | </body> |
300 | </body> |
| 305 | </html> |
301 | </html> |
| 306 | |
302 | |