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

(-)originals/portage.py-2.0.49-r9 (-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.340 2003/09/29 18:13:42 carpaski Exp $
4
# $Header: /home/cvsroot/projects/portage/portage.py,v 1.2 2003/10/08 05:32:03 kvh Exp $
5
5
6
VERSION="2.0.49-r9"
6
VERSION="2.0.49-r9-k1"
7
7
8
from stat import *
8
from stat import *
9
from commands import *
9
from commands import *
Lines 1098-1103 Link Here
1098
	else:
1098
	else:
1099
		return 16            # interrupted by signal
1099
		return 16            # interrupted by signal
1100
1100
1101
1102
#KVH
1103
def returnFileSizeInDir(mydir,myfile):
1104
	"If myfile found in mydir, return size of myfile; otherwise 0"
1105
1106
	st_size=0
1107
	try:
1108
		mystat=os.stat(mydir+"/"+myfile)
1109
		st_size=mystat[ST_SIZE]
1110
	except (OSError,IOError),e:
1111
		st_size=0
1112
	return st_size
1113
1114
#KVH
1115
def findFileInDistDirs(myfile):
1116
	"Check all directories in DISTDIRS for myfile"
1117
1118
	mydir=""
1119
1120
	if settings["DISTDIRS"]=="":
1121
		return mydir
1122
1123
# Traverse through all directories
1124
	for d in settings["DISTDIRS"].split(":"):
1125
#     print "^^^ Checking for "+myfile+" in "+d
1126
		st_size=returnFileSizeInDir(d,myfile)
1127
		if st_size:
1128
			mydir=d
1129
			break
1130
1131
	return mydir
1132
1101
def fetch(myuris, listonly=0, fetchonly=0):
1133
def fetch(myuris, listonly=0, fetchonly=0):
1102
	"fetch files.  Will use digest file if available."
1134
	"fetch files.  Will use digest file if available."
1103
	if ("mirror" in features) and ("nomirror" in settings["RESTRICT"].split()):
1135
	if ("mirror" in features) and ("nomirror" in settings["RESTRICT"].split()):
Lines 1116-1121 Link Here
1116
	resumecommand=string.replace(resumecommand,"${DISTDIR}",settings["DISTDIR"])
1148
	resumecommand=string.replace(resumecommand,"${DISTDIR}",settings["DISTDIR"])
1117
	mydigests=None
1149
	mydigests=None
1118
	digestfn=settings["FILESDIR"]+"/digest-"+settings["PF"]
1150
	digestfn=settings["FILESDIR"]+"/digest-"+settings["PF"]
1151
1152
#KVH
1153
	settings["SRC_LINKS"]=settings["PORTAGE_TMPDIR"]+"/source-links"
1154
	try:
1155
		if not os.path.exists(settings["SRC_LINKS"]):
1156
			os.makedirs(settings["SRC_LINKS"])
1157
			os.chown(settings["SRC_LINKS"],portage_uid,portage_gid)
1158
		else:
1159
			#O.K. we'll clean out old links here...
1160
			src_links = settings["SRC_LINKS"]
1161
			files = os.listdir(src_links)
1162
			for file in files:
1163
				jfile = src_links+"/"+file
1164
				if os.path.islink(jfile):
1165
					os.remove(jfile)
1166
				else:
1167
					pass
1168
1169
	except Exception, e:
1170
		print "!!! Filesystem error. (Read-Only?)"
1171
		print "!!!",e
1172
		return 0
1173
1174
1119
	if os.path.exists(digestfn):
1175
	if os.path.exists(digestfn):
1120
		myfile=open(digestfn,"r")
1176
		myfile=open(digestfn,"r")
1121
		mylines=myfile.readlines()
1177
		mylines=myfile.readlines()
Lines 1179-1184 Link Here
1179
		else:
1235
		else:
1180
				filedict[myfile].append(myuri)
1236
				filedict[myfile].append(myuri)
1181
	for myfile in filedict.keys():
1237
	for myfile in filedict.keys():
1238
#		print "^^^ myfile ",myfile
1182
		if listonly:
1239
		if listonly:
1183
			fetched=0
1240
			fetched=0
1184
			sys.stderr.write("\n")
1241
			sys.stderr.write("\n")
Lines 1186-1219 Link Here
1186
			if listonly:
1243
			if listonly:
1187
				sys.stderr.write(loc+" ")
1244
				sys.stderr.write(loc+" ")
1188
				continue
1245
				continue
1189
			try:
1246
1190
				mystat=os.stat(settings["DISTDIR"]+"/"+myfile)
1247
			fetched=0
1191
				if mydigests!=None and mydigests.has_key(myfile):
1248
			indistdirs=0
1192
					#if we have the digest file, we know the final size and can resume the download.
1249
			# Try the normal place first
1193
					if mystat[ST_SIZE]<mydigests[myfile]["size"]:
1250
			filedir=settings["DISTDIR"]
1194
						fetched=1
1251
			mystsize=returnFileSizeInDir(filedir,myfile)
1252
1253
			# If not DISTDIR, try all DISTDIRS
1254
			if mystsize==0 and settings["DISTDIRS"]:
1255
				filedir=findFileInDistDirs(myfile)
1256
				if filedir!="":
1257
					mystsize=returnFileSizeInDir(filedir,myfile)
1258
					indistdirs=1
1259
1260
			if mydigests!=None and mydigests.has_key(myfile):
1261
				#if we have the digest file, we know the final size and can resume the download.
1262
				if mystsize == 0:
1263
					fetched=0
1264
				elif mystsize<mydigests[myfile]["size"]:
1265
					fetched=1
1266
					# Do not allow resume for files in DISTDIRS
1267
					if indistdirs==1:
1268
						fetched=0
1269
				else:
1270
					#we already have it downloaded, skip.
1271
					#if our file is bigger than the recorded size, digestcheck should catch it.
1272
					if not fetchonly:
1273
						fetched=2
1195
					else:
1274
					else:
1196
						#we already have it downloaded, skip.
1275
						# Check md5sum's at each fetch for fetchonly.
1197
						#if our file is bigger than the recorded size, digestcheck should catch it.
1276
						mymd5=perform_md5(filedir+"/"+myfile)
1198
						if not fetchonly:
1277
						if mymd5 != mydigests[myfile]["md5"]:
1199
							fetched=2
1278
							sys.stderr.write("!!! Previously fetched file: "+str(myfile)+" MD5 FAILED! Refetching...\n")
1279
#							os.unlink(settings["DISTDIR"]+"/"+myfile)
1280
							fetched=0
1200
						else:
1281
						else:
1201
							# Check md5sum's at each fetch for fetchonly.
1282
							sys.stderr.write(">>> Previously fetched file: "+str(myfile)+" MD5 ;-)\n")
1202
							mymd5=perform_md5(settings["DISTDIR"]+"/"+myfile)
1283
							fetched=2
1203
							if mymd5 != mydigests[myfile]["md5"]:
1284
							break #No need to keep looking for this file, we have it!
1204
								sys.stderr.write("!!! Previously fetched file: "+str(myfile)+" MD5 FAILED! Refetching...\n")
1285
			else:
1205
								os.unlink(settings["DISTDIR"]+"/"+myfile)
1286
				#we don't have the digest file, but the file exists.  Assume it is fully downloaded.
1206
								fetched=0
1287
				fetched=2
1207
							else:
1208
								sys.stderr.write(">>> Previously fetched file: "+str(myfile)+" MD5 ;-)\n")
1209
								fetched=2
1210
								break #No need to keep looking for this file, we have it!
1211
				else:
1212
					#we don't have the digest file, but the file exists.  Assume it is fully downloaded.
1213
					fetched=2
1214
			except (OSError,IOError),e:
1215
				fetched=0
1216
			if fetched!=2:
1288
			if fetched!=2:
1289
				# Reset filedir to point to original DISTDIR
1290
				filedir=settings["DISTDIR"]
1291
1217
				#we either need to resume or start the download
1292
				#we either need to resume or start the download
1218
				#you can't use "continue" when you're inside a "try" block
1293
				#you can't use "continue" when you're inside a "try" block
1219
				if fetched==1:
1294
				if fetched==1:
Lines 1275-1280 Link Here
1275
		if (fetched!=2) and not listonly:
1350
		if (fetched!=2) and not listonly:
1276
			sys.stderr.write("!!! Couldn't download "+str(myfile)+". Aborting.\n")
1351
			sys.stderr.write("!!! Couldn't download "+str(myfile)+". Aborting.\n")
1277
			return 0
1352
			return 0
1353
1354
#KVH
1355
# Create a new directory to store all the distfile links.
1356
# settings["SRC_LINKS"]=settings["PORTAGE_TMPDIR"]+"/source-links"
1357
		if not listonly and not fetchonly:
1358
#			print "^^^ "+myfile+" is located in "+filedir
1359
			target = filedir + "/" + myfile
1360
			dest = settings["SRC_LINKS"] + "/" + myfile
1361
#			print "^^^ "+target+" --> "+dest
1362
			try:
1363
				os.symlink(target,dest)
1364
			except Exception, e:
1365
				# Should not happen since we clear out the directory above.
1366
				# May already exists...should likely ignore errors here...
1367
				print "^^^ Error : "+dest+ " already exists! (ignore)"
1368
	
1278
	return 1
1369
	return 1
1279
1370
1280
1371
Lines 1300-1307 Link Here
1300
	"""generates digest file if missing.  Assumes all files are available.	If
1391
	"""generates digest file if missing.  Assumes all files are available.	If
1301
	overwrite=0, the digest will only be created if it doesn't already exist."""
1392
	overwrite=0, the digest will only be created if it doesn't already exist."""
1302
1393
1394
# KVH - Change basedir to SRC_LINKS
1395
#  basedir=settings["DISTDIR"]+"/"
1396
	basedir=settings["SRC_LINKS"]+"/"
1397
1303
	# archive files
1398
	# archive files
1304
	basedir=settings["DISTDIR"]+"/"
1305
	digestfn=settings["FILESDIR"]+"/digest-"+settings["PF"]
1399
	digestfn=settings["FILESDIR"]+"/digest-"+settings["PF"]
1306
1400
1307
	# portage files -- p(ortagefiles)basedir
1401
	# portage files -- p(ortagefiles)basedir
Lines 1527-1537 Link Here
1527
			retval=spawnebuild(actionmap[mydo]["dep"],actionmap,debug,alwaysdep)
1621
			retval=spawnebuild(actionmap[mydo]["dep"],actionmap,debug,alwaysdep)
1528
			if retval:
1622
			if retval:
1529
				return retval
1623
				return retval
1530
	# spawn ebuild.sh
1624
1625
#KVH
1626
	settings["ODISTDIR"]=settings["DISTDIR"]
1627
	settings["DISTDIR"]=settings["SRC_LINKS"]
1628
1629
#  print "^^^ Current [DISTDIR] "+settings["DISTDIR"]
1630
   # spawn ebuild.sh
1531
	mycommand="/usr/sbin/ebuild.sh "
1631
	mycommand="/usr/sbin/ebuild.sh "
1532
	return spawn(mycommand + mydo,debug,
1632
	ret=spawn(mycommand + mydo,debug,
1533
				actionmap[mydo]["args"][0],
1633
		actionmap[mydo]["args"][0],
1534
				actionmap[mydo]["args"][1])
1634
		actionmap[mydo]["args"][1])
1635
1636
	settings["DISTDIR"]=settings["ODISTDIR"]
1637
1638
	return ret
1639
1640
	# spawn ebuild.sh
1641
#	mycommand="/usr/sbin/ebuild.sh "
1642
#	return spawn(mycommand + mydo,debug,
1643
#				actionmap[mydo]["args"][0],
1644
#				actionmap[mydo]["args"][1])
1535
1645
1536
def doebuild(myebuild,mydo,myroot,debug=0,listonly=0,fetchonly=0):
1646
def doebuild(myebuild,mydo,myroot,debug=0,listonly=0,fetchonly=0):
1537
	global settings,db
1647
	global settings,db

Return to bug 27669