]> git.decadent.org.uk Git - dak.git/commitdiff
Merge commit 'stew/contents' into merge
authorJoerg Jaspert <joerg@debian.org>
Fri, 30 Oct 2009 09:10:17 +0000 (10:10 +0100)
committerJoerg Jaspert <joerg@debian.org>
Fri, 30 Oct 2009 09:10:17 +0000 (10:10 +0100)
* commit 'stew/contents':
  bootstrap_bin working
  merge from master with sqla

Signed-off-by: Joerg Jaspert <joerg@debian.org>
1  2 
dak/dakdb/update17.py
daklib/config.py
daklib/dbconn.py
daklib/utils.py

diff --combined dak/dakdb/update17.py
index 0000000000000000000000000000000000000000,0d7efa9efec6c77e325aaa4c885e1766477452d4..c4e0f2458a9dc5e93bb53928b075c3422079a027
mode 000000,100644..100755
--- /dev/null
@@@ -1,0 -1,62 +1,63 @@@
 -        
+ #!/usr/bin/env python
+ # coding=utf8
+ """
+ adding a bin_contents table to hold lists of files contained in .debs and .udebs
+ @contact: Debian FTP Master <ftpmaster@debian.org>
+ @copyright: 2009  Mike O'Connor <stew@debian.org>
+ @license: GNU General Public License version 2 or later
+ """
+ # This program is free software; you can redistribute it and/or modify
+ # it under the terms of the GNU General Public License as published by
+ # the Free Software Foundation; either version 2 of the License, or
+ # (at your option) any later version.
+ # This program is distributed in the hope that it will be useful,
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ # GNU General Public License for more details.
+ # You should have received a copy of the GNU General Public License
+ # along with this program; if not, write to the Free Software
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ ################################################################################
+ ################################################################################
+ import psycopg2
+ import time
+ from daklib.dak_exceptions import DBUpdateError
+ ################################################################################
+ def do_update(self):
+     print "adding a bin_contents table to hold lists of files contained in .debs and .udebs"
+     try:
+         c = self.db.cursor()
+         c.execute("""CREATE TABLE bin_contents (
+         file text,
+         binary_id integer,
+         UNIQUE(file,binary_id))""" )
 -        self.db.commit()
++
+         c.execute("""ALTER TABLE ONLY bin_contents
+         ADD CONSTRAINT bin_contents_bin_fkey
+         FOREIGN KEY (binary_id) REFERENCES binaries(id)
+         ON DELETE CASCADE;""")
+         c.execute("""CREATE INDEX ind_bin_contents_binary ON bin_contents(binary_id);""" )
++        c.execute("UPDATE config SET value = '17' WHERE name = 'db_revision'")
++       self.db.commit()
+     except psycopg2.ProgrammingError, msg:
+         self.db.rollback()
+         raise DBUpdateError, "Unable to apply process-new update 17, rollback issued. Error message : %s" % (str(msg))
diff --combined daklib/config.py
index 09df17bb06be100a2a753793c5416f3750cf3e30,b98a6fc9db5e926b7c4871241b22fc8855a0c683..c2d2fe5506c675682db0de4b464d310ca2d2fa82
@@@ -35,7 -35,8 +35,7 @@@ from singleton import Singleto
  
  ################################################################################
  
- default_config = "/etc/dak/dak.conf"
 -#default_config = "/etc/dak/dak.conf"
 -default_config = "/home/stew/etc/dak/dak.conf"     #: default dak config, defines host properties
++default_config = "/etc/dak/dak.conf" #: default dak config, defines host properties
  
  def which_conf_file(Cnf):
      res = socket.gethostbyaddr(socket.gethostname())
