Port genacls.pkgdb to the new pkgdb API while being backward compatible with the old one
This commit is contained in:
parent
ff3b208137
commit
32f824900c
1 changed files with 100 additions and 81 deletions
|
@ -9,6 +9,14 @@ import grp
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
{% if env == 'staging' %}
|
||||||
|
VCS_URL = 'https://admin.stg.fedoraproject.org/pkgdb/api/vcs?format=json'
|
||||||
|
GRP_URL = 'https://admin.stg.fedoraproject.org/pkgdb/api/groups?format=json'
|
||||||
|
{% else %}
|
||||||
|
VCS_URL = 'https://admin.fedoraproject.org/pkgdb/api/vcs?format=json'
|
||||||
|
GRP_URL = 'https://admin.fedoraproject.org/pkgdb/api/groups?format=json'
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# Get the users in various groups
|
# Get the users in various groups
|
||||||
|
@ -22,7 +30,8 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
# Set the active branches to create ACLs for
|
# Set the active branches to create ACLs for
|
||||||
# Give them the git branch eqiv until pkgdb follows suite
|
# Give them the git branch eqiv until pkgdb follows suite
|
||||||
ACTIVE = {'OLPC-2': 'olpc2', 'OLPC-3': 'olpc3', 'EL-4': 'el4',
|
ACTIVE = {
|
||||||
|
'OLPC-2': 'olpc2', 'OLPC-3': 'olpc3', 'EL-4': 'el4',
|
||||||
'EL-5': 'el5', 'el5': 'el5', 'el6': 'el6', 'EL-6': 'el6',
|
'EL-5': 'el5', 'el5': 'el5', 'el6': 'el6', 'EL-6': 'el6',
|
||||||
'epel7': 'epel7',
|
'epel7': 'epel7',
|
||||||
'F-11': 'f11', 'F-12': 'f12', 'F-13': 'f13', 'f14': 'f14', 'f15':
|
'F-11': 'f11', 'F-12': 'f12', 'F-13': 'f13', 'f14': 'f14', 'f15':
|
||||||
|
@ -31,24 +40,12 @@ if __name__ == '__main__':
|
||||||
'devel': 'master', 'master': 'master'}
|
'devel': 'master', 'master': 'master'}
|
||||||
|
|
||||||
# Create a "regex"ish list 0f the reserved branches
|
# Create a "regex"ish list 0f the reserved branches
|
||||||
RESERVED = ['f[0-9][0-9]', 'epel[0-9]', 'epel[0-9][0-9]', 'el[0-9]', 'olpc[0-9]']
|
RESERVED = [
|
||||||
|
'f[0-9][0-9]', 'epel[0-9]', 'epel[0-9][0-9]', 'el[0-9]',
|
||||||
|
'olpc[0-9]']
|
||||||
|
|
||||||
# Read the ACL information from the packageDB
|
# Read the ACL information from the packageDB
|
||||||
{% if env == 'staging' %}
|
data = requests.get(VCS_URL).json()
|
||||||
url = 'https://admin.stg.fedoraproject.org/pkgdb/api/vcs?format=json'
|
|
||||||
{% else %}
|
|
||||||
url = 'https://admin.fedoraproject.org/pkgdb/api/vcs?format=json'
|
|
||||||
{% endif %}
|
|
||||||
data = requests.get(url).json()
|
|
||||||
|
|
||||||
# Get a list of all the packages
|
|
||||||
acls = data['packageAcls']
|
|
||||||
pkglist = data['packageAcls'].keys()
|
|
||||||
pkglist.sort()
|
|
||||||
|
|
||||||
# sanity check
|
|
||||||
if len(pkglist) < 2500:
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
# print out our user groups
|
# print out our user groups
|
||||||
print '@admins = %s' % ' '.join(TRUSTED)
|
print '@admins = %s' % ' '.join(TRUSTED)
|
||||||
|
@ -58,11 +55,7 @@ if __name__ == '__main__':
|
||||||
print '@fedora-ppc = %s' % ' '.join(PPC)
|
print '@fedora-ppc = %s' % ' '.join(PPC)
|
||||||
|
|
||||||
# Get a list of all the groups
|
# Get a list of all the groups
|
||||||
{% if env == 'staging' %}
|
groups = requests.get(GRP_URL).json()
|
||||||
groups = requests.get('https://admin.stg.fedoraproject.org/pkgdb/api/groups?format=json').json()
|
|
||||||
{% else %}
|
|
||||||
groups = requests.get('https://admin.fedoraproject.org/pkgdb/api/groups?format=json').json()
|
|
||||||
{% endif %}
|
|
||||||
for group in groups['groups']:
|
for group in groups['groups']:
|
||||||
print '@%s = %s' % (group, ' '.join(grp.getgrnam(group)[3]))
|
print '@%s = %s' % (group, ' '.join(grp.getgrnam(group)[3]))
|
||||||
|
|
||||||
|
@ -76,7 +69,22 @@ if __name__ == '__main__':
|
||||||
#print ' RW private- = @all'
|
#print ' RW private- = @all'
|
||||||
# dont' enable the above until we prevent building for real from private-
|
# dont' enable the above until we prevent building for real from private-
|
||||||
|
|
||||||
|
# Get a list of all the packages
|
||||||
|
for key in data:
|
||||||
|
if key == 'title':
|
||||||
|
continue
|
||||||
|
|
||||||
|
acls = data[key]
|
||||||
|
pkglist = data[key].keys()
|
||||||
|
pkglist.sort()
|
||||||
|
|
||||||
|
if key != 'packageAcls':
|
||||||
|
key = '%s/' % key
|
||||||
|
else:
|
||||||
|
key = ''
|
||||||
|
|
||||||
for pkg in pkglist:
|
for pkg in pkglist:
|
||||||
|
|
||||||
branchAcls = {} # Check whether we need to set separate per branch acls
|
branchAcls = {} # Check whether we need to set separate per branch acls
|
||||||
buffer = [] # Buffer the output per package
|
buffer = [] # Buffer the output per package
|
||||||
masters = [] # Folks that have commit to master
|
masters = [] # Folks that have commit to master
|
||||||
|
@ -91,8 +99,9 @@ if __name__ == '__main__':
|
||||||
if 'packager' in acls[pkg][branch]['commit']['groups']:
|
if 'packager' in acls[pkg][branch]['commit']['groups']:
|
||||||
# If the packager group is defined, everyone has access
|
# If the packager group is defined, everyone has access
|
||||||
buffer.append(' RWC %s = @all' % (ACTIVE[branch]))
|
buffer.append(' RWC %s = @all' % (ACTIVE[branch]))
|
||||||
branchAcls.setdefault('@all', []).append((pkg,
|
branchAcls.setdefault('@all', []).append(
|
||||||
ACTIVE[branch]))
|
(pkg, ACTIVE[branch])
|
||||||
|
)
|
||||||
if branch == 'master':
|
if branch == 'master':
|
||||||
masters.append('@all')
|
masters.append('@all')
|
||||||
if '@all' not in writers:
|
if '@all' not in writers:
|
||||||
|
@ -116,21 +125,31 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
# Print the committers to the acl for this package-branch
|
# Print the committers to the acl for this package-branch
|
||||||
committers = ' '.join(committers)
|
committers = ' '.join(committers)
|
||||||
buffer.append(' RWC %s = %s' %
|
buffer.append(
|
||||||
(ACTIVE[branch], committers))
|
' RWC %s = %s' % (ACTIVE[branch], committers))
|
||||||
branchAcls.setdefault(committers, []).append((pkg,
|
branchAcls.setdefault(committers, []).append(
|
||||||
ACTIVE[branch]))
|
(pkg, ACTIVE[branch])
|
||||||
|
)
|
||||||
|
|
||||||
print
|
print ''
|
||||||
print 'repo %s' % pkg
|
print 'repo %s%s' % (key, pkg)
|
||||||
#if len(branchAcls.keys()) == 1:
|
|
||||||
# acl = branchAcls.keys()[0]
|
|
||||||
# print ' RW = %s' % acl
|
|
||||||
#else:
|
|
||||||
print '\n'.join(buffer)
|
print '\n'.join(buffer)
|
||||||
for reserved in RESERVED:
|
for reserved in RESERVED:
|
||||||
print ' - %s = @all' % reserved
|
print ' - %s = @all' % reserved
|
||||||
print ' RWC refs/tags/ = %s' % ' '.join(writers)
|
print ' RWC refs/tags/ = %s' % ' '.join(writers)
|
||||||
if masters:
|
if masters:
|
||||||
print ' RWC = %s' % ' '.join(masters)
|
print ' RWC = %s' % ' '.join(masters)
|
||||||
|
|
||||||
|
# Bring backward compatibility while we keep the symlinks in place
|
||||||
|
# from the old to the new locations.
|
||||||
|
if key == 'rpms/':
|
||||||
|
print ''
|
||||||
|
print 'repo %s' % (pkg)
|
||||||
|
print '\n'.join(buffer)
|
||||||
|
for reserved in RESERVED:
|
||||||
|
print ' - %s = @all' % reserved
|
||||||
|
print ' RWC refs/tags/ = %s' % ' '.join(writers)
|
||||||
|
if masters:
|
||||||
|
print ' RWC = %s' % ' '.join(masters)
|
||||||
|
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue