-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: Merge osbuildbootc into here, use osbuild/images PR
- Take the code from https://github.com/achilleas-k/images/tree/bifrost-image/cmd/osbuild-deploy-container and merge it into this repository, using the code from osbuild/images#243 as a `replace` - Also merge in osbuildbootc
- Loading branch information
Showing
2,386 changed files
with
811,556 additions
and
1,907 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
FROM quay.io/fedora/fedora:39 as builder | ||
FROM registry.fedoraproject.org/fedora:39 AS builder | ||
RUN dnf -y install golang make | ||
COPY . /src | ||
RUN cd /src && make && make install DESTDIR=/instroot | ||
|
||
FROM quay.io/fedora/fedora:39 | ||
COPY --from=builder /instroot / | ||
RUN /usr/lib/osbuildbootc/installdeps.sh | ||
ENTRYPOINT ["osbuildbootc"] | ||
ENTRYPOINT ["osbuildbootc"] |
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,9 @@ | ||
FROM quay.io/fedora/fedora:39 as builder | ||
RUN dnf -y install golang make | ||
COPY . /src | ||
RUN cd /src && make && make install DESTDIR=/instroot | ||
|
||
FROM quay.io/fedora/fedora:39 | ||
COPY --from=builder /instroot / | ||
RUN /usr/lib/osbuildbootc/installdeps.sh | ||
ENTRYPOINT ["osbuildbootc"] |
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,53 @@ | ||
|
||
# osbuildbootc | ||
|
||
## Usage | ||
|
||
This tool can be invoked as a pre-built container image, and it can also be installed | ||
as a standalone tool inside another environment. The implementation uses qemu+KVM. | ||
|
||
Example invocation for the container image: | ||
|
||
```bash | ||
podman run --rm -ti --security-opt label=disable --device /dev/kvm -v $(pwd):/srv -w /srv ghcr.io/cgwalters/osbuildbootc:latest build-qcow2 -I quay.io/cgwalters/ostest example.qcow2 | ||
``` | ||
|
||
Explanation of podman arguments: | ||
|
||
- `--security-opt label=disable`: This is necessary to bind mount in host paths at all | ||
- `--device /dev/kvm`: Pass the KVM device into the container image | ||
- `-v $(pwd):/srv -w /srv`: Pass the current directory as `/srv` into the container | ||
|
||
Note that by default KVM is required. You can set the `OSBUILD_NO_KVM` environment variable | ||
to use full qemu emulation if necessary. | ||
|
||
### Take a container image from remote registry, output a qcow2 | ||
|
||
```bash | ||
osbuildbootc build-qcow2 quay.io/centos-boot/fedora-boot-cloud:eln fedora-boot-cloud.qcow2 | ||
``` | ||
|
||
### Take a container image stored in local OCI directory | ||
|
||
In some scenarios it may be desirable to have local disk caches of container images, | ||
instead of fetching from a registry every time. | ||
|
||
Note here we need to specify the *target* image after installtion to ensure that | ||
the machine will fetch updates from the registry. | ||
|
||
```bash | ||
osbuildbootc build-qcow2 --transport oci oci:cgwalters-ostest -I -t quay.io/cgwalters/ostest foo.qcow2 | ||
``` | ||
|
||
## Development | ||
|
||
This project is mostly in Go. However, it also has some shell script because | ||
some nontrivial code was inherited from [coreos-assembler](https://github.com/coreos/coreos-assembler/). | ||
|
||
It's recommended to use e.g. [a toolbox](https://github.com/containers/toolbox/) for development: | ||
|
||
```bash | ||
make && sudo make install | ||
``` | ||
|
||
Then you can run `osbuildbootc`. |
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 |
---|---|---|
@@ -1,52 +1,14 @@ | ||
# osbuildbootc | ||
# Tooling for generating disk images from bootc images | ||
|
||
## Usage | ||
This project currently merges two tools with unrelated history, called | ||
`osbuild-deploy-container` and `osbuildbootc`. | ||
|
||
This tool can be invoked as a pre-built container image, and it can also be installed | ||
as a standalone tool inside another environment. The implementation uses qemu+KVM. | ||
For more on bootc, see [its upstream repository](https://github.com/containers/bootc). | ||
|
||
Example invocation for the container image: | ||
## osbuild-deploy-container | ||
|
||
```bash | ||
podman run --rm -ti --security-opt label=disable --device /dev/kvm -v $(pwd):/srv -w /srv ghcr.io/cgwalters/osbuildbootc:latest build-qcow2 -I quay.io/cgwalters/ostest example.qcow2 | ||
``` | ||
See [README.md.osbuild-deploy-container](README.md.osbuild-deploy-container) | ||
|
||
Explanation of podman arguments: | ||
## osbuildbootc | ||
|
||
- `--security-opt label=disable`: This is necessary to bind mount in host paths at all | ||
- `--device /dev/kvm`: Pass the KVM device into the container image | ||
- `-v $(pwd):/srv -w /srv`: Pass the current directory as `/srv` into the container | ||
|
||
Note that by default KVM is required. You can set the `OSBUILD_NO_KVM` environment variable | ||
to use full qemu emulation if necessary. | ||
|
||
### Take a container image from remote registry, output a qcow2 | ||
|
||
```bash | ||
osbuildbootc build-qcow2 quay.io/centos-boot/fedora-boot-cloud:eln fedora-boot-cloud.qcow2 | ||
``` | ||
|
||
### Take a container image stored in local OCI directory | ||
|
||
In some scenarios it may be desirable to have local disk caches of container images, | ||
instead of fetching from a registry every time. | ||
|
||
Note here we need to specify the *target* image after installtion to ensure that | ||
the machine will fetch updates from the registry. | ||
|
||
```bash | ||
osbuildbootc build-qcow2 --transport oci oci:cgwalters-ostest -I -t quay.io/cgwalters/ostest foo.qcow2 | ||
``` | ||
|
||
## Development | ||
|
||
This project is mostly in Go. However, it also has some shell script because | ||
some nontrivial code was inherited from [coreos-assembler](https://github.com/coreos/coreos-assembler/). | ||
|
||
It's recommended to use e.g. [a toolbox](https://github.com/containers/toolbox/) for development: | ||
|
||
```bash | ||
make && sudo make install | ||
``` | ||
|
||
Then you can run `osbuildbootc`. | ||
See [README.md.osbuildbootc](README.md.osbuildbootc) |
File renamed without changes.
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,58 @@ | ||
{ | ||
"aarch64": [ | ||
{ | ||
"baseurl": "https://odcs.fedoraproject.org/composes/production/latest-Fedora-ELN/compose/BaseOS/aarch64/os/", | ||
"name": "baseos" | ||
}, | ||
{ | ||
"baseurl": "https://odcs.fedoraproject.org/composes/production/latest-Fedora-ELN/compose/AppStream/aarch64/os/", | ||
"name": "appstream" | ||
}, | ||
{ | ||
"baseurl": "https://odcs.fedoraproject.org/composes/production/latest-Fedora-ELN/compose/CRB/aarch64/os/", | ||
"name": "crb" | ||
} | ||
], | ||
"ppc64le": [ | ||
{ | ||
"baseurl": "https://odcs.fedoraproject.org/composes/production/latest-Fedora-ELN/compose/BaseOS/ppc64le/os/", | ||
"name": "baseos" | ||
}, | ||
{ | ||
"baseurl": "https://odcs.fedoraproject.org/composes/production/latest-Fedora-ELN/compose/AppStream/ppc64le/os/", | ||
"name": "appstream" | ||
}, | ||
{ | ||
"baseurl": "https://odcs.fedoraproject.org/composes/production/latest-Fedora-ELN/compose/CRB/ppc64le/os/", | ||
"name": "crb" | ||
} | ||
], | ||
"s390x": [ | ||
{ | ||
"baseurl": "https://odcs.fedoraproject.org/composes/production/latest-Fedora-ELN/compose/BaseOS/s390x/os/", | ||
"name": "baseos" | ||
}, | ||
{ | ||
"baseurl": "https://odcs.fedoraproject.org/composes/production/latest-Fedora-ELN/compose/AppStream/s390x/os/", | ||
"name": "appstream" | ||
}, | ||
{ | ||
"baseurl": "https://odcs.fedoraproject.org/composes/production/latest-Fedora-ELN/compose/CRB/s390x/os/", | ||
"name": "crb" | ||
} | ||
], | ||
"x86_64": [ | ||
{ | ||
"baseurl": "https://odcs.fedoraproject.org/composes/production/latest-Fedora-ELN/compose/BaseOS/x86_64/os/", | ||
"name": "baseos" | ||
}, | ||
{ | ||
"baseurl": "https://odcs.fedoraproject.org/composes/production/latest-Fedora-ELN/compose/AppStream/x86_64/os/", | ||
"name": "appstream" | ||
}, | ||
{ | ||
"baseurl": "https://odcs.fedoraproject.org/composes/production/latest-Fedora-ELN/compose/CRB/x86_64/os/", | ||
"name": "crb" | ||
} | ||
] | ||
} |
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,113 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"math/rand" | ||
|
||
"github.com/osbuild/images/internal/common" | ||
"github.com/osbuild/images/internal/users" | ||
"github.com/osbuild/images/internal/workload" | ||
"github.com/osbuild/images/pkg/blueprint" | ||
"github.com/osbuild/images/pkg/container" | ||
"github.com/osbuild/images/pkg/disk" | ||
"github.com/osbuild/images/pkg/image" | ||
"github.com/osbuild/images/pkg/manifest" | ||
"github.com/osbuild/images/pkg/ostree" | ||
"github.com/osbuild/images/pkg/platform" | ||
"github.com/osbuild/images/pkg/rpmmd" | ||
"github.com/osbuild/images/pkg/runner" | ||
) | ||
|
||
func Manifest(imageref string, config *BuildConfig, repos []rpmmd.RepoConfig, arch string, seed int64) (*manifest.Manifest, error) { | ||
|
||
source := rand.NewSource(seed) | ||
|
||
// math/rand is good enough in this case | ||
/* #nosec G404 */ | ||
rng := rand.New(source) | ||
|
||
baseImage := &ostree.ImageOptions{ | ||
Container: imageref, | ||
TLSVerify: common.ToPtr(true), | ||
} | ||
|
||
img, err := pipelines(baseImage, config, arch, rng) | ||
if err != nil { | ||
fail(err.Error()) | ||
} | ||
mf := manifest.New() | ||
mf.Distro = manifest.DISTRO_FEDORA | ||
runner := &runner.Fedora{Version: 39} | ||
_, err = img.InstantiateManifest(&mf, repos, runner, rng) | ||
|
||
return &mf, err | ||
} | ||
|
||
func pipelines(baseImage *ostree.ImageOptions, config *BuildConfig, arch string, rng *rand.Rand) (image.ImageKind, error) { | ||
if baseImage == nil { | ||
fail("pipeline: no base image defined") | ||
} | ||
ref := "ostree/1/1/0" | ||
containerSource := container.SourceSpec{ | ||
Source: baseImage.Container, | ||
Name: baseImage.Container, | ||
TLSVerify: baseImage.TLSVerify, | ||
} | ||
|
||
img := image.NewOSTreeContainerDiskImage(containerSource, ref) | ||
|
||
var customizations *blueprint.Customizations | ||
if config != nil && config.Blueprint != nil { | ||
customizations = config.Blueprint.Customizations | ||
} | ||
img.Users = users.UsersFromBP(customizations.GetUsers()) | ||
img.Groups = users.GroupsFromBP(customizations.GetGroups()) | ||
|
||
img.KernelOptionsAppend = []string{ | ||
"rw", | ||
"console=tty0", | ||
"console=ttyS0", | ||
} | ||
|
||
img.SysrootReadOnly = true | ||
|
||
switch arch { | ||
case platform.ARCH_X86_64.String(): | ||
img.Platform = &platform.X86{ | ||
BasePlatform: platform.BasePlatform{ | ||
ImageFormat: platform.FORMAT_QCOW2, | ||
}, | ||
BIOS: true, | ||
UEFIVendor: "fedora", | ||
} | ||
case platform.ARCH_AARCH64.String(): | ||
img.Platform = &platform.Aarch64{ | ||
UEFIVendor: "fedora", | ||
BasePlatform: platform.BasePlatform{ | ||
ImageFormat: platform.FORMAT_QCOW2, | ||
QCOW2Compat: "1.1", | ||
}, | ||
} | ||
} | ||
|
||
img.OSName = "default" | ||
|
||
if kopts := customizations.GetKernel(); kopts != nil && kopts.Append != "" { | ||
img.KernelOptionsAppend = append(img.KernelOptionsAppend, kopts.Append) | ||
} | ||
|
||
img.Workload = &workload.Custom{} | ||
|
||
basept, ok := partitionTables[arch] | ||
if !ok { | ||
fail(fmt.Sprintf("pipelines: no partition tables defined for %s", arch)) | ||
} | ||
size := uint64(10 * common.GibiByte) | ||
pt, err := disk.NewPartitionTable(&basept, nil, size, disk.RawPartitioningMode, nil, rng) | ||
check(err) | ||
img.PartitionTable = pt | ||
|
||
img.Filename = "disk.qcow2" | ||
|
||
return img, nil | ||
} |
Oops, something went wrong.