Lines 1477-1493
Link Here
|
1477 |
spawn_func = portage.process.spawn_fakeroot |
1477 |
spawn_func = portage.process.spawn_fakeroot |
1478 |
elif "sandbox" in features and platform.system() == 'Darwin': |
1478 |
elif "sandbox" in features and platform.system() == 'Darwin': |
1479 |
keywords["opt_name"] += " macossandbox" |
1479 |
keywords["opt_name"] += " macossandbox" |
1480 |
sbprefixpath = mysettings["PORTAGE_BUILDDIR"] |
1480 |
sbprofile = MACOSSANDBOX_PROFILE |
1481 |
|
1481 |
|
1482 |
# escape some characters with special meaning in re's |
1482 |
# determine variable names from profile: split |
1483 |
sbprefixre = sbprefixpath.replace("+", "\+") |
1483 |
# "text@@VARNAME@@moretext@@OTHERVAR@@restoftext" into |
1484 |
sbprefixre = sbprefixre.replace("*", "\*") |
1484 |
# ("text", # "VARNAME", "moretext", "OTHERVAR", "restoftext") |
1485 |
sbprefixre = sbprefixre.replace("[", "\[") |
1485 |
# and extract variable named by reading every second item. |
1486 |
sbprefixre = sbprefixre.replace("[", "\[") |
1486 |
variables = [] |
|
|
1487 |
for line in sbprofile.split("\n"): |
1488 |
variables.extend(line.split("@@")[1:-1:2]) |
1489 |
|
1490 |
for var in variables: |
1491 |
paths = "" |
1492 |
if var in mysettings: |
1493 |
paths = mysettings[var] |
1494 |
else: |
1495 |
writemsg("Warning: sandbox profile references variable %s " |
1496 |
"which is not set.\nThe rule using it will have no " |
1497 |
"effect, which is most likely not the intended " |
1498 |
"result.\nPlease check make.conf/make.globals.\n" % |
1499 |
var) |
1500 |
|
1501 |
# not set or empty value |
1502 |
if not paths: |
1503 |
sbprofile = sbprofile.replace("@@%s@@" % var, "") |
1504 |
continue |
1487 |
|
1505 |
|
1488 |
sbprofile = MACOSSANDBOX_PROFILE |
1506 |
rules_literal = "" |
1489 |
sbprofile = sbprofile.replace("@@WRITEABLE_PREFIX@@", sbprefixpath) |
1507 |
rules_regex = "" |
1490 |
sbprofile = sbprofile.replace("@@WRITEABLE_PREFIX_RE@@", sbprefixre) |
1508 |
|
|
|
1509 |
# FIXME: Allow for quoting inside the variable to allow paths with |
1510 |
# spaces in them? |
1511 |
for path in paths.split(" "): |
1512 |
# do a second round of token replacements to be able to |
1513 |
# reference settings like EPREFIX or PORTAGE_BUILDDIR. |
1514 |
for token in path.split("@@")[1:-1:2]: |
1515 |
if token not in mysettings: |
1516 |
continue |
1517 |
|
1518 |
path = path.replace("@@%s@@" % token, mysettings[token]) |
1519 |
|
1520 |
if "@@" in path: |
1521 |
# unreplaced tokens left - silently ignore path - needed |
1522 |
# for PORTAGE_ACTUAL_DISTDIR which isn't always set |
1523 |
pass |
1524 |
elif path[-1] == os.sep: |
1525 |
# path ends in slash - make it a regex and allow access |
1526 |
# recursively. |
1527 |
path = path.replace("+", "\+") |
1528 |
path = path.replace("*", "\*") |
1529 |
path = path.replace("[", "\[") |
1530 |
path = path.replace("[", "\[") |
1531 |
rules_regex += " #\"^%s\"\n" % path |
1532 |
else: |
1533 |
rules_literal += " #\"%s\"\n" % path |
1534 |
|
1535 |
rules = "" |
1536 |
if rules_literal: |
1537 |
rules += " (literal\n" + rules_literal + " )\n" |
1538 |
if rules_regex: |
1539 |
rules += " (regex\n" + rules_regex + " )\n" |
1540 |
sbprofile = sbprofile.replace("@@%s@@" % var, rules) |
1491 |
|
1541 |
|
1492 |
keywords["profile"] = sbprofile |
1542 |
keywords["profile"] = sbprofile |
1493 |
spawn_func = portage.process.spawn_macossandbox |
1543 |
spawn_func = portage.process.spawn_macossandbox |