Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
prusnak committed Oct 20, 2009
1 parent ce0c2a5 commit 661d927
Show file tree
Hide file tree
Showing 18 changed files with 759 additions and 767 deletions.
332 changes: 166 additions & 166 deletions dist/osc.complete

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions mktar.py
Expand Up @@ -9,21 +9,21 @@
release = False
v = core.__version__
if (len(sys.argv) > 1 and sys.argv[1] == '-r'):
release = True
release = True

if release:
if (v.endswith('_SVN')):
v=v[:-4]
print "don't forget to increase version in osc/core.py after release"
if (v.endswith('_SVN')):
v=v[:-4]
print "don't forget to increase version in osc/core.py after release"
else:
v += subprocess.Popen(["svnversion", "."], stdout=subprocess.PIPE).stdout.read().strip()
v += subprocess.Popen(["svnversion", "."], stdout=subprocess.PIPE).stdout.read().strip()

d = "osc-" + v
f = d+".tar.bz2"
subprocess.check_call(["svn", "export", ".", d])
if release:
# TODO: create tag for release
subprocess.check_call(["sed", "-ie", "/^__version__/s/_SVN//", d+"/osc/core.py"])
# TODO: create tag for release
subprocess.check_call(["sed", "-ie", "/^__version__/s/_SVN//", d+"/osc/core.py"])
subprocess.check_call(["tar", "--force-local", "--owner=root", "--group=root", "-cjf", f, d])
subprocess.call(["rm", "-rf", d]) # XXX how to do this in python properly?
print f
10 changes: 3 additions & 7 deletions osc-wrapper.py
@@ -1,12 +1,11 @@
#!/usr/bin/env python

# this wrapper exists so it can be put into /usr/bin, but still allows the
# this wrapper exists so it can be put into /usr/bin, but still allows the
# python module to be called within the source directory during development


import sys, locale
# this is a hack to make osc work as expected with utf-8 characters, no matter
# how site.py is set...
# this is a hack to make osc work as expected with utf-8 characters,
# no matter how site.py is set...
reload(sys)
loc = locale.getdefaultlocale()[1]
if not loc:
Expand All @@ -21,6 +20,3 @@

r = babysitter.run(osccli)
sys.exit(r)



8 changes: 4 additions & 4 deletions osc/OscConfigParser.py
@@ -1,14 +1,14 @@
# Copyright 2008,2009 Marcus Huewe <suse-tux@gmx.de>
#
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 2
# as published by the Free Software Foundation;
#
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
Expand Down Expand Up @@ -97,7 +97,7 @@ def __init__(self, sectname, dict = {}):
Line.__init__(self, sectname, 'section')
self._lines = []
self._dict = dict

def _find(self, name):
for line in self._lines:
if line.name == name:
Expand Down
2 changes: 1 addition & 1 deletion osc/babysitter.py
Expand Up @@ -141,7 +141,7 @@ def run(prg):
except AttributeError, e:
print >>sys.stderr, e
return 1

except RPMError, e:
print >>sys.stderr, e
return 1
Expand Down
96 changes: 48 additions & 48 deletions osc/build.py
Expand Up @@ -30,7 +30,7 @@
's390': 's390',
}

