summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
9af3682)
Signed-off-by: Mark Hymers <mhy@debian.org>
import apt_pkg, commands
from daklib import daklog
import apt_pkg, commands
from daklib import daklog
-from daklib import queue
+from daklib.queue import *
from daklib import utils
from daklib.dbconn import *
from daklib.binary import copy_temporary_contents
from daklib import utils
from daklib.dbconn import *
from daklib.binary import copy_temporary_contents
if stable_queue:
stable_install(u, summary, short_summary, stable_queue, log_urgency)
else:
if stable_queue:
stable_install(u, summary, short_summary, stable_queue, log_urgency)
else:
- install(u, log_urgency)
+ install(u, session, log_urgency)
elif answer == 'Q':
sys.exit(0)
elif answer == 'Q':
sys.exit(0)
source.source = u.pkg.dsc["source"]
source.version = u.pkg.dsc["version"] # NB: not files[file]["version"], that has no epoch
source.maintainer_id = get_or_set_maintainer(u.pkg.dsc["maintainer"], session).maintainer_id
source.source = u.pkg.dsc["source"]
source.version = u.pkg.dsc["version"] # NB: not files[file]["version"], that has no epoch
source.maintainer_id = get_or_set_maintainer(u.pkg.dsc["maintainer"], session).maintainer_id
- source.changedby_id = get_or_set_maintainer(u.pkg.dsc["changed-by"], session).maintainer_id
- source.fingerprint_id = get_or_set_fingerprint(u.pkg.dsc["fingerprint"], session).fingerprint_id
+ source.changedby_id = get_or_set_maintainer(u.pkg.changes["changed-by"], session).maintainer_id
+ source.fingerprint_id = get_or_set_fingerprint(u.pkg.changes["fingerprint"], session).fingerprint_id
source.install_date = datetime.now().date()
dsc_component = entry["component"]
source.install_date = datetime.now().date()
dsc_component = entry["component"]
dscfile.poolfile_id = entry["files id"]
session.add(dscfile)
dscfile.poolfile_id = entry["files id"]
session.add(dscfile)
- for dsc_file, dentry in u.pkg.dsc_files.keys():
+ for dsc_file, dentry in u.pkg.dsc_files.items():
df = DSCFile()
df.source_id = source.source_id
df = DSCFile()
df.source_id = source.source_id
# files id is stored in dsc_files by check_dsc().
files_id = dentry.get("files id", None)
# files id is stored in dsc_files by check_dsc().
files_id = dentry.get("files id", None)
+ # Find the entry in the files hash
+ # TODO: Bail out here properly
+ dfentry = None
+ for f, e in u.pkg.files.items():
+ if f == dsc_file:
+ dfentry = e
+ break
+
- filename = dentry["pool name"] + dsc_file
+ filename = dfentry["pool name"] + dsc_file
(found, obj) = check_poolfile(filename, dentry["size"], dentry["md5sum"], dsc_location_id)
# FIXME: needs to check for -1/-2 and or handle exception
(found, obj) = check_poolfile(filename, dentry["size"], dentry["md5sum"], dsc_location_id)
# FIXME: needs to check for -1/-2 and or handle exception
# If still not found, add it
if files_id is None:
# If still not found, add it
if files_id is None:
+ # HACK: Force sha1sum etc into dentry
+ dentry["sha1sum"] = dfentry["sha1sum"]
+ dentry["sha256sum"] = dfentry["sha256sum"]
poolfile = add_poolfile(filename, dentry, dsc_location_id, session)
files_id = poolfile.file_id
poolfile = add_poolfile(filename, dentry, dsc_location_id, session)
files_id = poolfile.file_id
session.flush()
# Add the src_uploaders to the DB
session.flush()
# Add the src_uploaders to the DB
- uploader_ids = [maintainer_id]
+ uploader_ids = [source.maintainer_id]
if u.pkg.dsc.has_key("uploaders"):
for up in u.pkg.dsc["uploaders"].split(","):
up = up.strip()
if u.pkg.dsc.has_key("uploaders"):
for up in u.pkg.dsc["uploaders"].split(","):
up = up.strip()
su = SrcUploader()
su.maintainer_id = up
su = SrcUploader()
su.maintainer_id = up
- su.source_id = source_id
+ su.source_id = source.source_id
session.add(su)
session.flush()
session.add(su)
session.flush()
# Find poolfile id
filename = entry["pool name"] + filename
# Find poolfile id
filename = entry["pool name"] + filename
+ fullpath = os.path.join(cnf["Dir::Pool"], filename)
if not entry.get("location id", None):
entry["location id"] = get_location(cnf["Dir::Pool"], entry["component"], utils.where_am_i(), session).location_id
if not entry.get("location id", None):
entry["location id"] = get_location(cnf["Dir::Pool"], entry["component"], utils.where_am_i(), session).location_id
bin.poolfile_id = entry["files id"]
# Find source id
bin.poolfile_id = entry["files id"]
# Find source id
- bin_sources = get_sources_from_name(entry["source package"], entry["source version"])
+ bin_sources = get_sources_from_name(entry["source package"], entry["source version"], session=session)
if len(bin_sources) != 1:
raise NoSourceFieldError, "Unable to find a unique source id for %s (%s), %s, file %s, type %s, signed by %s" % \
(bin.package, bin.version, bin.architecture.arch_string,
if len(bin_sources) != 1:
raise NoSourceFieldError, "Unable to find a unique source id for %s (%s), %s, file %s, type %s, signed by %s" % \
(bin.package, bin.version, bin.architecture.arch_string,
ba = BinAssociation()
ba.binary_id = bin.binary_id
ba.suite_id = get_suite(suite_name).suite_id
ba = BinAssociation()
ba.binary_id = bin.binary_id
ba.suite_id = get_suite(suite_name).suite_id
session.flush()
# Deal with contents
session.flush()
# Deal with contents
- contents = copy_temporary_contents(bin.package, bin.version, bin.architecture.arch_string, filename, reject=None)
+ contents = copy_temporary_contents(bin.package, bin.version, bin.architecture.arch_string, fullpath, None, session)
- print "REJECT\n" + "\n".join(contents.rejects)
+ print "REJECT\nCould not determine contents of package %s" % bin.package
session.rollback()
raise MissingContents, "No contents stored for package %s, and couldn't determine contents of %s" % (bin.package, filename)
session.rollback()
raise MissingContents, "No contents stored for package %s, and couldn't determine contents of %s" % (bin.package, filename)
-def install(u, log_urgency=True):
+def install(u, session, log_urgency=True):
cnf = Config()
summarystats = SummaryStats()
print "Installing."
cnf = Config()
summarystats = SummaryStats()
print "Installing."
- Logger.log(["installing changes",pkg.changes_file])
-
- # Begin a transaction; if we bomb out anywhere between here and the COMMIT WORK below, the DB will not be changed.
- session = DBConn().session()
+ Logger.log(["installing changes", u.pkg.changes_file])
# Ensure that we have all the hashes we need below.
u.ensure_hashes()
# Ensure that we have all the hashes we need below.
u.ensure_hashes()
return
# Add the .dsc file to the DB first
return
# Add the .dsc file to the DB first
- for newfile in u.pkg.files.keys():
+ for newfile, entry in u.pkg.files.items():
if entry["type"] == "dsc":
dsc_component, dsc_location_id = add_dsc_to_db(u, newfile, session)
# Add .deb / .udeb files to the DB (type is always deb, dbtype is udeb/deb)
if entry["type"] == "dsc":
dsc_component, dsc_location_id = add_dsc_to_db(u, newfile, session)
# Add .deb / .udeb files to the DB (type is always deb, dbtype is udeb/deb)
- for newfile in u.pkg.files.keys():
+ for newfile, entry in u.pkg.files.items():
if entry["type"] == "deb":
add_deb_to_db(u, newfile, session)
if entry["type"] == "deb":
add_deb_to_db(u, newfile, session)
summarystats.accept_count += 1
################################################################################
summarystats.accept_count += 1
################################################################################
-def stable_install(u, summary, short_summary, fromsuite_name="proposed-updates"):
+def stable_install(u, session, summary, short_summary, fromsuite_name="proposed-updates"):
summarystats = SummaryStats()
fromsuite_name = fromsuite_name.lower()
summarystats = SummaryStats()
fromsuite_name = fromsuite_name.lower()
fromsuite = get_suite(fromsuite_name)
tosuite = get_suite(tosuite_name)
fromsuite = get_suite(fromsuite_name)
tosuite = get_suite(tosuite_name)
- # Begin a transaction; if we bomb out anywhere between here and
- # the COMMIT WORK below, the DB won't be changed.
- session = DBConn().session()
-
# Add the source to stable (and remove it from proposed-updates)
for newfile, entry in u.pkg.files.items():
if entry["type"] == "dsc":
# Add the source to stable (and remove it from proposed-updates)
for newfile, entry in u.pkg.files.items():
if entry["type"] == "dsc":
################################################################################
################################################################################
-def process_it(changes_file, stable_queue=None, log_urgency=True):
+def process_it(changes_file, stable_queue, log_urgency, session):
cnf = Config()
u = Upload()
cnf = Config()
u = Upload()
# overwrite_checks should not be performed if installing to stable
overwrite_checks = False
# overwrite_checks should not be performed if installing to stable
overwrite_checks = False
+ u.pkg.load_dot_dak(cfile)
u.update_subst()
if stable_queue:
u.pkg.changes_file = old
u.update_subst()
if stable_queue:
u.pkg.changes_file = old
- u.accepted_checks(overwrite_checks)
+ u.accepted_checks(overwrite_checks, True, session)
action(u, stable_queue, log_urgency)
# Restore CWD
action(u, stable_queue, log_urgency)
# Restore CWD
# Sort the .changes files so that we process sourceful ones first
changes_files.sort(utils.changes_compare)
# Sort the .changes files so that we process sourceful ones first
changes_files.sort(utils.changes_compare)
# Process the changes files
for changes_file in changes_files:
print "\n" + changes_file
# Process the changes files
for changes_file in changes_files:
print "\n" + changes_file
- process_it(changes_file, stable_queue, log_urgency)
+ session = DBConn().session()
+ process_it(changes_file, stable_queue, log_urgency, session)
+ session.close()
if summarystats.accept_count:
sets = "set"
if summarystats.accept_count:
sets = "set"
contents stored in pending_content_associations
"""
contents stored in pending_content_associations
"""
- # first see if contents exist:
if session is None:
session = DBConn().session()
if session is None:
session = DBConn().session()
arch = get_architecture(archname, session=session)
arch = get_architecture(archname, session=session)
+ # first see if contents exist:
in_pcaq = """SELECT 1 FROM pending_content_associations
WHERE package=:package
AND version=:version
in_pcaq = """SELECT 1 FROM pending_content_associations
WHERE package=:package
AND version=:version
'version': version,
'archid': arch.arch_id}
'version': version,
'archid': arch.arch_id}
check = session.execute(in_pcaq, vals)
if check.rowcount > 0:
check = session.execute(in_pcaq, vals)
if check.rowcount > 0:
session.execute(sql, vals)
session.commit()
session.execute(sql, vals)
session.commit()
+ if privatetrans:
+ session.close()
+
return exists
__all__.append('copy_temporary_contents')
return exists
__all__.append('copy_temporary_contents')
# If it does, update things to ensure it's not removed prematurely
else:
# If it does, update things to ensure it's not removed prematurely
else:
- qb = get_queue_build(dest, suite_id, session)
+ qb = get_queue_build(dest, s.suite_id, session)
if qb is None:
qb.in_queue = True
qb.last_used = None
if qb is None:
qb.in_queue = True
qb.last_used = None
###############################################################################
###############################################################################
-def get_type(f, session=None):
+def get_type(f, session):
"""
Get the file type of C{f}
@type f: dict
@param f: file entry from Changes object
"""
Get the file type of C{f}
@type f: dict
@param f: file entry from Changes object
+ @type session: SQLA Session
+ @param session: SQL Alchemy session object
+
@rtype: string
@return: filetype
"""
@rtype: string
@return: filetype
"""
- if session is None:
- session = DBConn().session()
-
# Determine the type
if f.has_key("dbtype"):
file_type = file["dbtype"]
# Determine the type
if f.has_key("dbtype"):
file_type = file["dbtype"]
pkg = f["package"]
priority = f["priority"]
section = f["section"]
pkg = f["package"]
priority = f["priority"]
section = f["section"]
- file_type = get_type(f)
+ file_type = get_type(f, session)
component = f["component"]
if file_type == "dsc":
component = f["component"]
if file_type == "dsc":
if new[pkg].has_key("othercomponents"):
print "WARNING: %s already present in %s distribution." % (pkg, new[pkg]["othercomponents"])
if new[pkg].has_key("othercomponents"):
print "WARNING: %s already present in %s distribution." % (pkg, new[pkg]["othercomponents"])
return new
################################################################################
return new
################################################################################
# If 'dak process-unchecked' crashed out in the right place, architecture may still be a string.
if not self.pkg.changes.has_key("architecture") or not \
# If 'dak process-unchecked' crashed out in the right place, architecture may still be a string.
if not self.pkg.changes.has_key("architecture") or not \
- isinstance(changes["architecture"], DictType):
+ isinstance(self.pkg.changes["architecture"], DictType):
self.pkg.changes["architecture"] = { "Unknown" : "" }
# and maintainer2047 may not exist.
self.pkg.changes["architecture"] = { "Unknown" : "" }
# and maintainer2047 may not exist.
(self.pkg.changes["changedby822"] != self.pkg.changes["maintainer822"]):
self.Subst["__MAINTAINER_FROM__"] = self.pkg.changes["changedby2047"]
(self.pkg.changes["changedby822"] != self.pkg.changes["maintainer822"]):
self.Subst["__MAINTAINER_FROM__"] = self.pkg.changes["changedby2047"]
- self.Subst["__MAINTAINER_TO__"] = "%s, %s" % (self.pkg.changes["changedby2047"], changes["maintainer2047"])
+ self.Subst["__MAINTAINER_TO__"] = "%s, %s" % (self.pkg.changes["changedby2047"], self.pkg.changes["maintainer2047"])
self.Subst["__MAINTAINER__"] = self.pkg.changes.get("changed-by", "Unknown")
else:
self.Subst["__MAINTAINER_FROM__"] = self.pkg.changes["maintainer2047"]
self.Subst["__MAINTAINER__"] = self.pkg.changes.get("changed-by", "Unknown")
else:
self.Subst["__MAINTAINER_FROM__"] = self.pkg.changes["maintainer2047"]
for suite in self.pkg.changes["distribution"].keys():
self.per_suite_file_checks(f, suite, session)
for suite in self.pkg.changes["distribution"].keys():
self.per_suite_file_checks(f, suite, session)
# If the .changes file says it has source, it must have source.
if self.pkg.changes["architecture"].has_key("source"):
if not has_source:
# If the .changes file says it has source, it must have source.
if self.pkg.changes["architecture"].has_key("source"):
if not has_source:
self.rejects.append("%s: no .tar.gz or .orig.tar.gz in 'Files' field." % (dsc_filename))
# Ensure source is newer than existing source in target suites
self.rejects.append("%s: no .tar.gz or .orig.tar.gz in 'Files' field." % (dsc_filename))
# Ensure source is newer than existing source in target suites
- self.check_source_against_db(dsc_filename)
-
- self.check_dsc_against_db(dsc_filename)
+ session = DBConn().session()
+ self.check_source_against_db(dsc_filename, session)
+ self.check_dsc_against_db(dsc_filename, session)
+ session.close()
if self.pkg.files[f].has_key("new"):
self.rejects.append("%s may not upload NEW file %s" % (uid, f))
if self.pkg.files[f].has_key("new"):
self.rejects.append("%s may not upload NEW file %s" % (uid, f))
###########################################################################
def build_summaries(self):
""" Build a summary of changes the upload introduces. """
###########################################################################
def build_summaries(self):
""" Build a summary of changes the upload introduces. """
targetdir = cnf["Dir::Queue::Accepted"]
print "Accepting."
targetdir = cnf["Dir::Queue::Accepted"]
print "Accepting."
self.logger.log(["Accepting changes", self.pkg.changes_file])
self.pkg.write_dot_dak(targetdir)
self.logger.log(["Accepting changes", self.pkg.changes_file])
self.pkg.write_dot_dak(targetdir)
return 0
################################################################################
return 0
################################################################################
- def in_override_p(self, package, component, suite, binary_type, file, session=None):
+ def in_override_p(self, package, component, suite, binary_type, file, session):
"""
Check if a package already has override entries in the DB
"""
Check if a package already has override entries in the DB
- if session is None:
- session = DBConn().session()
-
if binary_type == "": # must be source
file_type = "dsc"
else:
if binary_type == "": # must be source
file_type = "dsc"
else:
- anysuite = [suite] + self.Cnf.ValueList("Suite::%s::VersionChecks::Enhances" % (suite))
+ anysuite = [suite] + Cnf.ValueList("Suite::%s::VersionChecks::Enhances" % (suite))
for (s, v) in sv_list:
if s in [ x.lower() for x in anysuite ]:
if not anyversion or apt_pkg.VersionCompare(anyversion, v) <= 0:
for (s, v) in sv_list:
if s in [ x.lower() for x in anysuite ]:
if not anyversion or apt_pkg.VersionCompare(anyversion, v) <= 0:
self.reject.append("%s: old version (%s) in %s <= new version (%s) targeted at %s." % (file, existent_version, suite, new_version, target_suite))
################################################################################
self.reject.append("%s: old version (%s) in %s <= new version (%s) targeted at %s." % (file, existent_version, suite, new_version, target_suite))
################################################################################
- def check_binary_against_db(self, file, session=None):
- if session is None:
- session = DBConn().session()
-
+ def check_binary_against_db(self, file, session):
# Ensure version is sane
q = session.query(BinAssociation)
q = q.join(DBBinary).filter(DBBinary.package==self.pkg.files[file]["package"])
# Ensure version is sane
q = session.query(BinAssociation)
q = q.join(DBBinary).filter(DBBinary.package==self.pkg.files[file]["package"])
################################################################################
################################################################################
- def check_source_against_db(self, file, session=None):
+ def check_source_against_db(self, file, session):
- if session is None:
- session = DBConn().session()
-
source = self.pkg.dsc.get("source")
version = self.pkg.dsc.get("version")
source = self.pkg.dsc.get("source")
version = self.pkg.dsc.get("version")
file, version, sourceful=True)
################################################################################
file, version, sourceful=True)
################################################################################
- def check_dsc_against_db(self, file, session=None):
+ def check_dsc_against_db(self, file, session):
"""
@warning: NB: this function can remove entries from the 'files' index [if
"""
@warning: NB: this function can remove entries from the 'files' index [if
- if session is None:
- session = DBConn().session()
-
self.pkg.orig_tar_gz = None
# Try and find all files mentioned in the .dsc. This has
self.pkg.orig_tar_gz = None
# Try and find all files mentioned in the .dsc. This has
found = "%s in incoming" % (dsc_name)
# Check the file does not already exist in the archive
found = "%s in incoming" % (dsc_name)
# Check the file does not already exist in the archive
- ql = get_poolfile_like_name(dsc_name)
+ ql = get_poolfile_like_name(dsc_name, session)
# Strip out anything that isn't '%s' or '/%s$'
for i in ql:
# Strip out anything that isn't '%s' or '/%s$'
for i in ql:
old_file_fh.close()
actual_size = os.stat(old_file)[stat.ST_SIZE]
found = old_file
old_file_fh.close()
actual_size = os.stat(old_file)[stat.ST_SIZE]
found = old_file
- suite_type = f.location.archive_type
+ suite_type = x.location.archive_type
# need this for updating dsc_files in install()
# need this for updating dsc_files in install()
- dsc_entry["files id"] = f.file_id
+ dsc_entry["files id"] = x.file_id
# See install() in process-accepted...
# See install() in process-accepted...
- self.pkg.orig_tar_id = f.file_id
+ self.pkg.orig_tar_id = x.file_id
self.pkg.orig_tar_gz = old_file
self.pkg.orig_tar_gz = old_file
- self.pkg.orig_tar_location = f.location.location_id
+ self.pkg.orig_tar_location = x.location.location_id
else:
# TODO: Record the queues and info in the DB so we don't hardcode all this crap
# Not there? Check the queue directories...
for directory in [ "Accepted", "New", "Byhand", "ProposedUpdates", "OldProposedUpdates", "Embargoed", "Unembargoed" ]:
else:
# TODO: Record the queues and info in the DB so we don't hardcode all this crap
# Not there? Check the queue directories...
for directory in [ "Accepted", "New", "Byhand", "ProposedUpdates", "OldProposedUpdates", "Embargoed", "Unembargoed" ]:
- in_otherdir = os.path.join(self.Cnf["Dir::Queue::%s" % (directory)], dsc_name)
+ in_otherdir = os.path.join(Cnf["Dir::Queue::%s" % (directory)], dsc_name)
if os.path.exists(in_otherdir):
in_otherdir_fh = utils.open_file(in_otherdir)
actual_md5 = apt_pkg.md5sum(in_otherdir_fh)
if os.path.exists(in_otherdir):
in_otherdir_fh = utils.open_file(in_otherdir)
actual_md5 = apt_pkg.md5sum(in_otherdir_fh)
self.rejects.append("size for %s doesn't match %s." % (found, file))
################################################################################
self.rejects.append("size for %s doesn't match %s." % (found, file))
################################################################################
- def accepted_checks(self, overwrite_checks=True, session=None):
+ def accepted_checks(self, overwrite_checks, session):
# Recheck anything that relies on the database; since that's not
# frozen between accept and our run time when called from p-a.
# overwrite_checks is set to False when installing to stable/oldstable
# Recheck anything that relies on the database; since that's not
# frozen between accept and our run time when called from p-a.
# overwrite_checks is set to False when installing to stable/oldstable
- if session is None:
- session = DBConn().session()
-
propogate={}
nopropogate={}
propogate={}
nopropogate={}
+ # Find the .dsc (again)
+ dsc_filename = None
+ for f in self.pkg.files.keys():
+ if self.pkg.files[f]["type"] == "dsc":
+ dsc_filename = f
+
for checkfile in self.pkg.files.keys():
# The .orig.tar.gz can disappear out from under us is it's a
# duplicate of one in the archive.
for checkfile in self.pkg.files.keys():
# The .orig.tar.gz can disappear out from under us is it's a
# duplicate of one in the archive.
# propogate in the case it is in the override tables:
for suite in self.pkg.changes.get("propdistribution", {}).keys():
# propogate in the case it is in the override tables:
for suite in self.pkg.changes.get("propdistribution", {}).keys():
- if self.in_override_p(entry["package"], entry["component"], suite, entry.get("dbtype",""), checkfile):
+ if self.in_override_p(entry["package"], entry["component"], suite, entry.get("dbtype",""), checkfile, session):
propogate[suite] = 1
else:
nopropogate[suite] = 1
propogate[suite] = 1
else:
nopropogate[suite] = 1
for checkfile in self.pkg.files.keys():
# Check the package is still in the override tables
for suite in self.pkg.changes["distribution"].keys():
for checkfile in self.pkg.files.keys():
# Check the package is still in the override tables
for suite in self.pkg.changes["distribution"].keys():
- if not self.in_override_p(entry["package"], entry["component"], suite, entry.get("dbtype",""), checkfile):
+ if not self.in_override_p(entry["package"], entry["component"], suite, entry.get("dbtype",""), checkfile, session):
self.rejects.append("%s is NEW for %s." % (checkfile, suite))
################################################################################
self.rejects.append("%s is NEW for %s." % (checkfile, suite))
################################################################################
templatefile = open_file(filename)
template = templatefile.read()
for x in map.keys():
templatefile = open_file(filename)
template = templatefile.read()
for x in map.keys():
- template = template.replace(x,map[x])
+ template = template.replace(x, str(map[x]))
templatefile.close()
return template
templatefile.close()
return template