Commit Graph

1451 Commits

Author SHA1 Message Date
Nalin Dahyabhai 705ba3b9b6 imagebuildah: try to rein in use of transport names in image specs
Try to limit which image transports we accept in stages, and scope the
ones that use path names to the context directory.  At some point
anything that isn't an image ID or pullable spec should start being
rejected.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-11-04 10:10:29 -05:00
Nalin Dahyabhai 7c58fc17f7 imagebuildah: use a longer-lived overlay over the build context
Mount a read-write overlay directory over the build context directory to
restore the ability to use it as a covert cache of sorts during the
lifetime of each platform's build, but in a way that still ensures that
we don't modify the real build context directory.

N.B.: builds where FROM in one stage referenced a relative path which
had been written to a bind-mounted default build context directory by an
earlier stage broke when we started making those bind mounts into
overlays to prevent/discard modifications to that directory, and while
this extends the lifetime of that overlay so that it's consistent
throughout the build, those relative path names are still going to point
to the wrong location.

Since we need to determine SELinux labeling before mounting the overlay,
go ahead and calculate the labels to use before creating the first
builder, and remove the logic that had whichever stage thought it was
the first one set them in its parent object for use by other stages, in
what was probably a racey way.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-11-03 18:07:34 -05:00
Nalin Dahyabhai 1e6bb467fe Add --metadata-file
Add a MetadataFile field to BuildOptions, to which we write a dictionary
of information about a just-committed image.

Pay more attention to sourceDateEpoch than to timestamp when we're
tagging an existing image with the intended destination name.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-10-21 12:17:11 -04:00
Nalin Dahyabhai 45da9cff3b Introduce CommitResults(), which returns a results struct
Add a CommitResults() method which returns a structure on success,
changing Commit() into a wrapper for it which returns a subset of the
data to keep its signature stable.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-10-21 12:15:41 -04:00
Adam Eijdenberg 8fa05dfd07 fix(build): make --tag oci-archive:xxx.tar work with simple images
Previously using outputing to a tar would fail with a simple `FROM xxx`
image.

This now will complete the copy (including passing through any specified
timestamp) and stop before trying to tag a non-registry stored result.

Signed-off-by: Adam Eijdenberg <adam@continusec.com>
2025-10-21 09:14:10 +11:00
openshift-merge-bot[bot] 991a731441
Merge pull request #6274 from userid0x0/cmdAdd_proxyFix
build,add: add support for corporate proxies
2025-10-17 17:13:55 +00:00
Nalin Dahyabhai 5a849d1765 commit: always return the config digest as the image ID
When committing, if we didn't get an image ID off the bat because the
image wasn't being committed to local storage, try to return the image's
configuration blob digest, which is what is traditionally used as the
image's ID.

