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

Collapse All | Expand All

(-)a/pym/gentoolkit/eclean/search.py (-26 / +21 lines)
Lines 538-566 def findPackages( Link Here
538
		print( pp.error("(Check your make.conf file and environment)."), file=sys.stderr)
538
		print( pp.error("(Check your make.conf file and environment)."), file=sys.stderr)
539
		print( pp.error("Error: %s" %str(er)), file=sys.stderr)
539
		print( pp.error("Error: %s" %str(er)), file=sys.stderr)
540
		exit(1)
540
		exit(1)
541
	for root, dirs, files in os.walk(pkgdir):
541
542
		if root[-3:] == 'All':
542
	# if portage supports FEATURES=binpkg-multi-instance, then
543
	# then cpv_all can return multiple instances per cpv, where
544
	# instances are distinguishable by some extra attributes
545
	bin_dbapi = portage.binarytree(pkgdir=pkgdir, settings=var_dbapi.settings).dbapi
546
	for cpv in bin_dbapi.cpv_all():
547
		mtime = int(bin_dbapi.aux_get(cpv, ['_mtime_'])[0])
548
		if time_limit and mtime >= time_limit:
549
			# time-limit exclusion
543
			continue
550
			continue
544
		for file in files:
551
		# dict is cpv->[cpvs] (supports binpkg-multi-instance)
545
			if file[-5:] == ".tbz2":
552
		clean_me.setdefault(cpv, []).append(cpv)
546
				category = os.path.basename(root)
553
547
				cpv = category+"/"+file[:-5]
548
			elif file[-5:] == ".xpak":
549
				category = os.path.basename(os.path.dirname(root))
550
				cpv = category+"/"+file.rpartition('-')[0]
551
			else:
552
				# ignore other files
553
				continue
554
			path = os.path.join(root, file)
555
			st = os.lstat(path)
556
			if time_limit and (st[stat.ST_MTIME] >= time_limit):
557
				# time-limit exclusion
558
				continue
559
			# dict is cpv->[files] (2 files in general, because of symlink)
560
			clean_me.setdefault(cpv,[]).append(path)
561
			#if os.path.islink(path):
562
			if stat.S_ISLNK(st[stat.ST_MODE]):
563
				clean_me[cpv].append(os.path.realpath(path))
564
	# keep only obsolete ones
554
	# keep only obsolete ones
565
	if destructive and package_names:
555
	if destructive and package_names:
566
		cp_all = dict.fromkeys(var_dbapi.cp_all())
556
		cp_all = dict.fromkeys(var_dbapi.cp_all())
Lines 576-585 def findPackages( Link Here
576
			del clean_me[cpv]
566
			del clean_me[cpv]
577
			continue
567
			continue
578
		if destructive and var_dbapi.cpv_exists(cpv):
568
		if destructive and var_dbapi.cpv_exists(cpv):
579
			buildtime = var_dbapi.aux_get(cpv, ['BUILD_TIME'])[0].encode('utf-8').strip()
569
			buildtime = var_dbapi.aux_get(cpv, ['BUILD_TIME'])[0]
580
			clean_me[cpv] = [path for path in clean_me[cpv]
570
			clean_me[cpv] = [cpv for cpv in clean_me[cpv]
581
				# only keep path if BUILD_TIME is identical with vartree
571
				# only keep path if BUILD_TIME is identical with vartree
582
				if portage.xpak.tbz2(path).getfile('BUILD_TIME').strip() != buildtime]
572
				if bin_dbapi.aux_get(cpv, ['BUILD_TIME'])[0] != buildtime]
583
			if not clean_me[cpv]:
573
			if not clean_me[cpv]:
584
				# nothing we can clean for this package
574
				# nothing we can clean for this package
585
				del clean_me[cpv]
575
				del clean_me[cpv]
Lines 588-591 def findPackages( Link Here
588
			# exlusion because of --package-names
578
			# exlusion because of --package-names
589
			del clean_me[cpv]
579
			del clean_me[cpv]
590
580
581
	# the getname method to correctly supports FEATURES=binpkg-multi-instance,
582
	# allowing for multiple paths per cpv (the API used here is also compatible
583
	# with older portage which does not support binpkg-multi-instance)
584
	for cpv, cpvs in clean_me.items():
585
		clean_me[cpv] = [bin_dbapi.bintree.getname(cpv) for cpv in cpvs]
586
591
	return clean_me
587
	return clean_me
592
- 

Return to bug 586658