未验证 提交 38d8ab04 编写于 作者: A Ansgar Burchardt

Merge branch 'debug'

#!/usr/bin/env python
# coding=utf8
"""
Add a debug suite field to the suite table
@contact: Debian FTP Master <ftpmaster@debian.org>
@copyright: 2015, Paul Tagliamonte <paultag@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
from daklib.dak_exceptions import DBUpdateError
from daklib.config import Config
statements = [
"""
ALTER TABLE suite ADD COLUMN debugsuite_id INTEGER REFERENCES suite(id)
""",
"""
COMMENT ON COLUMN suite.debugsuite_id IS 'Suite to redirect debug packages (Section: debug) to'
"""
]
################################################################################
def do_update(self):
print __doc__
try:
cnf = Config()
c = self.db.cursor()
for stmt in statements:
c.execute(stmt)
c.execute("UPDATE config SET value = '110' WHERE name = 'db_revision'")
self.db.commit()
except psycopg2.ProgrammingError as msg:
self.db.rollback()
raise DBUpdateError('Unable to apply sick update 110, rollback issued. Error message: {0}'.format(msg))
......@@ -49,6 +49,7 @@ from daklib.urgencylog import UrgencyLog
from daklib.packagelist import PackageList
import daklib.announce
import daklib.utils
# Globals
Options = None
......@@ -141,6 +142,12 @@ def comment_accept(upload, srcqueue, comments, transaction):
component_name = section.split('/', 1)[0]
return get_mapped_component(component_name, session=session)
def is_debug_binary(db_binary):
return daklib.utils.is_in_debug_section(db_binary.proxy)
def has_debug_binaries(upload):
return any((is_debug_binary(x) for x in upload.binaries))
def source_component_func(db_source):
package_list = PackageList(db_source.proxy)
component = source_component_from_package_list(package_list, upload.target_suite)
......@@ -157,13 +164,54 @@ def comment_accept(upload, srcqueue, comments, transaction):
all_target_suites.extend([q.suite for q in upload.target_suite.copy_queues])
for suite in all_target_suites:
debug_suite = suite.debug_suite
if upload.source is not None:
transaction.copy_source(upload.source, suite, source_component_func(upload.source), allow_tainted=allow_tainted)
# If we have Source in this upload, let's include it into
# upload suite.
transaction.copy_source(
upload.source,
suite,
source_component_func(upload.source),
allow_tainted=allow_tainted,
)
if debug_suite is not None and has_debug_binaries(upload):
# If we're handing a debug package, we also need to include the
# source in the debug suite as well.
transaction.copy_source(
upload.source,
debug_suite,
source_component_func(upload.source),
allow_tainted=allow_tainted,
)
for db_binary in upload.binaries:
# build queues may miss the source package if this is a binary-only upload
# Now, let's work out where to copy this guy to -- if it's
# a debug binary, and the suite has a debug suite, let's go
# ahead and target the debug suite rather then the stock
# suite.
copy_to_suite = suite
if debug_suite is not None and is_debug_binary(db_binary):
copy_to_suite = debug_suite
# build queues may miss the source package if this is a
# binary-only upload.
if suite != upload.target_suite:
transaction.copy_source(db_binary.source, suite, source_component_func(db_binary.source), allow_tainted=allow_tainted)
transaction.copy_binary(db_binary, suite, binary_component_func(db_binary), allow_tainted=allow_tainted, extra_archives=[upload.target_suite.archive])
transaction.copy_source(
db_binary.source,
copy_to_suite,
source_component_func(db_binary.source),
allow_tainted=allow_tainted,
)
transaction.copy_binary(
db_binary,
copy_to_suite,
binary_component_func(db_binary),
allow_tainted=allow_tainted,
extra_archives=[upload.target_suite.archive],
)
# Copy .changes if needed
if upload.target_suite.copychanges:
......
......@@ -1025,14 +1025,33 @@ class ArchiveUpload(object):
source = self.changes.source
if source is not None:
component = source_component_func(source)
db_source = self.transaction.install_source(self.directory, source, suite, component, changed_by, fingerprint=self.fingerprint)
db_source = self.transaction.install_source(
self.directory,
source,
suite,
component,
changed_by,
fingerprint=self.fingerprint
)
else:
db_source = None
db_binaries = []
for binary in self.changes.binaries:
copy_to_suite = suite
if utils.is_in_debug_section(binary.control) and suite.debug_suite is not None:
copy_to_suite = suite.debug_suite
component = binary_component_func(binary)
db_binary = self.transaction.install_binary(self.directory, binary, suite, component, fingerprint=self.fingerprint, source_suites=source_suites, extra_source_archives=extra_source_archives)
db_binary = self.transaction.install_binary(
self.directory,
binary,
copy_to_suite,
component,
fingerprint=self.fingerprint,
source_suites=source_suites,
extra_source_archives=extra_source_archives
)
db_binaries.append(db_binary)
if suite.copychanges:
......
......@@ -286,13 +286,41 @@ class ExternalHashesCheck(Check):
class BinaryCheck(Check):
"""Check binary packages for syntax errors."""
def check(self, upload):
debug_deb_name_postfix = "-dbgsym"
# XXX: Handle dynamic debug section name here
for binary in upload.changes.binaries:
self.check_binary(upload, binary)
binary_names = set([ binary.control['Package'] for binary in upload.changes.binaries ])
for bn in binary_names:
if bn not in upload.changes.binary_names:
raise Reject('Package {0} is not mentioned in Binary field in changes'.format(bn))
binaries = {binary.control['Package']: binary
for binary in upload.changes.binaries}
for name, binary in binaries.items():
if name in upload.changes.binary_names:
# Package is listed in Binary field. Everything is good.
pass
elif daklib.utils.is_in_debug_section(binary.control):
# If we have a binary package in the debug section, we
# can allow it to not be present in the Binary field
# in the .changes file, so long as its name (without
# -dbgsym) is present in the Binary list.
if not name.endswith(debug_deb_name_postfix):
raise Reject('Package {0} is in the debug section, but '
'does not end in {1}.'.format(name, debug_deb_name_postfix))
# Right, so, it's named properly, let's check that
# the corresponding package is in the Binary list
origin_package_name = name[:-len(debug_deb_name_postfix)]
if origin_package_name not in upload.changes.binary_names:
raise Reject(
"Debug package {debug}'s corresponding binary package "
"{origin} is not present in the Binary field.".format(
debug=name, origin=origin_package_name))
else:
# Someone was a nasty little hacker and put a package
# into the .changes that isn't in debian/control. Bad,
# bad person.
raise Reject('Package {0} is not mentioned in Binary field in changes'.format(name))
return True
......
......@@ -2548,6 +2548,7 @@ class DBConn(object):
properties = dict(suite_id = self.tbl_suite.c.id,
policy_queue = relation(PolicyQueue, primaryjoin=(self.tbl_suite.c.policy_queue_id == self.tbl_policy_queue.c.id)),
new_queue = relation(PolicyQueue, primaryjoin=(self.tbl_suite.c.new_queue_id == self.tbl_policy_queue.c.id)),
debug_suite = relation(Suite, remote_side=[self.tbl_suite.c.id]),
copy_queues = relation(BuildQueue,
secondary=self.tbl_suite_build_queue_copy),
srcformats = relation(SrcFormat, secondary=self.tbl_suite_src_formats,
......
......@@ -1325,3 +1325,17 @@ def parse_built_using(control):
bu.append((source_name, source_version))
return bu
################################################################################
def is_in_debug_section(control):
"""binary package is a debug package
@type control: dict-like
@param control: control file of binary package
@rtype Boolean
@return: True if the binary package is a debug package
"""
section = control['Section'].split('/', 1)[-1]
return section == "debug"
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册