diff --git a/Cargo.lock b/Cargo.lock index 7c499b4..0f06d5a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,11 +2,15 @@ # It is not intended for manual editing. version = 4 +[[package]] +name = "hello" +version = "0.1.0" + [[package]] name = "libc" -version = "0.2.172" +version = "0.2.174" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa" +checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776" [[package]] name = "nit" diff --git a/Cargo.toml b/Cargo.toml index 23313e2..741e010 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,12 +1,6 @@ -[package] -name = "nit" -version = "0.1.0" -edition = "2024" -license = "MIT" - -[features] -aws = [] -default = ["aws"] - -[dependencies] -libc = "0.2.172" +[workspace] +resolver = "2" +members = [ + "crates/nit", + "crates/hello", +] diff --git a/Containerfile b/Containerfile index c13261b..65bb7c5 100644 --- a/Containerfile +++ b/Containerfile @@ -21,6 +21,7 @@ WORKDIR /src RUN cargo build ${CARGOFLAGS} WORKDIR /build_cpio RUN cp /src/target/${TARGET}/release/nit init +RUN cp /src/target/${TARGET}/release/hello hello ENV KBUILD_BUILD_TIMESTAMP=1 COPY <<-EOF initramfs.list file /init init 0755 0 0 @@ -33,6 +34,7 @@ COPY <<-EOF initramfs.list dir /sys 0755 0 0 dir /usr 0755 0 0 dir /usr/bin 0755 0 0 + file /usr/bin/hello hello 0755 0 0 dir /usr/sbin 0755 0 0 dir /dev 0755 0 0 dir /dev/shm 0755 0 0 diff --git a/crates/hello/Cargo.toml b/crates/hello/Cargo.toml new file mode 100644 index 0000000..f6f3649 --- /dev/null +++ b/crates/hello/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "hello" +version = "0.1.0" +edition = "2024" + +[dependencies] diff --git a/crates/hello/src/main.rs b/crates/hello/src/main.rs new file mode 100644 index 0000000..50d7212 --- /dev/null +++ b/crates/hello/src/main.rs @@ -0,0 +1,6 @@ +fn main() { + println!("Hello, world!"); + loop { + std::thread::sleep(std::time::Duration::from_secs(5)); + } +} diff --git a/crates/nit/Cargo.lock b/crates/nit/Cargo.lock new file mode 100644 index 0000000..7c499b4 --- /dev/null +++ b/crates/nit/Cargo.lock @@ -0,0 +1,16 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "libc" +version = "0.2.172" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa" + +[[package]] +name = "nit" +version = "0.1.0" +dependencies = [ + "libc", +] diff --git a/crates/nit/Cargo.toml b/crates/nit/Cargo.toml new file mode 100644 index 0000000..23313e2 --- /dev/null +++ b/crates/nit/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "nit" +version = "0.1.0" +edition = "2024" +license = "MIT" + +[features] +aws = [] +default = ["aws"] + +[dependencies] +libc = "0.2.172" diff --git a/src/config.rs b/crates/nit/src/config.rs similarity index 98% rename from src/config.rs rename to crates/nit/src/config.rs index 83cd0b0..f9696b5 100644 --- a/src/config.rs +++ b/crates/nit/src/config.rs @@ -39,7 +39,7 @@ pub fn get_config() -> Result { let platform = platform::get_current_platform(values.remove("platform").as_deref())?; - let target = values.remove("target").unwrap_or(String::from("/bin/sh")); + let target = values.remove("target").unwrap_or(String::from("/usr/bin/hello")); Ok(Config { platform, mode, target }) } diff --git a/src/main.rs b/crates/nit/src/main.rs similarity index 100% rename from src/main.rs rename to crates/nit/src/main.rs diff --git a/src/platform/aws.rs b/crates/nit/src/platform/aws.rs similarity index 100% rename from src/platform/aws.rs rename to crates/nit/src/platform/aws.rs diff --git a/src/platform/mod.rs b/crates/nit/src/platform/mod.rs similarity index 100% rename from src/platform/mod.rs rename to crates/nit/src/platform/mod.rs diff --git a/src/result.rs b/crates/nit/src/result.rs similarity index 100% rename from src/result.rs rename to crates/nit/src/result.rs diff --git a/src/system/mod.rs b/crates/nit/src/system/mod.rs similarity index 100% rename from src/system/mod.rs rename to crates/nit/src/system/mod.rs diff --git a/src/system/syscall.rs b/crates/nit/src/system/syscall.rs similarity index 100% rename from src/system/syscall.rs rename to crates/nit/src/system/syscall.rs