diff --git a/Cargo.lock b/Cargo.lock index ea6129e..339a04b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -47,7 +47,7 @@ checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" [[package]] name = "listen-probe" -version = "0.0.0" +version = "0.1.0" [[package]] name = "memchr" @@ -57,14 +57,14 @@ checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" [[package]] name = "notify-probe" -version = "0.0.0" +version = "0.1.0" dependencies = [ "libc", ] [[package]] name = "oxctl" -version = "0.0.0" +version = "0.1.0" dependencies = [ "oxinit-ipc", "oxinit-log", @@ -73,7 +73,7 @@ dependencies = [ [[package]] name = "oxinit" -version = "0.0.0" +version = "0.1.0" dependencies = [ "libc", "oxinit-cgroup", @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "oxinit-cgroup" -version = "0.0.0" +version = "0.1.0" dependencies = [ "oxinit-unit", "thiserror", @@ -98,7 +98,7 @@ dependencies = [ [[package]] name = "oxinit-graph" -version = "0.0.0" +version = "0.1.0" dependencies = [ "oxinit-unit", "thiserror", @@ -106,7 +106,7 @@ dependencies = [ [[package]] name = "oxinit-ipc" -version = "0.0.0" +version = "0.1.0" dependencies = [ "serde", "serde_json", @@ -114,22 +114,22 @@ dependencies = [ [[package]] name = "oxinit-log" -version = "0.0.0" +version = "0.1.0" [[package]] name = "oxinit-service" -version = "0.0.0" +version = "0.1.0" dependencies = [ "oxinit-unit", ] [[package]] name = "oxinit-timer" -version = "0.0.0" +version = "0.1.0" [[package]] name = "oxinit-unit" -version = "0.0.0" +version = "0.1.0" dependencies = [ "basic-toml", "oxinit-timer", @@ -139,14 +139,14 @@ dependencies = [ [[package]] name = "oxinit-user" -version = "0.0.0" +version = "0.1.0" dependencies = [ "thiserror", ] [[package]] name = "oxlogd" -version = "0.0.0" +version = "0.1.0" dependencies = [ "oxinit-log", "rustix", @@ -280,7 +280,7 @@ dependencies = [ [[package]] name = "xtask" -version = "0.0.0" +version = "0.1.0" [[package]] name = "zmij" diff --git a/Cargo.toml b/Cargo.toml index 2abdc5f..224b7ea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,6 +18,7 @@ members = [ ] [workspace.package] +version = "0.1.0" edition = "2021" rust-version = "1.95" license = "MIT OR Apache-2.0" diff --git a/README.md b/README.md index 3276df6..cf77244 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,9 @@ A service manager and PID 1 for Linux, written in Rust. [![Status](https://img.shields.io/badge/status-pre--alpha-orange)](ROADMAP.md) [![CI](https://github.com/youhide/oxinit/actions/workflows/ci.yml/badge.svg)](https://github.com/youhide/oxinit/actions/workflows/ci.yml) -**Pre-alpha. Nothing is stable.** See [ROADMAP.md](ROADMAP.md) for what works. +**Pre-alpha. Nothing is stable**, and the unit format may change between any +two releases. See [ROADMAP.md](ROADMAP.md) for what works and what each +milestone was verified against. ## What this is, in one picture diff --git a/crates/listen-probe/Cargo.toml b/crates/listen-probe/Cargo.toml index 5863f8c..a6cfaae 100644 --- a/crates/listen-probe/Cargo.toml +++ b/crates/listen-probe/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "listen-probe" -version = "0.0.0" +version.workspace = true description = "Test fixture: a socket-activated service, and a client to poke it" edition.workspace = true rust-version.workspace = true diff --git a/crates/notify-probe/Cargo.toml b/crates/notify-probe/Cargo.toml index 62eba52..15c9feb 100644 --- a/crates/notify-probe/Cargo.toml +++ b/crates/notify-probe/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "notify-probe" -version = "0.0.0" +version.workspace = true description = "Test fixture: a service that speaks sd_notify" edition.workspace = true rust-version.workspace = true diff --git a/crates/oxctl/Cargo.toml b/crates/oxctl/Cargo.toml index 7f9b774..c0f392e 100644 --- a/crates/oxctl/Cargo.toml +++ b/crates/oxctl/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "oxctl" -version = "0.0.0" +version.workspace = true description = "Command-line client for oxinit" edition.workspace = true rust-version.workspace = true diff --git a/crates/oxctl/src/main.rs b/crates/oxctl/src/main.rs index 45bb293..1b65588 100644 --- a/crates/oxctl/src/main.rs +++ b/crates/oxctl/src/main.rs @@ -27,6 +27,7 @@ commands: restart stop, then start once it is down logs what the unit has written, from /var/log/oxinit reload re-read the unit directories + --version which build this is `logs` reads the file directly. It does not go through oxinit: the control socket has to stay responsive, and bulk data is what would stop it being. @@ -70,6 +71,11 @@ fn run(args: &[String]) -> Result<(), String> { return Err(format!("{command} needs a unit name\n\n{USAGE}")) } + ("--version" | "-V", _) => { + println!("oxctl {}", env!("CARGO_PKG_VERSION")); + return Ok(()); + } + ("" | "help" | "--help" | "-h", _) => { println!("{USAGE}"); return Ok(()); diff --git a/crates/oxinit-cgroup/Cargo.toml b/crates/oxinit-cgroup/Cargo.toml index 53433be..ea9419f 100644 --- a/crates/oxinit-cgroup/Cargo.toml +++ b/crates/oxinit-cgroup/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "oxinit-cgroup" -version = "0.0.0" +version.workspace = true description = "cgroup v2 hierarchy, limits, accounting, and emptiness" edition.workspace = true rust-version.workspace = true diff --git a/crates/oxinit-graph/Cargo.toml b/crates/oxinit-graph/Cargo.toml index 7dc84d6..f658460 100644 --- a/crates/oxinit-graph/Cargo.toml +++ b/crates/oxinit-graph/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "oxinit-graph" -version = "0.0.0" +version.workspace = true description = "Dependency resolution and start ordering" edition.workspace = true rust-version.workspace = true diff --git a/crates/oxinit-ipc/Cargo.toml b/crates/oxinit-ipc/Cargo.toml index a8ed16e..bdf91df 100644 --- a/crates/oxinit-ipc/Cargo.toml +++ b/crates/oxinit-ipc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "oxinit-ipc" -version = "0.0.0" +version.workspace = true description = "Control protocol types, shared by oxinit and oxctl" edition.workspace = true rust-version.workspace = true diff --git a/crates/oxinit-log/Cargo.toml b/crates/oxinit-log/Cargo.toml index d119035..a6b73f6 100644 --- a/crates/oxinit-log/Cargo.toml +++ b/crates/oxinit-log/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "oxinit-log" -version = "0.0.0" +version.workspace = true description = "Log record format, line splitting, and rotation policy" edition.workspace = true rust-version.workspace = true diff --git a/crates/oxinit-service/Cargo.toml b/crates/oxinit-service/Cargo.toml index 3d4e15a..8d8fd15 100644 --- a/crates/oxinit-service/Cargo.toml +++ b/crates/oxinit-service/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "oxinit-service" -version = "0.0.0" +version.workspace = true description = "Service state machine and restart policy" edition.workspace = true rust-version.workspace = true diff --git a/crates/oxinit-timer/Cargo.toml b/crates/oxinit-timer/Cargo.toml index 30a01d2..fcf3d0e 100644 --- a/crates/oxinit-timer/Cargo.toml +++ b/crates/oxinit-timer/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "oxinit-timer" -version = "0.0.0" +version.workspace = true description = "Timer schedules and the calendar arithmetic behind them" edition.workspace = true rust-version.workspace = true diff --git a/crates/oxinit-unit/Cargo.toml b/crates/oxinit-unit/Cargo.toml index d5a8b23..7b22829 100644 --- a/crates/oxinit-unit/Cargo.toml +++ b/crates/oxinit-unit/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "oxinit-unit" -version = "0.0.0" +version.workspace = true description = "Unit file parsing and validation" edition.workspace = true rust-version.workspace = true diff --git a/crates/oxinit-user/Cargo.toml b/crates/oxinit-user/Cargo.toml index 4fe0ea1..f109580 100644 --- a/crates/oxinit-user/Cargo.toml +++ b/crates/oxinit-user/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "oxinit-user" -version = "0.0.0" +version.workspace = true description = "Resolving a username against /etc/passwd and /etc/group" edition.workspace = true rust-version.workspace = true diff --git a/crates/oxinit/Cargo.toml b/crates/oxinit/Cargo.toml index ca90a57..0cd386b 100644 --- a/crates/oxinit/Cargo.toml +++ b/crates/oxinit/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "oxinit" -version = "0.0.0" +version.workspace = true description = "PID 1 and service manager" edition.workspace = true rust-version.workspace = true diff --git a/crates/oxinit/src/main.rs b/crates/oxinit/src/main.rs index 711beb5..d6037ab 100644 --- a/crates/oxinit/src/main.rs +++ b/crates/oxinit/src/main.rs @@ -84,6 +84,14 @@ const SIGUSR2: u32 = libc::SIGUSR2 as u32; const SIGPWR: u32 = libc::SIGPWR as u32; fn main() -> ExitCode { + // Before the pid check, deliberately. `oxinit --version` has to work for + // somebody holding a binary and asking what it is, and that person is + // exactly the one who cannot run it as PID 1 to find out. + if std::env::args().any(|arg| arg == "--version" || arg == "-V") { + println!("oxinit {}", env!("CARGO_PKG_VERSION")); + return ExitCode::SUCCESS; + } + if !rustix::process::getpid().is_init() { eprintln!( "oxinit: running as pid {}, not 1. oxinit is an init system; \ diff --git a/crates/oxlogd/Cargo.toml b/crates/oxlogd/Cargo.toml index 99ace6d..6bee6ec 100644 --- a/crates/oxlogd/Cargo.toml +++ b/crates/oxlogd/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "oxlogd" -version = "0.0.0" +version.workspace = true description = "Reads service output and writes it" edition.workspace = true rust-version.workspace = true diff --git a/crates/oxlogd/src/main.rs b/crates/oxlogd/src/main.rs index e984119..dfa37b5 100644 --- a/crates/oxlogd/src/main.rs +++ b/crates/oxlogd/src/main.rs @@ -55,6 +55,11 @@ fn main() -> ExitCode { } fn run() -> Result<(), String> { + if std::env::args().any(|arg| arg == "--version" || arg == "-V") { + println!("oxlogd {}", env!("CARGO_PKG_VERSION")); + return Ok(()); + } + let dir = std::env::args() .skip_while(|arg| arg != "--dir") .nth(1) diff --git a/crates/xtask/Cargo.toml b/crates/xtask/Cargo.toml index 1669f6f..c6d7d68 100644 --- a/crates/xtask/Cargo.toml +++ b/crates/xtask/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "xtask" -version = "0.0.0" +version.workspace = true description = "Build and boot automation" edition.workspace = true rust-version.workspace = true