<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,22 +1,6 @@
-Right now we merged in the support for STOREDIR, but it's very basic. storedir needs to be set to /var/tmp/catalyst.
-This isn't exactly optimal. We need to make things sexy again and allow for the storedir's layout to be totally
-configured. Might be good to actually have STOREDIR not be the mirror, dunno. So we can copy to the mirror only
-if the build succeeds.
+BUG: ^C of metro does not cause command failure if script executing (so it doesn't perform &quot;die&quot;
+steps properly.)
 
-The parser allows multiple definitions of &quot;foo&quot; in a single file, which shouldn't be allowed. Instead, it should
-be detected and an exception should be thrown.
-
-The parser's conditional support means that order of evaluation matters. For example:
-
-? subarch foo {
-	bar: oni
-}
-
-subarch: foo
-
-Will result in bar not being defined.
-
-CHOST needs to be required for bash scripts
 
 More robust parser - this does not throw an exception and just silently keeps foo undefined:
 </diff>
      <filename>BUGS</filename>
    </modified>
    <modified>
      <diff>@@ -2,6 +2,12 @@
 
 : snapshot
 name: funtoo-$[target/version]
-path: git://github.com/funtoo/portage.git
-branch: funtoo.org
 type: git
+
+[section git]
+
+name: portage
+remote: git://github.com/funtoo/portage.git
+branch: funtoo.org
+options: pull
+</diff>
      <filename>etc/USER-snapshot-funtoo.conf</filename>
    </modified>
    <modified>
      <diff>@@ -2,6 +2,11 @@
 
 : snapshot
 name: portage-$[target/version]
-path: git://github.com/funtoo/portage.git
-branch: gentoo.org
 type: git
+
+[section git]
+
+name: portage
+remote: git://github.com/funtoo/portage.git
+branch: gentoo.org
+options: pull</diff>
      <filename>etc/USER-snapshot.conf</filename>
    </modified>
    <modified>
      <diff>@@ -9,6 +9,7 @@
 
 tmp: /var/tmp/metro
 metro: /usr/lib/metro
+git: /root/git/cloned
 distfiles: /usr/portage/distfiles
 work: $[path/tmp]/$[target/name]
 
@@ -48,3 +49,8 @@ profile: default/linux/$[target/arch]/2008.0
 
 outfile: /usr/portage/distfiles/probe
 
+[section target]
+
+[when target is snapshot]
+
+path: /root/git/portage</diff>
      <filename>etc/metro.conf</filename>
    </modified>
    <modified>
      <diff>@@ -199,8 +199,11 @@ def main():
 		
 try:		
 	main()
-except (MetroError,KeyError),arg:
-	print &quot;metro:&quot;,arg
+except MetroError,arg:
+	print __app__+&quot;:&quot;,arg
+	sys.exit(1)
+except KeyError,arg:
+	print __app__+&quot;:&quot;,arg
 	sys.exit(1)
 except flexdata.FlexDataError:
 	sys.exit(1)</diff>
      <filename>metro</filename>
    </modified>
    <modified>
      <diff>@@ -9,13 +9,12 @@ BASH_BINARY             = &quot;/bin/bash&quot;
 class MetroError(Exception):
 	def __init__(self, message):
 		if message:
-			(type,value)=sys.exc_info()[:2]
-			if value!=None:
-				print 
-				print traceback.print_exc(file=sys.stdout)
-			print
-			print &quot;!!! metro: &quot;+message
-			print
+			self.message = message
+	def __str__(self):
+		if self.message:
+			return self.message
+		else:
+			return &quot;(no message)&quot;
 	
 try:
         import resource
