--- /dev/null
-
+ #!/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))
+
+
+
################################################################################
- 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())
# 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:
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,