Skip to content

[bug] pbuild doesn't detect Dockerfile.dapper with Type: docker in project config #1066

@Priyankasaggu11929

Description

@Priyankasaggu11929

In the following OBS project config, pbuild does not automatically detect the presence of a Dockerfile.dapper file in the package source:

%if %_repository == "example-repo"
Type: docker
BuildEngine: docker
...
%endif

Although, changing Type: docker to Type: dapper makes OBS detect Dockerfile.dapper as the build recipe:

%if %_repository == "example-repo"
Type: dapper
BuildEngine: docker
...
%endif

This appears to work by accident, since Type: dapper is not a valid value.

I further tested with any random Type: abc which also made OBS pick up any file matching *.abc in the package source as a build recipe. This seems to be a bug or unintended behaviour.

The current implementation for finding the build recipe, (i) either via the configured Type: or (ii) via auto-detection - is present here and may require an update:

return $files{'Dockerfile'} if $type eq 'docker' && $files{'Dockerfile'};
return $files{'fissile.yml'} if $type eq 'fissile' && $files{'fissile.yml'};
return $files{'Chart.yaml'} if $type eq 'helm' && $files{'Chart.yaml'};
return (grep {/flatpak\.(?:ya?ml|json)$/} sort keys %files)[0] if $type eq 'flatpak';
return $files{'PKGBUILD'} if $type eq 'arch' && $files{'PKGBUILD'};
return $files{'APKBUILD'} if $type eq 'apk' && $files{'APKBUILD'};
my $pkg = $p->{'pkg'};
$pkg = $p->{'flavor'} if $p->{'flavor'};
return $files{"Dockerfile.$pkg"} if $type eq 'docker' && $files{"Dockerfile.$pkg"};
return $files{"$pkg.$type"} if $files{"$pkg.$type"};
# try again without last components
return $files{"$1.$type"} if $pkg =~ /^(.*?)\./ && $files{"$1.$type"};
my @files = grep {/\.$type$/} keys %files;
@files = grep {/^\Q$pkg\E/i} @files if @files > 1;
return $files{$files[0]} if @files == 1;
if (@files > 1) {
@files = sort @files;
return $files{$files[0]};
}
return $files{'debian.control'} if $type eq 'dsc' && $files{'debian.control'};
return $files{'debian/control'} if $type eq 'dsc' && $files{'debian/control'};
# as last resort ignore the type for image/container building
if ($type ne 'docker') {
return $files{'Dockerfile'} if $files{'Dockerfile'};
return $files{"Dockerfile.$pkg"} if $files{"Dockerfile.$pkg"};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions