Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 124203
Collapse All | Expand All

(-)pym/portage.py (-2 / +4 lines)
Lines 2743-2750 Link Here
2743
2743
2744
	# if any of these are being called, handle them -- running them out of the sandbox -- and stop now.
2744
	# if any of these are being called, handle them -- running them out of the sandbox -- and stop now.
2745
	if mydo=="clean":
2745
	if mydo=="clean":
2746
		logfile=None
2746
		import portage_ebuild
2747
	if mydo in ["help","clean","setup"]:
2747
		portage_ebuild.ebuild_clean(mysettings)
2748
		return 0
2749
	elif mydo in ["help","setup"]:
2748
		return spawn(EBUILD_SH_BINARY+" "+mydo,mysettings,debug=debug,free=1,logfile=logfile)
2750
		return spawn(EBUILD_SH_BINARY+" "+mydo,mysettings,debug=debug,free=1,logfile=logfile)
2749
	elif mydo in ["prerm","postrm","preinst","postinst","config"]:
2751
	elif mydo in ["prerm","postrm","preinst","postinst","config"]:
2750
		mysettings.load_infodir(pkg_dir)
2752
		mysettings.load_infodir(pkg_dir)
(-)pym/portage_ebuild.py (+70 lines)
Line 0 Link Here
1
2
from portage_exec import spawn
3
from portage_util import writemsg
4
import errno, os, shutil
5
6
def ebuild_clean(mysettings):
7
	"""This function is called from doebuild to perform the clean phase."""
8
9
	chflags = {"BSD":"noschg,nouchg,nosappnd,nouappnd,nosunlnk,nouunlnk",
10
	"Darwin":"noschg,nouchg,nosappnd,nouappnd"}
11
	if mysettings["USERLAND"] in chflags:
12
		spawn(["chflags", "-R", chflags[mysettings["USERLAND"]],
13
		mysettings["PORTAGE_BUILDDIR"]])
14
15
	for subdir in ("image", "distdir"):
16
		shutil.rmtree(os.path.join(mysettings["PORTAGE_BUILDDIR"], subdir), ignore_errors=True)
17
18
	features = mysettings["FEATURES"].split()
19
	if "keeptemp" in features:
20
		try:
21
			os.rename(os.path.join(mysettings["T"], "environment"),
22
			os.path.join(mysettings["T"], "environment.keeptemp"))
23
		except OSError, oe:
24
			if oe.errno == errno.ENOENT:
25
				pass
26
			elif oe.errno in (errno.EPERM, errno.EACCES):
27
				writemsg("%s\n" % oe)
28
			else:
29
				raise oe
30
	else:
31
		shutil.rmtree(mysettings["T"], ignore_errors=True)
32
	if "keepwork" not in features:
33
		for x in (".compiled", ".installed", ".packaged", ".tested", ".unpacked"):
34
			try:
35
				os.unlink(os.path.join(mysettings["PORTAGE_BUILDDIR"], x))
36
			except OSError, oe:
37
				if oe.errno == errno.ENOENT:
38
					pass
39
				elif oe.errno in (errno.EPERM, errno.EACCES):
40
					writemsg("%s\n" % oe)
41
				else:
42
					raise oe
43
		shutil.rmtree(os.path.join(mysettings["PORTAGE_BUILDDIR"], "build-info"), ignore_errors=True)
44
		shutil.rmtree(mysettings["WORKDIR"], ignore_errors=True)
45
46
	# remove directories only if they are empty, leaving any files intact
47
	if os.path.isfile(os.path.join(mysettings["PORTAGE_BUILDDIR"], ".unpacked")):
48
		for dirpath, dirnames, filenames in os.walk(mysettings["PORTAGE_BUILDDIR"], topdown=False):
49
			for name in dirnames:
50
				mypath = os.path.join(dirpath, name)
51
				if not mypath.startswith(mysettings["WORKDIR"]):
52
					try:
53
						os.rmdir(mypath)
54
					except OSError, oe:
55
						if oe.errno in (errno.ENOTEMPTY, errno.ENOENT):
56
							pass
57
						elif oe.errno in (errno.EPERM, errno.EACCES):
58
							writemsg("%s\n" % oe)
59
						else:
60
							raise oe
61
62
	try:
63
		os.rmdir(mysettings["PORTAGE_BUILDDIR"])
64
	except OSError, oe:
65
		if oe.errno in (errno.ENOTEMPTY, errno.ENOENT):
66
			pass
67
		elif oe.errno in (errno.EPERM, errno.EACCES):
68
			writemsg("%s\n" % oe)
69
		else:
70
			raise oe

Return to bug 124203