/[kernel]/people/waldi/scripts/snapshot/package.py
ViewVC logotype

Diff of /people/waldi/scripts/snapshot/package.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 8378 by waldi, Sat Jan 27 22:01:58 2007 UTC revision 8379 by waldi, Thu Mar 22 10:58:49 2007 UTC
# Line 17  Line 17 
17  # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18    
19  import os.path, shutil, sys, time  import os.path, shutil, sys, time
20  import debian_linux  import debian_linux.config
21    
22  base = os.path.expanduser("~/debian/kernel/snapshot")  class Config(dict):
23  repository = "svn://svn.debian.org/kernel/"      schema_item_boolean = debian_linux.config.schema_item_boolean
24  orig_base = os.path.expanduser("~/debian/kernel/orig")      schema_item_list = debian_linux.config.schema_item_list
25    
26        class schema_item_path(object):
27            def __call__(self, i):
28                return os.path.expanduser(i.strip())
29    
30        schema = {
31            'base': schema_item_path(),
32            'native': schema_item_boolean(),
33            'orig': schema_item_path(),
34        }
35    
36        def __init__(self, config):
37            parser = debian_linux.config.config_parser(self.schema, [config])
38            for section in iter(parser):
39                # TODO: don't split sections in parser
40                self[section[0]] = parser[section]
41    
42  def _spawnvefn(mode, file, args, env, func, prepare, prepare_arg):  def _spawnvefn(mode, file, args, env, func, prepare, prepare_arg):
43      # Internal helper; func is the exec*() function to use      # Internal helper; func is the exec*() function to use
# Line 88  class storage(object): Line 104  class storage(object):
104          if ret:          if ret:
105              raise ExecutionError(ret)              raise ExecutionError(ret)
106    
     def _exec_chdir(self, executable, args, dir, force = False, output = True):  
         args_real = [executable.split(os.sep)[-1]] + args  
         ret = spawnv_chdir(os.P_WAIT, executable, args_real, dir)  
         if ret:  
             raise ExecutionError(ret)  
   
107      def _mk(self, dir):      def _mk(self, dir):
108          try:          try:
109              os.makedirs(dir, 0755)              os.makedirs(dir, 0755)
# Line 117  class storage(object): Line 127  class storage(object):
127          self._rm(self.dir)          self._rm(self.dir)
128    
129  class repository_svn(storage):  class repository_svn(storage):
130      def __init__(self, dir, path):      def __init__(self, dir, uri):
131          storage.__init__(self, dir)          storage.__init__(self, dir)
132          self.path = path          self.uri = uri
133          self.checkout()          self.checkout()
134    
135      def checkout(self):      def checkout(self):
136          path_real = '%s/%s' % (repository, self.path)          args = ['co', '-q', self.uri, self.dir]
         args = ['co', '-q', path_real, self.dir]  
