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 / +22 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
	# cpv_all can return multiple instances per cpv, where
544
	# instances are distinguishable by some extra attributes
545
	# provided by portage's _pkg_str class
546
	bin_dbapi = portage.binarytree(pkgdir=pkgdir, settings=var_dbapi.settings).dbapi
547
	for cpv in bin_dbapi.cpv_all():
548
		mtime = int(bin_dbapi.aux_get(cpv, ['_mtime_'])[0])
549
		if time_limit and mtime >= time_limit:
550
			# time-limit exclusion
543
			continue
551
			continue
544
		for file in files:
552
		# dict is cpv->[pkgs] (supports binpkg-multi-instance)
545
			if file[-5:] == ".tbz2":
553
		clean_me.setdefault(cpv, []).append(cpv)
546
				category = os.path.basename(root)
554
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
555
	# keep only obsolete ones
565
	if destructive and package_names:
556
	if destructive and package_names:
566
		cp_all = dict.fromkeys(var_dbapi.cp_all())
557
		cp_all = dict.fromkeys(var_dbapi.cp_all())
Lines 576-585 def findPackages( Link Here
576
			del clean_me[cpv]
567
			del clean_me[cpv]
577
			continue
568
			continue
578
		if destructive and var_dbapi.cpv_exists(cpv):
569
		if destructive and var_dbapi.cpv_exists(cpv):
579
			buildtime = var_dbapi.aux_get(cpv, ['BUILD_TIME'])[0].encode('utf-8').strip()
570
			buildtime = var_dbapi.aux_get(cpv, ['BUILD_TIME'])[0]
580
			clean_me[cpv] = [path for path in clean_me[cpv]
571
			clean_me[cpv] = [pkg for pkg in clean_me[cpv]
581
				# only keep path if BUILD_TIME is identical with vartree
572
				# only keep path if BUILD_TIME is identical with vartree
582
				if portage.xpak.tbz2(path).getfile('BUILD_TIME').strip() != buildtime]
573
				if bin_dbapi.aux_get(pkg, ['BUILD_TIME'])[0] != buildtime]
583
			if not clean_me[cpv]:
574
			if not clean_me[cpv]:
584
				# nothing we can clean for this package
575
				# nothing we can clean for this package
585
				del clean_me[cpv]
576
				del clean_me[cpv]
Lines 588-591 def findPackages( Link Here
588
			# exlusion because of --package-names
579
			# exlusion because of --package-names
589
			del clean_me[cpv]
580
			del clean_me[cpv]
590
581
582
	# the getname method correctly supports FEATURES=binpkg-multi-instance,
583
	# allowing for multiple paths per cpv (the API used here is also compatible
584
	# with older portage which does not support binpkg-multi-instance)
585
	for cpv, pkgs in clean_me.items():
586
		clean_me[cpv] = [bin_dbapi.bintree.getname(pkg) for pkg in pkgs]
587
591
	return clean_me
588
	return clean_me
592
- 

Return to bug 586658