add signed flag to repo table

This commit is contained in:
Jay Greguske 2016-03-14 10:01:03 -04:00 committed by Mike McLean
parent 97b6d4f866
commit 9b504a280c
4 changed files with 18 additions and 7 deletions

View file

@ -4980,7 +4980,7 @@ class NewSignedRepoTask(BaseTaskHandler):
upload, files, keypaths = results[subtasks[arch]]
self.session.host.signedRepoMove(
repo_id, upload, files, arch, keypaths)
self.session.host.repoDone(repo_id, data, expire=True, signed=True)
self.session.host.repoDone(repo_id, data, expire=False, signed=True)
return 'Signed repository #%s successfully generated' % repo_id

View file

@ -51,6 +51,7 @@ CREATE TABLE permissions (
INSERT INTO permissions (name) VALUES ('admin');
INSERT INTO permissions (name) VALUES ('build');
INSERT INTO permissions (name) VALUES ('repo');
INSERT INTO permissions (name) VALUES ('image');
INSERT INTO permissions (name) VALUES ('livecd');
INSERT INTO permissions (name) VALUES ('maven-import');
INSERT INTO permissions (name) VALUES ('win-import');
@ -409,7 +410,8 @@ CREATE TABLE repo (
id SERIAL NOT NULL PRIMARY KEY,
create_event INTEGER NOT NULL REFERENCES events(id) DEFAULT get_event(),
tag_id INTEGER NOT NULL REFERENCES tag(id),
state INTEGER
state INTEGER,
signed BOOLEAN DEFAULT 'false'
) WITHOUT OIDS;
-- external yum repos

View file

@ -2458,7 +2458,7 @@ def signed_repo_init(tag, keys, task_opts):
task_opts['event'] = _singleValue("SELECT get_event()")
insert = InsertProcessor('repo')
insert.set(id=repo_id, create_event=task_opts['event'], tag_id=tag_id,
state=state)
state=state, signed=True)
insert.execute()
repodir = koji.pathinfo.signedrepo(repo_id, tinfo['name'])
for arch in arches:
@ -2495,6 +2495,7 @@ def repo_info(repo_id, strict=False):
('EXTRACT(EPOCH FROM events.time)', 'create_ts'),
('repo.tag_id', 'tag_id'),
('tag.name', 'tag_name'),
('repo.signed', 'signed'),
)
q = """SELECT %s FROM repo
JOIN tag ON tag_id=tag.id
@ -10101,16 +10102,20 @@ class RootExports(object):
taginfo['extra'][key] = ancestor['extra'][key]
return taginfo
def getRepo(self, tag, state=None, event=None):
def getRepo(self, tag, state=None, event=None, signed=False):
if isinstance(tag, (int, long)):
id = tag
else:
id = get_tag_id(tag, strict=True)
fields = ['repo.id', 'repo.state', 'repo.create_event', 'events.time', 'EXTRACT(EPOCH FROM events.time)']
aliases = ['id', 'state', 'create_event', 'creation_time', 'create_ts']
fields = ['repo.id', 'repo.state', 'repo.create_event', 'events.time', 'EXTRACT(EPOCH FROM events.time)', 'repo.signed']
aliases = ['id', 'state', 'create_event', 'creation_time', 'create_ts', 'signed']
joins = ['events ON repo.create_event = events.id']
clauses = ['repo.tag_id = %(id)i']
if signed:
clauses.append('repo.signed is true')
else:
clauses.append('repo.signed is false')
if event:
# the repo table doesn't have all the fields of a _config table, just create_event
clauses.append('create_event <= %(event)i')

View file

@ -134,7 +134,11 @@ class ManagedRepo(object):
(self.tag_id, self.repo_id))
return False
tag_name = tag_info['name']
path = pathinfo.repo(self.repo_id, tag_name)
rinfo = self.session.repoInfo(self.repo_id, strict=True)
if rinfo['signed']:
path = pathinfo.signedrepo(self.repo_id, tag_name)
else:
path = pathinfo.repo(self.repo_id, tag_name)
try:
#also check dir age. We do this because a repo can be created from an older event
#and should not be removed based solely on that event's timestamp.