This allows the --iidfile flag to write a value to a file in situations
where the image isn't being written to local storage.  The image ID is
of limited value in these cases, since we can't use it to look up the
image anywhere else, but at least we don't write a file that just has
the digest name prefix or log an empty string.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-10-14 11:17:41 -04:00
Nalin Dahyabhai a654d35349 Make some test files different from each other
In case there's some opportunistic hard linking going on, which might be
causing problems when the tests are packaged and run in an environment
which is wildly different from CI.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-10-02 09:20:50 -04:00
Nalin Dahyabhai 9cd4768bde tests/run.bats: "run masks" test: accept "unreadable" masked directories
When checking that certain directories are masked, treat the
readable-but-empty case as acceptable, as before, and now also accept
the actually-unreadable case, which can happen with crun 1.24.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-09-16 10:03:08 -04:00
Nalin Dahyabhai a18468f703 Run: create parent directories of mount targets with mode 0755
Relax the permissions on directories we create to hold mount targets,
from 0700 to 0755.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-09-16 09:57:13 -04:00
openshift-merge-bot[bot] 48ac5410cb
Merge pull request #6380 from nalind/go1.24
Update to Go 1.24
2025-09-15 18:41:48 +00:00
Nalin Dahyabhai 6e4d1ca83a tests/run.bats: "run masks" test: accept "unreadable" masked directories
When checking that certain directories are masked, treat the
readable-but-empty case as acceptable, as before, and now also accept
actually-unreadable case, which can happen with crun 1.24.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-09-10 15:34:41 -04:00
Nalin Dahyabhai 7aedebdccd modernize: JSON doesn't do "omitempty" structs, so stop asking
Drop the "omitempty" tag from the "json" tag on struct members that are
themselves structs, since the JSON encoder doesn't actually do that, per
golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-09-10 13:19:38 -04:00
Nalin Dahyabhai 16680a4dfd modernize: use strings.CutPrefix/SplitSeq/FieldsSeq
Use the CutPrefix(), SplitSeq(), and FieldsSeq() functions from the
strings package when chopping up or iterating over parts of strings, per
golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-09-10 13:11:00 -04:00
Nalin Dahyabhai 76c18c8970 chroot: use $PATH when finding commands
Use the $PATH from the runtime config, if it includes one, so that when
the command to run isn't an absolute path and the command isn't being
processed by the shell, exec.Command()'s internal call to
exec.LookPath() will find it.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-09-10 12:55:59 -04:00
Jan Kaluza a0a9ac6380 Switch common, storage and image to monorepo.
Signed-off-by: Jan Kaluza <jkaluza@redhat.com>
2025-08-29 15:04:28 +02:00
Nalin Dahyabhai c4cfbcda8d Handle tagged+digested references when processing --all-platforms
When checking the platforms of the base images, if we encounter a
reference which includes both a tag and a digest, work around it like
the pull logic does: try it without the tag.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-08-25 15:18:53 -04:00
Nalin Dahyabhai b436176d4a Add --transient-store global option
Add another global storage configuration option.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-08-18 15:11:35 -04:00
openshift-merge-bot[bot] b7de827961
Merge pull request #6341 from nalind/add-imagestore-flag
Support "--imagestore" global flags
2025-08-15 23:38:01 +00:00
Nalin Dahyabhai fc748f85a4 Support "--imagestore" global flags
Add the global --imagestore flag to the buildah command and to the copy
and imgtype test helpers.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-08-13 21:25:19 -04:00
Nalin Dahyabhai a20e25136f Commit: don't depend on MountImage(), because .imagestore
Fall back to creating a new builder with it if MountImage() fails on the
base image, because when the store is configured with its "imagestore"
option, that can happen.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-08-13 21:22:23 -04:00
Nalin Dahyabhai 69a50588c5 Rework how we decide what to filter out of layer diffs
After narrowing down the list of parent directories which we might need
to exclude to those which are present in the base image, filter them out
of the layer diff as it is generated.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-08-11 15:49:28 -04:00
Nalin Dahyabhai bf2cbe1645 Note that we have to build `true` first for the sake of its tests
Add a note that we need a test binary built for the sake of a few
conformance tests, for people who run the conformance tests directly
instead of using the top-level makefile target.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-08-11 15:49:28 -04:00
openshift-merge-bot[bot] 3ed8ff91a7
Merge pull request #6314 from nalind/no-more-instructions
imagebuildah.StageExecutor.Execute: commit more "no instructions" cases
2025-08-07 15:11:29 +00:00
openshift-merge-bot[bot] f753f46ac4
Merge pull request #6307 from nalind/reap
Run: reap stray processes
2025-08-07 15:08:26 +00:00
openshift-merge-bot[bot] d31fe58f41
Merge pull request #6310 from nalind/copy-dest-dot
copy: assume a destination with basename "." is a directory
2025-08-07 14:59:34 +00:00
Nalin Dahyabhai 2ae2ec75bc copy: assume a destination with basename "." is a directory
Assume that if the destination location for an ADD or COPY has a
basename of ".", that we're meant to treat it as a directory.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-08-06 12:57:10 -04:00
flouthoc e31b047293
generatePathChecksum: ignore ModTime, AccessTime and ChangeTime
When generating a checksum for files mounted into container via
`--mount=type=bind` ignore their `ModTime`, `AccessTime` and
`ChangeTime` so we can maintain cache burst consistency with `COPY`
command.

Closes: https://github.com/containers/buildah/issues/6291

Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2025-08-06 08:28:42 -07:00
openshift-merge-bot[bot] 9b4b85a159
Merge pull request #6315 from nalind/history-unset-label-timestamp
History should note unset-label, timestamp, and rewrite-timestamp
2025-08-06 08:50:00 +00:00
Nalin Dahyabhai 70d0451b86 History should note unset-label, timestamp, and rewrite-timestamp
Make the history created-by field note when a label was unset, or if the
one of the CLI flags that modifies the timestamps in the layer were
used, so that the cache evaluation logic can factor that into account.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-08-04 18:49:45 -04:00
Nalin Dahyabhai fb6ce9d07b imagebuildah.StageExecutor.Execute: commit more "no instructions" cases
When there are no instructions to process, we try to reuse the base
image.  When we've been told, out of band, to remove labels or
environment variables, or affect annotations, we still need to, though,
so check for values of more of those flags.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-08-04 14:30:25 -04:00
Nalin Dahyabhai 87f60f60c6 Only suppress "noted" items when not squashing
When suppressing what we think are pulled-up directories at commit-time,
only do that when we're _not_ squashing the image, in which case we
really do need to output it into the one layer that our output image
will have.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-08-01 16:55:16 -04:00
Nalin Dahyabhai 27c40b3dbe Reap stray processes
run: after we've picked up the exit status of the "main" process that
we're running, reap anything that was reparented to us before returning.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-08-01 13:30:47 -04:00
openshift-merge-bot[bot] 3b37ca6ad5
Merge pull request #6296 from nalind/pulled-up-directories
Exclude pulled up parent directories at commit-time
2025-07-28 21:14:39 +00:00
Romain Geissler f949a49ab0
Restore the default meaning of `--pull` (should be `always`).
Now the bud --help output correctly reads that the default behavior when
--pull is not provided at all is "missing", and that the default value
for --pull if explicitly provided but without value is "always".

