mirror of
https://github.com/openSUSE/osc.git
synced 2025-02-25 11:42:12 +01:00
Support docker builds
This commit is contained in:
parent
bea940c02d
commit
8bffeb70e5
23
osc/build.py
23
osc/build.py
@ -341,6 +341,11 @@ def get_built_files(pacdir, buildtype):
|
|||||||
'-type', 'f'],
|
'-type', 'f'],
|
||||||
stdout=subprocess.PIPE).stdout.read().strip()
|
stdout=subprocess.PIPE).stdout.read().strip()
|
||||||
s_built = ''
|
s_built = ''
|
||||||
|
elif buildtype == 'docker':
|
||||||
|
b_built = subprocess.Popen(['find', os.path.join(pacdir, 'DOCKER'),
|
||||||
|
'-type', 'f'],
|
||||||
|
stdout=subprocess.PIPE).stdout.read().strip()
|
||||||
|
s_built = ''
|
||||||
elif buildtype == 'dsc' or buildtype == 'collax':
|
elif buildtype == 'dsc' or buildtype == 'collax':
|
||||||
b_built = subprocess.Popen(['find', os.path.join(pacdir, 'DEBS'),
|
b_built = subprocess.Popen(['find', os.path.join(pacdir, 'DEBS'),
|
||||||
'-name', '*.deb'],
|
'-name', '*.deb'],
|
||||||
@ -510,9 +515,11 @@ def main(apiurl, opts, argv):
|
|||||||
build_type = 'appimage'
|
build_type = 'appimage'
|
||||||
if os.path.basename(build_descr) == 'snapcraft.yaml':
|
if os.path.basename(build_descr) == 'snapcraft.yaml':
|
||||||
build_type = 'snapcraft'
|
build_type = 'snapcraft'
|
||||||
if build_type not in ['spec', 'dsc', 'kiwi', 'arch', 'collax', 'livebuild', 'snapcraft', 'appimage']:
|
if os.path.basename(build_descr) == 'Dockerfile':
|
||||||
|
build_type = 'docker'
|
||||||
|
if build_type not in ['spec', 'dsc', 'kiwi', 'arch', 'collax', 'livebuild', 'snapcraft', 'appimage', 'docker']:
|
||||||
raise oscerr.WrongArgs(
|
raise oscerr.WrongArgs(
|
||||||
'Unknown build type: \'%s\'. Build description should end in .spec, .dsc, .kiwi, or .livebuild. Or being named PKGBUILD, build.collax, appimage.yml or snapcraft.yaml' \
|
'Unknown build type: \'%s\'. Build description should end in .spec, .dsc, .kiwi, or .livebuild. Or being named PKGBUILD, build.collax, appimage.yml, snapcraft.yaml or Dockerfile' \
|
||||||
% build_type)
|
% build_type)
|
||||||
if not os.path.isfile(build_descr):
|
if not os.path.isfile(build_descr):
|
||||||
raise oscerr.WrongArgs('Error: build description file named \'%s\' does not exist.' % build_descr)
|
raise oscerr.WrongArgs('Error: build description file named \'%s\' does not exist.' % build_descr)
|
||||||
@ -948,8 +955,8 @@ def main(apiurl, opts, argv):
|
|||||||
if old_pkg_dir != None:
|
if old_pkg_dir != None:
|
||||||
buildargs.append('--oldpackages=%s' % old_pkg_dir)
|
buildargs.append('--oldpackages=%s' % old_pkg_dir)
|
||||||
|
|
||||||
# Make packages from buildinfo available as repos for kiwi
|
# Make packages from buildinfo available as repos for kiwi/docker
|
||||||
if build_type == 'kiwi':
|
if build_type == 'kiwi' or build_type == 'docker':
|
||||||
if os.path.exists('repos'):
|
if os.path.exists('repos'):
|
||||||
shutil.rmtree('repos')
|
shutil.rmtree('repos')
|
||||||
os.mkdir('repos')
|
os.mkdir('repos')
|
||||||
@ -990,6 +997,8 @@ def main(apiurl, opts, argv):
|
|||||||
os.link(path + "/" + filename, tffn)
|
os.link(path + "/" + filename, tffn)
|
||||||
else:
|
else:
|
||||||
os.symlink(path + "/" + filename, tffn)
|
os.symlink(path + "/" + filename, tffn)
|
||||||
|
|
||||||
|
if build_type == 'kiwi':
|
||||||
# Is a obsrepositories tag used?
|
# Is a obsrepositories tag used?
|
||||||
try:
|
try:
|
||||||
tree = ET.parse(build_descr)
|
tree = ET.parse(build_descr)
|
||||||
@ -1075,7 +1084,7 @@ def main(apiurl, opts, argv):
|
|||||||
|
|
||||||
print('Writing build configuration')
|
print('Writing build configuration')
|
||||||
|
|
||||||
if build_type == 'kiwi':
|
if build_type == 'kiwi' or build_type == 'docker':
|
||||||
rpmlist = [ '%s %s\n' % (i.name, i.fullfilename) for i in bi.deps if not i.noinstall ]
|
rpmlist = [ '%s %s\n' % (i.name, i.fullfilename) for i in bi.deps if not i.noinstall ]
|
||||||
else:
|
else:
|
||||||
rpmlist = [ '%s %s\n' % (i.name, i.fullfilename) for i in bi.deps ]
|
rpmlist = [ '%s %s\n' % (i.name, i.fullfilename) for i in bi.deps ]
|
||||||
@ -1091,9 +1100,9 @@ def main(apiurl, opts, argv):
|
|||||||
rpmlist.append('preinstall: ' + ' '.join(bi.preinstall_list) + '\n')
|
rpmlist.append('preinstall: ' + ' '.join(bi.preinstall_list) + '\n')
|
||||||
rpmlist.append('vminstall: ' + ' '.join(bi.vminstall_list) + '\n')
|
rpmlist.append('vminstall: ' + ' '.join(bi.vminstall_list) + '\n')
|
||||||
rpmlist.append('runscripts: ' + ' '.join(bi.runscripts_list) + '\n')
|
rpmlist.append('runscripts: ' + ' '.join(bi.runscripts_list) + '\n')
|
||||||
if build_type != 'kiwi' and bi.noinstall_list:
|
if build_type != 'kiwi' and build_type != 'docker' and bi.noinstall_list:
|
||||||
rpmlist.append('noinstall: ' + ' '.join(bi.noinstall_list) + '\n')
|
rpmlist.append('noinstall: ' + ' '.join(bi.noinstall_list) + '\n')
|
||||||
if build_type != 'kiwi' and bi.installonly_list:
|
if build_type != 'kiwi' and build_type != 'docker' and bi.installonly_list:
|
||||||
rpmlist.append('installonly: ' + ' '.join(bi.installonly_list) + '\n')
|
rpmlist.append('installonly: ' + ' '.join(bi.installonly_list) + '\n')
|
||||||
|
|
||||||
rpmlist_file = NamedTemporaryFile(prefix='rpmlist.')
|
rpmlist_file = NamedTemporaryFile(prefix='rpmlist.')
|
||||||
|
@ -5775,7 +5775,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
for subarch in osc.build.can_also_build.get(mainarch):
|
for subarch in osc.build.can_also_build.get(mainarch):
|
||||||
all_archs.append(subarch)
|
all_archs.append(subarch)
|
||||||
for arg in args:
|
for arg in args:
|
||||||
if arg.endswith('.spec') or arg.endswith('.dsc') or arg.endswith('.kiwi') or arg.endswith('.livebuild') or arg == 'PKGBUILD' or arg == 'build.collax':
|
if arg.endswith('.spec') or arg.endswith('.dsc') or arg.endswith('.kiwi') or arg.endswith('.livebuild') or arg == 'PKGBUILD' or arg == 'build.collax' or arg == 'Dockerfile':
|
||||||
arg_descr = arg
|
arg_descr = arg
|
||||||
else:
|
else:
|
||||||
if (arg == osc.build.hostarch or arg in all_archs) and arg_arch is None:
|
if (arg == osc.build.hostarch or arg in all_archs) and arg_arch is None:
|
||||||
@ -5836,7 +5836,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
# can be implemented using
|
# can be implemented using
|
||||||
# reduce(lambda x, y: x + y, (glob.glob(x) for x in ('*.spec', '*.dsc', '*.kiwi')))
|
# reduce(lambda x, y: x + y, (glob.glob(x) for x in ('*.spec', '*.dsc', '*.kiwi')))
|
||||||
# but be a bit more readable :)
|
# but be a bit more readable :)
|
||||||
descr = glob.glob('*.spec') + glob.glob('*.dsc') + glob.glob('*.kiwi') + glob.glob('*.livebuild') + glob.glob('PKGBUILD') + glob.glob('build.collax')
|
descr = glob.glob('*.spec') + glob.glob('*.dsc') + glob.glob('*.kiwi') + glob.glob('*.livebuild') \
|
||||||
|
+ glob.glob('PKGBUILD') + glob.glob('build.collax') + glob.glob('Dockerfile')
|
||||||
|
|
||||||
# FIXME:
|
# FIXME:
|
||||||
# * request repos from server and select by build type.
|
# * request repos from server and select by build type.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user