r12312 - in /tools/snapshots/scripts: README snapshot-package

kilian at users.alioth.debian.org kilian at users.alioth.debian.org
Sat Aug 11 22:29:26 UTC 2007


Author: kilian
Date: Sat Aug 11 22:29:26 2007
New Revision: 12312

URL: http://svn.debian.org/wsvn/pkg-gnome/?sc=1&rev=12312
Log:
add git support.

Added:
    tools/snapshots/scripts/README
Modified:
    tools/snapshots/scripts/snapshot-package

Added: tools/snapshots/scripts/README
URL: http://svn.debian.org/wsvn/pkg-gnome/tools/snapshots/scripts/README?rev=12312&op=file
==============================================================================
--- tools/snapshots/scripts/README (added)
+++ tools/snapshots/scripts/README Sat Aug 11 22:29:26 2007
@@ -1,0 +1,3 @@
+to get debian_linux, try:
+svn co -r9096 svn://svn.debian.org/kernel/dists/trunk/linux-2.6/debian/lib/python/debian_linux
+

Modified: tools/snapshots/scripts/snapshot-package
URL: http://svn.debian.org/wsvn/pkg-gnome/tools/snapshots/scripts/snapshot-package?rev=12312&op=diff
==============================================================================
--- tools/snapshots/scripts/snapshot-package (original)
+++ tools/snapshots/scripts/snapshot-package Sat Aug 11 22:29:26 2007
@@ -138,11 +138,54 @@
     def remove(self):
         self._rm(self.dir)
 
+class repository_git(storage):
+    def __init__(self, dir, uri, branch):
+        storage.__init__(self, dir)
+        self.uri = uri
+        self.branch = branch
+
+    def checkout(self):
+        if not os.path.exists(self.dir):
+          args = ['clone', '-q', self.uri, self.dir]
+          self.exec_git(args)
+        if str(self.branch) != '':
+          args = ['git', 'checkout', '--track', '-b', '%s' % self.branch, 'origin/%s' % self.branch]
+          spawnv_chdir(os.P_WAIT, "/usr/bin/git", args, self.dir)
+        args = ['git', 'pull']
+        spawnv_chdir(os.P_WAIT, "/usr/bin/git", args, self.dir)
+
+    def exec_git(self, args):
+        try:
+          self._exec("/usr/bin/git", args)
+        except OSError: pass
+
+    def get_revision(self):
+      _rules = r"""
+^\s*
+committer
+\s+
+(?P<commiter>.+)\s+
+(?P<timestamp>[0-9]+)\s+
+(?P<direction>[-+])
+(?P<hour>[0-9]{2,2})
+(?P<min>[0-9]{2,2})
+"""
+      _re = re.compile(_rules, re.X)
+      for line in os.popen("cd %s;/usr/bin/git log --pretty=raw HEAD^..HEAD" % self.dir).read().split("\n"):
+        if line.startswith('committer'):
+          m = _re.match(line)
+          if not m:
+            return False
+          hour = int(m.group('hour'))
+          if str(m.group('direction')) == '-':
+            hour = hour -1;
+          return int(m.group('timestamp')) + hour*3600 + int(m.group('min'))*60
+      return False
+
 class repository_svn(storage):
     def __init__(self, dir, uri):
         storage.__init__(self, dir)
         self.uri = uri
-        self.checkout()
 
     def checkout(self):
         args = ['co', '-q', self.uri, self.dir]
@@ -152,6 +195,12 @@
         try:
           self._exec("/usr/bin/svn", args)
         except OSError: pass
+
+    def get_revision(self):
+      for line in os.popen("svn info %s" % checkout_dir, 'r').read().split('\n'):
+          if line.startswith('Last Changed Rev: '):
+              return int(line.split()[-1])
+      return False
 
 class LastFile(object):
     revision = 0
@@ -175,12 +224,14 @@
     checkout_dir = os.path.join(base, "checkout-" + path.replace('/', '_'))
     last_file = os.path.join(base, "last-" + path.replace('/', '_'))
 
-    checkout_storage = repository_svn(checkout_dir, "%s/%s" % (entry['repository'], path))
-
-    for line in os.popen("svn info %s" % checkout_dir, 'r').read().split('\n'):
-        if line.startswith('Last Changed Rev: '):
-            revision = int(line.split()[-1])
-
+    if entry['repository'].startswith('git://'):
+      repository = repository_git(checkout_dir, "%s/%s" % (entry['repository'], path), entry['branch'])
+    else:
+      repository = repository_svn(checkout_dir, "%s/%s" % (entry['repository'], path))
+
+    checkout_storage = repository.checkout()
+
+    revision = repository.get_revision()
     last = LastFile(last_file)
 
     if revision <= last.revision:
@@ -308,20 +359,24 @@
     f.write(changelog_text)
     del f
 
-    svn_pkg = "/usr/bin/svn-buildpackage" # needs svn-buildpackage 0.6.16etch1 or newer.
-    list = ['svn-buildpackage', '-S', '-d', '--svn-ignore', '-rfakeroot', '--svn-noninteractive']
+    append_list = []
+    if not native:
+      append_list.append('-sd')
+    else:
+      append_list.append('-sa')
     sign = entry.get('sign', None)
     if sign:
-        list.append('-k%s' % sign)
-    if not native:
-        #if version.upstream != upstream:
-        #    list.append('-sa')
-        #else:
-        #    list.append('-sd')
-        list.append('-sd')
-    else:
-      list.append('-sa')
-    spawnv_chdir(os.P_WAIT, svn_pkg, list, package_dir)
+      append_list.append('-k%s' % sign)
+    if entry['repository'].startswith('git://'):
+      repository = 'git'
+      pkg_cmd = "/usr/bin/git-buildpackage" 
+      list = ['git-buildpackage', '--git-ignore-new', '--git-cleaner=fakeroot debian/rules clean', '--git-builder=dpkg-buildpackage -S %s -d -rfakeroot -us -uc' % ' '.join(append_list)]
+    else:
+      repository = 'svn'
+      pkg_cmd = "/usr/bin/svn-buildpackage" # needs svn-buildpackage 0.6.16etch1 or newer.
+      list = ['svn-buildpackage', '-S', '-d', '--svn-ignore', '-rfakeroot', '--svn-noninteractive']
+      list.append(append_list)
+    spawnv_chdir(os.P_WAIT, pkg_cmd, list, package_dir)
     prefix = '%s_%s' % (package_name, version.complete_noepoch)
     suffices = ['.dsc', '_source.changes']
     if native:
@@ -333,10 +388,13 @@
         except OSError: pass
 
     for suffix in suffices:
+      if repository == 'svn':
         gen = os.path.join(gen_dir, "build-area/%s%s" % (prefix, suffix))
-        out = os.path.join(out_dir, "%s%s" % (prefix, suffix))
-        os.link(gen, out)
-        os.unlink(gen)
+      else:
+        gen = os.path.join(gen_dir, "%s%s" % (prefix, suffix))
+      out = os.path.join(out_dir, "%s%s" % (prefix, suffix))
+      os.link(gen, out)
+      os.unlink(gen)
 
     #print "Cleaning up."
     package_storage.remove()
@@ -352,13 +410,20 @@
     return True
 
 def main():
-    if len(sys.argv) > 1:
+    if (len(sys.argv) > 1) and os.path.isfile(sys.argv[1]):
       config = Config(sys.argv[1])
     else:
       sys.stderr.write('package.py config.cfg\n')
       return False
     if len(sys.argv) > 2:
-        paths = sys.argv[2:]
+        paths = {}
+        requested_paths = sys.argv[2:]
+        available_paths = config.keys()
+        for path in requested_paths:
+          if path in available_paths:
+            paths.append(path)
+          else:
+            print "Skipping nonexistant path %s ...\n" % path
     else:
         paths = config.keys()
     for path in paths:




More information about the pkg-gnome-commits mailing list