Fixes #6266.

Signed-off-by: Romain Geissler <romain.geissler@amadeus.com>
2025-07-28 16:21:31 +00:00
Nalin Dahyabhai ff07ebc3ec Test that pulled up parent directories are excluded at commit
Add a test that causes parent directories of mount targets to be "pulled
up" if we're running on top of overlay in a situation where its native
diff method is available, and ensure that we can still avoid adding
those directories to the committed layer when we're the only reason they
were pulled up.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-07-24 13:13:53 -04:00
flouthoc 3502889676
stage_executor: check platform of cache candidates
When building images for `manifest` list using `--platform` same image
is used for multiple platform if base is `scratch` , following PR adds a
check to always verify `platform` of `cache` with `target`.

Closes: https://github.com/containers/podman/issues/18723

Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2025-07-11 09:44:07 -07:00
openshift-merge-bot[bot] 252cc24fd5
Merge pull request #6240 from 2004joshua/link
feat: ADD/COPY --link support for buildah
2025-07-11 15:27:00 +00:00
Alexander Merkle 2df30a83cb build,add: add support for corporate proxies
Use the Proxy Environment http_proxy/HTTPS_PROXY/NO_PROXY to handle the
http request.

Signed-off-by: Alexander Merkle <alexander.merkle@lauterbach.com>
2025-07-11 11:43:15 +02:00
Joshua Arrevillaga eea4838d88 ADD/COPY --link support added
What type of PR is this?
/kind feature

What this PR does / why we need it:
It implements --link for COPY and ADD instructions and enables the creation of
cachable layers that can be reused independently across builds.

Follows buildkit `--link` specifications

How to verify it
bats tests/bud.bats

Which issue(s) this PR fixes:
Fixes #4325

Does this PR introduce a user-facing change?
Yes, gives extra functionality to Containerfiles

Signed-off-by: Joshua Arrevillaga <2004jarrevillaga@gmail.com>
2025-07-09 17:14:28 -04:00
Lokesh Mandvekar 063ee76258
RPM/TMT: account for passwd binary moving to tests
Signed-off-by: Lokesh Mandvekar <lsm5@redhat.com>
Co-authored-by: flouthoc <flouthoc.git@gmail.com>
Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2025-07-09 06:31:09 -07:00
flouthoc af210ea877
buildah: move passwd command to tests
https://github.com/containers/buildah/issues/6182

Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2025-07-09 06:31:04 -07:00
openshift-merge-bot[bot] f67acf9a69
Merge pull request #6267 from rahilarious/main
Remove BUILDTAG btrfs_noversion as no longer effective
2025-07-09 09:21:08 +00:00
Nalin Dahyabhai 16c0bdad5f Update "bud with --cpu-shares" test, and rename it
Update "the bud with --cpu-shares" test to expect the a cgroupsv2 value
computed using either the older formula or the newer one introduced in
github.com/opencontainers/cgroups v0.0.3, and give it a unique name so
that it can be selected more easily with bats's "--filter" flag.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-07-08 16:38:40 -04:00
Rahil Bhimjiani 7a482acebc
Remove BUILDTAG btrfs_noversion as no longer effective
https://github.com/containers/storage/pull/2308

Signed-off-by: Rahil Bhimjiani <me@rahil.rocks>
2025-07-07 19:30:09 +05:30
openshift-merge-bot[bot] f28c074787
Merge pull request #6247 from nalind/source-date-epoch-build-arg
Accept SOURCE_DATE_EPOCH as a build-arg
2025-06-26 19:30:16 +00:00
openshift-merge-bot[bot] 9f6205610c
Merge pull request #6242 from nalind/common-formats
Use containers/common's formats package instead of our own
2025-06-25 19:53:42 +00:00
openshift-merge-bot[bot] f828ea2f75
Merge pull request #6243 from cevich/add_release_test
Add conditional release-checking system test
2025-06-25 19:26:02 +00:00
Nalin Dahyabhai 149bf968f5 Accept SOURCE_DATE_EPOCH as a build-arg
When SOURCE_DATE_EPOCH is passed in as a build-arg, treat it as we would
if it was passed in via the environment or its own CLI flag.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-06-25 15:19:32 -04:00
Chris Evich 0832c3e081
Add conditional release-checking system test
Unfortunately on a number of occasions, Buildah has been released
officially with a `-dev` suffix in the version number.  Assist in
catching this mistake at release time by the addition of a simple
conditional test.  Note that it must be positively enabled by a
magic env. var. before executing the system tests.

Also (thanks to @lsm5) update the TMT test to trigger the new
condition for future Fedora releases.

Signed-off-by: Chris Evich <cevich@redhat.com>
2025-06-24 10:57:46 -04:00