Skip to content

Commit

Permalink
Support the mkosi build type
Browse files Browse the repository at this point in the history
Unlike other recipe files, OBS detects this by matching the prefix rather
than the suffix. As this would cause conflicts with e.g. mkosi.spec the
build type detection had to be changed a bit.
  • Loading branch information
Vogtinator committed Oct 10, 2024
1 parent 8f10569 commit d9151d8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
38 changes: 23 additions & 15 deletions osc/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,11 @@ def get_built_files(pacdir, buildtype):
'-type', 'f'],
stdout=subprocess.PIPE).stdout.read().strip()
s_built = ''
elif buildtype == 'mkosi':
b_built = subprocess.Popen(['find', os.path.join(pacdir, 'OTHER'),
'-type', 'f'],
stdout=subprocess.PIPE).stdout.read().strip()
s_built = ''
else:
print('WARNING: Unknown package type \'%s\'.' % buildtype, file=sys.stderr)
b_built = ''
Expand Down Expand Up @@ -755,37 +760,40 @@ def main(apiurl, store, opts, argv):

build_descr = os.path.abspath(build_descr)
build_type = os.path.splitext(build_descr)[1][1:]
if os.path.basename(build_descr) == 'PKGBUILD':
if build_type in ['spec', 'dsc', 'kiwi', 'productcompose', 'livebuild']:
# File extension works
pass
elif os.path.basename(build_descr) == 'PKGBUILD':
build_type = 'arch'
if os.path.basename(build_descr) == 'build.collax':
elif os.path.basename(build_descr) == 'build.collax':
build_type = 'collax'
if os.path.basename(build_descr) == 'appimage.yml':
elif os.path.basename(build_descr) == 'appimage.yml':
build_type = 'appimage'
if os.path.basename(build_descr) == 'Chart.yaml':
elif os.path.basename(build_descr) == 'Chart.yaml':
build_type = 'helm'
if os.path.basename(build_descr) == 'snapcraft.yaml':
elif os.path.basename(build_descr) == 'snapcraft.yaml':
build_type = 'snapcraft'
if os.path.basename(build_descr) == 'simpleimage':
elif os.path.basename(build_descr) == 'simpleimage':
build_type = 'simpleimage'
if os.path.basename(build_descr) == 'Containerfile' or os.path.basename(build_descr).startswith('Containerfile.'):
elif os.path.basename(build_descr) == 'Containerfile' or os.path.basename(build_descr).startswith('Containerfile.'):
build_type = 'docker'
if os.path.basename(build_descr) == 'Dockerfile' or os.path.basename(build_descr).startswith('Dockerfile.'):
elif os.path.basename(build_descr) == 'Dockerfile' or os.path.basename(build_descr).startswith('Dockerfile.'):
build_type = 'docker'
if os.path.basename(build_descr) == 'fissile.yml':
elif os.path.basename(build_descr) == 'fissile.yml':
build_type = 'fissile'
if os.path.basename(build_descr) == '_preinstallimage':
elif os.path.basename(build_descr) == '_preinstallimage':
build_type = 'preinstallimage'
if build_descr.endswith('flatpak.yaml') or build_descr.endswith('flatpak.yml') or build_descr.endswith('flatpak.json'):
elif build_descr.endswith('flatpak.yaml') or build_descr.endswith('flatpak.yml') or build_descr.endswith('flatpak.json'):
build_type = 'flatpak'
if build_type not in ['spec', 'dsc', 'kiwi', 'arch', 'collax', 'livebuild',
'simpleimage', 'snapcraft', 'appimage', 'docker', 'helm',
'podman', 'fissile', 'flatpak', 'preinstallimage', 'productcompose']:
elif os.path.basename(build_descr).startswith('mkosi.'):
build_type = 'mkosi'
else:
raise oscerr.WrongArgs(
'Unknown build type: \'%s\'. '
'Build description should end in .spec, .dsc, .kiwi, .productcompose or .livebuild. '
'Or being named PKGBUILD, build.collax, simpleimage, appimage.yml, '
'Chart.yaml, snapcraft.yaml, flatpak.json, flatpak.yml, flatpak.yaml, '
'preinstallimage or Dockerfile' % build_type)
'preinstallimage, Dockerfile.*, Containerfile.* or mkosi.*' % build_type)

if not os.path.isfile(build_descr):
raise oscerr.WrongArgs('Error: build description file named \'%s\' does not exist.' % build_descr)
Expand Down
4 changes: 3 additions & 1 deletion osc/commandline.py
Original file line number Diff line number Diff line change
Expand Up @@ -7109,7 +7109,7 @@ def parse_repoarchdescr(self, args, noinit=False, alternative_project=None, igno
glob.glob('Dockerfile.*') + glob.glob('Containerfile') + glob.glob('Containerfile.*') + \
glob.glob('fissile.yml') + glob.glob('appimage.yml') + glob.glob('Chart.yaml') + \
glob.glob('*flatpak.yaml') + glob.glob('*flatpak.yml') + glob.glob('*flatpak.json') + \
glob.glob('*.productcompose')
glob.glob('*.productcompose') + glob.glob('mkosi.*')

# FIXME:
# * request repos from server and select by build type.
Expand Down Expand Up @@ -7153,6 +7153,8 @@ def parse_repoarchdescr(self, args, noinit=False, alternative_project=None, igno
pac = multibuild_package
if recipe == 'PKGBUILD':
cands = [d for d in descr if d.startswith(recipe)]
elif recipe == 'mkosi':
cands = [d for d in descr if d.startswith('mkosi.')]
else:
cands = [d for d in descr if d.endswith('.' + recipe)]
if len(cands) > 1:
Expand Down

0 comments on commit d9151d8

Please sign in to comment.