From: Andrew Gaffney Date: Mon, 22 Dec 2008 04:47:50 +0000 (-0600) Subject: Add support for purging to snapshot target X-Git-Tag: CATALYST_2_0_6_916~52 X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=a4731005eabe56f7b5d00a10eb9ddb16276794a4;p=catalyst.git Add support for purging to snapshot target --- diff --git a/ChangeLog b/ChangeLog index be7dd1b1..54797d9f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,10 @@ # Copyright 2002-2008 Gentoo Foundation; 2008 Chris Gianelloni, Andrew Gaffney # Distributed under the GPL v2 + 22 Dec 2008; Andrew Gaffney + modules/snapshot_target.py: + Add support for purging to snapshot target + 21 Dec 2008; Andrew Gaffney TODO: Add mix-in cdtar idea to TODO diff --git a/modules/snapshot_target.py b/modules/snapshot_target.py index 1957e56a..0609377b 100644 --- a/modules/snapshot_target.py +++ b/modules/snapshot_target.py @@ -29,6 +29,13 @@ class snapshot_target(generic_stage_target): 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"]+"..." @@ -55,6 +62,23 @@ class snapshot_target(generic_stage_target): 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})