From 7cfe576b943b54f4bff9d605ec99d9ce939c22a8 Mon Sep 17 00:00:00 2001 From: "John P. Davis" Date: Mon, 17 May 2004 01:56:19 +0000 Subject: [PATCH] forgot the snapshot target .. oops git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/catalyst/trunk@373 d1e1f19c-881f-0410-ab34-b69fee027534 --- modules/snapshot_target.py | 50 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 modules/snapshot_target.py diff --git a/modules/snapshot_target.py b/modules/snapshot_target.py new file mode 100644 index 00000000..e6934ed0 --- /dev/null +++ b/modules/snapshot_target.py @@ -0,0 +1,50 @@ +# Distributed under the GNU General Public License version 2 +# Copyright 2003-2004 Gentoo Technologies, Inc. +# $Header: /var/cvsroot/gentoo/src/catalyst/modules/snapshot_target.py,v 1.1 2004/05/17 01:56:19 zhen Exp $ + +""" +Builder class for snapshots. +""" + +import os,string,imp,types,shutil +from catalyst_support import * +from generic_stage_target import * +from stat import * + +class snapshot_target(generic_target): + def __init__(self,myspec,addlargs): + self.required_values=["version_stamp","target"] + self.valid_values=["version_stamp","target"] + generic_target.__init__(self,myspec,addlargs) + self.settings=myspec + self.settings["target_subpath"]="portage-"+self.settings["version_stamp"] + st=self.settings["storedir"] + self.settings["snapshot_path"]=st+"/snapshots/"+self.settings["target_subpath"]+".tar.bz2" + self.settings["tmp_path"]=st+"/tmp/"+self.settings["target_subpath"] + + def setup(self): + x=self.settings["storedir"]+"/snapshots" + if not os.path.exists(x): + os.makedirs(x) + + def run(self): + self.setup() + print "Creating Portage tree snapshot "+self.settings["version_stamp"]+" from "+self.settings["portdir"]+"..." + mytmp=self.settings["tmp_path"] + if os.path.exists(mytmp): + cmd("rm -rf "+mytmp,"Could not remove existing directory: "+mytmp) + os.makedirs(mytmp) + cmd("rsync -a --exclude /packages/ --exclude /distfiles/ --exclude CVS/ "+self.settings["portdir"]+"/ "+mytmp+"/portage/","Snapshot failure") + print "Compressing Portage snapshot tarball..." + cmd("tar cjf "+self.settings["snapshot_path"]+" -C "+mytmp+" portage","Snapshot creation failure") + self.cleanup() + + def cleanup(self): + print "Cleaning up temporary snapshot directory..." + #Be a good citizen and clean up after ourselves + cmd("rm -rf "+self.settings["tmp_path"],"Snapshot cleanup failure") + +def register(foo): + foo.update({"snapshot":snapshot_target}) + return foo + -- 2.26.2