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: /mnt/alpha/cvsroot/kvh/portage-df/portage.py,v 1.30 2003/08/31 23:29:17 kvh Exp $ |
4 |
# $Header: /home/cvsroot/gentoo-src/portage/pym/portage.py,v 1.337 2003/08/22 17:09:37 carpaski Exp $ |
5 |
|
5 |
|
6 |
VERSION="2.0.49-r2-k1" |
6 |
VERSION="2.0.49-r2" |
7 |
|
7 |
|
8 |
from stat import * |
8 |
from stat import * |
9 |
from commands import * |
9 |
from commands import * |
Lines 1092-1129
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 |
|
1127 |
def fetch(myuris, listonly=0, fetchonly=0): |
1095 |
def fetch(myuris, listonly=0, fetchonly=0): |
1128 |
"fetch files. Will use digest file if available." |
1096 |
"fetch files. Will use digest file if available." |
1129 |
if ("mirror" in features) and ("nomirror" in settings["RESTRICT"].split()): |
1097 |
if ("mirror" in features) and ("nomirror" in settings["RESTRICT"].split()): |
Lines 1142-1172
Link Here
|
1142 |
resumecommand=string.replace(resumecommand,"${DISTDIR}",settings["DISTDIR"]) |
1110 |
resumecommand=string.replace(resumecommand,"${DISTDIR}",settings["DISTDIR"]) |
1143 |
mydigests=None |
1111 |
mydigests=None |
1144 |
digestfn=settings["FILESDIR"]+"/digest-"+settings["PF"] |
1112 |
digestfn=settings["FILESDIR"]+"/digest-"+settings["PF"] |
1145 |
|
|
|
1146 |
#KVH |
1147 |
settings["SRC_LINKS"]=settings["PORTAGE_TMPDIR"]+"/source-links" |
1148 |
|
1149 |
try: |
1150 |
if not os.path.exists(settings["SRC_LINKS"]): |
1151 |
os.makedirs(settings["SRC_LINKS"]) |
1152 |
os.chown(settings["SRC_LINKS"],portage_uid,portage_gid) |
1153 |
else: |
1154 |
#O.K. we'll clean out old links here... |
1155 |
src_links = settings["SRC_LINKS"] |
1156 |
files = os.listdir(src_links) |
1157 |
for file in files: |
1158 |
jfile = src_links+"/"+file |
1159 |
if os.path.islink(jfile): |
1160 |
os.remove(jfile) |
1161 |
else: |
1162 |
pass |
1163 |
|
1164 |
except Exception, e: |
1165 |
print "!!! Filesystem error. (Read-Only?)" |
1166 |
print "!!!",e |
1167 |
return 0 |
1168 |
|
1169 |
|
1170 |
if os.path.exists(digestfn): |
1113 |
if os.path.exists(digestfn): |
1171 |
myfile=open(digestfn,"r") |
1114 |
myfile=open(digestfn,"r") |
1172 |
mylines=myfile.readlines() |
1115 |
mylines=myfile.readlines() |
Lines 1237-1288
Link Here
|
1237 |
if listonly: |
1180 |
if listonly: |
1238 |
sys.stderr.write(loc+" ") |
1181 |
sys.stderr.write(loc+" ") |
1239 |
continue |
1182 |
continue |
1240 |
|
1183 |
try: |
1241 |
fetched=0 |
1184 |
mystat=os.stat(settings["DISTDIR"]+"/"+myfile) |
1242 |
indistdirs=0 |
1185 |
if mydigests!=None and mydigests.has_key(myfile): |
1243 |
# Try the normal place first |
1186 |
#if we have the digest file, we know the final size and can resume the download. |
1244 |
filedir=settings["DISTDIR"] |
1187 |
if mystat[ST_SIZE]<mydigests[myfile]["size"]: |
1245 |
mystsize=returnFileSizeInDir(filedir,myfile) |
1188 |
fetched=1 |
1246 |
|
|
|
1247 |
# If not DISTDIR, try all DISTDIRS |
1248 |
if mystsize==0 and settings["DISTDIRS"]: |
1249 |
filedir=findFileInDistDirs(myfile) |
1250 |
if filedir!="": |
1251 |
mystsize=returnFileSizeInDir(filedir,myfile) |
1252 |
indistdirs=1 |
1253 |
|
1254 |
if mydigests!=None and mydigests.has_key(myfile): |
1255 |
#if we have the digest file, we know the final size and can resume the download. |
1256 |
if mystsize == 0: |
1257 |
fetched=0 |
1258 |
elif mystsize<mydigests[myfile]["size"]: |
1259 |
fetched=1 |
1260 |
# Do not allow resume for files in DISTDIRS |
1261 |
if indistdirs==1: |
1262 |
fetched=0 |
1263 |
else: |
1264 |
#we already have it downloaded, skip. |
1265 |
#if our file is bigger than the recorded size, digestcheck should catch it. |
1266 |
if not fetchonly: |
1267 |
fetched=2 |
1268 |
else: |
1189 |
else: |
1269 |
# Check md5sum's at each fetch for fetchonly. |
1190 |
#we already have it downloaded, skip. |
1270 |
mymd5=perform_md5(filedir+"/"+myfile) |
1191 |
#if our file is bigger than the recorded size, digestcheck should catch it. |
1271 |
if mymd5 != mydigests[myfile]["md5"]: |
1192 |
if not fetchonly: |
1272 |
sys.stderr.write("!!! Previously fetched file: "+str(myfile)+" MD5 FAILED! Refetching...\n") |
|
|
1273 |
# os.unlink(settings["DISTDIR"]+"/"+myfile) |
1274 |
fetched=0 |
1275 |
else: |
1276 |
sys.stderr.write(">>> Previously fetched file: "+str(myfile)+" MD5 ;-)\n") |
1277 |
fetched=2 |
1193 |
fetched=2 |
1278 |
break #No need to keep looking for this file, we have it! |
1194 |
else: |
1279 |
else: |
1195 |
# Check md5sum's at each fetch for fetchonly. |
1280 |
#we don't have the digest file, but the file exists. Assume it is fully downloaded. |
1196 |
mymd5=perform_md5(settings["DISTDIR"]+"/"+myfile) |
1281 |
fetched=2 |
1197 |
if mymd5 != mydigests[myfile]["md5"]: |
|
|
1198 |
sys.stderr.write("!!! Previously fetched file: "+str(myfile)+" MD5 FAILED! Refetching...\n") |
1199 |
os.unlink(settings["DISTDIR"]+"/"+myfile) |
1200 |
fetched=0 |
1201 |
else: |
1202 |
sys.stderr.write(">>> Previously fetched file: "+str(myfile)+" MD5 ;-)\n") |
1203 |
fetched=2 |
1204 |
break #No need to keep looking for this file, we have it! |
1205 |
else: |
1206 |
#we don't have the digest file, but the file exists. Assume it is fully downloaded. |
1207 |
fetched=2 |
1208 |
except (OSError,IOError),e: |
1209 |
fetched=0 |
1282 |
if fetched!=2: |
1210 |
if fetched!=2: |
1283 |
# Reset filedir to point to original DISTDIR |
|
|
1284 |
filedir=settings["DISTDIR"] |
1285 |
|
1286 |
#we either need to resume or start the download |
1211 |
#we either need to resume or start the download |
1287 |
#you can't use "continue" when you're inside a "try" block |
1212 |
#you can't use "continue" when you're inside a "try" block |
1288 |
if fetched==1: |
1213 |
if fetched==1: |
Lines 1344-1365
Link Here
|
1344 |
if (fetched!=2) and not listonly: |
1269 |
if (fetched!=2) and not listonly: |
1345 |
sys.stderr.write("!!! Couldn't download "+str(myfile)+". Aborting.\n") |
1270 |
sys.stderr.write("!!! Couldn't download "+str(myfile)+". Aborting.\n") |
1346 |
return 0 |
1271 |
return 0 |
1347 |
|
|
|
1348 |
#KVH |
1349 |
# Create a new directory to store all the distfile links. |
1350 |
# settings["SRC_LINKS"]=settings["PORTAGE_TMPDIR"]+"/source-links" |
1351 |
if not listonly and not fetchonly: |
1352 |
# print "^^^ "+myfile+" is located in "+filedir |
1353 |
target = filedir + "/" + myfile |
1354 |
dest = settings["SRC_LINKS"] + "/" + myfile |
1355 |
# print "^^^ "+target+" --> "+dest |
1356 |
try: |
1357 |
os.symlink(target,dest) |
1358 |
except Exception, e: |
1359 |
# Should not happen since we clear out the directory above. |
1360 |
# May already exists...should likely ignore errors here... |
1361 |
print "^^^ Error : "+dest+ " already exists! (ignore)" |
1362 |
|
1363 |
return 1 |
1272 |
return 1 |
1364 |
|
1273 |
|
1365 |
|
1274 |
|
Lines 1385-1395
Link Here
|
1385 |
"""generates digest file if missing. Assumes all files are available. If |
1294 |
"""generates digest file if missing. Assumes all files are available. If |
1386 |
overwrite=0, the digest will only be created if it doesn't already exist.""" |
1295 |
overwrite=0, the digest will only be created if it doesn't already exist.""" |
1387 |
|
1296 |
|
1388 |
# KVH - Change basedir to SRC_LINKS |
|
|
1389 |
# basedir=settings["DISTDIR"]+"/" |
1390 |
basedir=settings["SRC_LINKS"]+"/" |
1391 |
|
1392 |
# archive files |
1297 |
# archive files |
|
|
1298 |
basedir=settings["DISTDIR"]+"/" |
1393 |
digestfn=settings["FILESDIR"]+"/digest-"+settings["PF"] |
1299 |
digestfn=settings["FILESDIR"]+"/digest-"+settings["PF"] |
1394 |
|
1300 |
|
1395 |
# portage files -- p(ortagefiles)basedir |
1301 |
# portage files -- p(ortagefiles)basedir |
Lines 1615-1641
Link Here
|
1615 |
retval=spawnebuild(actionmap[mydo]["dep"],actionmap,debug,alwaysdep) |
1521 |
retval=spawnebuild(actionmap[mydo]["dep"],actionmap,debug,alwaysdep) |
1616 |
if retval: |
1522 |
if retval: |
1617 |
return retval |
1523 |
return retval |
1618 |
|
|
|
1619 |
#KVH |
1620 |
settings["ODISTDIR"]=settings["DISTDIR"] |
1621 |
settings["DISTDIR"]=settings["SRC_LINKS"] |
1622 |
|
1623 |
# print "^^^ Current [DISTDIR] "+settings["DISTDIR"] |
1624 |
# spawn ebuild.sh |
1625 |
mycommand="/usr/sbin/ebuild.sh " |
1626 |
ret=spawn(mycommand + mydo,debug, |
1627 |
actionmap[mydo]["args"][0], |
1628 |
actionmap[mydo]["args"][1]) |
1629 |
|
1630 |
settings["DISTDIR"]=settings["ODISTDIR"] |
1631 |
|
1632 |
return ret |
1633 |
|
1634 |
# spawn ebuild.sh |
1524 |
# spawn ebuild.sh |
1635 |
# mycommand="/usr/sbin/ebuild.sh " |
1525 |
mycommand="/usr/sbin/ebuild.sh " |
1636 |
# return spawn(mycommand + mydo,debug, |
1526 |
return spawn(mycommand + mydo,debug, |
1637 |
# actionmap[mydo]["args"][0], |
1527 |
actionmap[mydo]["args"][0], |
1638 |
# actionmap[mydo]["args"][1]) |
1528 |
actionmap[mydo]["args"][1]) |
1639 |
|
1529 |
|
1640 |
def doebuild(myebuild,mydo,myroot,debug=0,listonly=0,fetchonly=0): |
1530 |
def doebuild(myebuild,mydo,myroot,debug=0,listonly=0,fetchonly=0): |
1641 |
global settings |
1531 |
global settings |