forked from rpm-software-management/mock
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes: rpm-software-management#1482
- Loading branch information
Showing
2 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
""" | ||
Generate OCI from prepared build chroot. | ||
Use given OCI image as build chroot (TODO). | ||
""" | ||
|
||
from mockbuild.util import do | ||
|
||
requires_api_version = "1.1" | ||
|
||
|
||
def init(plugins, conf, buildroot): | ||
""" The obligatory plugin entry point """ | ||
OCIAsBuildroot(plugins, conf, buildroot) | ||
|
||
|
||
class OCIAsBuildroot: | ||
""" | ||
OCIAsBuildroot plugin (class). | ||
""" | ||
def __init__(self, plugins, conf, buildroot): | ||
self.buildroot = buildroot | ||
self.state = buildroot.state | ||
self.conf = conf | ||
plugins.add_hook("postdeps", self.produce_buildroot_image) | ||
|
||
def _produce_image_as_root(self): | ||
|
||
name = "mock-container-foo" | ||
tarball = "/tmp/mock.tar" | ||
chroot = self.buildroot.make_chroot_path() | ||
do(["buildah", "from", "--name", name, "scratch"]) | ||
do(["buildah", "add", name, chroot, "/"]) | ||
do(["buildah", "commit", "--format", "oci", name, | ||
"oci-archive:" + tarball]) | ||
|
||
def produce_buildroot_image(self): | ||
""" Generate OCI image from buildroot using Buildah """ | ||
with self.buildroot.uid_manager.elevated_privileges(): | ||
self._produce_image_as_root() |