Skip to content

Commit

Permalink
Support an optional suffix for Dockerfile recipes
Browse files Browse the repository at this point in the history
  • Loading branch information
mlschroe committed Oct 23, 2023
1 parent f64b65d commit b36acc4
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion PBuild/Job.pm
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ sub collect_result {
}
@d = ('ARCHPKGS') if $p->{'recipe'} =~ /PKGBUILD$/;
@d = ('KIWI') if $p->{'recipe'} =~ /\.kiwi$/;
@d = ('DOCKER') if $p->{'recipe'} =~ /Dockerfile$/;
@d = ('DOCKER') if $p->{'recipe'} =~ /Dockerfile(\.|$)/;
@d = ('FISSILE') if $p->{'recipe'} =~ /fissile\.yml$/;
@d = ('HELM') if $p->{'recipe'} =~ /Chart\.yaml$/;
push @d, 'OTHER';
Expand Down
4 changes: 3 additions & 1 deletion PBuild/Recipe.pm
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ sub find_recipe {
return $files{'PKGBUILD'} ? $files{'PKGBUILD'} : undef if $type eq 'arch';
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"};
Expand All @@ -60,6 +61,7 @@ sub find_recipe {
# 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"};
}
if ($type ne 'kiwi') {
@files = grep {/\.kiwi$/} keys %files;
Expand Down Expand Up @@ -202,7 +204,7 @@ sub looks_like_packagedir {
return 0 if grep {/^_build\./} @files;
for my $file (@files) {
return 1 if $file =~ /\.(?:spec|dsc|kiwi)$/;
return 1 if $file =~ /^mkosi\./;
return 1 if $file =~ /^(?:Dockerfile|mkosi)\./;
return 1 if $file eq 'snapcraft.yaml' || $file eq 'appimage.yml';
return 1 if $file eq 'Dockerfile' || $file eq 'fissile.yml' || $file eq 'Chart.yml';
return 1 if $file eq 'PKGBUILD';
Expand Down
4 changes: 2 additions & 2 deletions build-recipe
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ recipe_set_buildtype() {
PKGBUILD) BUILDTYPE=arch ;;
snapcraft.yaml) BUILDTYPE=snapcraft ;;
appimage.yml) BUILDTYPE=appimage ;;
Dockerfile) BUILDTYPE=docker ;;
Dockerfile|Dockerfile.*) BUILDTYPE=docker ;;
fissile.yml) BUILDTYPE=fissile ;;
build.collax) BUILDTYPE=collax ;;
_preinstallimage) BUILDTYPE=preinstallimage ;;
Expand All @@ -140,7 +140,7 @@ recipe_set_buildtype() {
mkosi.*) BUILDTYPE=mkosi ;;
esac
if test -z "$BUILDTYPE" ; then
cleanup_and_exit 1 "I don't know how to build $RECIPEFILE"
cleanup_and_exit 1 "I don't know how to build $RECIPEFILE"
fi
# we can't query right after vm startup, so we put the BUILDENGINE in the build.data
if test -z "$RUNNING_IN_VM" ; then
Expand Down
4 changes: 2 additions & 2 deletions download_assets
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ for my $dir (@dirs) {
find_assets($assetmgr, $bconf, $p, $opts->{'recipe'});
} else {
for my $file (sort keys %$files) {
next unless $file eq 'sources' || $file eq 'go.sum' || $file eq 'PKGBUILD' || $file eq 'Dockerfile' || $file =~ /\.(?:spec|dsc|kiwi)/;
find_assets($assetmgr, $bconf, $p, $file);
next unless $file eq 'sources' || $file eq 'go.sum' || $file eq 'PKGBUILD' || $file eq 'Dockerfile' || $file =~ /^Dockerfile\./ || $file =~ /\.(?:spec|dsc|kiwi)/;
find_assets($assetmgr, $bconf, $p, $file);
}
}
}
Expand Down

0 comments on commit b36acc4

Please sign in to comment.