Skip to content

Commit

Permalink
(wip) refactor code, initial disk support
Browse files Browse the repository at this point in the history
  • Loading branch information
korewaChino committed Sep 23, 2023
1 parent dd0dbaf commit b09ab4b
Show file tree
Hide file tree
Showing 6 changed files with 464 additions and 68 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/arm-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: ARM cross-build test

on:
push:

jobs:
unit-test:
runs-on: ubuntu-latest
container:
image: ghcr.io/terrapkg/builder:f38
# priv
options: --cap-add=SYS_ADMIN --privileged

steps:
- uses: actions/checkout@v4

- name: Install dependencies
run: |
dnf install -y \
xorriso \
rpm \
limine \
systemd \
btrfs-progs \
e2fsprogs \
xfsprogs \
dosfstools \
grub2 \
grub2-efi \
uboot-images-armv8 \
uboot-tools \
rustc \
cargo
- uses: Swatinem/rust-cache@v2

- name: Build and install katsu
run: |
cargo install --path .
- name: Run test
run: |
pushd tests
katsu katsudon-arm.yaml
popd
50 changes: 47 additions & 3 deletions src/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,33 @@ use std::path::PathBuf;
use serde_derive::Deserialize;
use smartstring::alias::String as SStr;

#[derive(Deserialize, Debug)]
#[derive(Deserialize, Debug, Default, Clone)]
#[serde(rename_all = "lowercase")]
pub enum OutputFormat {
/// The ISO file will be created.
/// This is the default.
#[default]
Iso,
/// Generates a disk image
/// This is not implemented yet.
Disk,
}

// from string to enum
impl From<&str> for OutputFormat {
fn from(value: &str) -> Self {
match value.to_lowercase().as_str() {
"iso" => Self::Iso,
"disk" => Self::Disk,
_ => {
tracing::warn!("Unknown format: {}, setting ISO mode", value);
Self::Iso
}
}
}
}

#[derive(Deserialize, Debug, Clone)]
pub struct Config {
/// The name of the distro / edition.
/// This is used to name the directory with the ISO content.
Expand All @@ -26,9 +52,27 @@ pub struct Config {
pub dnf: Option<String>,
/// The volume id of the ISO file.
pub volid: String,
/// The system architecture.
/// - `x86` (default)
pub arch: Option<String>,
/// Output format.
pub format: OutputFormat,

/// The disk layout of the new system.
pub disk: Option<DiskLayout>,
}
#[derive(Deserialize, Debug, Clone)]
pub struct DiskLayout {
/// Create bootloader partition?
pub bootloader: bool,
/// Filesystem of the bootloader partition.
pub root_format: String,
/// Total size of the disk image.
pub disk_size: String,
}

#[derive(Deserialize, Debug)]

#[derive(Deserialize, Debug, Clone)]
pub struct System {
/// The release version of the new system.
pub releasever: u8,
Expand All @@ -46,7 +90,7 @@ pub struct System {
pub kernel_params: Option<String>,
}

#[derive(Deserialize, Debug)]
#[derive(Deserialize, Debug, Clone)]
pub struct Script {
/// The path to the init script.
/// The init script is run after the mountpoint is created but before the packages are installed.
Expand Down
Loading

0 comments on commit b09ab4b

Please sign in to comment.