2006-07-14 19:39:46 +02:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
2006-10-12 15:22:56 +02:00
|
|
|
# Copyright (C) 2006 Peter Poeml / Novell Inc. All rights reserved.
|
2006-07-14 19:39:46 +02:00
|
|
|
# This program is free software; it may be used, copied, modified
|
|
|
|
# and distributed under the terms of the GNU General Public Licence,
|
|
|
|
# either version 2, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import os
|
2008-03-11 16:18:02 +01:00
|
|
|
import re
|
2006-07-14 19:39:46 +02:00
|
|
|
import sys
|
|
|
|
from tempfile import NamedTemporaryFile
|
|
|
|
from osc.fetch import *
|
2008-01-07 15:54:31 +01:00
|
|
|
from osc.core import get_buildinfo, store_read_apiurl, store_read_project, store_read_package, meta_exists, quote_plus, get_buildconfig
|
2006-10-10 16:04:34 +02:00
|
|
|
import osc.conf
|
2008-06-20 15:37:49 +02:00
|
|
|
import oscerr
|
2008-10-11 22:26:45 +02:00
|
|
|
import subprocess
|
2007-03-12 21:00:47 +01:00
|
|
|
try:
|
|
|
|
from xml.etree import cElementTree as ET
|
|
|
|
except ImportError:
|
|
|
|
import cElementTree as ET
|
2006-07-14 19:39:46 +02:00
|
|
|
|
2007-04-25 13:22:40 +02:00
|
|
|
from conf import config
|
2006-07-14 19:39:46 +02:00
|
|
|
|
|
|
|
change_personality = {
|
|
|
|
'i686': 'linux32',
|
|
|
|
'i586': 'linux32',
|
2008-06-20 15:37:49 +02:00
|
|
|
'i386': 'linux32',
|
2006-07-14 19:39:46 +02:00
|
|
|
'ppc': 'powerpc32',
|
|
|
|
's390': 's390',
|
|
|
|
}
|
|
|
|
|
|
|
|
can_also_build = {
|
2008-06-20 15:37:49 +02:00
|
|
|
'x86_64': ['i686', 'i586', 'i386'],
|
2006-07-14 19:39:46 +02:00
|
|
|
'i686': ['i586'],
|
2008-06-20 15:37:49 +02:00
|
|
|
'i386': ['i586'],
|
2006-07-14 19:39:46 +02:00
|
|
|
'ppc64': ['ppc'],
|
|
|
|
's390x': ['s390'],
|
|
|
|
}
|
|
|
|
|
2006-07-17 15:53:17 +02:00
|
|
|
# real arch of this machine
|
2006-07-14 19:39:46 +02:00
|
|
|
hostarch = os.uname()[4]
|
|
|
|
if hostarch == 'i686': # FIXME
|
|
|
|
hostarch = 'i586'
|
|
|
|
|
|
|
|
|
|
|
|
class Buildinfo:
|
|
|
|
"""represent the contents of a buildinfo file"""
|
|
|
|
|
2008-01-23 20:37:44 +01:00
|
|
|
def __init__(self, filename, apiurl=config['apiurl']):
|
2006-07-14 19:39:46 +02:00
|
|
|
|
2006-10-10 16:04:34 +02:00
|
|
|
try:
|
|
|
|
tree = ET.parse(filename)
|
|
|
|
except:
|
2008-07-04 14:56:32 +02:00
|
|
|
print >>sys.stderr, 'could not parse the buildinfo:'
|
2007-04-25 23:10:49 +02:00
|
|
|
print >>sys.stderr, open(filename).read()
|
2006-10-10 16:04:34 +02:00
|
|
|
sys.exit(1)
|
|
|
|
|
2006-07-14 19:39:46 +02:00
|
|
|
root = tree.getroot()
|
|
|
|
|
|
|
|
if root.find('error') != None:
|
2008-01-11 17:44:08 +01:00
|
|
|
sys.stderr.write('buildinfo is broken... it says:\n')
|
2006-07-14 19:39:46 +02:00
|
|
|
error = root.find('error').text
|
|
|
|
sys.stderr.write(error + '\n')
|
|
|
|
sys.exit(1)
|
|
|
|
|
2008-01-23 20:37:44 +01:00
|
|
|
if apiurl.startswith('https://') or apiurl.startswith('http://'):
|
|
|
|
import urlparse
|
|
|
|
scheme, netloc, path = urlparse.urlsplit(apiurl)[0:3]
|
|
|
|
apisrv = netloc+path
|
|
|
|
else:
|
|
|
|
print >>sys.stderr, 'invalid protocol for the apiurl: \'%s\'' % apiurl
|
|
|
|
sys.exit(1)
|
|
|
|
|
2006-07-14 19:39:46 +02:00
|
|
|
# are we building .rpm or .deb?
|
|
|
|
# need the right suffix for downloading
|
|
|
|
# if a package named debhelper is in the dependencies, it must be .deb
|
|
|
|
self.pacsuffix = 'rpm'
|
|
|
|
for node in root.findall('dep'):
|
|
|
|
if node.text == 'debhelper':
|
|
|
|
self.pacsuffix = 'deb'
|
|
|
|
break
|
|
|
|
|
|
|
|
self.buildarch = root.find('arch').text
|
2008-10-31 16:41:19 +01:00
|
|
|
if root.find('debuginfo') != None:
|
|
|
|
self.debuginfo = root.find('debuginfo').text
|
|
|
|
else:
|
|
|
|
self.debuginfo = 0
|
2006-07-14 19:39:46 +02:00
|
|
|
|
|
|
|
self.deps = []
|
|
|
|
for node in root.findall('bdep'):
|
2008-06-20 15:37:49 +02:00
|
|
|
p_name = node.get('name')
|
|
|
|
p_arch = node.get('arch')
|
|
|
|
if not p_arch:
|
|
|
|
p_arch = self.buildarch
|
|
|
|
p_version = node.get('version')
|
|
|
|
p_release = node.get('release')
|
|
|
|
|
2008-06-23 10:38:05 +02:00
|
|
|
if not (p_name and p_arch and p_version):
|
2008-06-20 15:37:49 +02:00
|
|
|
raise oscerr.APIError(
|
2008-06-23 10:38:05 +02:00
|
|
|
"buildinfo for package %s/%s/%s is incomplete" % (p_name, p_arch, p_version))
|
2008-06-20 15:37:49 +02:00
|
|
|
|
|
|
|
p = Pac(p_name,
|
|
|
|
p_version,
|
|
|
|
p_release,
|
2006-07-14 19:39:46 +02:00
|
|
|
node.get('project'),
|
|
|
|
node.get('repository'),
|
2008-06-20 15:37:49 +02:00
|
|
|
p_arch,
|
2007-03-29 01:37:34 +02:00
|
|
|
node.get('preinstall'),
|
|
|
|
node.get('runscripts'),
|
2006-07-14 19:39:46 +02:00
|
|
|
self.buildarch, # buildarch is used only for the URL to access the full tree...
|
2008-01-23 20:37:44 +01:00
|
|
|
self.pacsuffix,
|
|
|
|
scheme,
|
|
|
|
apisrv)
|
2006-07-14 19:39:46 +02:00
|
|
|
self.deps.append(p)
|
|
|
|
|
2007-03-29 01:37:34 +02:00
|
|
|
self.preinstall_list = [ dep.name for dep in self.deps if dep.preinstall ]
|
|
|
|
self.runscripts_list = [ dep.name for dep in self.deps if dep.runscripts ]
|
2006-07-14 19:39:46 +02:00
|
|
|
|
2007-05-02 15:49:57 +02:00
|
|
|
def has_dep(self, name):
|
|
|
|
for i in self.deps:
|
|
|
|
if i.name == name:
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
|
|
|
def remove_dep(self, name):
|
|
|
|
for i in self.deps:
|
|
|
|
if i.name == name:
|
|
|
|
self.deps.remove(i)
|
|
|
|
return True
|
|
|
|
return False
|
2006-07-14 19:39:46 +02:00
|
|
|
|
|
|
|
|
|
|
|
class Pac:
|
|
|
|
"""represent a package to be downloaded"""
|
2007-03-29 01:37:34 +02:00
|
|
|
def __init__(self, name, version, release, project, repository, arch,
|
2008-01-23 20:37:44 +01:00
|
|
|
preinstall, runscripts, buildarch, pacsuffix, scheme=config['scheme'], apisrv=config['apisrv']):
|
2006-07-14 19:39:46 +02:00
|
|
|
|
|
|
|
self.name = name
|
|
|
|
self.version = version
|
|
|
|
self.release = release
|
|
|
|
self.arch = arch
|
|
|
|
self.project = project
|
|
|
|
self.repository = repository
|
2007-03-29 01:37:34 +02:00
|
|
|
self.preinstall = preinstall
|
|
|
|
self.runscripts = runscripts
|
2006-07-14 19:39:46 +02:00
|
|
|
self.buildarch = buildarch
|
|
|
|
self.pacsuffix = pacsuffix
|
|
|
|
|
|
|
|
# build a map to fill our the URL templates
|
|
|
|
self.mp = {}
|
|
|
|
self.mp['name'] = self.name
|
|
|
|
self.mp['version'] = self.version
|
|
|
|
self.mp['release'] = self.release
|
|
|
|
self.mp['arch'] = self.arch
|
|
|
|
self.mp['project'] = self.project
|
|
|
|
self.mp['repository'] = self.repository
|
2007-03-29 01:37:34 +02:00
|
|
|
self.mp['preinstall'] = self.preinstall
|
|
|
|
self.mp['runscripts'] = self.runscripts
|
2006-07-14 19:39:46 +02:00
|
|
|
self.mp['buildarch'] = self.buildarch
|
|
|
|
self.mp['pacsuffix'] = self.pacsuffix
|
|
|
|
|
2008-01-23 20:37:44 +01:00
|
|
|
self.mp['scheme'] = scheme
|
|
|
|
self.mp['apisrv'] = apisrv
|
2007-04-25 13:22:40 +02:00
|
|
|
|
2006-07-14 19:39:46 +02:00
|
|
|
self.filename = '%(name)s-%(version)s-%(release)s.%(arch)s.%(pacsuffix)s' % self.mp
|
|
|
|
|
|
|
|
self.mp['filename'] = self.filename
|
|
|
|
|
|
|
|
|
|
|
|
def makeurls(self, cachedir, urllist):
|
|
|
|
|
|
|
|
self.urllist = []
|
|
|
|
|
|
|
|
# build up local URL
|
|
|
|
# by using the urlgrabber with local urls, we basically build up a cache.
|
|
|
|
# the cache has no validation, since the package servers don't support etags,
|
|
|
|
# or if-modified-since, so the caching is simply name-based (on the assumption
|
|
|
|
# that the filename is suitable as identifier)
|
|
|
|
self.localdir = '%s/%s/%s/%s' % (cachedir, self.project, self.repository, self.arch)
|
|
|
|
self.fullfilename=os.path.join(self.localdir, self.filename)
|
|
|
|
self.url_local = 'file://%s/' % self.fullfilename
|
|
|
|
|
|
|
|
# first, add the local URL
|
|
|
|
self.urllist.append(self.url_local)
|
|
|
|
|
|
|
|
# remote URLs
|
|
|
|
for url in urllist:
|
|
|
|
self.urllist.append(url % self.mp)
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.name
|
|
|
|
|
2007-05-02 15:49:57 +02:00
|
|
|
def __repr__(self):
|
|
|
|
return "%s" % self.name
|
|
|
|
|
2006-07-14 19:39:46 +02:00
|
|
|
|
|
|
|
|
|
|
|
def get_built_files(pacdir, pactype):
|
|
|
|
if pactype == 'rpm':
|
2008-10-11 22:26:45 +02:00
|
|
|
b_built = subprocess.Popen('find %s -name \*.rpm' \
|
|
|
|
% os.path.join(pacdir, 'RPMS'),
|
|
|
|
stdout=subprocess.PIPE, shell=True).stdout.read().strip()
|
|
|
|
s_built = subprocess.Popen('find %s -name \*.rpm' \
|
|
|
|
% os.path.join(pacdir, 'SRPMS'),
|
|
|
|
stdout=subprocess.PIPE, shell=True).stdout.read().strip()
|
2006-07-14 19:39:46 +02:00
|
|
|
else:
|
2008-10-11 22:26:45 +02:00
|
|
|
b_built = subprocess.Popen('find %s -name \*.deb' \
|
|
|
|
% os.path.join(pacdir, 'DEBS'),
|
|
|
|
stdout=subprocess.PIPE, shell=True).stdout.read().strip()
|
2006-07-14 19:39:46 +02:00
|
|
|
s_built = None
|
|
|
|
return s_built, b_built
|
|
|
|
|
|
|
|
|
2007-05-03 17:54:40 +02:00
|
|
|
def get_prefer_pkgs(dirs, wanted_arch):
|
2007-05-02 15:49:57 +02:00
|
|
|
# XXX learn how to do the same for Debian packages
|
|
|
|
import glob
|
|
|
|
paths = []
|
|
|
|
for dir in dirs:
|
2008-05-04 16:00:42 +02:00
|
|
|
paths += glob.glob(os.path.join(os.path.abspath(dir), '*.rpm'))
|
2007-05-03 17:54:40 +02:00
|
|
|
prefer_pkgs = []
|
2007-05-02 15:49:57 +02:00
|
|
|
|
|
|
|
for path in paths:
|
|
|
|
if path.endswith('src.rpm'):
|
|
|
|
continue
|
|
|
|
if path.find('-debuginfo-') > 0:
|
|
|
|
continue
|
2008-10-11 22:26:45 +02:00
|
|
|
arch, name = subprocess.Popen('rpm -qp --nosignature --nodigest --qf "%%{arch} %%{name}\\n" %s' \
|
|
|
|
% path, stdout=subprocess.PIPE, shell=True).stdout.read().split()
|
|
|
|
# instead of thip assumption, we should probably rather take the
|
2007-05-02 15:49:57 +02:00
|
|
|
# requested arch for this package from buildinfo
|
|
|
|
# also, it will ignore i686 packages, how to handle those?
|
|
|
|
if arch == wanted_arch or arch == 'noarch':
|
2007-05-03 17:54:40 +02:00
|
|
|
prefer_pkgs.append((name, path))
|
2007-05-02 15:49:57 +02:00
|
|
|
|
2007-05-03 17:54:40 +02:00
|
|
|
return dict(prefer_pkgs)
|
2007-05-02 15:49:57 +02:00
|
|
|
|
|
|
|
|
2007-04-25 13:22:40 +02:00
|
|
|
def main(opts, argv):
|
2006-07-14 19:39:46 +02:00
|
|
|
|
2007-04-25 13:22:40 +02:00
|
|
|
repo = argv[0]
|
|
|
|
arch = argv[1]
|
|
|
|
spec = argv[2]
|
2007-05-02 15:49:57 +02:00
|
|
|
|
2006-07-14 19:39:46 +02:00
|
|
|
buildargs = []
|
2007-05-14 10:29:50 +02:00
|
|
|
if not opts.userootforbuild:
|
|
|
|
buildargs.append('--norootforbuild')
|
2007-04-25 13:22:40 +02:00
|
|
|
if opts.clean:
|
|
|
|
buildargs.append('--clean')
|
|
|
|
if opts.noinit:
|
|
|
|
buildargs.append('--noinit')
|
2008-07-23 22:05:09 +02:00
|
|
|
if opts.nochecks:
|
|
|
|
buildargs.append('--no-checks')
|
2007-09-03 12:25:18 +02:00
|
|
|
if not opts.no_changelog:
|
2007-08-14 13:26:13 +02:00
|
|
|
buildargs.append('--changelog')
|
2008-04-24 11:00:23 +02:00
|
|
|
if opts.jobs:
|
|
|
|
buildargs.append('--jobs %s' % opts.jobs)
|
2008-05-08 14:21:57 +02:00
|
|
|
if opts.baselibs:
|
|
|
|
buildargs.append('--baselibs')
|
2008-09-24 15:13:33 +02:00
|
|
|
if opts.debuginfo:
|
|
|
|
buildargs.append('--debug')
|
2007-05-02 15:49:57 +02:00
|
|
|
|
2008-01-07 15:54:31 +01:00
|
|
|
if opts.local_package:
|
|
|
|
pac = '_repository'
|
|
|
|
if opts.alternative_project:
|
|
|
|
prj = opts.alternative_project
|
|
|
|
pac = '_repository'
|
2008-10-14 12:38:22 +02:00
|
|
|
apiurl = config['apiurl']
|
|
|
|
else:
|
|
|
|
prj = store_read_project(os.curdir)
|
|
|
|
pac = store_read_package(os.curdir)
|
|
|
|
apiurl = store_read_apiurl(os.curdir)
|
2007-05-02 15:49:57 +02:00
|
|
|
|
|
|
|
if not os.path.exists(spec):
|
|
|
|
print >>sys.stderr, 'Error: specfile \'%s\' does not exist.' % spec
|
|
|
|
return 1
|
|
|
|
|
2006-10-10 16:04:34 +02:00
|
|
|
# make it possible to override configuration of the rc file
|
2008-04-09 20:45:59 +02:00
|
|
|
for var in ['OSC_PACKAGECACHEDIR', 'OSC_SU_WRAPPER', 'OSC_BUILD_ROOT']:
|
2006-10-10 16:04:34 +02:00
|
|
|
val = os.getenv(var)
|
|
|
|
if val:
|
|
|
|
if var.startswith('OSC_'): var = var[4:]
|
|
|
|
var = var.lower().replace('_', '-')
|
|
|
|
if config.has_key(var):
|
|
|
|
print 'Overriding config value for %s=\'%s\' with \'%s\'' % (var, config[var], val)
|
|
|
|
config[var] = val
|
|
|
|
|
2006-09-15 18:13:15 +02:00
|
|
|
config['build-root'] = config['build-root'] % {'repo': repo, 'arch': arch}
|
2006-07-14 19:39:46 +02:00
|
|
|
|
2008-07-12 14:06:23 +02:00
|
|
|
if not opts.extra_pkgs:
|
|
|
|
extra_pkgs = config['extra-pkgs']
|
|
|
|
elif opts.extra_pkgs == ['']:
|
|
|
|
extra_pkgs = None
|
|
|
|
else:
|
|
|
|
extra_pkgs = opts.extra_pkgs
|
|
|
|
|
2006-07-14 19:39:46 +02:00
|
|
|
print 'Getting buildinfo from server'
|
|
|
|
bi_file = NamedTemporaryFile(suffix='.xml', prefix='buildinfo.', dir = '/tmp')
|
2007-05-09 11:36:55 +02:00
|
|
|
try:
|
2008-10-14 12:38:22 +02:00
|
|
|
bi_text = ''.join(get_buildinfo(apiurl,
|
2008-01-07 15:54:31 +01:00
|
|
|
prj,
|
|
|
|
pac,
|
2007-05-09 11:36:55 +02:00
|
|
|
repo,
|
|
|
|
arch,
|
2007-05-12 22:18:23 +02:00
|
|
|
specfile=open(spec).read(),
|
2008-07-12 14:06:23 +02:00
|
|
|
addlist=extra_pkgs))
|
2008-01-07 15:54:31 +01:00
|
|
|
except urllib2.HTTPError, e:
|
|
|
|
if e.code == 404:
|
|
|
|
# check what caused the 404
|
|
|
|
if meta_exists(metatype='prj', path_args=(quote_plus(prj), ),
|
|
|
|
template_args=None, create_new=False):
|
2008-10-14 12:38:22 +02:00
|
|
|
if pac == '_repository' or meta_exists(metatype='pkg', path_args=(quote_plus(prj), quote_plus(pac)),
|
|
|
|
template_args=None, create_new=False):
|
2008-01-07 15:54:31 +01:00
|
|
|
print >>sys.stderr, 'wrong repo/arch?'
|
|
|
|
sys.exit(1)
|
|
|
|
else:
|
|
|
|
print >>sys.stderr, 'The package \'%s\' does not exists - please ' \
|
|
|
|
'rerun with \'--local-package\'' % pac
|
|
|
|
sys.exit(1)
|
|
|
|
else:
|
|
|
|
print >>sys.stderr, 'The project \'%s\' does not exists - please ' \
|
|
|
|
'rerun with \'--alternative-project <alternative_project>\'' % prj
|
|
|
|
sys.exit(1)
|
2008-06-12 14:12:29 +02:00
|
|
|
else:
|
|
|
|
raise
|
2007-05-09 11:36:55 +02:00
|
|
|
bi_file.write(bi_text)
|
|
|
|
bi_file.flush()
|
|
|
|
|
2008-10-14 12:38:22 +02:00
|
|
|
bi = Buildinfo(bi_file.name, apiurl)
|
2008-10-31 16:41:19 +01:00
|
|
|
if bi.debuginfo:
|
|
|
|
buildargs.append('--debug')
|
|
|
|
buildargs = ' '.join(set(buildargs))
|
2006-07-14 19:39:46 +02:00
|
|
|
|
2008-08-15 16:04:27 +02:00
|
|
|
# real arch of this machine
|
|
|
|
# vs.
|
|
|
|
# arch we are supposed to build for
|
|
|
|
if hostarch != bi.buildarch:
|
|
|
|
if not bi.buildarch in can_also_build.get(hostarch, []):
|
|
|
|
print >>sys.stderr, 'Error: hostarch \'%s\' cannot build \'%s\'.' % (hostarch, bi.buildarch)
|
|
|
|
return 1
|
|
|
|
|
2007-05-02 15:49:57 +02:00
|
|
|
rpmlist_prefers = []
|
2007-05-03 17:54:40 +02:00
|
|
|
if opts.prefer_pkgs:
|
2007-05-02 15:49:57 +02:00
|
|
|
print 'Evaluating preferred packages'
|
|
|
|
# the resulting dict will also contain packages which are not on the install list
|
|
|
|
# but they won't be installed
|
2007-05-03 17:54:40 +02:00
|
|
|
prefer_pkgs = get_prefer_pkgs(opts.prefer_pkgs, bi.buildarch)
|
2007-05-02 15:49:57 +02:00
|
|
|
|
2007-05-03 17:54:40 +02:00
|
|
|
for name, path in prefer_pkgs.iteritems():
|
2007-05-02 15:49:57 +02:00
|
|
|
if bi.has_dep(name):
|
2008-01-07 15:54:31 +01:00
|
|
|
# We remove a preferred package from the buildinfo, so that the
|
|
|
|
# fetcher doesn't take care about them.
|
|
|
|
# Instead, we put it in a list which is appended to the rpmlist later.
|
|
|
|
# At the same time, this will make sure that these packages are
|
|
|
|
# not verified.
|
|
|
|
bi.remove_dep(name)
|
|
|
|
rpmlist_prefers.append((name, path))
|
|
|
|
print ' - %s (%s)' % (name, path)
|
|
|
|
continue
|
2006-07-14 19:39:46 +02:00
|
|
|
|
|
|
|
print 'Updating cache of required packages'
|
|
|
|
fetcher = Fetcher(cachedir = config['packagecachedir'],
|
|
|
|
urllist = config['urllist'],
|
2008-08-20 11:45:49 +02:00
|
|
|
api_host_options = config['api_host_options'],
|
2007-09-10 14:22:13 +02:00
|
|
|
http_debug = config['http_debug'])
|
2007-05-02 15:49:57 +02:00
|
|
|
|
2006-07-14 19:39:46 +02:00
|
|
|
# now update the package cache
|
|
|
|
fetcher.run(bi)
|
|
|
|
|
|
|
|
if bi.pacsuffix == 'rpm':
|
|
|
|
"""don't know how to verify .deb packages. They are verified on install
|
|
|
|
anyway, I assume... verifying package now saves time though, since we don't
|
|
|
|
even try to set up the buildroot if it wouldn't work."""
|
|
|
|
|
2008-01-24 19:06:45 +01:00
|
|
|
if opts.no_verify:
|
|
|
|
print 'Skipping verification of package signatures'
|
|
|
|
else:
|
|
|
|
print 'Verifying integrity of cached packages'
|
|
|
|
verify_pacs([ i.fullfilename for i in bi.deps ])
|
2006-07-14 19:39:46 +02:00
|
|
|
|
|
|
|
print 'Writing build configuration'
|
|
|
|
|
2007-05-02 15:49:57 +02:00
|
|
|
rpmlist = [ '%s %s\n' % (i.name, i.fullfilename) for i in bi.deps ]
|
|
|
|
rpmlist += [ '%s %s\n' % (i[0], i[1]) for i in rpmlist_prefers ]
|
2006-07-14 19:39:46 +02:00
|
|
|
|
2007-05-02 15:49:57 +02:00
|
|
|
rpmlist.append('preinstall: ' + ' '.join(bi.preinstall_list) + '\n')
|
|
|
|
rpmlist.append('runscripts: ' + ' '.join(bi.runscripts_list) + '\n')
|
2006-07-14 19:39:46 +02:00
|
|
|
|
2007-05-02 15:49:57 +02:00
|
|
|
rpmlist_file = NamedTemporaryFile(prefix='rpmlist.', dir = '/tmp')
|
|
|
|
rpmlist_file.writelines(rpmlist)
|
|
|
|
rpmlist_file.flush()
|
|
|
|
os.fsync(rpmlist_file)
|
2006-07-14 19:39:46 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print 'Getting buildconfig from server'
|
|
|
|
bc_file = NamedTemporaryFile(prefix='buildconfig.', dir = '/tmp')
|
2008-10-14 12:38:22 +02:00
|
|
|
bc_file.write(get_buildconfig(apiurl, prj, pac, repo, arch))
|
2008-01-07 15:54:31 +01:00
|
|
|
bc_file.flush()
|
2006-07-14 19:39:46 +02:00
|
|
|
|
|
|
|
|
|
|
|
print 'Running build'
|
|
|
|
|
2007-05-14 10:29:50 +02:00
|
|
|
cmd = '%s --root=%s --rpmlist=%s --dist=%s %s %s' \
|
2006-07-14 19:39:46 +02:00
|
|
|
% (config['build-cmd'],
|
2006-09-15 18:13:15 +02:00
|
|
|
config['build-root'],
|
2007-05-02 15:49:57 +02:00
|
|
|
rpmlist_file.name,
|
2006-07-14 19:39:46 +02:00
|
|
|
bc_file.name,
|
|
|
|
spec,
|
|
|
|
buildargs)
|
|
|
|
|
|
|
|
if config['su-wrapper'].startswith('su '):
|
|
|
|
tmpl = '%s \'%s\''
|
|
|
|
else:
|
|
|
|
tmpl = '%s %s'
|
|
|
|
cmd = tmpl % (config['su-wrapper'], cmd)
|
|
|
|
|
2008-08-15 16:04:27 +02:00
|
|
|
# change personality, if needed
|
2006-07-14 19:39:46 +02:00
|
|
|
if hostarch != bi.buildarch:
|
2008-08-15 16:04:27 +02:00
|
|
|
cmd = change_personality[bi.buildarch] + ' ' + cmd
|
2006-07-14 19:39:46 +02:00
|
|
|
|
|
|
|
print cmd
|
2008-10-11 22:26:45 +02:00
|
|
|
rc = subprocess.call(cmd, shell=True)
|
2008-01-24 19:18:03 +01:00
|
|
|
if rc:
|
|
|
|
print
|
|
|
|
print 'The buildroot was:', config['build-root']
|
|
|
|
sys.exit(rc)
|
2006-07-14 19:39:46 +02:00
|
|
|
|
2006-07-14 20:31:35 +02:00
|
|
|
pacdirlink = os.path.join(config['build-root'], '.build.packages')
|
|
|
|
if os.path.exists(pacdirlink):
|
|
|
|
pacdirlink = os.readlink(pacdirlink)
|
2006-09-15 18:17:49 +02:00
|
|
|
pacdir = os.path.join(config['build-root'], pacdirlink)
|
2006-07-14 20:31:35 +02:00
|
|
|
|
|
|
|
if os.path.exists(pacdir):
|
|
|
|
(s_built, b_built) = get_built_files(pacdir, bi.pacsuffix)
|
|
|
|
|
|
|
|
print
|
|
|
|
if s_built: print s_built
|
2007-05-02 15:49:57 +02:00
|
|
|
print
|
2006-07-14 20:31:35 +02:00
|
|
|
print b_built
|
2006-07-14 19:39:46 +02:00
|
|
|
|
2007-05-03 17:54:40 +02:00
|
|
|
if opts.keep_pkgs:
|
|
|
|
for i in b_built.splitlines():
|
|
|
|
import shutil
|
|
|
|
shutil.copy2(i, os.path.join(opts.keep_pkgs, os.path.basename(i)))
|
|
|
|
|
2006-07-14 19:39:46 +02:00
|
|
|
|