mirror of
https://github.com/edera-dev/krata.git
synced 2025-08-02 12:50:54 +00:00
feat(build): fetch kernels from image registry instead of building the kernel (#156)
Now that we have the kernel build infrastructure at https://github.com/edera-dev/kernels it makes sense to drop building the kernel and download the kernel images directly. This change introduces a ./hack/kernel/fetch.sh script which is backed by crates/build We utilize the OCI infrastructure itself to download the kernel image. The DEV guide has been updated to include calling the fetch script, and the OS builder now uses this method instead. Due to the lack of need for the kernel build infra to exist here now, it has also been removed. This should significantly speed up full builds. This change will also enable us to turn on os build workflows for all PRs. We should likely make the OS status checks required once this is merged.
This commit is contained in:
parent
2462a99fdc
commit
d46aa878af
6
.github/workflows/check.yml
vendored
6
.github/workflows/check.yml
vendored
@ -11,8 +11,7 @@ jobs:
|
||||
name: fmt
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
|
||||
- uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
|
||||
with:
|
||||
egress-policy: audit
|
||||
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
|
||||
@ -27,8 +26,7 @@ jobs:
|
||||
name: shellcheck
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
|
||||
- uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
|
||||
with:
|
||||
egress-policy: audit
|
||||
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
|
||||
|
3
.github/workflows/client.yml
vendored
3
.github/workflows/client.yml
vendored
@ -27,8 +27,7 @@ jobs:
|
||||
run:
|
||||
shell: bash
|
||||
steps:
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
|
||||
- uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
|
||||
with:
|
||||
egress-policy: audit
|
||||
- run: git config --global core.autocrlf false && git config --global core.eol lf
|
||||
|
36
.github/workflows/kernel.yml
vendored
36
.github/workflows/kernel.yml
vendored
@ -1,36 +0,0 @@
|
||||
name: kernel
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- "kernel/**"
|
||||
- "hack/ci/**"
|
||||
merge_group:
|
||||
branches:
|
||||
- main
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
arch:
|
||||
- x86_64
|
||||
- aarch64
|
||||
env:
|
||||
TARGET_ARCH: "${{ matrix.arch }}"
|
||||
name: kernel build ${{ matrix.arch }}
|
||||
steps:
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
|
||||
with:
|
||||
egress-policy: audit
|
||||
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
|
||||
with:
|
||||
submodules: recursive
|
||||
- uses: dtolnay/rust-toolchain@d388a4836fcdbde0e50e395dc79a2670ccdef13f # stable
|
||||
- run: ./hack/ci/install-linux-deps.sh
|
||||
- run: ./hack/kernel/build.sh
|
||||
env:
|
||||
KRATA_KERNEL_BUILD_JOBS: "5"
|
8
.github/workflows/nightly.yml
vendored
8
.github/workflows/nightly.yml
vendored
@ -16,11 +16,9 @@ jobs:
|
||||
TARGET_ARCH: "${{ matrix.arch }}"
|
||||
name: nightly server ${{ matrix.arch }}
|
||||
steps:
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
|
||||
- uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
|
||||
with:
|
||||
submodules: recursive
|
||||
@ -80,11 +78,9 @@ jobs:
|
||||
run:
|
||||
shell: bash
|
||||
steps:
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
|
||||
- uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
- run: git config --global core.autocrlf false && git config --global core.eol lf
|
||||
if: ${{ matrix.platform.os == 'windows' }}
|
||||
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
|
||||
|
9
.github/workflows/os.yml
vendored
9
.github/workflows/os.yml
vendored
@ -3,10 +3,6 @@ on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- "os/**"
|
||||
- "hack/os/**"
|
||||
- "hack/ci/**"
|
||||
merge_group:
|
||||
branches:
|
||||
- main
|
||||
@ -23,8 +19,7 @@ jobs:
|
||||
TARGET_ARCH: "${{ matrix.arch }}"
|
||||
name: os build ${{ matrix.arch }}
|
||||
steps:
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
|
||||
- uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
|
||||
with:
|
||||
egress-policy: audit
|
||||
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
|
||||
@ -35,8 +30,6 @@ jobs:
|
||||
targets: "${{ matrix.arch }}-unknown-linux-gnu,${{ matrix.arch }}-unknown-linux-musl"
|
||||
- run: ./hack/ci/install-linux-deps.sh
|
||||
- run: ./hack/os/build.sh
|
||||
env:
|
||||
KRATA_KERNEL_BUILD_JOBS: "5"
|
||||
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
|
||||
with:
|
||||
name: krata-os-${{ matrix.arch }}
|
||||
|
14
.github/workflows/release-binaries.yml
vendored
14
.github/workflows/release-binaries.yml
vendored
@ -25,8 +25,7 @@ jobs:
|
||||
TARGET_ARCH: "${{ matrix.arch }}"
|
||||
name: release-binaries server ${{ matrix.arch }}
|
||||
steps:
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
|
||||
- uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
|
||||
with:
|
||||
egress-policy: audit
|
||||
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
|
||||
@ -37,20 +36,12 @@ jobs:
|
||||
targets: "${{ matrix.arch }}-unknown-linux-gnu,${{ matrix.arch }}-unknown-linux-musl"
|
||||
- run: ./hack/ci/install-linux-deps.sh
|
||||
- run: ./hack/dist/bundle.sh
|
||||
env:
|
||||
KRATA_KERNEL_BUILD_JOBS: "5"
|
||||
- run: "./hack/ci/assemble-release-assets.sh bundle-systemd ${{ github.event.release.tag_name }} ${{ matrix.arch }} target/dist/bundle-systemd-${{ matrix.arch }}.tgz"
|
||||
- run: ./hack/dist/deb.sh
|
||||
env:
|
||||
KRATA_KERNEL_BUILD_SKIP: "1"
|
||||
- run: "./hack/ci/assemble-release-assets.sh debian ${{ github.event.release.tag_name }} ${{ matrix.arch }} target/dist/*.deb"
|
||||
- run: ./hack/dist/apk.sh
|
||||
env:
|
||||
KRATA_KERNEL_BUILD_SKIP: "1"
|
||||
- run: "./hack/ci/assemble-release-assets.sh alpine ${{ github.event.release.tag_name }} ${{ matrix.arch }} target/dist/*_${{ matrix.arch }}.apk"
|
||||
- run: ./hack/os/build.sh
|
||||
env:
|
||||
KRATA_KERNEL_BUILD_SKIP: "1"
|
||||
- run: "./hack/ci/assemble-release-assets.sh os ${{ github.event.release.tag_name }} ${{ matrix.arch }} target/os/krata-${{ matrix.arch }}.qcow2"
|
||||
- run: "./hack/ci/upload-release-assets.sh ${{ github.event.release.tag_name }}"
|
||||
env:
|
||||
@ -76,8 +67,7 @@ jobs:
|
||||
shell: bash
|
||||
timeout-minutes: 60
|
||||
steps:
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
|
||||
- uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
|
||||
with:
|
||||
egress-policy: audit
|
||||
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
|
||||
|
41
.github/workflows/release-plz.yml
vendored
41
.github/workflows/release-plz.yml
vendored
@ -14,24 +14,23 @@ jobs:
|
||||
name: release-plz
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
|
||||
with:
|
||||
egress-policy: audit
|
||||
- uses: actions/create-github-app-token@a0de6af83968303c8c955486bf9739a57d23c7f1 # v1.10.0
|
||||
id: generate-token
|
||||
with:
|
||||
app-id: "${{ secrets.EDERA_CULTIVATION_APP_ID }}"
|
||||
private-key: "${{ secrets.EDERA_CULTIVATION_APP_PRIVATE_KEY }}"
|
||||
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
|
||||
with:
|
||||
submodules: recursive
|
||||
fetch-depth: 0
|
||||
token: "${{ steps.generate-token.outputs.token }}"
|
||||
- uses: dtolnay/rust-toolchain@d388a4836fcdbde0e50e395dc79a2670ccdef13f # stable
|
||||
- run: ./hack/ci/install-linux-deps.sh
|
||||
- name: release-plz
|
||||
uses: MarcoIeni/release-plz-action@a2904442184b59b09f10f6c7197cfa8e48bd2fc4 # v0.5.57
|
||||
env:
|
||||
GITHUB_TOKEN: "${{ steps.generate-token.outputs.token }}"
|
||||
CARGO_REGISTRY_TOKEN: "${{ secrets.KRATA_RELEASE_CARGO_TOKEN }}"
|
||||
- uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
|
||||
with:
|
||||
egress-policy: audit
|
||||
- uses: actions/create-github-app-token@a0de6af83968303c8c955486bf9739a57d23c7f1 # v1.10.0
|
||||
id: generate-token
|
||||
with:
|
||||
app-id: "${{ secrets.EDERA_CULTIVATION_APP_ID }}"
|
||||
private-key: "${{ secrets.EDERA_CULTIVATION_APP_PRIVATE_KEY }}"
|
||||
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
|
||||
with:
|
||||
submodules: recursive
|
||||
fetch-depth: 0
|
||||
token: "${{ steps.generate-token.outputs.token }}"
|
||||
- uses: dtolnay/rust-toolchain@d388a4836fcdbde0e50e395dc79a2670ccdef13f # stable
|
||||
- run: ./hack/ci/install-linux-deps.sh
|
||||
- name: release-plz
|
||||
uses: MarcoIeni/release-plz-action@a2904442184b59b09f10f6c7197cfa8e48bd2fc4 # v0.5.57
|
||||
env:
|
||||
GITHUB_TOKEN: "${{ steps.generate-token.outputs.token }}"
|
||||
CARGO_REGISTRY_TOKEN: "${{ secrets.KRATA_RELEASE_CARGO_TOKEN }}"
|
||||
|
13
.github/workflows/server.yml
vendored
13
.github/workflows/server.yml
vendored
@ -19,8 +19,7 @@ jobs:
|
||||
TARGET_ARCH: "${{ matrix.arch }}"
|
||||
name: server build ${{ matrix.arch }}
|
||||
steps:
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
|
||||
- uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
|
||||
with:
|
||||
egress-policy: audit
|
||||
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
|
||||
@ -40,11 +39,9 @@ jobs:
|
||||
TARGET_ARCH: "${{ matrix.arch }}"
|
||||
name: server test ${{ matrix.arch }}
|
||||
steps:
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
|
||||
- uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
|
||||
with:
|
||||
submodules: recursive
|
||||
@ -62,8 +59,7 @@ jobs:
|
||||
TARGET_ARCH: "${{ matrix.arch }}"
|
||||
name: server clippy ${{ matrix.arch }}
|
||||
steps:
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
|
||||
- uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
|
||||
with:
|
||||
egress-policy: audit
|
||||
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
|
||||
@ -85,8 +81,7 @@ jobs:
|
||||
TARGET_ARCH: "${{ matrix.arch }}"
|
||||
name: server initrd ${{ matrix.arch }}
|
||||
steps:
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
|
||||
- uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
|
||||
with:
|
||||
egress-policy: audit
|
||||
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
|
||||
|
15
Cargo.lock
generated
15
Cargo.lock
generated
@ -1406,6 +1406,21 @@ dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "krata-buildtools"
|
||||
version = "0.0.10"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"env_logger",
|
||||
"krata-oci",
|
||||
"krata-tokio-tar",
|
||||
"oci-spec",
|
||||
"scopeguard",
|
||||
"tokio",
|
||||
"tokio-stream",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "krata-ctl"
|
||||
version = "0.0.10"
|
||||
|
@ -1,5 +1,6 @@
|
||||
[workspace]
|
||||
members = [
|
||||
"crates/build",
|
||||
"crates/krata",
|
||||
"crates/oci",
|
||||
"crates/guest",
|
||||
|
4
DEV.md
4
DEV.md
@ -64,10 +64,10 @@ $ git clone https://github.com/edera-dev/krata.git krata
|
||||
$ cd krata
|
||||
```
|
||||
|
||||
6. Build a guest kernel image:
|
||||
6. Fetch the guest kernel image:
|
||||
|
||||
```sh
|
||||
$ ./hack/kernel/build.sh
|
||||
$ ./hack/kernel/fetch.sh -u
|
||||
```
|
||||
|
||||
7. Copy the guest kernel artifacts to `/var/lib/krata/guest/kernel` so it is automatically detected by kratad:
|
||||
|
25
crates/build/Cargo.toml
Normal file
25
crates/build/Cargo.toml
Normal file
@ -0,0 +1,25 @@
|
||||
[package]
|
||||
name = "krata-buildtools"
|
||||
description = "Build tools for krata."
|
||||
license.workspace = true
|
||||
version.workspace = true
|
||||
homepage.workspace = true
|
||||
repository.workspace = true
|
||||
edition = "2021"
|
||||
resolver = "2"
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
anyhow = { workspace = true }
|
||||
env_logger = { workspace = true }
|
||||
oci-spec = { workspace = true }
|
||||
scopeguard = { workspace = true }
|
||||
tokio = { workspace = true }
|
||||
tokio-stream = { workspace = true }
|
||||
krata-oci = { path = "../oci", version = "^0.0.10" }
|
||||
krata-tokio-tar = { workspace = true }
|
||||
uuid = { workspace = true }
|
||||
|
||||
[[bin]]
|
||||
name = "build-fetch-kernel"
|
||||
path = "bin/fetch_kernel.rs"
|
120
crates/build/bin/fetch_kernel.rs
Normal file
120
crates/build/bin/fetch_kernel.rs
Normal file
@ -0,0 +1,120 @@
|
||||
use std::{
|
||||
env::{self, args},
|
||||
path::PathBuf,
|
||||
};
|
||||
|
||||
use anyhow::{anyhow, Result};
|
||||
use env_logger::Env;
|
||||
use krataoci::{
|
||||
name::ImageName,
|
||||
packer::{service::OciPackerService, OciPackedFormat},
|
||||
progress::OciProgressContext,
|
||||
registry::OciPlatform,
|
||||
};
|
||||
use oci_spec::image::{Arch, Os};
|
||||
use tokio::{
|
||||
fs::{self, File},
|
||||
io::BufReader,
|
||||
};
|
||||
use tokio_stream::StreamExt;
|
||||
use tokio_tar::Archive;
|
||||
use uuid::Uuid;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<()> {
|
||||
env_logger::Builder::from_env(Env::default().default_filter_or("warn")).init();
|
||||
fs::create_dir_all("target/kernel").await?;
|
||||
|
||||
let arch = env::var("TARGET_ARCH").map_err(|_| anyhow!("missing TARGET_ARCH env var"))?;
|
||||
let platform = OciPlatform::new(
|
||||
Os::Linux,
|
||||
match arch.as_str() {
|
||||
"x86_64" => Arch::Amd64,
|
||||
"aarch64" => Arch::ARM64,
|
||||
_ => {
|
||||
return Err(anyhow!("unknown architecture '{}'", arch));
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
let image = ImageName::parse(&args().nth(1).unwrap())?;
|
||||
let mut cache_dir = std::env::temp_dir().clone();
|
||||
cache_dir.push(format!("krata-cache-{}", Uuid::new_v4()));
|
||||
fs::create_dir_all(&cache_dir).await?;
|
||||
|
||||
let _delete_cache_dir = scopeguard::guard(cache_dir.clone(), |dir| {
|
||||
let _ = std::fs::remove_dir_all(dir);
|
||||
});
|
||||
|
||||
let (context, _) = OciProgressContext::create();
|
||||
let service = OciPackerService::new(None, &cache_dir, platform).await?;
|
||||
let packed = service
|
||||
.request(image.clone(), OciPackedFormat::Tar, false, context)
|
||||
.await?;
|
||||
let annotations = packed
|
||||
.manifest
|
||||
.item()
|
||||
.annotations()
|
||||
.clone()
|
||||
.unwrap_or_default();
|
||||
let Some(format) = annotations.get("dev.edera.kernel.format") else {
|
||||
return Err(anyhow!(
|
||||
"image manifest missing 'dev.edera.kernel.format' annotation"
|
||||
));
|
||||
};
|
||||
let Some(version) = annotations.get("dev.edera.kernel.version") else {
|
||||
return Err(anyhow!(
|
||||
"image manifest missing 'dev.edera.kernel.version' annotation"
|
||||
));
|
||||
};
|
||||
let Some(flavor) = annotations.get("dev.edera.kernel.flavor") else {
|
||||
return Err(anyhow!(
|
||||
"image manifest missing 'dev.edera.kernel.flavor' annotation"
|
||||
));
|
||||
};
|
||||
|
||||
if format != "1" {
|
||||
return Err(anyhow!("kernel format version '{}' is unknown", format));
|
||||
}
|
||||
|
||||
let file = BufReader::new(File::open(packed.path).await?);
|
||||
let mut archive = Archive::new(file);
|
||||
let mut entries = archive.entries()?;
|
||||
|
||||
let kernel_image_tar_path = PathBuf::from("kernel/image");
|
||||
let kernel_addons_tar_path = PathBuf::from("kernel/addons.squashfs");
|
||||
let kernel_image_out_path = PathBuf::from(format!("target/kernel/kernel-{}", arch));
|
||||
let kernel_addons_out_path = PathBuf::from(format!("target/kernel/addons-{}.squashfs", arch));
|
||||
|
||||
if kernel_image_out_path.exists() {
|
||||
fs::remove_file(&kernel_image_out_path).await?;
|
||||
}
|
||||
|
||||
if kernel_addons_out_path.exists() {
|
||||
fs::remove_file(&kernel_addons_out_path).await?;
|
||||
}
|
||||
|
||||
while let Some(entry) = entries.next().await {
|
||||
let mut entry = entry?;
|
||||
let path = entry.path()?.to_path_buf();
|
||||
|
||||
if !entry.header().entry_type().is_file() {
|
||||
continue;
|
||||
}
|
||||
|
||||
if path == kernel_image_tar_path {
|
||||
entry.unpack(&kernel_image_out_path).await?;
|
||||
} else if path == kernel_addons_tar_path {
|
||||
entry.unpack(&kernel_addons_out_path).await?;
|
||||
}
|
||||
}
|
||||
|
||||
if !kernel_image_out_path.exists() {
|
||||
return Err(anyhow!("image did not contain a file named /kernel/image"));
|
||||
}
|
||||
|
||||
println!("kernel version: v{}", version);
|
||||
println!("kernel flavor: {}", flavor);
|
||||
|
||||
Ok(())
|
||||
}
|
5
hack/dist/bundle.sh
vendored
5
hack/dist/bundle.sh
vendored
@ -24,10 +24,7 @@ do
|
||||
cp "${KRATA_DIR}/target/${RUST_TARGET}/release/${X}" "${BUNDLE_DIR}/${X}"
|
||||
done
|
||||
./hack/initrd/build.sh
|
||||
if [ "${KRATA_KERNEL_BUILD_SKIP}" != "1" ]
|
||||
then
|
||||
./hack/kernel/build.sh "-j${KRATA_KERNEL_BUILD_JOBS}"
|
||||
fi
|
||||
./hack/kernel/fetch.sh
|
||||
|
||||
cd "${BUNDLE_DIR}"
|
||||
|
||||
|
@ -1,36 +0,0 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
REAL_SCRIPT="$(realpath "${0}")"
|
||||
cd "$(dirname "${REAL_SCRIPT}")/../.."
|
||||
KRATA_DIR="$(realpath "${PWD}")"
|
||||
|
||||
# shellcheck source-path=SCRIPTDIR source=common.sh
|
||||
. "${KRATA_DIR}/hack/kernel/common.sh"
|
||||
|
||||
make -C "${KERNEL_SRC}" ARCH="${TARGET_ARCH_KERNEL}" -j"${KRATA_KERNEL_BUILD_JOBS}" "${CROSS_COMPILE_MAKE}" "${IMAGE_TARGET}" modules
|
||||
|
||||
rm -rf "${MODULES_INSTALL_PATH}"
|
||||
rm -rf "${ADDONS_OUTPUT_PATH}"
|
||||
rm -rf "${ADDONS_SQUASHFS_PATH}"
|
||||
|
||||
make -C "${KERNEL_SRC}" ARCH="${TARGET_ARCH_KERNEL}" -j"${KRATA_KERNEL_BUILD_JOBS}" "${CROSS_COMPILE_MAKE}" INSTALL_MOD_PATH="${MODULES_INSTALL_PATH}" modules_install
|
||||
KERNEL_MODULES_VER="$(ls "${MODULES_INSTALL_PATH}/lib/modules")"
|
||||
|
||||
mkdir -p "${ADDONS_OUTPUT_PATH}"
|
||||
mv "${MODULES_INSTALL_PATH}/lib/modules/${KERNEL_MODULES_VER}" "${MODULES_OUTPUT_PATH}"
|
||||
rm -rf "${MODULES_INSTALL_PATH}"
|
||||
[ -L "${MODULES_OUTPUT_PATH}/build" ] && unlink "${MODULES_OUTPUT_PATH}/build"
|
||||
|
||||
mksquashfs "${ADDONS_OUTPUT_PATH}" "${ADDONS_SQUASHFS_PATH}" -all-root
|
||||
|
||||
if [ "${TARGET_ARCH_STANDARD}" = "x86_64" ]
|
||||
then
|
||||
cp "${KERNEL_SRC}/arch/x86/boot/bzImage" "${OUTPUT_DIR}/kernel-${TARGET_ARCH_STANDARD}"
|
||||
elif [ "${TARGET_ARCH_STANDARD}" = "aarch64" ]
|
||||
then
|
||||
cp "${KERNEL_SRC}/arch/arm64/boot/Image.gz" "${OUTPUT_DIR}/kernel-${TARGET_ARCH_STANDARD}"
|
||||
else
|
||||
echo "ERROR: unable to determine what file is the vmlinuz for ${TARGET_ARCH_STANDARD}" > /dev/stderr
|
||||
exit 1
|
||||
fi
|
@ -1,75 +0,0 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
REAL_SCRIPT="$(realpath "${0}")"
|
||||
cd "$(dirname "${REAL_SCRIPT}")/../.."
|
||||
KRATA_DIR="$(realpath "${PWD}")"
|
||||
KERNEL_DIR="${KRATA_DIR}/kernel"
|
||||
|
||||
cd "${KRATA_DIR}"
|
||||
|
||||
TARGET_ARCH_STANDARD="$(KRATA_ARCH_KERNEL_NAME=0 ./hack/build/arch.sh)"
|
||||
TARGET_ARCH_KERNEL="$(KRATA_ARCH_KERNEL_NAME=1 ./hack/build/arch.sh)"
|
||||
C_TARGET="$(KRATA_TARGET_C_MODE=1 KRATA_TARGET_IGNORE_LIBC=1 ./hack/build/target.sh)"
|
||||
IS_CROSS_COMPILE="$(./hack/build/cross-compile.sh)"
|
||||
|
||||
if [ "${IS_CROSS_COMPILE}" = "1" ]
|
||||
then
|
||||
CROSS_COMPILE_MAKE="CROSS_COMPILE=${C_TARGET}-"
|
||||
else
|
||||
CROSS_COMPILE_MAKE="CROSS_COMPILE="
|
||||
fi
|
||||
|
||||
# shellcheck source-path=SCRIPTDIR source=../../kernel/config.sh
|
||||
. "${KERNEL_DIR}/config.sh"
|
||||
KERNEL_SRC="${KERNEL_DIR}/linux-${KERNEL_VERSION}-${TARGET_ARCH_STANDARD}"
|
||||
|
||||
if [ -z "${KRATA_KERNEL_BUILD_JOBS}" ]
|
||||
then
|
||||
KRATA_KERNEL_BUILD_JOBS="$(nproc)"
|
||||
fi
|
||||
|
||||
if [ ! -f "${KERNEL_SRC}/Makefile" ]
|
||||
then
|
||||
rm -rf "${KERNEL_SRC}"
|
||||
mkdir -p "${KERNEL_SRC}"
|
||||
curl --progress-bar -L -o "${KERNEL_SRC}.txz" "${KERNEL_SRC_URL}"
|
||||
tar xf "${KERNEL_SRC}.txz" --strip-components 1 -C "${KERNEL_SRC}"
|
||||
rm "${KERNEL_SRC}.txz"
|
||||
fi
|
||||
|
||||
OUTPUT_DIR="${KRATA_DIR}/target/kernel"
|
||||
mkdir -p "${OUTPUT_DIR}"
|
||||
|
||||
KERNEL_CONFIG_FILE="${KERNEL_DIR}/krata-${TARGET_ARCH_STANDARD}.config"
|
||||
|
||||
if [ ! -f "${KERNEL_CONFIG_FILE}" ]
|
||||
then
|
||||
echo "ERROR: kernel config file not found for ${TARGET_ARCH_STANDARD}" > /dev/stderr
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cp "${KERNEL_CONFIG_FILE}" "${KERNEL_SRC}/.config"
|
||||
make -C "${KERNEL_SRC}" ARCH="${TARGET_ARCH_KERNEL}" "${CROSS_COMPILE_MAKE}" olddefconfig
|
||||
|
||||
# shellcheck disable=SC2034
|
||||
IMAGE_TARGET="bzImage"
|
||||
|
||||
if [ "${TARGET_ARCH_STANDARD}" = "x86_64" ]
|
||||
then
|
||||
# shellcheck disable=SC2034
|
||||
IMAGE_TARGET="bzImage"
|
||||
elif [ "${TARGET_ARCH_STANDARD}" = "aarch64" ]
|
||||
then
|
||||
# shellcheck disable=SC2034
|
||||
IMAGE_TARGET="Image.gz"
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC2034
|
||||
MODULES_INSTALL_PATH="${OUTPUT_DIR}/modules-install-${TARGET_ARCH_STANDARD}"
|
||||
# shellcheck disable=SC2034
|
||||
ADDONS_OUTPUT_PATH="${OUTPUT_DIR}/addons-${TARGET_ARCH_STANDARD}"
|
||||
# shellcheck disable=SC2034
|
||||
MODULES_OUTPUT_PATH="${ADDONS_OUTPUT_PATH}/modules"
|
||||
# shellcheck disable=SC2034
|
||||
ADDONS_SQUASHFS_PATH="${OUTPUT_DIR}/addons-${TARGET_ARCH_STANDARD}.squashfs"
|
@ -1,16 +0,0 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
REAL_SCRIPT="$(realpath "${0}")"
|
||||
cd "$(dirname "${REAL_SCRIPT}")/../.."
|
||||
KRATA_DIR="$(realpath "${PWD}")"
|
||||
|
||||
# shellcheck source-path=SCRIPTDIR source=common.sh
|
||||
. "${KRATA_DIR}/hack/kernel/common.sh"
|
||||
|
||||
rm -rf "${MODULES_INSTALL_PATH}"
|
||||
rm -rf "${ADDONS_OUTPUT_PATH}"
|
||||
rm -rf "${ADDONS_SQUASHFS_PATH}"
|
||||
|
||||
make -C "${KERNEL_SRC}" ARCH="${TARGET_ARCH_KERNEL}" "${CROSS_COMPILE_MAKE}" INSTALL_MOD_PATH="${MODULES_INSTALL_PATH}" nconfig
|
||||
cp "${KERNEL_SRC}/.config" "${KERNEL_CONFIG_FILE}"
|
17
hack/kernel/fetch.sh
Executable file
17
hack/kernel/fetch.sh
Executable file
@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
REAL_SCRIPT="$(realpath "${0}")"
|
||||
cd "$(dirname "${REAL_SCRIPT}")/../.."
|
||||
KRATA_DIR="${PWD}"
|
||||
cd "${KRATA_DIR}"
|
||||
|
||||
TARGET_ARCH="$(./hack/build/arch.sh)"
|
||||
|
||||
if [ "${1}" != "-u" ] && [ -f "target/kernel/kernel-${TARGET_ARCH}" ]
|
||||
then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
export TARGET_ARCH
|
||||
exec ./hack/build/cargo.sh run -q --bin build-fetch-kernel ghcr.io/edera-dev/kernels:latest
|
Loading…
Reference in New Issue
Block a user