@@ -285,7 +284,12 @@ def spawn(mycommand,env={},raw_exit_code=False,opt_name=None,fd_pipes=None,retur
         # loop through pids (typically one, unless logging), either waiting on their death, or waxing them
         # if the main pid (mycommand) returned badly.
         while len(mypid):
-                retval=os.waitpid(mypid[-1],0)[1]
+		try:
+                	retval=os.waitpid(mypid[-1],0)[1]
+		except KeyboardInterrupt:
+			print &quot;Keyboard interrupt detected, aborting script...&quot;
+			os.kill(mypid[-1],signal.SIGINT)
+			continue
                 if retval != 0:
                         cleanup(mypid[0:-1],block_exceptions=False)
                         # at this point we've killed all other kid pids generated via this call.</diff>
      <filename>modules/catalyst_support.py</filename>
    </modified>
    <modified>
      <diff>@@ -18,20 +18,43 @@ run/rsync: [
 
 run/git: [
 #!/bin/bash
-	cd $[path/work] || exit 1
-	git clone $[target/path] portage || exit 1
-	cd portage || exit 1
-	if [ &quot;`git branch | grep ^* | cut -f2 -d&quot; &quot;`&quot; != &quot;$[target/branch]&quot; ]
-	then
-		echo &quot;Local branch does not exist yet, Metro will create it...&quot;
-		git checkout --track -b $[target/branch] origin/$[target/branch] || exit 1
-	fi
-	git archive --prefix=portage/ HEAD | bzip2 &gt; $[path/mirror/snapshot]
-	if [ $? -ne 0 ]
-	then
-		rm -f $[path/mirror/snapshot]
-		exit 1
-	fi
+
+die() {
+	rm -f $[path/mirror/snapshot]
+	echo &quot;$*&quot;
+	exit 1
+}
+
+# On keyboard interrupt, clean up our partially-completed file...
+trap &quot;die Removing incomplete $[path/mirror/snapshot]...&quot; INT
+
+! [ -d &quot;$[path/git]&quot; ] &amp;&amp; install -d &quot;$[path/git]&quot;
+
+if ! [ -e &quot;$[path/git]/$[git/name]&quot; ]
+then
+	# create repo if it doesn't exist
+	git clone $[git/remote] $[path/git]/$[git/name] || die &quot;Couldn't clone git repo&quot;
+fi
+cd $[path/git]/$[git/name] || die &quot;Couldn't change directories to git repo&quot;
+branch=`git rev-parse --symbolic --branches | grep &quot;^$[git/branch]&quot;`
+if [ &quot;$branch&quot; != &quot;$[git/branch]&quot; ]
+then
+	# create local branch since it doesn't exist yet
+	git checkout -b --track $[git/branch] origin/$[git/branch] || die &quot;Couldn't create local git branch&quot;
+else
+	# otherwise, make sure the branch is active (so we can pull if necessary)
+	git checkout $[git/branch] || die &quot;Couldn't checkout local git branch&quot;
+fi
+options=&quot;$[git/options]&quot;
+if [ &quot;${options/pull/}&quot; != &quot;${options}&quot; ]
+then
+	echo &quot;Performing git pull...&quot;
+	# if we have the &quot;pull&quot; option in git/options, then make sure we're up-to-date
+	git pull &gt; /dev/null || die &quot;Couldn't perform git pull&quot;
+fi
+echo &quot;Creating $[path/mirror/snapshot]...&quot;
+( git archive --prefix=portage/ $[git/branch] || die &quot;Couldn't create git archive&quot; ) | ( bzip2 &gt; $[path/mirror/snapshot] || die &quot;Git bzip2 failure&quot; )
+echo &quot;Snapshot $[path/mirror/snapshot] created.&quot;
 ]
 
 [section portage]</diff>
      <filename>specs/targets/snapshot.spec</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>6ce927ea4ba52f1bb7f917ff269d7e3f02fa58c5</id>
    </parent>
  </parents>
  <author>
    <name>Daniel Robbins</name>
    <email>drobbins@funtoo.org</email>
  </author>
  <url>http://github.com/funtoo/metro/commit/856f852dd6f0c4d4af72bb80e13e9ee15be3a1d3</url>
  <id>856f852dd6f0c4d4af72bb80e13e9ee15be3a1d3</id>
  <committed-date>2008-10-24T13:46:34-07:00</committed-date>
  <authored-date>2008-10-24T13:46:34-07:00</authored-date>
  <message>robustness fixes and git intelligence upgrade

A script running under Metro will now have an opportunity to clean
up after itself if Metro is interrupted by the user by handling
the SIGINT signal.

Git now has a local cache of repositories so if you are using a
remote repository, Git will not need to clone every time. Still
working on metro.conf syntax but overall it looks like it's working
well. Also using git-archive correctly which saves disk space.</message>
  <tree>6ca437971341864d88fff766588d3790e8093c53</tree>
  <committer>
    <name>Daniel Robbins</name>
    <email>drobbins@funtoo.org</email>
  </committer>
</commit>