can_also_build = {
can_also_build = {
'armv4l': [ 'armv4l' ],
'armv5el':[ 'armv4l', 'armv5el' ],
'armv6l' :[ 'armv4l', 'armv5el' ],
Expand Down Expand Up @@ -83,7 +83,7 @@ def __init__(self, filename, apiurl, buildtype = 'spec', localpkgs = []):
self.buildarch = root.find('arch').text
self.release = "0"
if root.find('release') != None:
self.release = root.find('release').text
self.release = root.find('release').text
self.downloadurl = root.get('downloadurl')
self.debuginfo = 0
if root.find('debuginfo') != None:
Expand Down Expand Up @@ -125,9 +125,9 @@ class Pac:
def __init__(self, node, buildarch, pacsuffix, apiurl, localpkgs = []):

self.mp = {}
for i in ['name', 'package',
'version', 'release',
'project', 'repository',
for i in ['name', 'package',
'version', 'release',
'project', 'repository',
'preinstall', 'vminstall', 'noinstall', 'runscripts',
]:
self.mp[i] = node.get(i)
Expand All @@ -151,7 +151,7 @@ def __init__(self, node, buildarch, pacsuffix, apiurl, localpkgs = []):

if pacsuffix == 'deb' and not (self.mp['name'] and self.mp['arch'] and self.mp['version']):
raise oscerr.APIError(
"buildinfo for package %s/%s/%s is incomplete"
"buildinfo for package %s/%s/%s is incomplete"
% (self.mp['name'], self.mp['arch'], self.mp['version']))

self.mp['apiurl'] = apiurl
Expand Down Expand Up @@ -186,7 +186,7 @@ def makeurls(self, cachedir, urllist):
self.fullpartname = os.path.join(self.localdir, self.partname)
self.url_local = 'file://%s/' % self.fullfilename

# first, add the local URL
# first, add the local URL
self.urllist.append(self.url_local)

# remote URLs
Expand All @@ -203,21 +203,21 @@ def __repr__(self):

def get_built_files(pacdir, pactype):
if pactype == 'rpm':
b_built = subprocess.Popen(['find', os.path.join(pacdir, 'RPMS'),
b_built = subprocess.Popen(['find', os.path.join(pacdir, 'RPMS'),
'-name', '*.rpm'],
stdout=subprocess.PIPE).stdout.read().strip()
s_built = subprocess.Popen(['find', os.path.join(pacdir, 'SRPMS'),
s_built = subprocess.Popen(['find', os.path.join(pacdir, 'SRPMS'),
'-name', '*.rpm'],
stdout=subprocess.PIPE).stdout.read().strip()
elif pactype == 'kiwi':
b_built = subprocess.Popen(['find', os.path.join(pacdir, 'KIWI'),
b_built = subprocess.Popen(['find', os.path.join(pacdir, 'KIWI'),
'-type', 'f'],
stdout=subprocess.PIPE).stdout.read().strip()
else:
b_built = subprocess.Popen(['find', os.path.join(pacdir, 'DEBS'),
'-name', '*.deb'],
stdout=subprocess.PIPE).stdout.read().strip()
s_built = subprocess.Popen(['find', os.path.join(pacdir, 'SOURCES.DEB'),
s_built = subprocess.Popen(['find', os.path.join(pacdir, 'SOURCES.DEB'),
'-type', 'f'],
stdout=subprocess.PIPE).stdout.read().strip()
return s_built, b_built
Expand Down Expand Up @@ -338,7 +338,7 @@ def main(opts, argv):
return 1

# make it possible to override configuration of the rc file
for var in ['OSC_PACKAGECACHEDIR', 'OSC_SU_WRAPPER', 'OSC_BUILD_ROOT']:
for var in ['OSC_PACKAGECACHEDIR', 'OSC_SU_WRAPPER', 'OSC_BUILD_ROOT']:
val = os.getenv(var)
if val:
if var.startswith('OSC_'): var = var[4:]
Expand Down Expand Up @@ -373,23 +373,23 @@ def main(opts, argv):
bi_file = None
try:
if opts.noinit:
if not os.path.isfile(bi_file_name):
print >>sys.stderr, '--noinit is not possible, no local build info file'
sys.exit(1)
print 'Use local .buildinfo.xml file as build description'
bi_file = open(bi_file_name, 'r')
if not os.path.isfile(bi_file_name):
print >>sys.stderr, '--noinit is not possible, no local build info file'
sys.exit(1)
print 'Use local .buildinfo.xml file as build description'
bi_file = open(bi_file_name, 'r')
else:
print 'Getting buildinfo from server and store to local directory as .buildinfo.xml'
bi_file = open(bi_file_name, 'w+')
bi_text = ''.join(get_buildinfo(apiurl,
prj,
pac,
repo,
arch,
specfile=build_descr_data,
addlist=extra_pkgs))
bi_file.write(bi_text)
bi_file.flush()
print 'Getting buildinfo from server and store to local directory as .buildinfo.xml'
bi_file = open(bi_file_name, 'w+')
bi_text = ''.join(get_buildinfo(apiurl,
prj,
pac,
repo,
arch,
specfile=build_descr_data,
addlist=extra_pkgs))
bi_file.write(bi_text)
bi_file.flush()
except urllib2.HTTPError, e:
if e.code == 404:
# check what caused the 404
Expand All @@ -415,7 +415,7 @@ def main(opts, argv):
buildargs.append('--debug')
buildargs = ' '.join(set(buildargs))

# real arch of this machine
# real arch of this machine
# vs.
# arch we are supposed to build for
if hostarch != bi.buildarch:
Expand Down Expand Up @@ -445,7 +445,7 @@ def main(opts, argv):
# transform 'url1, url2, url3' form into a list
if 'urllist' in config:
if type(config['urllist']) == str:
re_clist = re.compile('[, ]+')
re_clist = re.compile('[, ]+')
urllist = [ i.strip() for i in re_clist.split(config['urllist'].strip()) ]
else:
urllist = config['urllist']
Expand All @@ -455,7 +455,7 @@ def main(opts, argv):
urllist.append(bi.downloadurl + '/%(extproject)s/%(extrepository)s/%(arch)s/%(filename)s')
urllist.append( '%(apiurl)s/build/%(project)s/%(repository)s/%(repoarch)s/%(repopackage)s/%(repofilename)s' )

fetcher = Fetcher(cachedir = config['packagecachedir'],
fetcher = Fetcher(cachedir = config['packagecachedir'],
urllist = urllist,
api_host_options = config['api_host_options'],
offline = opts.noinit,
Expand Down Expand Up @@ -535,18 +535,18 @@ def main(opts, argv):

vm_options=""
if config['build-device'] and config['build-memory'] and config['build-type']:
if config['build-type'] == "kvm":
vm_options="--kvm " + config['build-device']
elif config['build-type'] == "xen":
vm_options="--xen " + config['build-device']
else:
print "ERROR: unknown VM is set ! (" + config['build-type'] + ")"
sys.exit(1)
if config['build-swap']:
vm_options+=" --swap " + config['build-swap']
if config['build-memory']:
vm_options+=" --memory " + config['build-memory']
if config['build-type'] == "kvm":
vm_options="--kvm " + config['build-device']
elif config['build-type'] == "xen":
vm_options="--xen " + config['build-device']
else:
print "ERROR: unknown VM is set ! (" + config['build-type'] + ")"
sys.exit(1)
if config['build-swap']:
vm_options+=" --swap " + config['build-swap']
if config['build-memory']:
vm_options+=" --memory " + config['build-memory']

print 'Running build'
# special handling for overlay and rsync-src/dest
specialcmdopts = " "
Expand Down Expand Up @@ -583,13 +583,13 @@ def main(opts, argv):
cmd = '%s --root=%s --rpmlist=%s --dist=%s %s --arch=%s --release=%s %s %s %s' \
% (config['build-cmd'],
config['build-root'],
rpmlist_file.name,
bc_file.name,
rpmlist_file.name,
bc_file.name,
specialcmdopts,
bi.buildarch,
bi.release,
vm_options,
build_descr,
build_descr,
buildargs)

if config['su-wrapper'].startswith('su '):
Expand All @@ -603,7 +603,7 @@ def main(opts, argv):
cmd = (change_personality.get(bi.buildarch, '') + ' ' + cmd).strip()

rc = subprocess.call(cmd, shell=True)
if rc:
if rc:
print
print 'The buildroot was:', config['build-root']
sys.exit(rc)
Expand All @@ -615,7 +615,7 @@ def main(opts, argv):

if os.path.exists(pacdir):
(s_built, b_built) = get_built_files(pacdir, bi.pacsuffix)

print
if s_built: print s_built
print
Expand Down

0 comments on commit 661d927

Please sign in to comment.