Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 27669 | Differences between
and this patch

Collapse All | Expand All

(-)portage.py-2.0.49-r3 (-32 / +142 lines)
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.32 2003/09/07 02:28:10 kvh Exp $
5
5
6
VERSION="2.0.49-r3"
6
VERSION="2.0.49-r3-k2"
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 1110-1115 Link Here
1110
	resumecommand=string.replace(resumecommand,"${DISTDIR}",settings["DISTDIR"])
1142
	resumecommand=string.replace(resumecommand,"${DISTDIR}",settings["DISTDIR"])
1111
	mydigests=None
1143
	mydigests=None
1112
	digestfn=settings["FILESDIR"]+"/digest-"+settings["PF"]
1144
	digestfn=settings["FILESDIR"]+"/digest-"+settings["PF"]
1145
1146
#KVH
1147
	settings["SRC_LINKS"]=settings["PORTAGE_TMPDIR"]+"/source-links"
1148
	try:
1149
		if not os.path.exists(settings["SRC_LINKS"]):
1150
			os.makedirs(settings["SRC_LINKS"])
1151
			os.chown(settings["SRC_LINKS"],portage_uid,portage_gid)
1152
		else:
1153
			#O.K. we'll clean out old links here...
1154
			src_links = settings["SRC_LINKS"]
1155
			files = os.listdir(src_links)
1156
			for file in files:
1157
				jfile = src_links+"/"+file
1158
				if os.path.islink(jfile):
1159
					os.remove(jfile)
1160
				else:
1161
					pass
1162
1163
	except Exception, e:
1164
		print "!!! Filesystem error. (Read-Only?)"
1165
		print "!!!",e
1166
		return 0
1167
1168
1113
	if os.path.exists(digestfn):
1169
	if os.path.exists(digestfn):
1114
		myfile=open(digestfn,"r")
1170
		myfile=open(digestfn,"r")
1115
		mylines=myfile.readlines()
1171
		mylines=myfile.readlines()
Lines 1173-1178 Link Here
1173
		else:
1229
		else:
1174
				filedict[myfile].append(myuri)
1230
				filedict[myfile].append(myuri)
1175
	for myfile in filedict.keys():
1231
	for myfile in filedict.keys():
1232
#		print "^^^ myfile ",myfile
1176
		if listonly:
1233
		if listonly:
1177
			fetched=0
1234
			fetched=0
1178
			sys.stderr.write("\n")
1235
			sys.stderr.write("\n")
Lines 1180-1213 Link Here
1180
			if listonly:
1237
			if listonly:
1181
				sys.stderr.write(loc+" ")
1238
				sys.stderr.write(loc+" ")
1182
				continue
1239
				continue
1183
			try:
1240
1184
				mystat=os.stat(settings["DISTDIR"]+"/"+myfile)
1241
			fetched=0
1185
				if mydigests!=None and mydigests.has_key(myfile):
1242
			indistdirs=0
1186
					#if we have the digest file, we know the final size and can resume the download.
1243
			# Try the normal place first
1187
					if mystat[ST_SIZE]<mydigests[myfile]["size"]:
1244
			filedir=settings["DISTDIR"]
1188
						fetched=1
1245
			mystsize=returnFileSizeInDir(filedir,myfile)
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
1189
					else:
1268
					else:
1190
						#we already have it downloaded, skip.
1269
						# Check md5sum's at each fetch for fetchonly.
1191
						#if our file is bigger than the recorded size, digestcheck should catch it.
1270
						mymd5=perform_md5(filedir+"/"+myfile)
1192
						if not fetchonly:
1271
						if mymd5 != mydigests[myfile]["md5"]:
1193
							fetched=2
1272
							sys.stderr.write("!!! Previously fetched file: "+str(myfile)+" MD5 FAILED! Refetching...\n")
1273
#							os.unlink(settings["DISTDIR"]+"/"+myfile)
1274
							fetched=0
1194
						else:
1275
						else:
1195
							# Check md5sum's at each fetch for fetchonly.
