1
0
forked from brl/citadel-tools

Install bzImage files with kernel version suffix

This commit is contained in:
Bruce Leidl 2019-08-21 00:26:03 -04:00
parent ba29516212
commit 8ec6f87a22
2 changed files with 31 additions and 13 deletions

View File

@ -5,7 +5,7 @@ use std::fs;
use std::thread::{self,JoinHandle};
use std::time::{self,Instant};
use libcitadel::Result;
use libcitadel::{Result, UtsName};
use libcitadel::ResourceImage;
use crate::boot::disks;
use crate::boot::rootfs::setup_rootfs_resource;
@ -47,7 +47,7 @@ fn try_copy_artifacts() -> Result<bool> {
deploy_artifacts()?;
return Ok(true);
}
for part in disks::DiskPartition::boot_partitions()? {
for part in disks::DiskPartition::boot_partitions(false)? {
part.mount("/boot")?;
if rootfs_image.exists() {
@ -60,6 +60,12 @@ fn try_copy_artifacts() -> Result<bool> {
Ok(false)
}
fn kernel_version() -> String {
let utsname = UtsName::uname();
let v = utsname.release().split('-').collect::<Vec<_>>();
v[0].to_string()
}
fn deploy_artifacts() -> Result<()> {
let run_images = Path::new(IMAGE_DIRECTORY);
if !run_images.exists() {
@ -72,8 +78,12 @@ fn deploy_artifacts() -> Result<()> {
println!("Copying {:?} from /boot/images to /run/citadel/images", entry.file_name());
fs::copy(entry.path(), run_images.join(entry.file_name()))?;
}
println!("Copying bzImage to /run/citadel/images");
fs::copy("/boot/bzImage", "/run/citadel/images/bzImage")?;
let kv = kernel_version();
println!("Copying bzImage-{} to /run/citadel/images", kv);
let from = format!("/boot/bzImage-{}", kv);
let to = format!("/run/citadel/images/bzImage-{}", kv);
fs::copy(from, to)?;
println!("Copying bootx64.efi to /run/citadel/images");
fs::copy("/boot/EFI/BOOT/bootx64.efi", "/run/citadel/images/bootx64.efi")?;

View File

@ -92,8 +92,8 @@ timeout 5
";
const BOOT_CONF: &str = "\
title Subgraph OS (Citadel)
linux /bzImage
title Subgraph OS (Citadel $KERNEL_VERSION)
linux /bzImage-$KERNEL_VERSION
options root=/dev/mapper/rootfs $KERNEL_CMDLINE
";
@ -176,8 +176,9 @@ impl Installer {
pub fn verify(&self) -> Result<()> {
let kernel_img = self.kernel_imagename();
let bzimage = format!("bzImage-{}", self.kernel_version());
let artifacts = vec![
"bootx64.efi", "bzImage",
"bootx64.efi", bzimage.as_str(),
kernel_img.as_str(), EXTRA_IMAGE_NAME,
];
@ -290,11 +291,15 @@ impl Installer {
self.info("Writing /boot/loader/loader.conf")?;
fs::write(format!("{}/loader/loader.conf", INSTALL_MOUNT), LOADER_CONF)?;
let kernel_version = self.kernel_version();
self.info("Writing /boot/entries/boot.conf")?;
fs::write(format!("{}/loader/entries/boot.conf", INSTALL_MOUNT),
BOOT_CONF.replace("$KERNEL_CMDLINE", KERNEL_CMDLINE))?;
fs::write(format!("{}/loader/entries/boot.conf", INSTALL_MOUNT), BOOT_CONF
.replace("$KERNEL_CMDLINE", KERNEL_CMDLINE)
.replace("$KERNEL_VERSION", &kernel_version)
)?;
self.copy_artifact("bzImage", INSTALL_MOUNT)?;
let kernel_bzimage = format!("bzImage-{}", kernel_version);
self.copy_artifact(&kernel_bzimage, INSTALL_MOUNT)?;
self.copy_artifact("bootx64.efi", format!("{}/EFI/BOOT", INSTALL_MOUNT))?;
if self.install_syslinux {
@ -306,7 +311,6 @@ impl Installer {
if self.install_syslinux {
self.setup_syslinux_post_umount()?;
}
Ok(())
}
@ -488,10 +492,14 @@ impl Installer {
}
}
fn kernel_imagename(&self) -> String {
fn kernel_version(&self) -> String {
let utsname = UtsName::uname();
let v = utsname.release().split('-').collect::<Vec<_>>();
format!("citadel-kernel-{}.img", v[0])
v[0].to_string()
}
fn kernel_imagename(&self) -> String {
format!("citadel-kernel-{}.img", self.kernel_version())
}
fn target_partition(&self, num: usize) -> String {