for f in self.queuefiles:
if f.fileid is not None and f.fileid == poolfile.file_id or \
f.poolfile.filename == poolfile_basename:
- # In this case, update the QueueFile entry so we
+ # In this case, update the BuildQueueFile entry so we
# don't remove it too early
f.lastused = datetime.now()
DBConn().session().object_session(pf).add(f)
return f
- # Prepare QueueFile object
- qf = QueueFile()
- qf.queue_id = self.queue_id
+ # Prepare BuildQueueFile object
+ qf = BuildQueueFile()
+ qf.build_queue_id = self.build_queue_id
qf.lastused = datetime.now()
- qf.filename = dest
+ qf.filename = poolfile_basename
- targetpath = qf.fullpath
+ targetpath = poolfile.fullpath
queuepath = os.path.join(self.path, poolfile_basename)
try:
- if self.copy_pool_files:
+ if self.copy_files:
# We need to copy instead of symlink
import utils
- utils.copy(targetfile, queuepath)
+ utils.copy(targetpath, queuepath)
# NULL in the fileid field implies a copy
qf.fileid = None
else:
- os.symlink(targetfile, queuepath)
+ os.symlink(targetpath, queuepath)
qf.fileid = poolfile.file_id
except OSError:
return None
__all__.append('BuildQueue')
@session_wrapper
-def get_queue(queuename, session=None):
+def get_build_queue(queuename, session=None):
"""
- Returns Queue object for given C{queue name}, creating it if it does not
+ Returns BuildQueue object for given C{queue name}, creating it if it does not
exist.
@type queuename: string
@param session: Optional SQLA session object (a temporary one will be
generated if not supplied)
- @rtype: Queue
- @return: Queue object for the given queue
+ @rtype: BuildQueue
+ @return: BuildQueue object for the given queue
"""
- q = session.query(Queue).filter_by(queue_name=queuename)
+ q = session.query(BuildQueue).filter_by(queue_name=queuename)
try:
return q.one()
except NoResultFound:
return None
-__all__.append('get_queue')
+__all__.append('get_build_queue')
################################################################################
################################################################################
-class KnownChange(object):
+class DBChange(object):
def __init__(self, *args, **kwargs):
pass
def __repr__(self):
- return '<KnownChange %s>' % self.changesname
+ return '<DBChange %s>' % self.changesname
-__all__.append('KnownChange')
+__all__.append('DBChange')
@session_wrapper
-def get_knownchange(filename, session=None):
+def get_dbchange(filename, session=None):
"""
- returns knownchange object for given C{filename}.
+ returns DBChange object for given C{filename}.
@type archive: string
@param archive: the name of the arhive
@return: Archive object for the given name (None if not present)
"""
- q = session.query(KnownChange).filter_by(changesname=filename)
+ q = session.query(DBChange).filter_by(changesname=filename)
try:
return q.one()
except NoResultFound:
return None
-__all__.append('get_knownchange')
+__all__.append('get_dbchange')
################################################################################
__all__.append('PolicyQueue')
+@session_wrapper
+def get_policy_queue(queuename, session=None):
+ """
+ Returns PolicyQueue object for given C{queue name}
+
+ @type queuename: string
+ @param queuename: The name of the queue
+
+ @type session: Session
+ @param session: Optional SQLA session object (a temporary one will be
+ generated if not supplied)
+
+ @rtype: PolicyQueue
+ @return: PolicyQueue object for the given queue
+ """
+
+ q = session.query(PolicyQueue).filter_by(queue_name=queuename)
+
+ try:
+ return q.one()
+ except NoResultFound:
+ return None
+
+__all__.append('get_policy_queue')
+
################################################################################
class Priority(object):
def add_dsc_to_db(u, filename, session=None):
entry = u.pkg.files[filename]
source = DBSource()
+ pfs = []
source.source = u.pkg.dsc["source"]
source.version = u.pkg.dsc["version"] # NB: not files[file]["version"], that has no epoch
filename = entry["pool name"] + filename
poolfile = add_poolfile(filename, entry, dsc_location_id, session)
session.flush()
+ pfs.append(poolfile)
entry["files id"] = poolfile.file_id
source.poolfile_id = entry["files id"]
# FIXME: needs to check for -1/-2 and or handle exception
if found and obj is not None:
files_id = obj.file_id
+ pfs.append(obj)
# If still not found, add it
if files_id is None:
dentry["sha1sum"] = dfentry["sha1sum"]
dentry["sha256sum"] = dfentry["sha256sum"]
poolfile = add_poolfile(filename, dentry, dsc_location_id, session)
+ pfs.append(poolfile)
files_id = poolfile.file_id
df.poolfile_id = files_id
session.flush()
- return dsc_component, dsc_location_id
+ return dsc_component, dsc_location_id, pfs
__all__.append('add_dsc_to_db')
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
+ entry["location id"] = get_location(cnf["Dir::Pool"], entry["component"], session=session).location_id
- if not entry.get("files id", None):
+ if entry.get("files id", None):
+ poolfile = get_poolfile_by_id(bin.poolfile_id)
+ bin.poolfile_id = entry["files id"]
+ else:
poolfile = add_poolfile(filename, entry, entry["location id"], session)
- entry["files id"] = poolfile.file_id
-
- bin.poolfile_id = entry["files id"]
+ bin.poolfile_id = entry["files id"] = poolfile.file_id
# Find source id
bin_sources = get_sources_from_name(entry["source package"], entry["source version"], session=session)
# session.rollback()
# raise MissingContents, "No contents stored for package %s, and couldn't determine contents of %s" % (bin.package, filename)
+ return poolfile
+
__all__.append('add_deb_to_db')
################################################################################
self.tbl_content_file_paths = Table('content_file_paths', self.db_meta, autoload=True)
self.tbl_changes_pending_binary = Table('changes_pending_binaries', self.db_meta, autoload=True)
self.tbl_changes_pending_files = Table('changes_pending_files', self.db_meta, autoload=True)
+ self.tbl_changes_pending_files_map = Table('changes_pending_files_map', self.db_meta, autoload=True)
self.tbl_changes_pending_source = Table('changes_pending_source', self.db_meta, autoload=True)
self.tbl_changes_pending_source_files = Table('changes_pending_source_files', self.db_meta, autoload=True)
self.tbl_changes_pool_files = Table('changes_pool_files', self.db_meta, autoload=True)
self.tbl_files = Table('files', self.db_meta, autoload=True)
self.tbl_fingerprint = Table('fingerprint', self.db_meta, autoload=True)
self.tbl_keyrings = Table('keyrings', self.db_meta, autoload=True)
- self.tbl_known_changes = Table('known_changes', self.db_meta, autoload=True)
+ self.tbl_changes = Table('changes', self.db_meta, autoload=True)
self.tbl_keyring_acl_map = Table('keyring_acl_map', self.db_meta, autoload=True)
self.tbl_location = Table('location', self.db_meta, autoload=True)
self.tbl_maintainer = Table('maintainer', self.db_meta, autoload=True)
properties = dict(keyring_name = self.tbl_keyrings.c.name,
keyring_id = self.tbl_keyrings.c.id))
- mapper(KnownChange, self.tbl_known_changes,
- properties = dict(known_change_id = self.tbl_known_changes.c.id,
+ mapper(DBChange, self.tbl_changes,
+ properties = dict(change_id = self.tbl_changes.c.id,
poolfiles = relation(PoolFile,
secondary=self.tbl_changes_pool_files,
backref="changeslinks"),
- files = relation(ChangePendingFile, backref="changesfile")))
+ files = relation(ChangePendingFile,
+ secondary=self.tbl_changes_pending_files_map,
+ backref="changesfile"),
+ in_queue_id = self.tbl_changes.c.in_queue,
+ in_queue = relation(PolicyQueue,
+ primaryjoin=(self.tbl_changes.c.in_queue==self.tbl_policy_queue.c.id)),
+ approved_for_id = self.tbl_changes.c.approved_for))
mapper(ChangePendingBinary, self.tbl_changes_pending_binary,
properties = dict(change_pending_binary_id = self.tbl_changes_pending_binary.c.id))
mapper(ChangePendingSource, self.tbl_changes_pending_source,
properties = dict(change_pending_source_id = self.tbl_changes_pending_source.c.id,
- change = relation(KnownChange),
+ change = relation(DBChange),
maintainer = relation(Maintainer,
primaryjoin=(self.tbl_changes_pending_source.c.maintainer_id==self.tbl_maintainer.c.id)),
changedby = relation(Maintainer,
source_files = relation(ChangePendingFile,
secondary=self.tbl_changes_pending_source_files,
backref="pending_sources")))
-
mapper(KeyringACLMap, self.tbl_keyring_acl_map,
properties = dict(keyring_acl_map_id = self.tbl_keyring_acl_map.c.id,
keyring = relation(Keyring, backref="keyring_acl_map"),