Install bzImage files with kernel version suffix
This commit is contained in:
parent
ba29516212
commit
8ec6f87a22
@ -5,7 +5,7 @@ use std::fs;
|
|||||||
use std::thread::{self,JoinHandle};
|
use std::thread::{self,JoinHandle};
|
||||||
use std::time::{self,Instant};
|
use std::time::{self,Instant};
|
||||||
|
|
||||||
use libcitadel::Result;
|
use libcitadel::{Result, UtsName};
|
||||||
use libcitadel::ResourceImage;
|
use libcitadel::ResourceImage;
|
||||||
use crate::boot::disks;
|
use crate::boot::disks;
|
||||||
use crate::boot::rootfs::setup_rootfs_resource;
|
use crate::boot::rootfs::setup_rootfs_resource;
|
||||||
@ -47,7 +47,7 @@ fn try_copy_artifacts() -> Result<bool> {
|
|||||||
deploy_artifacts()?;
|
deploy_artifacts()?;
|
||||||
return Ok(true);
|
return Ok(true);
|
||||||
}
|
}
|
||||||
for part in disks::DiskPartition::boot_partitions()? {
|
for part in disks::DiskPartition::boot_partitions(false)? {
|
||||||
part.mount("/boot")?;
|
part.mount("/boot")?;
|
||||||
|
|
||||||
if rootfs_image.exists() {
|
if rootfs_image.exists() {
|
||||||
@ -60,6 +60,12 @@ fn try_copy_artifacts() -> Result<bool> {
|
|||||||
Ok(false)
|
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<()> {
|
fn deploy_artifacts() -> Result<()> {
|
||||||
let run_images = Path::new(IMAGE_DIRECTORY);
|
let run_images = Path::new(IMAGE_DIRECTORY);
|
||||||
if !run_images.exists() {
|
if !run_images.exists() {
|
||||||
@ -72,8 +78,12 @@ fn deploy_artifacts() -> Result<()> {
|
|||||||
println!("Copying {:?} from /boot/images to /run/citadel/images", entry.file_name());
|
println!("Copying {:?} from /boot/images to /run/citadel/images", entry.file_name());
|
||||||
fs::copy(entry.path(), run_images.join(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");
|
println!("Copying bootx64.efi to /run/citadel/images");
|
||||||
fs::copy("/boot/EFI/BOOT/bootx64.efi", "/run/citadel/images/bootx64.efi")?;
|
fs::copy("/boot/EFI/BOOT/bootx64.efi", "/run/citadel/images/bootx64.efi")?;
|
||||||
|
@ -92,8 +92,8 @@ timeout 5
|
|||||||
";
|
";
|
||||||
|
|
||||||
const BOOT_CONF: &str = "\
|
const BOOT_CONF: &str = "\
|
||||||
title Subgraph OS (Citadel)
|
title Subgraph OS (Citadel $KERNEL_VERSION)
|
||||||
linux /bzImage
|
linux /bzImage-$KERNEL_VERSION
|
||||||
options root=/dev/mapper/rootfs $KERNEL_CMDLINE
|
options root=/dev/mapper/rootfs $KERNEL_CMDLINE
|
||||||
";
|
";
|
||||||
|
|
||||||
@ -176,8 +176,9 @@ impl Installer {
|
|||||||
|
|
||||||
pub fn verify(&self) -> Result<()> {
|
pub fn verify(&self) -> Result<()> {
|
||||||
let kernel_img = self.kernel_imagename();
|
let kernel_img = self.kernel_imagename();
|
||||||
|
let bzimage = format!("bzImage-{}", self.kernel_version());
|
||||||
let artifacts = vec![
|
let artifacts = vec![
|
||||||
"bootx64.efi", "bzImage",
|
"bootx64.efi", bzimage.as_str(),
|
||||||
kernel_img.as_str(), EXTRA_IMAGE_NAME,
|
kernel_img.as_str(), EXTRA_IMAGE_NAME,
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -290,11 +291,15 @@ impl Installer {
|
|||||||
self.info("Writing /boot/loader/loader.conf")?;
|
self.info("Writing /boot/loader/loader.conf")?;
|
||||||
fs::write(format!("{}/loader/loader.conf", INSTALL_MOUNT), 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")?;
|
self.info("Writing /boot/entries/boot.conf")?;
|
||||||
fs::write(format!("{}/loader/entries/boot.conf", INSTALL_MOUNT),
|
fs::write(format!("{}/loader/entries/boot.conf", INSTALL_MOUNT), BOOT_CONF
|
||||||
BOOT_CONF.replace("$KERNEL_CMDLINE", KERNEL_CMDLINE))?;
|
.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))?;
|
self.copy_artifact("bootx64.efi", format!("{}/EFI/BOOT", INSTALL_MOUNT))?;
|
||||||
|
|
||||||
if self.install_syslinux {
|
if self.install_syslinux {
|
||||||
@ -306,7 +311,6 @@ impl Installer {
|
|||||||
if self.install_syslinux {
|
if self.install_syslinux {
|
||||||
self.setup_syslinux_post_umount()?;
|
self.setup_syslinux_post_umount()?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -488,10 +492,14 @@ impl Installer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn kernel_imagename(&self) -> String {
|
fn kernel_version(&self) -> String {
|
||||||
let utsname = UtsName::uname();
|
let utsname = UtsName::uname();
|
||||||
let v = utsname.release().split('-').collect::<Vec<_>>();
|
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 {
|
fn target_partition(&self, num: usize) -> String {
|
||||||
|
Loading…
Reference in New Issue
Block a user