diff --combined daklib/dbconn.py
index 9b37af700f631b08fb7990dd4434d440cd6d8d54,1a1902d5dd3da64dd9b35facecbf29e79abe8f7a..49468a7556c250f314fe2370700f4c3cc7b2f98e
@@@ -231,6 -231,17 +231,17 @@@ __all__.append('BinAssociation'
  
  ################################################################################
  
+ class BinContents(object):
+     def __init__(self, *args, **kwargs):
+         pass
+     def __repr__(self):
+         return '<BinContents (%s, %s)>' % (self.binary, self.filename)
+ __all__.append('BinContents')
+ ################################################################################
  class DBBinary(object):
      def __init__(self, *args, **kwargs):
          pass
@@@ -458,15 -469,6 +469,6 @@@ __all__.append('DBConfig'
  
  ################################################################################
  
- class ContentFilename(object):
-     def __init__(self, *args, **kwargs):
-         pass
-     def __repr__(self):
-         return '<ContentFilename %s>' % self.filename
- __all__.append('ContentFilename')
  @session_wrapper
  def get_or_set_contents_file_id(filename, session=None):
      """
@@@ -633,28 -635,14 +635,14 @@@ def insert_content_paths(binary_id, ful
          # Insert paths
          pathcache = {}
          for fullpath in fullpaths:
-             # Get the necessary IDs ...
-             (path, file) = os.path.split(fullpath)
-             filepath_id = get_or_set_contents_path_id(path, session)
-             filename_id = get_or_set_contents_file_id(file, session)
-             pathcache[fullpath] = (filepath_id, filename_id)
+             if fullpath.startswith( './' ):
+                 fullpath = fullpath[2:]
 -            
 +
-         for fullpath, dat in pathcache.items():
-             ca = ContentAssociation()
-             ca.binary_id = binary_id
-             ca.filepath_id = dat[0]
-             ca.filename_id = dat[1]
-             session.add(ca)
+             session.execute( "INSERT INTO bin_contents ( file, binary_id ) VALUES ( :filename, :id )", { 'filename': fullpath, 'id': binary_id}  )
  
-         # Only commit if we set up the session ourself
+         session.commit()
          if privatetrans:
-             session.commit()
              session.close()
-         else:
-             session.flush()
          return True
  
      except:
@@@ -2354,6 -2342,7 +2342,7 @@@ class DBConn(Singleton)
                                   binary_id = self.tbl_bin_associations.c.bin,
                                   binary = relation(DBBinary)))
  
          mapper(DBBinary, self.tbl_binaries,
                 properties = dict(binary_id = self.tbl_binaries.c.id,
                                   package = self.tbl_binaries.c.package,
          mapper(DBConfig, self.tbl_config,
                 properties = dict(config_id = self.tbl_config.c.id))
  
-         mapper(ContentAssociation, self.tbl_content_associations,
-                properties = dict(ca_id = self.tbl_content_associations.c.id,
-                                  filename_id = self.tbl_content_associations.c.filename,
-                                  filename    = relation(ContentFilename),
-                                  filepath_id = self.tbl_content_associations.c.filepath,
-                                  filepath    = relation(ContentFilepath),
-                                  binary_id   = self.tbl_content_associations.c.binary_pkg,
-                                  binary      = relation(DBBinary)))
-         mapper(ContentFilename, self.tbl_content_file_names,
-                properties = dict(cafilename_id = self.tbl_content_file_names.c.id,
-                                  filename = self.tbl_content_file_names.c.file))
-         mapper(ContentFilepath, self.tbl_content_file_paths,
-                properties = dict(cafilepath_id = self.tbl_content_file_paths.c.id,
-                                  filepath = self.tbl_content_file_paths.c.path))
          mapper(DSCFile, self.tbl_dsc_files,
                 properties = dict(dscfile_id = self.tbl_dsc_files.c.id,
                                   source_id = self.tbl_dsc_files.c.source,
                 properties = dict(overridetype = self.tbl_override_type.c.type,
                                   overridetype_id = self.tbl_override_type.c.id))
  
-         mapper(PendingContentAssociation, self.tbl_pending_content_associations,
-                properties = dict(pca_id = self.tbl_pending_content_associations.c.id,
-                                  filepath_id = self.tbl_pending_content_associations.c.filepath,
-                                  filepath = relation(ContentFilepath),
-                                  filename_id = self.tbl_pending_content_associations.c.filename,
-                                  filename = relation(ContentFilename)))
          mapper(Priority, self.tbl_priority,
                 properties = dict(priority_id = self.tbl_priority.c.id))
  
diff --combined daklib/utils.py
index a6660ae1b9e291f89306dbc4ab1b032a09491ba5,21446fbe9f435685f8c2dcd0c2c8585f7db1b41c..b0e9a0d74c83e8c57d48f4fc82a46456f3224666
@@@ -45,7 -45,8 +45,8 @@@ from dak_exceptions import 
  from textutils import fix_maintainer
  from regexes import re_html_escaping, html_escaping, re_single_line_field, \
                      re_multi_line_field, re_srchasver, re_taint_free, \
-                     re_gpg_uid, re_re_mark, re_whitespace_comment, re_issource
+                     re_gpg_uid, re_re_mark, re_whitespace_comment, re_issource, \
+                     re_is_orig_source
  
  from formats import parse_format, validate_changes_format
  from srcformats import get_format_from_string
@@@ -304,13 -305,13 +305,13 @@@ def check_hash(where, files, hashname, 
          try:
              try:
                  file_handle = open_file(f)
--    
++
                  # Check for the hash entry, to not trigger a KeyError.
                  if not files[f].has_key(hash_key(hashname)):
                      rejmsg.append("%s: misses %s checksum in %s" % (f, hashname,
                          where))
                      continue
--    
++
                  # Actually check the hash for correctness.
                  if hashfunc(file_handle) != files[f][hash_key(hashname)]:
                      rejmsg.append("%s: %s check failed in %s" % (f, hashname,