Skip to content
Open
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
1 change: 1 addition & 0 deletions .fmf/version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
62 changes: 62 additions & 0 deletions .packit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
# See the documentation for more information:
# https://packit.dev/docs/configuration/

# name in upstream package repository or registry
upstream_package_name: bootupd
upstream_tag_template: v{version}

downstream_package_name: rust-bootupd

specfile_path: contrib/packaging/bootupd.spec

srpm_build_deps:
- cargo
- git
- libzstd-devel
- openssl-devel
- zstd

actions:
# The last setp here is required by Packit to return the archive name
# https://packit.dev/docs/configuration/actions#create-archive
create-archive:
- bash -c "cargo install cargo-vendor-filterer"
- bash -c "cargo xtask spec"
- bash -c "cat target/bootupd.spec"
- bash -c "cp target/bootupd* contrib/packaging/"
- bash -c "ls -1 target/bootupd*.tar.zstd | grep -v 'vendor'"
# Do nothing with spec file. Two steps here are for debugging
fix-spec-file:
- bash -c "cat contrib/packaging/bootupd.spec"
- bash -c "ls -al contrib/packaging/"

jobs:
- job: copr_build
trigger: pull_request
targets:
- fedora-rawhide-aarch64
- fedora-rawhide-x86_64

- job: tests
trigger: pull_request
targets:
- fedora-rawhide-aarch64
- fedora-rawhide-x86_64
tmt_plan: /tmt/plans/package

- job: propose_downstream
trigger: release
dist_git_branches:
fedora-rawhide:
fast_forward_merge_into: [fedora-latest-stable]

- job: koji_build
trigger: commit
dist_git_branches:
- fedora-all

- job: bodhi_update
trigger: commit
dist_git_branches:
- fedora-all
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ openssl = "^0.10"
os-release = "0.1.0"
regex = "1.12.2"
rpm-rs = { package = "rpm", version = "0.16.1", default-features = false, optional = true }
rustix = { version = "1.1.3", features = ["process", "fs"] }
rustix = { version = "1.1.3", features = ["process", "fs", "mount"] }
serde = { version = "^1.0", features = ["derive"] }
serde_json = "^1.0"
tempfile = "^3.24"
Expand Down
2 changes: 1 addition & 1 deletion contrib/packaging/bootupd.spec
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Summary: Bootloader updater

License: Apache-2.0
URL: https://github.com/coreos/bootupd
Source0: %{crates_source}
Source0: %{url}/releases/download/v%{version}/bootupd-%{version}.tar.zstd
Source1: %{url}/releases/download/v%{version}/bootupd-%{version}-vendor.tar.zstd
%if 0%{?fedora} || 0%{?rhel} >= 10
ExcludeArch: %{ix86}
Expand Down
5 changes: 5 additions & 0 deletions src/bios.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,4 +276,9 @@ impl Component for Bios {
fn get_efi_vendor(&self, _: &Path) -> Result<Option<String>> {
Ok(None)
}

/// Package mode copy is EFI-only
fn package_mode_copy_to_boot(&self, _root: &Path) -> Result<()> {
Ok(())
}
}
16 changes: 16 additions & 0 deletions src/bootupd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,22 @@ pub(crate) fn client_run_migrate_static_grub_config() -> Result<()> {
Ok(())
}

/// Copy bootloader files from /usr/lib/efi to boot/ESP for package mode installations.
pub(crate) fn copy_to_boot(root: &Path) -> Result<()> {
let all_components = get_components_impl(false);
if all_components.is_empty() {
anyhow::bail!("No components available for this platform.");
}

for component in all_components.values() {
component
.package_mode_copy_to_boot(root)
.with_context(|| format!("Failed to copy component {} to boot", component.name()))?;
}

Ok(())
}

/// Writes a stripped GRUB config to `stripped_config_name`, removing lines between
/// `### BEGIN /etc/grub.d/15_ostree ###` and `### END /etc/grub.d/15_ostree ###`.
fn strip_grub_config_file(
Expand Down
5 changes: 5 additions & 0 deletions src/cli/bootupctl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ pub enum CtlBackend {
Generate(super::bootupd::GenerateOpts),
#[clap(name = "install", hide = true)]
Install(super::bootupd::InstallOpts),
#[clap(name = "copy-to-boot", hide = true)]
CopyToBoot,
}

#[derive(Debug, Parser)]
Expand Down Expand Up @@ -109,6 +111,9 @@ impl CtlCommand {
CtlVerb::Backend(CtlBackend::Install(opts)) => {
super::bootupd::DCommand::run_install(opts)
}
CtlVerb::Backend(CtlBackend::CopyToBoot) => {
super::bootupd::DCommand::run_copy_to_boot()
}
CtlVerb::MigrateStaticGrubConfig => Self::run_migrate_static_grub_config(),
}
}
Expand Down
11 changes: 11 additions & 0 deletions src/cli/bootupd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ pub enum DVerb {
GenerateUpdateMetadata(GenerateOpts),
#[clap(name = "install", about = "Install components")]
Install(InstallOpts),
#[clap(
name = "copy-to-boot",
about = "Copy bootloader files from /usr/lib/efi to ESP (package mode), EFI only"
)]
CopyToBoot,
}

#[derive(Debug, Parser)]
Expand Down Expand Up @@ -88,6 +93,7 @@ impl DCommand {
match self.cmd {
DVerb::Install(opts) => Self::run_install(opts),
DVerb::GenerateUpdateMetadata(opts) => Self::run_generate_meta(opts),
DVerb::CopyToBoot => Self::run_copy_to_boot(),
}
}

Expand Down Expand Up @@ -122,4 +128,9 @@ impl DCommand {
.context("boot data installation failed")?;
Ok(())
}

pub(crate) fn run_copy_to_boot() -> Result<()> {
bootupd::copy_to_boot(std::path::Path::new("/")).context("copying to boot failed")?;
Ok(())
}
}
3 changes: 3 additions & 0 deletions src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ pub(crate) trait Component {

/// Locating efi vendor dir
fn get_efi_vendor(&self, sysroot: &Path) -> Result<Option<String>>;

/// Copy from /usr/lib/efi to boot/ESP (package mode)
fn package_mode_copy_to_boot(&self, root: &Path) -> Result<()>;
}

/// Given a component name, create an implementation.
Expand Down
Loading