mirror of
https://github.com/openSUSE/osc.git
synced 2025-09-07 21:58:41 +02:00
fix whitespace
This commit is contained in:
28
osc/build.py
28
osc/build.py
@@ -231,27 +231,27 @@ def get_built_files(pacdir, pactype):
|
||||
|
||||
def get_repo(path):
|
||||
"""Walks up path looking for any repodata directories.
|
||||
|
||||
|
||||
@param path path to a directory
|
||||
@return str path to repository directory containing repodata directory
|
||||
"""
|
||||
oldDirectory = None
|
||||
currentDirectory = os.path.abspath(path)
|
||||
repositoryDirectory = None
|
||||
|
||||
|
||||
# while there are still parent directories
|
||||
while currentDirectory != oldDirectory:
|
||||
children = os.listdir(currentDirectory)
|
||||
|
||||
|
||||
if "repodata" in children:
|
||||
repositoryDirectory = currentDirectory
|
||||
break
|
||||
|
||||
|
||||
# ascend
|
||||
oldDirectory = currentDirectory
|
||||
currentDirectory = os.path.abspath(os.path.join(oldDirectory,
|
||||
os.pardir))
|
||||
|
||||
|
||||
return repositoryDirectory
|
||||
|
||||
def get_prefer_pkgs(dirs, wanted_arch, type):
|
||||
@@ -259,11 +259,11 @@ def get_prefer_pkgs(dirs, wanted_arch, type):
|
||||
from util import repodata, packagequery, cpio
|
||||
paths = []
|
||||
repositories = []
|
||||
|
||||
|
||||
suffix = '*.rpm'
|
||||
if type == 'dsc':
|
||||
suffix = '*.deb'
|
||||
|
||||
|
||||
for dir in dirs:
|
||||
# check for repodata
|
||||
repository = get_repo(dir)
|
||||
@@ -271,15 +271,15 @@ def get_prefer_pkgs(dirs, wanted_arch, type):
|
||||
paths += glob.glob(os.path.join(os.path.abspath(dir), suffix))
|
||||
else:
|
||||
repositories.append(repository)
|
||||
|
||||
|
||||
packageQueries = packagequery.PackageQueries(wanted_arch)
|
||||
|
||||
|
||||
for repository in repositories:
|
||||
repodataPackageQueries = repodata.queries(repository)
|
||||
|
||||
|
||||
for packageQuery in repodataPackageQueries:
|
||||
packageQueries.add(packageQuery)
|
||||
|
||||
|
||||
for path in paths:
|
||||
if path.endswith('src.rpm'):
|
||||
continue
|
||||
@@ -287,10 +287,10 @@ def get_prefer_pkgs(dirs, wanted_arch, type):
|
||||
continue
|
||||
packageQuery = packagequery.PackageQuery.query(path)
|
||||
packageQueries.add(packageQuery)
|
||||
|
||||
|
||||
prefer_pkgs = dict((name, packageQuery.path())
|
||||
for name, packageQuery in packageQueries.iteritems())
|
||||
|
||||
|
||||
depfile = create_deps(packageQueries.values())
|
||||
cpio = cpio.CpioWrite()
|
||||
cpio.add('deps', '\n'.join(depfile))
|
||||
@@ -582,7 +582,7 @@ def main(opts, argv):
|
||||
# OBS 1.5 and before has no downloadurl defined in buildinfo
|
||||
if bi.downloadurl:
|
||||
urllist.append(bi.downloadurl + '/%(extproject)s/%(extrepository)s/%(arch)s/%(filename)s')
|
||||
if not opts.cpio_bulk_download:
|
||||
if not opts.cpio_bulk_download:
|
||||
urllist.append( '%(apiurl)s/build/%(project)s/%(repository)s/%(repoarch)s/%(repopackage)s/%(repofilename)s' )
|
||||
|
||||
fetcher = Fetcher(cachedir = config['packagecachedir'],
|
||||
|
@@ -388,7 +388,7 @@ class Osc(cmdln.Cmdln):
|
||||
for p in meta_get_packagelist(apiurl, project):
|
||||
if p.startswith("_patchinfo:"):
|
||||
patchinfo = p
|
||||
|
||||
|
||||
if opts.force or not patchinfo:
|
||||
print "Creating initial patchinfo..."
|
||||
query='cmd=createpatchinfo'
|
||||
@@ -798,7 +798,7 @@ class Osc(cmdln.Cmdln):
|
||||
(actionxml, cgi.escape(opts.message or ""))
|
||||
u = makeurl(apiurl, ['request'], query='cmd=create')
|
||||
f = http_POST(u, data=xml)
|
||||
|
||||
|
||||
root = ET.parse(f).getroot()
|
||||
sr_ids.append(root.get('id'))
|
||||
|
||||
@@ -1589,7 +1589,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
||||
package, tproject)
|
||||
|
||||
if r is None:
|
||||
print >>sys.stderr, 'ERROR: Attribute branch call came not back with a project.'
|
||||
print >>sys.stderr, 'ERROR: Attribute branch call came not back with a project.'
|
||||
sys.exit(1)
|
||||
|
||||
print "Project " + r + " created."
|
||||
@@ -1940,9 +1940,9 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
||||
args = slash_split(args)
|
||||
args = expand_proj_pack(args)
|
||||
|
||||
## FIXME:
|
||||
## FIXME:
|
||||
## if there is only one argument, and it ends in .ymp
|
||||
## then fetch it, Parse XML to get the first
|
||||
## then fetch it, Parse XML to get the first
|
||||
## metapackage.group.repositories.repository.url
|
||||
## and construct zypper cmd's for all
|
||||
## metapackage.group.software.item.name
|
||||
@@ -2862,7 +2862,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
||||
raise oscerr.WrongArgs('Too many arguments.')
|
||||
else:
|
||||
project, package, repository, arch = args
|
||||
|
||||
|
||||
offset=0
|
||||
if opts.start:
|
||||
offset = int(opts.start)
|
||||
@@ -2952,7 +2952,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
||||
wd = os.curdir
|
||||
args = slash_split(args)
|
||||
project = package = repository = arch = None
|
||||
|
||||
|
||||
if len(args) < 2:
|
||||
self.print_repos()
|
||||
|
||||
@@ -2995,9 +2995,9 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
||||
will be triggered when a certain package changes.
|
||||
This is no guarantee, since the new build might have changed dependencies.
|
||||
|
||||
dependson shows the build dependencies inside of a project, valid for a
|
||||
dependson shows the build dependencies inside of a project, valid for a
|
||||
given repository and architecture.
|
||||
NOTE: to see all binary packages, which can trigger a build you need to
|
||||
NOTE: to see all binary packages, which can trigger a build you need to
|
||||
refer the buildinfo, since this command shows only the dependencies
|
||||
inside of a project.
|
||||
|
||||
@@ -3017,7 +3017,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
||||
wd = os.curdir
|
||||
args = slash_split(args)
|
||||
project = packages = repository = arch = reverse = None
|
||||
|
||||
|
||||
if len(args) < 2 and (is_package_dir('.') or is_project_dir('.')):
|
||||
self.print_repos()
|
||||
|
||||
@@ -3088,7 +3088,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
||||
"""
|
||||
wd = os.curdir
|
||||
args = slash_split(args)
|
||||
|
||||
|
||||
if len(args) < 2 and is_package_dir('.'):
|
||||
self.print_repos()
|
||||
|
||||
@@ -3149,7 +3149,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
||||
|
||||
wd = os.curdir
|
||||
args = slash_split(args)
|
||||
|
||||
|
||||
if len(args) < 2 and is_package_dir('.'):
|
||||
self.print_repos()
|
||||
|
||||
@@ -4121,7 +4121,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
||||
extra_limiter='attribute/@name="%s"' % (opts.limit_to_attribute)
|
||||
if not opts.substring:
|
||||
opts.exact = True
|
||||
|
||||
|
||||
|
||||
role_filter=None
|
||||
if for_user:
|
||||
@@ -4374,7 +4374,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
||||
def do_bugowner(self, subcmd, opts, *args):
|
||||
"""${cmd_name}: Show bugowners of a project/package
|
||||
|
||||
osc bugowner PRJ
|
||||
osc bugowner PRJ
|
||||
osc bugowner PRJ PKG
|
||||
|
||||
Shortcut for osc maintainer -B [PRJ] PKG
|
||||
@@ -4817,7 +4817,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
||||
|
||||
dir_oldpatched = { 'apiurl': p.apiurl, 'project': p.prjname, 'package': p.name, 'srcmd5': p.srcmd5 }
|
||||
dir_oldpatched['entries'] = [[f.name, f.md5] for f in p.filelist]
|
||||
|
||||
|
||||
query = { 'rev': linkinfo.srcmd5 }
|
||||
u = makeurl(p.apiurl, ['source', linkinfo.project, linkinfo.package], query=query)
|
||||
f = http_GET(u)
|
||||
|
@@ -156,7 +156,7 @@ apiurl = %(apiurl)s
|
||||
# This is convenient when sharing the buildroot with ordinary userids
|
||||
# on the host.
|
||||
# This should not be 0
|
||||
# build-uid =
|
||||
# build-uid =
|
||||
|
||||
# extra packages to install when building packages locally (osc build)
|
||||
# this corresponds to osc build's -x option and can be overridden with that
|
||||
|
@@ -1727,7 +1727,7 @@ def parse_buildlogurl(buildlogurl):
|
||||
m = BUILDLOGURL_RE.match(buildlogurl)
|
||||
if not m:
|
||||
raise oscerr.WrongArgs('\'%s\' does not look like url with a build log' % buildlogurl)
|
||||
|
||||
|
||||
return (m.group('apiurl'), m.group('project'), m.group('package'), m.group('repository'), m.group('arch'))
|
||||
|
||||
def slash_split(l):
|
||||
@@ -3642,7 +3642,7 @@ def get_prj_results(apiurl, prj, hide_legend=False, csv=False, status_filter=Non
|
||||
for i in range(0, len(targets)):
|
||||
line.append(str(i%10))
|
||||
r.append(' '.join(line))
|
||||
|
||||
|
||||
r.append('')
|
||||
|
||||
if not hide_legend and len(pacs):
|
||||
|
@@ -176,7 +176,7 @@ class myHTTPSHandler(M2Crypto.m2urllib2.HTTPSHandler):
|
||||
|
||||
# Our change: Check to see if we're using a proxy.
|
||||
# Then create an appropriate ssl-aware connection.
|
||||
full_url = req.get_full_url()
|
||||
full_url = req.get_full_url()
|
||||
target_host = urlparse.urlparse(full_url)[1]
|
||||
|
||||
if (target_host != host):
|
||||
|
@@ -9,34 +9,34 @@ class PackageQueries(dict):
|
||||
package query, to a name, the package is evaluated to see if it matches the
|
||||
wanted architecture and if it has a greater version than the current value.
|
||||
"""
|
||||
|
||||
|
||||
# map debian arches to common obs arches
|
||||
architectureMap = {'i386': ['i586', 'i686'], 'amd64': ['x86_64']}
|
||||
|
||||
architectureMap = {'i386': ['i586', 'i686'], 'amd64': ['x86_64']}
|
||||
|
||||
def __init__(self, wanted_architecture):
|
||||
self.wanted_architecture = wanted_architecture
|
||||
super(PackageQueries, self).__init__()
|
||||
|
||||
|
||||
def add(self, query):
|
||||
"""Adds package query to dict if it is of the correct architecture and
|
||||
is newer (has a greater version) than the currently assigned package.
|
||||
|
||||
|
||||
@param a PackageQuery
|
||||
"""
|
||||
self.__setitem__(query.name(), query)
|
||||
|
||||
|
||||
def __setitem__(self, name, query):
|
||||
if name != query.name():
|
||||
raise ValueError("key '%s' does not match "
|
||||
"package query name '%s'" % (name, query.name()))
|
||||
|
||||
|
||||
architecture = query.arch()
|
||||
|
||||
|
||||
if (architecture in [self.wanted_architecture, 'noarch', 'all'] or
|
||||
self.wanted_architecture in self.architectureMap.get(architecture,
|
||||
[])):
|
||||
current_query = self.get(name)
|
||||
|
||||
|
||||
# if current query does not exist or is older than this new query
|
||||
if current_query is None or current_query.vercmp(query) <= 0:
|
||||
super(PackageQueries, self).__setitem__(name, query)
|
||||
@@ -63,10 +63,10 @@ class PackageQuery:
|
||||
|
||||
def description(self):
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
def path(self):
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
def provides(self):
|
||||
raise NotImplementedError
|
||||
|
||||
|
@@ -25,7 +25,7 @@ OPERATOR_BY_FLAGS = {
|
||||
|
||||
def primaryPath(directory):
|
||||
"""Returns path to the primary repository data file.
|
||||
|
||||
|
||||
@param directory repository directory that contains the repodata subdirectory
|
||||
@return str path to primary repository data file
|
||||
@raise IOError if repomd.xml contains no primary location
|
||||
@@ -33,7 +33,7 @@ def primaryPath(directory):
|
||||
metaDataPath = os.path.join(directory, "repodata", "repomd.xml")
|
||||
elementTree = ET.parse(metaDataPath)
|
||||
root = elementTree.getroot()
|
||||
|
||||
|
||||
for dataElement in root:
|
||||
if dataElement.get("type") == "primary":
|
||||
locationElement = dataElement.find(namespace("repo") + "location")
|
||||
@@ -43,110 +43,110 @@ def primaryPath(directory):
|
||||
break
|
||||
else:
|
||||
raise IOError("'%s' contains no primary location" % metaDataPath)
|
||||
|
||||
|
||||
return primaryPath
|
||||
|
||||
def queries(directory):
|
||||
"""Returns a list of RepoDataQueries constructed from the repodata under
|
||||
the directory.
|
||||
|
||||
|
||||
@param directory path to a repository directory (parent directory of
|
||||
repodata directory)
|
||||
@return list of RepoDataQuery instances
|
||||
@raise IOError if repomd.xml contains no primary location
|
||||
"""
|
||||
path = primaryPath(directory)
|
||||
|
||||
|
||||
gunzippedPrimary = gzip.GzipFile(path)
|
||||
elementTree = ET.parse(gunzippedPrimary)
|
||||
root = elementTree.getroot()
|
||||
|
||||
|
||||
packageQueries = []
|
||||
for packageElement in root:
|
||||
packageQuery = RepoDataQuery(directory, packageElement)
|
||||
packageQueries.append(packageQuery)
|
||||
|
||||
|
||||
return packageQueries
|
||||
|
||||
class RepoDataQuery(object):
|
||||
"""PackageQuery that reads in data from the repodata directory files."""
|
||||
|
||||
|
||||
def __init__(self, directory, element):
|
||||
"""Creates a RepoDataQuery from the a package Element under a metadata
|
||||
Element in a primary.xml file.
|
||||
|
||||
|
||||
@param directory repository directory path. Used to convert relative
|
||||
paths to full paths.
|
||||
@param element package Element
|
||||
"""
|
||||
self.__directory = os.path.abspath(directory)
|
||||
self.__element = element
|
||||
|
||||
|
||||
def __formatElement(self):
|
||||
return self.__element.find(namespace("common") + "format")
|
||||
|
||||
|
||||
def __parseEntry(self, element):
|
||||
entry = element.get("name")
|
||||
flags = element.get("flags")
|
||||
|
||||
|
||||
if flags is not None:
|
||||
version = element.get("ver")
|
||||
operator = OPERATOR_BY_FLAGS[flags]
|
||||
entry += " %s %s" % (operator, version)
|
||||
|
||||
|
||||
release = element.get("rel")
|
||||
if release is not None:
|
||||
entry += "-%s" % release
|
||||
|
||||
|
||||
return entry
|
||||
|
||||
|
||||
def __parseEntryCollection(self, collection):
|
||||
formatElement = self.__formatElement()
|
||||
collectionElement = formatElement.find(namespace("rpm") + collection)
|
||||
|
||||
|
||||
entries = []
|
||||
if collectionElement is not None:
|
||||
for entryElement in collectionElement.findall(namespace("rpm") +
|
||||
"entry"):
|
||||
entry = self.__parseEntry(entryElement)
|
||||
entries.append(entry)
|
||||
|
||||
|
||||
return entries
|
||||
|
||||
|
||||
def __versionElement(self):
|
||||
return self.__element.find(namespace("common") + "version")
|
||||
|
||||
|
||||
def arch(self):
|
||||
return self.__element.find(namespace("common") + "arch").text
|
||||
|
||||
|
||||
def description(self):
|
||||
return self.__element.find(namespace("common") + "description").text
|
||||
|
||||
|
||||
def distribution(self):
|
||||
return None
|
||||
|
||||
|
||||
def epoch(self):
|
||||
return self.__versionElement().get("epoch")
|
||||
|
||||
|
||||
def name(self):
|
||||
return self.__element.find(namespace("common") + "name").text
|
||||
|
||||
|
||||
def path(self):
|
||||
locationElement = self.__element.find(namespace("common") + "location")
|
||||
relativePath = locationElement.get("href")
|
||||
absolutePath = os.path.join(self.__directory, relativePath)
|
||||
|
||||
|
||||
return absolutePath
|
||||
|
||||
|
||||
def provides(self):
|
||||
return self.__parseEntryCollection("provides")
|
||||
|
||||
|
||||
def release(self):
|
||||
return self.__versionElement().get("rel")
|
||||
|
||||
|
||||
def requires(self):
|
||||
return self.__parseEntryCollection("requires")
|
||||
|
||||
|
||||
def vercmp(self, other):
|
||||
res = osc.util.rpmquery.RpmQuery.rpmvercmp(str(self.epoch()), str(other.epoch()))
|
||||
if res != 0:
|
||||
@@ -156,6 +156,6 @@ class RepoDataQuery(object):
|
||||
return res
|
||||
res = osc.util.rpmquery.RpmQuery.rpmvercmp(self.release(), other.release())
|
||||
return res
|
||||
|
||||
|
||||
def version(self):
|
||||
return self.__versionElement().get("ver")
|
||||
|
@@ -210,7 +210,7 @@ class RpmQuery(packagequery.PackageQuery):
|
||||
|
||||
def path(self):
|
||||
return self.__path
|
||||
|
||||
|
||||
def provides(self):
|
||||
return self.__reqprov(1047, 1112, 1113)
|
||||
|
||||
|
Reference in New Issue
Block a user