137          self.exec_svn(args)          self.exec_svn(args)
138    
139      def exec_svn(self, args):      def exec_svn(self, args):
140          self._exec("/usr/bin/svn", args)          self._exec("/usr/bin/svn", args)
141    
142  def package(path, dist, native = False):  def package(path, entry):
143      checkout_dir = "checkout-" + path.replace('/', '_')      base = entry['base']
144      last_file = "last-" + path.replace('/', '_')      native = entry.get('native', False)
145      checkout_storage = repository_svn(checkout_dir, path)  
146        checkout_dir = os.path.join(base, "checkout-" + path.replace('/', '_'))
147        last_file = os.path.join(base, "last-" + path.replace('/', '_'))
148        checkout_storage = repository_svn(checkout_dir, "%s/%s" % (entry['repository'], path))
149      changelog_entry = debian_linux.Changelog(checkout_dir)[0]      changelog_entry = debian_linux.Changelog(checkout_dir)[0]
150      package_name = changelog_entry.source      package_name = changelog_entry.source
151      package_version = changelog_entry.version.upstream      package_version = changelog_entry.version.upstream
152      package = "%s-%s" % (package_name, package_version)      package = "%s-%s" % (package_name, package_version)
153      package_dir = "gen/%s" % package      package_dir = "gen/%s" % package
154      package_orig = "%s_%s.orig.tar.gz" % (package_name, package_version)      package_orig = "%s_%s.orig.tar.gz" % (package_name, package_version)
155      package_orig_source = "%s/%s" % (orig_base, package_orig)      package_orig_source = "%s/%s" % (entry['orig'], package_orig)
156    
157      for line in os.popen("svn info %s" % checkout_dir, 'r').read().split('\n'):      for line in os.popen("svn info %s" % checkout_dir, 'r').read().split('\n'):
158          if line.startswith('Last Changed Rev: '):          if line.startswith('Last Changed Rev: '):
# Line 189  def package(path, dist, native = False): Line 201  def package(path, dist, native = False):
201      f.write("""\      f.write("""\
202  %s (%s-%s) %s; urgency=low  %s (%s-%s) %s; urgency=low
203    
204    * Snapshot.    * %s
205    
206   -- Bastian Blank <waldi@debian.org>  %s   -- %s  %s
207    
208  """ % (  """ % (
209          package_name, package_version, version_debian, dist,          package_name, package_version, version_debian, entry['dist'],
210            entry['changelog_text'], entry['changelog_maintainer'],
211          time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime()),          time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime()),
212      )      )
213  )  )
# Line 206  def package(path, dist, native = False): Line 219  def package(path, dist, native = False):
219          if spawnv_chdir(os.P_WAIT, "debian/rules", ['debian/rules', 'orig'], package_dir):          if spawnv_chdir(os.P_WAIT, "debian/rules", ['debian/rules', 'orig'], package_dir):
220              raise RuntimeError              raise RuntimeError
221    
222      list = ['dpkg-buildpackage', '-kDAEE1CDC', '-S']      list = ['dpkg-buildpackage', '-S']
223        sign = entry.get('sign', None)
224        if sign:
225            list.append('-k%s' % sign)
226      if not native:      if not native:
227          if version_upstream != last_upstream:          if version_upstream != last_upstream:
228              list.append('-sa')              list.append('-sa')
# Line 222  def package(path, dist, native = False): Line 238  def package(path, dist, native = False):
238    
239      for suffix in suffixes:      for suffix in suffixes:
240          prefix = '%s_%s-%s' % (package_name, package_version, version_debian)          prefix = '%s_%s-%s' % (package_name, package_version, version_debian)
         print prefix, suffix  
241          os.link("gen/%s%s" % (prefix, suffix), "out/%s%s" % (prefix, suffix))          os.link("gen/%s%s" % (prefix, suffix), "out/%s%s" % (prefix, suffix))
242          os.unlink("gen/%s%s" % (prefix, suffix))          os.unlink("gen/%s%s" % (prefix, suffix))
243    
# Line 230  def package(path, dist, native = False): Line 245  def package(path, dist, native = False):
245    
246      package_storage.remove()      package_storage.remove()
247    
248      spawnv_chdir(os.P_WAIT, 'dput', ['dput', 'debian-kernel', '%s_%s-%s_source.changes' % (package_name, package_version, version_debian)], "out")      spawnv_chdir(os.P_WAIT, 'dput', ['dput', entry['upload'], '%s_%s-%s_source.changes' % (package_name, package_version, version_debian)], "out")
249    
250  def main():  def main():
251      maps = {      config = Config(sys.argv[1])
252          "dists/sid/linux-2.6": {'dist': "kernel-dists-sid"},      if len(sys.argv) > 2:
253          "dists/trunk/linux-2.6": {'dist': "kernel-dists-trunk"},          paths = sys.argv[2:]
         "dists/trunk/linux-kbuild-2.6": {'dist': "kernel-dists-trunk"},  
         "dists/trunk/linux-modules-extra-2.6": {'dist': "kernel-dists-trunk", 'native': True},  
     }  
     if len(sys.argv) > 1:  
         paths = sys.argv[1:]  
254      else:      else:
255          paths = maps.keys()          paths = config.keys()
256      for path in paths:      for path in paths:
257          try:          try:
258               package(path, **maps[path])              c = config[path]
259                package(path, c)
260          except Exception, e:          except Exception, e:
261              import traceback              import traceback
262              traceback.print_exc()              traceback.print_exc()
263    
264  if __name__ == '__main__':  if __name__ == '__main__':
     os.chdir(base)  
265      main()      main()

Legend:
Removed from v.8378  
changed lines
  Added in v.8379

  ViewVC Help
Powered by ViewVC 1.1.5