Lines 1-9
Link Here
|
1 |
# portage.py -- core Portage functionality |
1 |
# portage.py -- core Portage functionality |
2 |
# Copyright 1998-2003 Daniel Robbins, Gentoo Technologies, Inc. |
2 |
# Copyright 1998-2003 Daniel Robbins, Gentoo Technologies, Inc. |
3 |
# Distributed under the GNU Public License v2 |
3 |
# Distributed under the GNU Public License v2 |
4 |
# $Header: /home/cvsroot/gentoo-src/portage/pym/portage.py,v 1.337 2003/08/22 17:09:37 carpaski Exp $ |
4 |
# $Header: /mnt/alpha/cvsroot/kvh/portage-df/portage.py,v 1.29 2003/08/31 21:54:36 kvh Exp $ |
5 |
|
5 |
|
6 |
VERSION="2.0.49-r2" |
6 |
VERSION="2.0.49-r2-k1" |
7 |
|
7 |
|
8 |
from stat import * |
8 |
from stat import * |
9 |
from commands import * |
9 |
from commands import * |
Lines 1092-1097
Link Here
|
1092 |
else: |
1092 |
else: |
1093 |
return 16 # interrupted by signal |
1093 |
return 16 # interrupted by signal |
1094 |
|
1094 |
|
|
|
1095 |
|
1096 |
#KVH |
1097 |
def returnFileSizeInDir(mydir,myfile): |
1098 |
"If myfile found in mydir, return size of myfile; otherwise 0" |
1099 |
|
1100 |
st_size=0 |
1101 |
try: |
1102 |
mystat=os.stat(mydir+"/"+myfile) |
1103 |
st_size=mystat[ST_SIZE] |
1104 |
except (OSError,IOError),e: |
1105 |
st_size=0 |
1106 |
return st_size |
1107 |
|
1108 |
#KVH |
1109 |
def findFileInDistDirs(myfile): |
1110 |
"Check all directories in DISTDIRS for myfile" |
1111 |
|
1112 |
mydir="" |
1113 |
|
1114 |
if settings["DISTDIRS"]=="": |
1115 |
return mydir |
1116 |
|
1117 |
# Traverse through all directories |
1118 |
for d in settings["DISTDIRS"].split(":"): |
1119 |
# print "^^^ Checking for "+myfile+" in "+d |
1120 |
st_size=returnFileSizeInDir(d,myfile) |
1121 |
if st_size: |
1122 |
mydir=d |
1123 |
break |
1124 |
|
1125 |
return mydir |
1126 |
|
1095 |
def fetch(myuris, listonly=0, fetchonly=0): |
1127 |
def fetch(myuris, listonly=0, fetchonly=0): |
1096 |
"fetch files. Will use digest file if available." |
1128 |
"fetch files. Will use digest file if available." |
1097 |
if ("mirror" in features) and ("nomirror" in settings["RESTRICT"].split()): |
1129 |
if ("mirror" in features) and ("nomirror" in settings["RESTRICT"].split()): |
Lines 1180-1191
Link Here
|
1180 |
if listonly: |
1212 |
if listonly: |
1181 |
sys.stderr.write(loc+" ") |
1213 |
sys.stderr.write(loc+" ") |
1182 |
continue |
1214 |
continue |
1183 |
try: |
1215 |
|
1184 |
mystat=os.stat(settings["DISTDIR"]+"/"+myfile) |
1216 |
|
1185 |
if mydigests!=None and mydigests.has_key(myfile): |
1217 |
fetched=0 |
1186 |
#if we have the digest file, we know the final size and can resume the download. |
1218 |
indistdirs=0 |
1187 |
if mystat[ST_SIZE]<mydigests[myfile]["size"]: |
1219 |
# Try the normal place first |
1188 |
fetched=1 |
1220 |
filedir=settings["DISTDIR"] |
|
|
1221 |
mystsize=returnFileSizeInDir(filedir,myfile) |
1222 |
|
1223 |
# If not DISTDIR, try all DISTDIRS |
1224 |
if mystsize==0 and settings["DISTDIRS"]: |
1225 |
filedir=findFileInDistDirs(myfile) |
1226 |
if filedir!="": |
1227 |
mystsize=returnFileSizeInDir(filedir,myfile) |
1228 |
indistdirs=1 |
1229 |
|
1230 |
|
1231 |
|
1232 |
|
1233 |
|
1234 |
|
1235 |
|
1236 |
|
1237 |
if mydigests!=None and mydigests.has_key(myfile): |
1238 |
#if we have the digest file, we know the final size and can resume the download. |
1239 |
if mystsize == 0: |
1240 |
fetched=0 |
1241 |
elif mystsize<mydigests[myfile]["size"]: |
1242 |
fetched=1 |
1243 |
# Do not allow resume for files in DISTDIRS |
1244 |
if indistdirs==1: |
1245 |
fetched=0 |
1189 |
else: |
1246 |
else: |
1190 |
#we already have it downloaded, skip. |
1247 |
#we already have it downloaded, skip. |
1191 |
#if our file is bigger than the recorded size, digestcheck should catch it. |
1248 |
#if our file is bigger than the recorded size, digestcheck should catch it. |
Lines 1205-1213
Link Here
|
1205 |
else: |
1262 |
else: |
1206 |
#we don't have the digest file, but the file exists. Assume it is fully downloaded. |
1263 |
#we don't have the digest file, but the file exists. Assume it is fully downloaded. |
1207 |
fetched=2 |
1264 |
fetched=2 |
1208 |
except (OSError,IOError),e: |
|
|
1209 |
fetched=0 |
1210 |
if fetched!=2: |
1265 |
if fetched!=2: |
|
|
1266 |
# Reset filedir to point to original DISTDIR |
1267 |
filedir=settings["DISTDIR"] |
1268 |
|
1211 |
#we either need to resume or start the download |
1269 |
#we either need to resume or start the download |
1212 |
#you can't use "continue" when you're inside a "try" block |
1270 |
#you can't use "continue" when you're inside a "try" block |
1213 |
if fetched==1: |
1271 |
if fetched==1: |
Lines 1269-1274
Link Here
|
1269 |
if (fetched!=2) and not listonly: |
1327 |
if (fetched!=2) and not listonly: |
1270 |
sys.stderr.write("!!! Couldn't download "+str(myfile)+". Aborting.\n") |
1328 |
sys.stderr.write("!!! Couldn't download "+str(myfile)+". Aborting.\n") |
1271 |
return 0 |
1329 |
return 0 |
|
|
1330 |
|
1331 |
#KVH |
1332 |
# Create a new directory to store all the distfile links. |
1333 |
# settings["SRC_LINKS"]=settings["PORTAGE_TMPDIR"]+"/source-links" |
1334 |
if not listonly and not fetchonly: |
1335 |
# print "^^^ "+myfile+" is located in "+filedir |
1336 |
target = filedir + "/" + myfile |
1337 |
dest = settings["SRC_LINKS"] + "/" + myfile |
1338 |
# print "^^^ "+target+" --> "+dest |
1339 |
try: |
1340 |
os.symlink(target,dest) |
1341 |
except Exception, e: |
1342 |
# Should not happen since we clear out the directory above. |
1343 |
# May already exists...should likely ignore errors here... |
1344 |
print "^^^ Error : "+dest+ " already exists! (ignore)" |
1345 |
|
1272 |
return 1 |
1346 |
return 1 |
1273 |
|
1347 |
|
1274 |
|
1348 |
|
Lines 1294-1301
Link Here
|
1294 |
"""generates digest file if missing. Assumes all files are available. If |
1368 |
"""generates digest file if missing. Assumes all files are available. If |
1295 |
overwrite=0, the digest will only be created if it doesn't already exist.""" |
1369 |
overwrite=0, the digest will only be created if it doesn't already exist.""" |
1296 |
|
1370 |
|
|
|
1371 |
# KVH - Change basedir to SRC_LINKS |
1372 |
# basedir=settings["DISTDIR"]+"/" |
1373 |
basedir=settings["SRC_LINKS"]+"/" |
1374 |
|
1297 |
# archive files |
1375 |
# archive files |
1298 |
basedir=settings["DISTDIR"]+"/" |
|
|
1299 |
digestfn=settings["FILESDIR"]+"/digest-"+settings["PF"] |
1376 |
digestfn=settings["FILESDIR"]+"/digest-"+settings["PF"] |
1300 |
|
1377 |
|
1301 |
# portage files -- p(ortagefiles)basedir |
1378 |
# portage files -- p(ortagefiles)basedir |
Lines 1521-1531
Link Here
|
1521 |
retval=spawnebuild(actionmap[mydo]["dep"],actionmap,debug,alwaysdep) |
1598 |
retval=spawnebuild(actionmap[mydo]["dep"],actionmap,debug,alwaysdep) |
1522 |
if retval: |
1599 |
if retval: |
1523 |
return retval |
1600 |
return retval |
1524 |
# spawn ebuild.sh |
1601 |
|
|
|
1602 |
#KVH |
1603 |
settings["ODISTDIR"]=settings["DISTDIR"] |
1604 |
settings["DISTDIR"]=settings["SRC_LINKS"] |
1605 |
|
1606 |
# print "^^^ Current [DISTDIR] "+settings["DISTDIR"] |
1607 |
# spawn ebuild.sh |
1525 |
mycommand="/usr/sbin/ebuild.sh " |
1608 |
mycommand="/usr/sbin/ebuild.sh " |
1526 |
return spawn(mycommand + mydo,debug, |
1609 |
ret=spawn(mycommand + mydo,debug, |
1527 |
actionmap[mydo]["args"][0], |
1610 |
actionmap[mydo]["args"][0], |
1528 |
actionmap[mydo]["args"][1]) |
1611 |
actionmap[mydo]["args"][1]) |
|
|
1612 |
|
1613 |
settings["DISTDIR"]=settings["ODISTDIR"] |
1614 |
|
1615 |
return ret |
1616 |
|
1617 |
# spawn ebuild.sh |
1618 |
# mycommand="/usr/sbin/ebuild.sh " |
1619 |
# return spawn(mycommand + mydo,debug, |
1620 |
# actionmap[mydo]["args"][0], |
1621 |
# actionmap[mydo]["args"][1]) |
1529 |
|
1622 |
|
1530 |
def doebuild(myebuild,mydo,myroot,debug=0,listonly=0,fetchonly=0): |
1623 |
def doebuild(myebuild,mydo,myroot,debug=0,listonly=0,fetchonly=0): |
1531 |
global settings |
1624 |
global settings |