Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iso: be able to build the ISO #58

Merged
merged 7 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ jobs:
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup up python
uses: actions/setup-python@v5
- name: Apt update
run: sudo apt update
- name: Install test dependencies
run: |
sudo apt update
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ The following image types are currently available via the `--type` argument:
|-----------------------|---------------------------------------------------------------------------------------|
| `ami` | [Amazon Machine Image](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AMIs.html) |
| `qcow2` **(default)** | [QEMU](https://www.qemu.org/) |
| `iso` | An unattended Anaconda installer that installs to the first disk found. |

## ☁️ Cloud uploaders

Expand Down
166 changes: 166 additions & 0 deletions bib/cmd/bootc-image-builder/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ func Manifest(c *ManifestConfig) (*manifest.Manifest, error) {
fallthrough
case "ami":
img, err = pipelinesForDiskImage(c, rng)
case "iso":
img, err = pipelinesForISO(c, rng)
default:
fail(fmt.Sprintf("Manifest(): unsupported image type %q", c.ImgType))
}
Expand Down Expand Up @@ -154,6 +156,170 @@ func pipelinesForDiskImage(c *ManifestConfig, rng *rand.Rand) (image.ImageKind,
return img, nil
}

func pipelinesForISO(c *ManifestConfig, rng *rand.Rand) (image.ImageKind, error) {
if c.Imgref == "" {
fail("pipeline: no base image defined")
}

containerSource := container.SourceSpec{
Source: c.Imgref,
Name: c.Imgref,
TLSVerify: &c.TLSVerify,
}

// The ref is not needed and will be removed from the ctor later
// in time
img := image.NewAnacondaContainerInstaller(containerSource, "")
img.SquashfsCompression = "zstd"
supakeen marked this conversation as resolved.
Show resolved Hide resolved

img.ExtraBasePackages = rpmmd.PackageSet{
Include: []string{
"aajohan-comfortaa-fonts",
"abattis-cantarell-fonts",
"alsa-firmware",
"alsa-tools-firmware",
"anaconda",
"anaconda-dracut",
"anaconda-install-env-deps",
"anaconda-widgets",
"atheros-firmware",
"audit",
"bind-utils",
"bitmap-fangsongti-fonts",
"brcmfmac-firmware",
"bzip2",
"cryptsetup",
"curl",
"dbus-x11",
"dejavu-sans-fonts",
"dejavu-sans-mono-fonts",
"device-mapper-persistent-data",
"dmidecode",
"dnf",
"dracut-config-generic",
"dracut-network",
"efibootmgr",
"ethtool",
"fcoe-utils",
"ftp",
"gdb-gdbserver",
"gdisk",
"glibc-all-langpacks",
"gnome-kiosk",
"google-noto-sans-cjk-ttc-fonts",
"grub2-tools",
"grub2-tools-extra",
"grub2-tools-minimal",
"grubby",
"gsettings-desktop-schemas",
"hdparm",
"hexedit",
"hostname",
"initscripts",
"ipmitool",
"iwlwifi-dvm-firmware",
"iwlwifi-mvm-firmware",
"jomolhari-fonts",
"kbd",
"kbd-misc",
"kdump-anaconda-addon",
"kernel",
"khmeros-base-fonts",
"less",
"libblockdev-lvm-dbus",
"libibverbs",
"libreport-plugin-bugzilla",
"libreport-plugin-reportuploader",
"librsvg2",
"linux-firmware",
"lldpad",
"lsof",
"madan-fonts",
"mt-st",
"mtr",
"net-tools",
"nfs-utils",
"nm-connection-editor",
"nmap-ncat",
"nss-tools",
"openssh-clients",
"openssh-server",
"ostree",
"pciutils",
"perl-interpreter",
"pigz",
"plymouth",
"python3-pyatspi",
"rdma-core",
"realtek-firmware",
"rit-meera-new-fonts",
"rng-tools",
"rpcbind",
"rpm-ostree",
"rsync",
"rsyslog",
"selinux-policy-targeted",
"sg3_utils",
"sil-abyssinica-fonts",
"sil-padauk-fonts",
"smartmontools",
"spice-vdagent",
"strace",
"systemd",
"tar",
"tigervnc-server-minimal",
"tigervnc-server-module",
"udisks2",
"udisks2-iscsi",
"usbutils",
"vim-minimal",
"volume_key",
"wget",
"xfsdump",
"xfsprogs",
"xorg-x11-drivers",
"xorg-x11-fonts-misc",
"xorg-x11-server-Xorg",
"xorg-x11-xauth",
"xrdb",
"xz",
},
}

img.ISOLabelTempl = "Container-Installer-%s"

var customizations *blueprint.Customizations
if c.Config != nil && c.Config.Blueprint != nil {
customizations = c.Config.Blueprint.Customizations
}

img.Users = users.UsersFromBP(customizations.GetUsers())
img.Groups = users.GroupsFromBP(customizations.GetGroups())

switch c.Architecture {
case arch.ARCH_X86_64:
img.Platform = &platform.X86{
BasePlatform: platform.BasePlatform{
ImageFormat: platform.FORMAT_ISO,
},
BIOS: true,
UEFIVendor: "fedora",
ondrejbudai marked this conversation as resolved.
Show resolved Hide resolved
}
case arch.ARCH_AARCH64:
img.Platform = &platform.Aarch64{
BasePlatform: platform.BasePlatform{
ImageFormat: platform.FORMAT_ISO,
},
UEFIVendor: "fedora",
}
}

img.OSName = "default"
img.Filename = "install.iso"

return img, nil
}

func createRand() *rand.Rand {
seed, err := cryptorand.Int(cryptorand.Reader, big.NewInt(math.MaxInt64))
if err != nil {
Expand Down
7 changes: 5 additions & 2 deletions bib/cmd/bootc-image-builder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ func makeManifest(c *ManifestConfig, cacheRoot string) (manifest.OSBuildManifest
return nil, err
}
}

mf, err := manifest.Serialize(depsolvedSets, containerSpecs, nil)
if err != nil {
fail(fmt.Sprintf("[ERROR] manifest serialization failed: %s", err.Error()))
Expand Down Expand Up @@ -200,8 +201,10 @@ func build(cmd *cobra.Command, args []string) {
exports = []string{"qcow2"}
case "ami":
exports = []string{"image"}
case "iso":
exports = []string{"bootiso"}
default:
fail(fmt.Sprintf("valid types are 'qcow2', 'ami', not: '%s'", imgType))
fail(fmt.Sprintf("valid types are 'qcow2', 'ami', 'iso', not: '%s'", imgType))
}

manifest_fname := fmt.Sprintf("manifest-%s.json", imgType)
Expand Down Expand Up @@ -266,7 +269,7 @@ func main() {
buildCmd.Flags().String("store", ".osbuild", "osbuild store for intermediate pipeline trees")
buildCmd.Flags().String("rpmmd", "/var/cache/osbuild/rpmmd", "rpm metadata cache directory")
buildCmd.Flags().String("config", "", "build config file")
buildCmd.Flags().String("type", "qcow2", "image type to build [qcow2, ami]")
buildCmd.Flags().String("type", "qcow2", "image type to build [qcow2, ami, iso]")
buildCmd.Flags().Bool("tls-verify", true, "require HTTPS and verify certificates when contacting registries")
buildCmd.Flags().String("aws-region", "", "target region for AWS uploads (only for type=ami)")
buildCmd.Flags().String("aws-bucket", "", "target S3 bucket name for intermediate storage when creating AMI (only for type=ami)")
Expand Down
Loading