1276
							sys.stderr.write(">>> Previously fetched file: "+str(myfile)+" MD5 ;-)\n")
1196
							mymd5=perform_md5(settings["DISTDIR"]+"/"+myfile)
1277
							fetched=2
1197
							if mymd5 != mydigests[myfile]["md5"]:
1278
							break #No need to keep looking for this file, we have it!
1198
								sys.stderr.write("!!! Previously fetched file: "+str(myfile)+" MD5 FAILED! Refetching...\n")
1279
			else:
1199
								os.unlink(settings["DISTDIR"]+"/"+myfile)
1280
				#we don't have the digest file, but the file exists.  Assume it is fully downloaded.
1200
								fetched=0
1281
				fetched=2
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
1210
			if fetched!=2:
1282
			if fetched!=2:
1283
				# Reset filedir to point to original DISTDIR
1284
				filedir=settings["DISTDIR"]
1285
1211
				#we either need to resume or start the download
1286
				#we either need to resume or start the download
1212
				#you can't use "continue" when you're inside a "try" block
1287
				#you can't use "continue" when you're inside a "try" block
1213
				if fetched==1:
1288
				if fetched==1:
Lines 1269-1274 Link Here
1269
		if (fetched!=2) and not listonly:
1344
		if (fetched!=2) and not listonly:
1270
			sys.stderr.write("!!! Couldn't download "+str(myfile)+". Aborting.\n")
1345
			sys.stderr.write("!!! Couldn't download "+str(myfile)+". Aborting.\n")
1271
			return 0
1346
			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
	
1272
	return 1
1363
	return 1
1273
1364
1274
1365
Lines 1294-1301 Link Here
1294
	"""generates digest file if missing.  Assumes all files are available.	If
1385
	"""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."""
1386
	overwrite=0, the digest will only be created if it doesn't already exist."""
1296
1387
1388
# KVH - Change basedir to SRC_LINKS
1389
#  basedir=settings["DISTDIR"]+"/"
1390
	basedir=settings["SRC_LINKS"]+"/"
1391
1297
	# archive files
1392
	# archive files
1298
	basedir=settings["DISTDIR"]+"/"
1299
	digestfn=settings["FILESDIR"]+"/digest-"+settings["PF"]
1393
	digestfn=settings["FILESDIR"]+"/digest-"+settings["PF"]
1300
1394
1301
	# portage files -- p(ortagefiles)basedir
1395
	# portage files -- p(ortagefiles)basedir
Lines 1521-1531 Link Here
1521
			retval=spawnebuild(actionmap[mydo]["dep"],actionmap,debug,alwaysdep)
1615
			retval=spawnebuild(actionmap[mydo]["dep"],actionmap,debug,alwaysdep)
1522
			if retval:
1616
			if retval:
1523
				return retval
1617
				return retval
1524
	# spawn ebuild.sh
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
1525
	mycommand="/usr/sbin/ebuild.sh "
1625
	mycommand="/usr/sbin/ebuild.sh "
1526
	return spawn(mycommand + mydo,debug,
1626
	ret=spawn(mycommand + mydo,debug,
1527
				actionmap[mydo]["args"][0],
1627
		actionmap[mydo]["args"][0],
1528
				actionmap[mydo]["args"][1])
1628
		actionmap[mydo]["args"][1])
1629
1630
	settings["DISTDIR"]=settings["ODISTDIR"]
1631
1632
	return ret
1633
1634
	# spawn ebuild.sh
1635
#	mycommand="/usr/sbin/ebuild.sh "
1636
#	return spawn(mycommand + mydo,debug,
1637
#				actionmap[mydo]["args"][0],
1638
#				actionmap[mydo]["args"][1])
1529
1639
1530
def doebuild(myebuild,mydo,myroot,debug=0,listonly=0,fetchonly=0):
1640
def doebuild(myebuild,mydo,myroot,debug=0,listonly=0,fetchonly=0):
1531
	global settings
1641
	global settings

Return to bug 27669