From 9e98f8052f28b8d0c57bb82f18b1202f0d255c25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Schr=C3=B6ter?= Date: Fri, 27 Oct 2023 11:20:22 +0200 Subject: [PATCH] Support also "Containerfile" for docker container builds As proposed by podman --- Build.pm | 1 + PBuild/Job.pm | 2 +- PBuild/Recipe.pm | 8 ++++++-- build-recipe | 4 ++-- download_assets | 2 +- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Build.pm b/Build.pm index 63e7b3754..b07355e3f 100644 --- a/Build.pm +++ b/Build.pm @@ -1265,6 +1265,7 @@ sub recipe2buildtype { return 'collax' if $recipe eq 'build.collax'; return 'snapcraft' if $recipe eq 'snapcraft.yaml'; return 'appimage' if $recipe eq 'appimage.yml'; + return 'docker' if $recipe eq 'Containerfile' || $recipe =~ /^Containerfile\..*/; return 'docker' if $recipe eq 'Dockerfile' || $recipe =~ /^Dockerfile\..*/; return 'fissile' if $recipe eq 'fissile.yml'; return 'preinstallimage' if $recipe eq '_preinstallimage'; diff --git a/PBuild/Job.pm b/PBuild/Job.pm index 9b1c5b74d..d25e680a9 100644 --- a/PBuild/Job.pm +++ b/PBuild/Job.pm @@ -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'} =~ /(Docker|Container)file(\.|$)/; @d = ('FISSILE') if $p->{'recipe'} =~ /fissile\.yml$/; @d = ('HELM') if $p->{'recipe'} =~ /Chart\.yaml$/; push @d, 'OTHER'; diff --git a/PBuild/Recipe.pm b/PBuild/Recipe.pm index ca8576f3c..5ccb73854 100644 --- a/PBuild/Recipe.pm +++ b/PBuild/Recipe.pm @@ -38,6 +38,7 @@ sub find_recipe { return $files{'simpleimage'} if $files{'simpleimage'}; return $files{'snapcraft.yaml'} if $type eq 'snapcraft' && $files{'snapcraft.yaml'}; return $files{'appimage.yml'} if $type eq 'appimage' && $files{'appimage.yml'}; + return $files{'Containerfile'} if $type eq 'docker' && $files{'Containerfile'}; 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'}; @@ -45,6 +46,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{"Containerfile.$pkg"} if $type eq 'docker' && $files{"Containerfile.$pkg"}; return $files{"Dockerfile.$pkg"} if $type eq 'docker' && $files{"Dockerfile.$pkg"}; return $files{"$pkg.$type"} if $files{"$pkg.$type"}; # try again without last components @@ -60,7 +62,9 @@ sub find_recipe { 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{'Containerfile'} if $files{'Containerfile'}; return $files{'Dockerfile'} if $files{'Dockerfile'}; + return $files{"Containerfile.$pkg"} if $files{"Containerfile.$pkg"}; return $files{"Dockerfile.$pkg"} if $files{"Dockerfile.$pkg"}; } if ($type ne 'kiwi') { @@ -204,9 +208,9 @@ 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 =~ /^(?:Dockerfile|mkosi)\./; + return 1 if $file =~ /^(?:Containerfile|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 'Containerfile' || $file eq 'Dockerfile' || $file eq 'fissile.yml' || $file eq 'Chart.yml'; return 1 if $file eq 'PKGBUILD'; } return 0; diff --git a/build-recipe b/build-recipe index a5088fa17..34244cdb4 100644 --- a/build-recipe +++ b/build-recipe @@ -125,7 +125,7 @@ recipe_set_buildtype() { PKGBUILD) BUILDTYPE=arch ;; snapcraft.yaml) BUILDTYPE=snapcraft ;; appimage.yml) BUILDTYPE=appimage ;; - Dockerfile|Dockerfile.*) BUILDTYPE=docker ;; + Containerfile|Containerfile.*|Dockerfile|Dockerfile.*) BUILDTYPE=docker ;; fissile.yml) BUILDTYPE=fissile ;; build.collax) BUILDTYPE=collax ;; _preinstallimage) BUILDTYPE=preinstallimage ;; @@ -191,7 +191,7 @@ expand_recipe_directories() { mkosi) types="mkosi." ;; esac fi - types="$types .spec _specsubdir:package _specsubdir:dist .dsc PKGBUILD Dockerfile build.collax .kiwi .src.rpm .nosrc.rpm simpleimage snapcraft.yaml Chart.yaml flatpak.yaml flatpak.json mkosi." + types="$types .spec _specsubdir:package _specsubdir:dist .dsc PKGBUILD Containerfile Dockerfile build.collax .kiwi .src.rpm .nosrc.rpm simpleimage snapcraft.yaml Chart.yaml flatpak.yaml flatpak.json mkosi." fi for t in $types ; do found= diff --git a/download_assets b/download_assets index b7878c9fb..58fe69469 100755 --- a/download_assets +++ b/download_assets @@ -153,7 +153,7 @@ 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 =~ /^Dockerfile\./ || $file =~ /\.(?:spec|dsc|kiwi)/; + next unless $file eq 'sources' || $file eq 'go.sum' || $file eq 'PKGBUILD' || $file eq 'Containerfile'|| $file eq 'Dockerfile' || $file =~ /^(?:Container|Docker)file\./ || $file =~ /\.(?:spec|dsc|kiwi)/; find_assets($assetmgr, $bconf, $p, $file); } }