log.debug( "scanning: %s" % (deb[1]) )
debfile = os.path.join( pooldir, deb[1] )
if os.path.exists( debfile ):
- Binary(debfile, self.reject).scan_package( deb[0] )
+ Binary(debfile, self.reject).scan_package(deb[0],True)
else:
- log.error( "missing .deb: %s" % deb[1] )
+ log.error("missing .deb: %s" % deb[1])
def generate(self):
"""
--- /dev/null
+#!/usr/bin/env python
+# coding=utf8
+
+"""
+Debian Archive Kit Database Update Script
+Copyright © 2008 Michael Casadevall <mcasadevall@debian.org>
+Copyright © 2009 Mike O'Connor <stew@debian.org>
+
+Debian Archive Kit Database Update Script 8
+"""
+
+# 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
+
+################################################################################
+
+# * Ganneff ponders how to best write the text to -devel. (need to tell em in
+# case they find more bugs). "We fixed the fucking idiotic broken implementation
+# to be less so" is probably not the nicest, even if perfect valid, way to say so
+
+################################################################################
+
+import psycopg2
+import time
+from daklib.dak_exceptions import DBUpdateError
+from daklib.utils import get_conf
+
+################################################################################
+
+def do_update(self):
+ print "pending_contents should distinguish by arch"
+ Cnf = get_conf()
+
+ try:
+ c = self.db.cursor()
+
+ c.execute("DELETE FROM pending_content_associations")
+ c.execute("""ALTER TABLE pending_content_associations
+ ADD COLUMN architecture integer NOT NULL""")
+ c.execute("""ALTER TABLE ONLY pending_content_associations
+ ADD CONSTRAINT pending_content_assiciations_arch
+ FOREIGN KEY (architecture)
+ REFERENCES architecture(id)
+ ON DELETE CASCADE""")
+ c.execute("UPDATE config SET value = '9' WHERE name = 'db_revision'")
+ self.db.commit()
+
+ except psycopg2.ProgrammingError, msg:
+ self.db.rollback()
+ raise DBUpdateError, "Unable to apply suite config updates, rollback issued. Error message : %s" % (str(msg))
suite_id = database.get_suite_id(suite)
projectB.query("INSERT INTO bin_associations (suite, bin) VALUES (%d, currval('binaries_id_seq'))" % (suite_id))
- if not database.copy_temporary_contents(package, version, newfile, reject):
+ if not database.copy_temporary_contents(package, version, architecture, newfile, reject):
print "REJECT\n" + reject_message,
projectB.query("ROLLBACK")
raise MissingContents, "No contents stored for package %s, and couldn't determine contents of %s" % (package, newfile )
# Check the version and for file overwrites
reject(Upload.check_binary_against_db(f),"")
- Binary(f, reject).scan_package( )
+ Binary(f, reject).scan_package()
# Checks for a source package...
else:
--- /dev/null
+stew@tang.vireo.org.14091:1236689528
\ No newline at end of file
finally:
os.chdir( cwd )
- def valid_deb(self):
+ def valid_deb(self, relaxed=False):
"""
Check deb contents making sure the .deb contains:
1. debian-binary
"""
self.__scan_ar()
rejected = not self.chunks
- if len(self.chunks) < 3:
- rejected = True
- self.reject("%s: found %d chunks, expected 3." % (self.filename, len(self.chunks)))
+ if relaxed:
+ if en(self.chunks) < 3:
+ rejected = True
+ self.reject("%s: found %d chunks, expected at least 3." % (self.filename, len(self.chunks)))
+ else
+ if en(self.chunks) != 3:
+ rejected = True
+ self.reject("%s: found %d chunks, expected 3." % (self.filename, len(self.chunks)))
if self.chunks[0] != "debian-binary":
rejected = True
self.reject("%s: first chunk is '%s', expected 'debian-binary'." % (self.filename, self.chunks[0]))
return not rejected
- def scan_package(self, bootstrap_id=0):
+ def scan_package(self, bootstrap_id=0, relaxed=False):
"""
Unpack the .deb, do sanity checking, and gather info from it.
@return True if the deb is valid and contents were imported
"""
result = False
- rejected = not self.valid_deb()
+ rejected = not self.valid_deb(relaxed)
if not rejected:
self.__unpack()
traceback.print_exc()
os.chdir(cwd)
+ self._cleanup()
return result
def check_utf8_package(self, package):
@return True if the deb is valid and contents were imported
"""
- rejected = not self.valid_deb()
+ rejected = not self.valid_deb(True)
self.__unpack()
if not rejected and self.tmpdir:
os.chdir(cwd)
-if __name__ == "__main__":
- Binary( "/srv/ftp.debian.org/queue/accepted/halevt_0.1.3-2_amd64.deb" ).scan_package()
################################################################################
-def copy_temporary_contents(package, version, deb, reject):
+def copy_temporary_contents(package, version, arch, deb, reject):
"""
copy the previously stored contents from the temp table to the permanant one
# first see if contents exist:
+ arch_id = database.get_architecture_id (architecture)
+
exists = projectB.query("""SELECT 1 FROM pending_content_associations
- WHERE package='%s' LIMIT 1""" % package ).getresult()
+ WHERE package='%s'
+ AND version='%s'
+ AND architecture=%d LIMIT 1"""
+ % package, version, arch_id ).getresult()
if not exists:
# This should NOT happen. We should have added contents
subst = {
"__PACKAGE__": package,
"__VERSION__": version,
+ "__ARCH__": arch,
"__TO_ADDRESS__": Cnf["Dinstall::MyAdminAddress"],
"__DAK_ADDRESS__": Cnf["Dinstall::MyEmailAddress"] }
sql = """INSERT INTO content_associations(binary_pkg,filepath,filename)
SELECT currval('binaries_id_seq'), filepath, filename FROM pending_content_associations
WHERE package='%s'
- AND version='%s'""" % (package, version)
+ AND version='%s'
+ AND architecture=%d""" % (package, version, arch_id)
projectB.query(sql)
projectB.query("""DELETE from pending_content_associations
WHERE package='%s'
- AND version='%s'""" % (package, version))
+ AND version='%s'
+ AND architecture=%d""" % (package, version, arch_id))
return exists
c.execute("BEGIN WORK")
try:
+ arch_id = self.get_architecture_id(package[Architecture])
# Remove any already existing recorded files for this package
c.execute("""DELETE FROM pending_content_associations
WHERE package=%(Package)s
- AND version=%(Version)s""", package )
+ AND version=%(Version)s
+ AND arch_id=%d""" % arch_id, package )
for fullpath in fullpaths:
(path, file) = os.path.split(fullpath)
path_id = self.get_or_set_contents_path_id(path)
c.execute("""INSERT INTO pending_content_associations
- (package, version, filepath, filename)
- VALUES (%%(Package)s, %%(Version)s, '%d', '%d')""" % (path_id, file_id),
- package )
+ (package, version, architecture, filepath, filename)
+ VALUES (%%(Package)s, %%(Version)s, '%d', '%d', '%d')"""
+ % (arch_id, path_id, file_id), package )
+
c.execute("COMMIT")
return True
except:
Subject: Missing contents for __PACKAGE__ in accepted queue
While processing the accepted queue, I didn't have contents in the
-database for __PACKAGE__ version __VERSION__. These contents should
-have been put into the database by process-unchecked when the package
-first arrived.
+database for __PACKAGE__ version __VERSION__ for arch __ARCH__. These
+contents should have been put into the database by process-unchecked
+when the package first arrived.
-This is probably stew's fault.
\ No newline at end of file
+This is probably stew's fault.