1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-01-26 06:46:13 +01:00

Support derived images for kiwi docker builds

Kiwi currently rejects the --set-container-derived-from option,
but this will hopefully change.
This commit is contained in:
Michael Schroeder 2017-05-16 14:02:37 +02:00
parent 8bffeb70e5
commit 7dae421d77
2 changed files with 38 additions and 14 deletions

View File

@ -200,7 +200,8 @@ class Pac:
for i in ['binary', 'package',
'epoch', 'version', 'release', 'hdrmd5',
'project', 'repository',
'preinstall', 'vminstall', 'noinstall', 'installonly', 'runscripts',
'preinstall', 'vminstall', 'runscripts',
'noinstall', 'installonly', 'notmeta',
]:
self.mp[i] = node.get(i)
@ -959,25 +960,39 @@ def main(apiurl, opts, argv):
if build_type == 'kiwi' or build_type == 'docker':
if os.path.exists('repos'):
shutil.rmtree('repos')
if os.path.exists('containers'):
shutil.rmtree('containers')
os.mkdir('repos')
for i in bi.deps:
if not i.extproject:
# remove
bi.deps.remove(i)
continue
if i.notmeta:
continue
# project
pdir = str(i.extproject).replace(':/', ':')
# repo
rdir = str(i.extrepository).replace(':/', ':')
# arch
adir = i.repoarch
# project/repo
prdir = "repos/"+pdir+"/"+rdir
# project/repo/arch
pradir = prdir+"/"+adir
# source fullfilename
sffn = i.fullfilename
filename = sffn.split("/")[-1]
# project/repo
if i.name.startswith("container:"):
prdir = "containers/"+pdir+"/"+rdir
pradir = prdir
filename = filename[10:]
if build_type == 'kiwi':
buildargs.append('--kiwi-parameter')
buildargs.append('--set-container-derived-from')
buildargs.append('--kiwi-parameter')
buildargs.append("obs:/"+pdir+"/"+rdir+"/"+filename)
else:
prdir = "repos/"+pdir+"/"+rdir
# project/repo/arch
pradir = prdir+"/"+adir
# target fullfilename
tffn = pradir+"/"+filename
if not os.path.exists(os.path.join(pradir)):

View File

@ -129,7 +129,12 @@ class Fetcher:
'(see .errors file)')
if package == '_repository':
n = re.sub(r'\.pkg\.tar\..z$', '.arch', hdr.filename)
pac = pkgs[n.rsplit('.', 1)[0]]
if n.startswith('container:'):
n = re.sub(r'\.tar\..z$', '.tar', hdr.filename)
pac = pkgs[n.rsplit('.', 1)[0]]
pac.canonname = hdr.filename
else:
pac = pkgs[n.rsplit('.', 1)[0]]
else:
# this is a kiwi product
pac = pkgs[hdr.filename]
@ -206,14 +211,18 @@ class Fetcher:
def move_package(self, tmpfile, destdir, pac_obj=None):
import shutil
pkgq = packagequery.PackageQuery.query(tmpfile, extra_rpmtags=(1044, 1051, 1052))
if pkgq:
canonname = pkgq.canonname()
else:
if pac_obj is None:
print('Unsupported file type: ', tmpfile, file=sys.stderr)
sys.exit(1)
canonname = pac_obj.binary
canonname = None
if pac_obj and pac_obj.name.startswith('container:'):
canonname = pac_obj.canonname
if canonname is None:
pkgq = packagequery.PackageQuery.query(tmpfile, extra_rpmtags=(1044, 1051, 1052))
if pkgq:
canonname = pkgq.canonname()
else:
if pac_obj is None:
print('Unsupported file type: ', tmpfile, file=sys.stderr)
sys.exit(1)
canonname = pac_obj.binary
fullfilename = os.path.join(destdir, canonname)
if pac_obj is not None: