# Copyright 2002-2008 Gentoo Foundation; 2008 Chris Gianelloni, Andrew Gaffney
# Distributed under the GPL v2
+ 22 Dec 2008; Andrew Gaffney <agaffney@gentoo.org>
+ modules/snapshot_target.py:
+ Add support for purging to snapshot target
+
21 Dec 2008; Andrew Gaffney <agaffney@gentoo.org> TODO:
Add mix-in cdtar idea to TODO
pass
def run(self):
+ if self.settings.has_key("PURGEONLY"):
+ self.purge()
+ return
+
+ if self.settings.has_key("PURGE"):
+ self.purge()
+
self.setup()
print "Creating Portage tree snapshot "+self.settings["version_stamp"]+\
" from "+self.settings["portdir"]+"..."
def cleanup(self):
print "Cleaning up..."
+
+ def purge(self):
+ myemp=self.settings["tmp_path"]
+ if os.path.isdir(myemp):
+ print "Emptying directory",myemp
+ """
+ stat the dir, delete the dir, recreate the dir and set
+ the proper perms and ownership
+ """
+ mystat=os.stat(myemp)
+ """ There's no easy way to change flags recursively in python """
+ if os.uname()[0] == "FreeBSD":
+ os.system("chflags -R noschg "+myemp)
+ shutil.rmtree(myemp)
+ os.makedirs(myemp,0755)
+ os.chown(myemp,mystat[ST_UID],mystat[ST_GID])
+ os.chmod(myemp,mystat[ST_MODE])
def register(foo):
foo.update({"snapshot":snapshot_target})