Lines 5-42
Link Here
|
5 |
|
5 |
|
6 |
import os |
6 |
import os |
7 |
import sys |
7 |
import sys |
|
|
8 |
import output |
8 |
|
9 |
|
9 |
def getroot(): |
10 |
def getroot(): |
10 |
try: |
11 |
try: |
11 |
a=os.environ["ROOT"] |
12 |
root_dir = os.environ['ROOT'] |
12 |
except: |
13 |
except KeyError: |
13 |
return "/" |
14 |
return '/' |
14 |
return os.path.normpath(a+"/") |
15 |
return os.path.normpath(root_dir + '/') |
15 |
|
16 |
|
16 |
os.environ["PORTAGE_CALLER"]="ebuild" |
17 |
err = lambda S: output.red('Error: ') + output.bold(S) |
17 |
|
18 |
|
18 |
if len(sys.argv)<=2: |
19 |
os.environ['PORTAGE_CALLER']='ebuild' |
19 |
print "expecting two arguments." |
20 |
if len(sys.argv) <= 2: raise SystemExit, err('expecting two arguments.') |
20 |
sys.exit(1) |
|
|
21 |
|
21 |
|
22 |
import portage |
22 |
import portage |
23 |
import getopt |
23 |
import getopt |
24 |
|
24 |
|
25 |
debug=0 |
25 |
debug = False |
26 |
|
26 |
opts, pargs = getopt.getopt(sys.argv[1:], '', ['debug']) |
27 |
opts,pargs=getopt.getopt(sys.argv[1:],'',['debug']) |
27 |
if '--debug' in map(lambda L: L[0], opts): debug = True |
28 |
for opt in opts: |
|
|
29 |
if opt[0]=='--debug': |
30 |
debug=1 |
31 |
|
32 |
for x in pargs[1:]: |
28 |
for x in pargs[1:]: |
33 |
try: |
29 |
try: |
34 |
a=portage.doebuild(pargs[0],x,getroot(),debug=debug) |
30 |
portage.doebuild(pargs[0],x,getroot(),debug=debug) |
35 |
except KeyboardInterrupt: |
31 |
except KeyboardInterrupt: |
36 |
print "(interrupted by user -- ctrl-C?)" |
32 |
raise SystemExit, err('interrupted by user -- ctrl-C?') |
37 |
a=1 |
|
|
38 |
except IOError: |
33 |
except IOError: |
39 |
a=1 |
34 |
raise SystemExit, err('ebuild: this ebuild generated output during the depend phase (bad)') |
40 |
print "ebuild: this ebuild generated output during the depend phase (bad)" |
|
|
41 |
if a: |
42 |
sys.exit(a) |