| 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">
|
| 3 |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
| 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>
|
| 10 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
| 11 |
<meta name="generator" content="Docutils 0.4: http://docutils.sourceforge.net/" />
|
| 12 |
<title>GLEP 47 -- Creating 'safe' environment variables</title>
|
| 13 |
<style type="text/css">
|
| 14 |
|
| 15 |
/*
|
| 16 |
:Author: David Goodger
|
| 17 |
:Contact: goodger@users.sourceforge.net
|
| 18 |
:date: $Date: 2007/01/25 03:26:26 $
|
| 19 |
:version: $Revision: 1.6 $
|
| 20 |
:copyright: This stylesheet has been placed in the public domain.
|
| 21 |
|
| 22 |
Default cascading style sheet for the PEP HTML output of Docutils.
|
| 23 |
*/
|
| 24 |
|
| 25 |
.first {
|
| 26 |
margin-top: 0 }
|
| 27 |
|
| 28 |
.last {
|
| 29 |
margin-bottom: 0 }
|
| 30 |
|
| 31 |
.navigation {
|
| 32 |
width: 100% ;
|
| 33 |
background: #cc99ff ;
|
| 34 |
margin-top: 0px ;
|
| 35 |
margin-bottom: 0px }
|
| 36 |
|
| 37 |
.navigation .navicon {
|
| 38 |
width: 150px ;
|
| 39 |
height: 35px }
|
| 40 |
|
| 41 |
.navigation .textlinks {
|
| 42 |
padding-left: 1em ;
|
| 43 |
text-align: left }
|
| 44 |
|
| 45 |
.navigation td, .navigation th {
|
| 46 |
padding-left: 0em ;
|
| 47 |
padding-right: 0em ;
|
| 48 |
vertical-align: middle }
|
| 49 |
|
| 50 |
.rfc2822 {
|
| 51 |
margin-top: 0.5em ;
|
| 52 |
margin-left: 0.5em ;
|
| 53 |
margin-right: 0.5em ;
|
| 54 |
margin-bottom: 0em }
|
| 55 |
|
| 56 |
.rfc2822 td {
|
| 57 |
text-align: left }
|
| 58 |
|
| 59 |
.rfc2822 th.field-name {
|
| 60 |
text-align: right ;
|
| 61 |
font-family: sans-serif ;
|
| 62 |
padding-right: 0.5em ;
|
| 63 |
font-weight: bold ;
|
| 64 |
margin-bottom: 0em }
|
| 65 |
|
| 66 |
a.toc-backref {
|
| 67 |
text-decoration: none ;
|
| 68 |
color: black }
|
| 69 |
|
| 70 |
body {
|
| 71 |
margin: 0px ;
|
| 72 |
margin-bottom: 1em ;
|
| 73 |
padding: 0px }
|
| 74 |
|
| 75 |
dd {
|
| 76 |
margin-bottom: 0.5em }
|
| 77 |
|
| 78 |
div.section {
|
| 79 |
margin-left: 1em ;
|
| 80 |
margin-right: 1em ;
|
| 81 |
margin-bottom: 1.5em }
|
| 82 |
|
| 83 |
div.section div.section {
|
| 84 |
margin-left: 0em ;
|
| 85 |
margin-right: 0em ;
|
| 86 |
margin-top: 1.5em }
|
| 87 |
|
| 88 |
div.abstract {
|
| 89 |
margin: 2em 5em }
|
| 90 |
|
| 91 |
div.abstract p.topic-title {
|
| 92 |
font-weight: bold ;
|
| 93 |
text-align: center }
|
| 94 |
|
| 95 |
div.attention, div.caution, div.danger, div.error, div.hint,
|
| 96 |
div.important, div.note, div.tip, div.warning {
|
| 97 |
margin: 2em ;
|
| 98 |
border: medium outset ;
|
| 99 |
padding: 1em }
|
| 100 |
|
| 101 |
div.attention p.admonition-title, div.caution p.admonition-title,
|
| 102 |
div.danger p.admonition-title, div.error p.admonition-title,
|
| 103 |
div.warning p.admonition-title {
|
| 104 |
color: red ;
|
| 105 |
font-weight: bold ;
|
| 106 |
font-family: sans-serif }
|
| 107 |
|
| 108 |
div.hint p.admonition-title, div.important p.admonition-title,
|
| 109 |
div.note p.admonition-title, div.tip p.admonition-title {
|
| 110 |
font-weight: bold ;
|
| 111 |
font-family: sans-serif }
|
| 112 |
|
| 113 |
div.figure {
|
| 114 |
margin-left: 2em }
|
| 115 |
|
| 116 |
div.footer, div.header {
|
| 117 |
font-size: smaller }
|
| 118 |
|
| 119 |
div.footer {
|
| 120 |
margin-left: 1em ;
|
| 121 |
margin-right: 1em }
|
| 122 |
|
| 123 |
div.system-messages {
|
| 124 |
margin: 5em }
|
| 125 |
|
| 126 |
div.system-messages h1 {
|
| 127 |
color: red }
|
| 128 |
|
| 129 |
div.system-message {
|
| 130 |
border: medium outset ;
|
| 131 |
padding: 1em }
|
| 132 |
|
| 133 |
div.system-message p.system-message-title {
|
| 134 |
color: red ;
|
| 135 |
font-weight: bold }
|
| 136 |
|
| 137 |
div.topic {
|
| 138 |
margin: 2em }
|
| 139 |
|
| 140 |
h1 {
|
| 141 |
font-family: sans-serif ;
|
| 142 |
font-size: large }
|
| 143 |
|
| 144 |
h2 {
|
| 145 |
font-family: sans-serif ;
|
| 146 |
font-size: medium }
|
| 147 |
|
| 148 |
h3 {
|
| 149 |
font-family: sans-serif ;
|
| 150 |
font-size: small }
|
| 151 |
|
| 152 |
h4 {
|
| 153 |
font-family: sans-serif ;
|
| 154 |
font-style: italic ;
|
| 155 |
font-size: small }
|
| 156 |
|
| 157 |
h5 {
|
| 158 |
font-family: sans-serif;
|
| 159 |
font-size: x-small }
|
| 160 |
|
| 161 |
h6 {
|
| 162 |
font-family: sans-serif;
|
| 163 |
font-style: italic ;
|
| 164 |
font-size: x-small }
|
| 165 |
|
| 166 |
.section hr {
|
| 167 |
width: 75% }
|
| 168 |
|
| 169 |
ol.simple, ul.simple {
|
| 170 |
margin-bottom: 1em }
|
| 171 |
|
| 172 |
ol.arabic {
|
| 173 |
list-style: decimal }
|
| 174 |
|
| 175 |
ol.loweralpha {
|
| 176 |
list-style: lower-alpha }
|
| 177 |
|
| 178 |
ol.upperalpha {
|
| 179 |
list-style: upper-alpha }
|
| 180 |
|
| 181 |
ol.lowerroman {
|
| 182 |
list-style: lower-roman }
|
| 183 |
|
| 184 |
ol.upperroman {
|
| 185 |
list-style: upper-roman }
|
| 186 |
|
| 187 |
p.caption {
|
| 188 |
font-style: italic }
|
| 189 |
|
| 190 |
p.credits {
|
| 191 |
font-style: italic ;
|
| 192 |
font-size: smaller }
|
| 193 |
|
| 194 |
p.label {
|
| 195 |
white-space: nowrap }
|
| 196 |
|
| 197 |
p.topic-title {
|
| 198 |
font-family: sans-serif ;
|
| 199 |
font-weight: bold }
|
| 200 |
|
| 201 |
pre.line-block {
|
| 202 |
font-family: serif ;
|
| 203 |
font-size: 100% }
|
| 204 |
|
| 205 |
pre.literal-block, pre.doctest-block {
|
| 206 |
margin-left: 2em ;
|
| 207 |
margin-right: 2em ;
|
| 208 |
background-color: #eeeeee }
|
| 209 |
|
| 210 |
span.classifier {
|
| 211 |
font-family: sans-serif ;
|
| 212 |
font-style: oblique }
|
| 213 |
|
| 214 |
span.classifier-delimiter {
|
| 215 |
font-family: sans-serif ;
|
| 216 |
font-weight: bold }
|
| 217 |
|
| 218 |
span.interpreted {
|
| 219 |
font-family: sans-serif }
|
| 220 |
|
| 221 |
span.option-argument {
|
| 222 |
font-style: italic }
|
| 223 |
|
| 224 |
span.pre {
|
| 225 |
white-space: pre }
|
| 226 |
|
| 227 |
span.problematic {
|
| 228 |
color: red }
|
| 229 |
|
| 230 |
table {
|
| 231 |
margin-top: 0.5em ;
|
| 232 |
margin-bottom: 0.5em }
|
| 233 |
|
| 234 |
td, th {
|
| 235 |
padding-left: 0.5em ;
|
| 236 |
padding-right: 0.5em ;
|
| 237 |
vertical-align: top }
|
| 238 |
|
| 239 |
td.num {
|
| 240 |
text-align: right }
|
| 241 |
|
| 242 |
th.field-name {
|
| 243 |
font-weight: bold ;
|
| 244 |
text-align: left ;
|
| 245 |
white-space: nowrap }
|
| 246 |
|
| 247 |
h1 tt, h2 tt, h3 tt, h4 tt, h5 tt, h6 tt {
|
| 248 |
font-size: 100% }
|
| 249 |
|
| 250 |
tt {
|
| 251 |
background-color: #eeeeee }
|
| 252 |
|
| 253 |
ul.auto-toc {
|
| 254 |
list-style-type: none }
|
| 255 |
|
| 256 |
</style>
|
| 257 |
</head>
|
| 258 |
<body bgcolor="white">
|
| 259 |
<table class="navigation" cellpadding="0" cellspacing="0"
|
| 260 |
width="100%" border="0">
|
| 261 |
<tr><td class="navicon" width="150" height="35">
|
| 262 |
<a href="http://www.gentoo.org/" title="Gentoo Linux Home Page">
|
| 263 |
<img src="http://www.gentoo.org/images/gentoo-new.gif" alt="[Gentoo]"
|
| 264 |
border="0" width="150" height="35" /></a></td>
|
| 265 |
<td class="textlinks" align="left">
|
| 266 |
[<b><a href="http://www.gentoo.org/">Gentoo Linux Home</a></b>]
|
| 267 |
[<b><a href="http://www.gentoo.org/proj/en/glep/">GLEP Index</a></b>]
|
| 268 |
[<b><a href="http://www.gentoo.org/proj/en/glep/glep-0047.txt">GLEP Source</a></b>]
|
| 269 |
</td></tr></table>
|
| 270 |
<table class="rfc2822 docutils field-list" frame="void" rules="none">
|
| 271 |
<col class="field-name" />
|
| 272 |
<col class="field-body" />
|
| 273 |
<tbody valign="top">
|
| 274 |
<tr class="field"><th class="field-name">GLEP:</th><td class="field-body">47</td>
|
| 275 |
</tr>
|
| 276 |
<tr class="field"><th class="field-name">Title:</th><td class="field-body">Creating 'safe' environment variables</td>
|
| 277 |
</tr>
|
| 278 |
<tr class="field"><th class="field-name">Version:</th><td class="field-body">1.4</td>
|
| 279 |
</tr>
|
| 280 |
<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">2006/02/13 21:00:50</a></td>
|
| 281 |
</tr>
|
| 282 |
<tr class="field"><th class="field-name">Author:</th><td class="field-body">Diego Pettenò, Fabian Groffen</td>
|
| 283 |
</tr>
|
| 284 |
<tr class="field"><th class="field-name">Status:</th><td class="field-body">Deferred</td>
|
| 285 |
</tr>
|
| 286 |
<tr class="field"><th class="field-name">Type:</th><td class="field-body">Standards Track</td>
|
| 287 |
</tr>
|
| 288 |
<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>
|
| 289 |
</tr>
|
| 290 |
<tr class="field"><th class="field-name">Created:</th><td class="field-body">14-Oct-2005</td>
|
| 291 |
</tr>
|
| 292 |
<tr class="field"><th class="field-name">Post-History:</th><td class="field-body">09-Feb-2006</td>
|
| 293 |
</tr>
|
| 294 |
</tbody>
|
| 295 |
</table>
|
| 296 |
<hr />
|
| 297 |
<div class="contents topic">
|
| 298 |
<p class="topic-title first"><a id="contents" name="contents">Contents</a></p>
|
| 299 |
<ul class="simple">
|
| 300 |
<li><a class="reference" href="#credits" id="id5" name="id5">Credits</a></li>
|
| 301 |
<li><a class="reference" href="#abstract" id="id6" name="id6">Abstract</a></li>
|
| 302 |
<li><a class="reference" href="#motivation" id="id7" name="id7">Motivation</a></li>
|
| 303 |
<li><a class="reference" href="#rationale" id="id8" name="id8">Rationale</a></li>
|
| 304 |
<li><a class="reference" href="#backwards-compatibility" id="id9" name="id9">Backwards Compatibility</a></li>
|
| 305 |
<li><a class="reference" href="#specification" id="id10" name="id10">Specification</a><ul>
|
| 306 |
<li><a class="reference" href="#variable-assignment" id="id11" name="id11">Variable Assignment</a></li>
|
| 307 |
</ul>
|
| 308 |
</li>
|
| 309 |
<li><a class="reference" href="#references" id="id12" name="id12">References</a></li>
|
| 310 |
<li><a class="reference" href="#copyright" id="id13" name="id13">Copyright</a></li>
|
| 311 |
</ul>
|
| 312 |
</div>
|
| 313 |
<div class="section">
|
| 314 |
<h1><a class="toc-backref" href="#id5" id="credits" name="credits">Credits</a></h1>
|
| 315 |
<p>The text of this GLEP is a result of a discussion and input of the
|
| 316 |
following persons, in no particular order: Mike Frysinger, Diego
|
| 317 |
Pettenò, Fabian Groffen and Finn Thain.</p>
|
| 318 |
</div>
|
| 319 |
<div class="section">
|
| 320 |
<h1><a class="toc-backref" href="#id6" id="abstract" name="abstract">Abstract</a></h1>
|
| 321 |
<p>In order for ebuilds and eclasses to be able to make host specific
|
| 322 |
decisions, it is necessary to have a number of environmental variables
|
| 323 |
which allow for such decisions. This GLEP introduces some measures that
|
| 324 |
need to be made to make these decisions 'safe', by making sure the
|
| 325 |
variables the decisions are based on are 'safe'. A small overlap with
|
| 326 |
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
|
| 327 |
keywords are being kept instead of 4-tuple keywords. Additionally, the
|
| 328 |
<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
|
| 329 |
<tt class="docutils literal"><span class="pre">CHOST</span></tt> and the 2-tuple keyword, instead of solely from they 4-tuple
|
| 330 |
keyword as proposed in GLEP 22.</p>
|
| 331 |
<p>The destiny of the <tt class="docutils literal"><span class="pre">USERLAND</span></tt> variable is out of the scope of this
|
| 332 |
GLEP. Depending on its presence in the tree, it may be decided to set
|
| 333 |
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
|
| 334 |
<tt class="docutils literal"><span class="pre">ARCH</span></tt>, or alternatively, e.g. via the profiles.</p>
|
| 335 |
</div>
|
| 336 |
<div class="section">
|
| 337 |
<h1><a class="toc-backref" href="#id7" id="motivation" name="motivation">Motivation</a></h1>
|
| 338 |
<p>The Gentoo/Alt project is in an emerging state to get ready to serve a
|
| 339 |
plethora of 'alternative' configurations such as FreeBSD, NetBSD,
|
| 340 |
DragonflyBSD, GNU/kFreeBSD, Mac OS X, (Open)Darwin, (Open)Solaris and so
|
| 341 |
on. As such, the project is in need for a better grip on the actual
|
| 342 |
host being built on. This information on the host environment is
|
| 343 |
necessary to make proper (automated) decisions on settings that are
|
| 344 |
highly dependant on the build environment, such as platform or C-library
|
| 345 |
implementation.</p>
|
| 346 |
</div>
|
| 347 |
<div class="section">
|
| 348 |
<h1><a class="toc-backref" href="#id8" id="rationale" name="rationale">Rationale</a></h1>
|
| 349 |
<p>Gentoo's unique Portage system allows easy installation of applications
|
| 350 |
from source packages. Compiling sources is prone to many environmental
|
| 351 |
settings and availability of certain tools. Only recently the Gentoo
|
| 352 |
for FreeBSD project has started, as second Gentoo project that operates
|
| 353 |
on a foreign host operating system using foreign (non-GNU) C-libraries
|
| 354 |
and userland utilities. Such projects suffer from the current implicit
|
| 355 |
assumption made within Gentoo Portage's ebuilds that there is a single
|
| 356 |
type of operating system, C-libraries and system utilities. In order to
|
| 357 |
enable ebuilds -- and also eclasses -- to be aware of these
|
| 358 |
environmental differences, information regarding it should be supplied.
|
| 359 |
Since decisions based on this information can be vital, it is of high
|
| 360 |
importance that this information can be trusted and the values can be
|
| 361 |
considered 'safe' and correct.</p>
|
| 362 |
</div>
|
| 363 |
<div class="section">
|
| 364 |
<h1><a class="toc-backref" href="#id9" id="backwards-compatibility" name="backwards-compatibility">Backwards Compatibility</a></h1>
|
| 365 |
<p>The proposed keywording scheme in this GLEP is fully compatible with the
|
| 366 |
current situation of the portage tree, this in contrast to GLEP 22. The
|
| 367 |
variables provided by GLEP 22 can't be extracted from the new keyword,
|
| 368 |
but since GLEP 22-style keywords aren't in the tree at the moment, that
|
| 369 |
is not a problem. The same information can be extracted from the CHOST
|
| 370 |
variable, if necessary. No modifications to ebuilds will have to be
|
| 371 |
made.</p>
|
| 372 |
</div>
|
| 373 |
<div class="section">
|
| 374 |
<h1><a class="toc-backref" href="#id10" id="specification" name="specification">Specification</a></h1>
|
| 375 |
<p>Unlike GLEP 22 the currently used keyword scheme is not changed.
|
| 376 |
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
|
| 377 |
for archs that require them. Archs for which a 1-tuple keyword
|
| 378 |
suffices, can keep that keyword. Since this doesn't change anything to
|
| 379 |
the current situation in the tree, it is considered to be a big
|
| 380 |
advantage over the 4-tuple keyword from GLEP 22. This GLEP is an
|
| 381 |
official specification of the syntax of the keyword.</p>
|
| 382 |
<p>Keywords will consist out of two parts separated by a hyphen ('-'). The
|
| 383 |
part up to the first hyphen from the left of the keyword 2-tuple is the
|
| 384 |
architecture, such as ppc64, sparc and x86. Allowed characters for the
|
| 385 |
architecture name are in <tt class="docutils literal"><span class="pre">a-z0-9</span></tt>. The remaining part on the right of
|
| 386 |
the first hyphen from the left indicates the operating system or
|
| 387 |
distribution, such as linux, macos, darwin, obsd, et-cetera. If the
|
| 388 |
right hand part is omitted, it implies the operating system/distribution
|
| 389 |
type is Gentoo GNU/Linux. In such case the hyphen is also omitted, and
|
| 390 |
the keyword consists of solely the architecture. The operating system
|
| 391 |
or distribution name can consist out of characters in <tt class="docutils literal"><span class="pre">a-zA-Z0-9_+:-</span></tt>.
|
| 392 |
Please note that the hyphen is an allowed character, and therefore the
|
| 393 |
separation of the two fields in the keyword is only determinable by
|
| 394 |
scanning for the first hyphen character from the start of the keyword
|
| 395 |
string. Examples of keywords following this specification are
|
| 396 |
ppc-darwin and x86. This is fully compatible with the current use of
|
| 397 |
keywords in the tree.</p>
|
| 398 |
<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
|
| 399 |
the profiles when other than their defaults for a GNU/Linux system.
|
| 400 |
They can as such easily be overridden and defined by the user. To
|
| 401 |
prevent this from happening, the variables should be auto filled by
|
| 402 |
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>
|
| 403 |
variable can be as easy as the others set by the user, it still is
|
| 404 |
assumed to be 'safe'. This assumption is grounded in the fact that the
|
| 405 |
variable itself is being used in various other places with the same
|
| 406 |
intention, and that an invalid <tt class="docutils literal"><span class="pre">CHOST</span></tt> will cause major malfunctioning
|
| 407 |
of the system. A user that changes the <tt class="docutils literal"><span class="pre">CHOST</span></tt> into something that is
|
| 408 |
not valid for the system, is already warned that this might render the
|
| 409 |
system unusable. Concluding, the 'safeness' of the <tt class="docutils literal"><span class="pre">CHOST</span></tt> variable
|
| 410 |
is based on externally assumed 'safeness', which's discussion falls
|
| 411 |
outside this GLEP.</p>
|
| 412 |
<p>Current USE-expansion of the variables is being maintained, as this
|
| 413 |
results in full backward compatibility. Since the variables themself
|
| 414 |
don't change in what they represent, but only how they are being
|
| 415 |
assigned, there should be no problem in maintaining them. Using
|
| 416 |
USE-expansion, conditional code can be written down in ebuilds, which is
|
| 417 |
not different from any existing methods at all:</p>
|
| 418 |
<pre class="literal-block">
|
| 419 |
...
|
| 420 |
RDEPEND="elibc_FreeBSD? ( sys-libs/com_err )"
|
| 421 |
...
|
| 422 |
src_compile() {
|
| 423 |
...
|
| 424 |
use elibc_FreeBSD && myconf="${myconf} -Dlibc=/usr/lib/libc.a"
|
| 425 |
...
|
| 426 |
}
|
| 427 |
</pre>
|
| 428 |
<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>
|
| 429 |
are available in the ebuild evironment and they can be used instead of
|
| 430 |
invoking <tt class="docutils literal"><span class="pre">xxx_Xxxx</span></tt> or in switch statements where they are actually
|
| 431 |
necessary.</p>
|
| 432 |
<p>A map file can be used to have the various <tt class="docutils literal"><span class="pre">CHOST</span></tt> values being
|
| 433 |
translated to the correct values for the four variables. This change is
|
| 434 |
invisible for ebuilds and eclasses, but allows to rely on these
|
| 435 |
variables as they are based on a 'safe' value -- the <tt class="docutils literal"><span class="pre">CHOST</span></tt> variable.
|
| 436 |
Ebuilds should not be sensitive to the keyword value, but use the
|
| 437 |
aforementioned four variables instead. They allow specific tests for
|
| 438 |
properties. If this is undesirable, the full <tt class="docutils literal"><span class="pre">CHOST</span></tt> variable can be
|
| 439 |
used to match a complete operating system.</p>
|
| 440 |
<div class="section">
|
| 441 |
<h2><a class="toc-backref" href="#id11" id="variable-assignment" name="variable-assignment">Variable Assignment</a></h2>
|
| 442 |
<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
|
| 443 |
file. The file can be overlaid, such that the following entries in the
|
| 444 |
map file (on the left of the arrow) will result in the assigned
|
| 445 |
variables on the right hand side of the arrow:</p>
|
| 446 |
<pre class="literal-block">
|
| 447 |
*-*-linux-* -> KERNEL="linux"
|
| 448 |
*-*-*-gnu -> ELIBC="glibc"
|
| 449 |
*-*-kfreebsd-gnu -> KERNEL="FreeBSD" ELIBC="glibc"
|
| 450 |
*-*-freebsd* -> KERNEL="FreeBSD" ELIBC="FreeBSD"
|
| 451 |
*-*-darwin* -> KERNEL="Darwin" ELIBC="Darwin"
|
| 452 |
*-*-netbsd* -> KERNEL="NetBSD" ELIBC="NetBSD"
|
| 453 |
*-*-solaris* -> KERNEL="Solaris" ELIBC="Solaris"
|
| 454 |
</pre>
|
| 455 |
<p>A way to achieve this is proposed by Mike Frysinger, which
|
| 456 |
suggests to have an env-map file, for instance filled with:</p>
|
| 457 |
<pre class="literal-block">
|
| 458 |
% cat env-map
|
| 459 |
*-linux-* KERNEL=linux
|
| 460 |
*-gnu ELIBC=glibc
|
| 461 |
x86_64-* ARCH=amd64
|
| 462 |
</pre>
|
| 463 |
<p>then the following bash script can be used to set the four variables to
|
| 464 |
their correct values:</p>
|
| 465 |
<pre class="literal-block">
|
| 466 |
% cat readmap
|
| 467 |
#!/bin/bash
|
| 468 |
|
| 469 |
CBUILD=${CBUILD:-${CHOST=${CHOST:-$1}}}
|
| 470 |
[[ -z ${CHOST} ]] && echo need chost
|
| 471 |
|
| 472 |
unset KERNEL ELIBC ARCH
|
| 473 |
|
| 474 |
while read LINE ; do
|
| 475 |
set -- ${LINE}
|
| 476 |
targ=$1
|
| 477 |
shift
|
| 478 |
[[ ${CBUILD} == ${targ} ]] && eval $@
|
| 479 |
done < env-map
|
| 480 |
|
| 481 |
echo ARCH=${ARCH} KERNEL=${KERNEL} ELIBC=${ELIBC}
|
| 482 |
</pre>
|
| 483 |
<p>Given the example env-map file, this script would result in:</p>
|
| 484 |
<pre class="literal-block">
|
| 485 |
% ./readmap x86_64-pc-linux-gnu
|
| 486 |
ARCH=amd64 KERNEL=linux ELIBC=glibc
|
| 487 |
</pre>
|
| 488 |
<p>The entries in the <tt class="docutils literal"><span class="pre">env-map</span></tt> file will be evaluated in a forward
|
| 489 |
linear full scan. A side-effect of this exhaustive search is that the
|
| 490 |
variables can be re-assigned if multiple entries match the given
|
| 491 |
<tt class="docutils literal"><span class="pre">CHOST</span></tt>. Because of this, the order of the entries does matter.
|
| 492 |
Because the <tt class="docutils literal"><span class="pre">env-map</span></tt> file size is assumed not to exceed the block
|
| 493 |
size of the file system, the performance penalty of a full scan versus
|
| 494 |
'first-hit-stop technique' is assumed to be minimal.</p>
|
| 495 |
<p>It should be noted, however, that the above bash script is a proof of
|
| 496 |
concept implementation. Since Portage is largerly written in Python, it
|
| 497 |
will be more efficient to write an equivalent of this code in Python
|
| 498 |
also. Coding wise, this is considered to be a non-issue, but the format
|
| 499 |
of the <tt class="docutils literal"><span class="pre">env-map</span></tt> file, and especially its wildcard characters, might
|
| 500 |
not be the best match with Python. For this purpose, the format
|
| 501 |
specification of the <tt class="docutils literal"><span class="pre">env-map</span></tt> file is deferred to the Python
|
| 502 |
implementation, and only the requirements are given here.</p>
|
| 503 |
<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>
|
| 504 |
pair, where <tt class="docutils literal"><span class="pre">key</span></tt> is a (regular) expression that matches a
|
| 505 |
chost-string, and <tt class="docutils literal"><span class="pre">value</span></tt> contains at least one, distinct variable
|
| 506 |
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
|
| 507 |
interpreter of the <tt class="docutils literal"><span class="pre">env-map</span></tt> file must scan the file linearly and
|
| 508 |
continue trying to match the <tt class="docutils literal"><span class="pre">key</span></tt>s and assign variables if
|
| 509 |
appropriate until the end of file.</p>
|
| 510 |
<p>Since Portage will use the <tt class="docutils literal"><span class="pre">env-map</span></tt> file, the location of the file is
|
| 511 |
beyond the scope of this GLEP and up to the Portage implementors.</p>
|
| 512 |
</div>
|
| 513 |
</div>
|
| 514 |
<div class="section">
|
| 515 |
<h1><a class="toc-backref" href="#id12" id="references" name="references">References</a></h1>
|
| 516 |
<table class="docutils footnote" frame="void" id="id3" rules="none">
|
| 517 |
<colgroup><col class="label" /><col /></colgroup>
|
| 518 |
<tbody valign="top">
|
| 519 |
<tr><td class="label"><a class="fn-backref" href="#id1" name="id3">[1]</a></td><td>GLEP 22, New "keyword" system to incorporate various
|
| 520 |
userlands/kernels/archs, Goodyear,
|
| 521 |
(<a class="reference" href="http://glep.gentoo.org/glep-0022.html">http://glep.gentoo.org/glep-0022.html</a>)</td></tr>
|
| 522 |
</tbody>
|
| 523 |
</table>
|
| 524 |
<table class="docutils footnote" frame="void" id="id4" rules="none">
|
| 525 |
<colgroup><col class="label" /><col /></colgroup>
|
| 526 |
<tbody valign="top">
|
| 527 |
<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
|
| 528 |
4-tuples, even though tuple in itself suggest a field consisting of
|
| 529 |
two values. For clarity: a 1-tuple describes a single value field,
|
| 530 |
while a 4-tuple describes a field consisting out of four values.</td></tr>
|
| 531 |
</tbody>
|
| 532 |
</table>
|
| 533 |
</div>
|
| 534 |
<div class="section">
|
| 535 |
<h1><a class="toc-backref" href="#id13" id="copyright" name="copyright">Copyright</a></h1>
|
| 536 |
<p>This document has been placed in the public domain.</p>
|
| 537 |
</div>
|
| 538 |
|
| 539 |
</div>
|
| 540 |
<div class="footer">
|
| 541 |
<hr class="footer" />
|
| 542 |
<a class="reference" href="glep-0047.txt">View document source</a>.
|
| 543 |
Generated on: 2006-10-10 20:23 UTC.
|
| 544 |
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.
|
| 545 |
|
| 546 |
</div>
|
| 547 |
</body>
|
| 548 |
</html>
|
| 549 |
|