From caa47b52f5e389ad62a1b4f6f4507d812fa424c8 Mon Sep 17 00:00:00 2001 From: Jeremy Soller <jeremy@system76.com> Date: Sun, 12 May 2019 10:13:20 -0600 Subject: [PATCH] 0.1.1: use redoxerd package and install to ~/.redoxer --- Cargo.lock | 26 +++++++++++++++++++++++++- Cargo.toml | 3 ++- res/base.toml | 1 + src/main.rs | 29 ++++++++++++++--------------- 4 files changed, 42 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1ff6a22..15c78ad 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -165,6 +165,16 @@ dependencies = [ "generic-array 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "dirs" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_users 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "err-derive" version = "0.1.5" @@ -635,10 +645,22 @@ dependencies = [ "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "redox_users" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "argon2rs 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "redoxer" -version = "0.1.0" +version = "0.1.1" dependencies = [ + "dirs 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "proc-mounts 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "redox_installer 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.0.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1022,6 +1044,7 @@ dependencies = [ "checksum constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8ff012e225ce166d4422e0e78419d901719760f62ae2b7969ca6b564d1b54a9e" "checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" "checksum digest 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "05f47366984d3ad862010e22c7ce81a7dbcaebbdfb37241a620f8b6596ee135c" +"checksum dirs 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3fd78930633bd1c6e35c4b42b1df7b0cbc6bc191146e512bb3bedf243fcc3901" "checksum err-derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3d8ff65eb6c2fc68e76557239d16f5698fd56603925b89856d3f0f7105fd4543" "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" @@ -1076,6 +1099,7 @@ dependencies = [ "checksum redox_pkgutils 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9fef74980c8aff7e3b1bd11ec90eb0fc021543f64ccfe615a4de1d798ff5fe4d" "checksum redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)" = "12229c14a0f65c4f1cb046a3b52047cdd9da1f4b30f8a39c5063c8bae515e252" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" +"checksum redox_users 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3fe5204c3a17e97dde73f285d49be585df59ed84b50a872baf416e73b62c3828" "checksum redoxfs 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d5f328f08a9edb0f941bcf44881baee686a8356d4bc90e5fc360a5961d176dde" "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" "checksum ring 0.13.5 (registry+https://github.com/rust-lang/crates.io-index)" = "2c4db68a2e35f3497146b7e4563df7d4773a2433230c5e4b448328e31740458a" diff --git a/Cargo.toml b/Cargo.toml index 6ac7312..bae95ea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "redoxer" -version = "0.1.0" +version = "0.1.1" description = "Method for quickly running programs inside of Redox from a KVM capable OS." license = "MIT" authors = ["Jeremy Soller <jeremy@system76.com>"] @@ -8,6 +8,7 @@ repository = "https://gitlab.redox-os.org/redox-os/redoxer" edition = "2018" [dependencies] +dirs = "1.0" redox_installer = "0.2" tempfile = "3.0" toml = "0.5" diff --git a/res/base.toml b/res/base.toml index 2f14d50..5a0f59f 100644 --- a/res/base.toml +++ b/res/base.toml @@ -19,6 +19,7 @@ netutils = {} nulld = {} ptyd = {} randd = {} +redoxerd = {} uutils = {} zerod = {} diff --git a/src/main.rs b/src/main.rs index a8fcf59..de28b07 100644 --- a/src/main.rs +++ b/src/main.rs @@ -130,12 +130,17 @@ fn running(program: &str) -> io::Result<bool> { .map(|x| x.success()) } -fn bootloader() -> io::Result<&'static Path> { - let bootloader_bin = Path::new("build/bootloader.bin"); +fn redoxer_dir() -> PathBuf { + dirs::home_dir().unwrap_or(PathBuf::from(".")) + .join(".redoxer") +} + +fn bootloader() -> io::Result<PathBuf> { + let bootloader_bin = redoxer_dir().join("bootloader.bin"); if ! bootloader_bin.is_file() { eprintln!("redoxer: building bootloader"); - let bootloader_dir = Path::new("build/bootloader"); + let bootloader_dir = redoxer_dir().join("bootloader"); if bootloader_dir.is_dir() { fs::remove_dir_all(&bootloader_dir)?; } @@ -151,23 +156,23 @@ fn bootloader() -> io::Result<&'static Path> { ) })?; - fs::rename(&bootloader_dir.join("bootloader"), bootloader_bin)?; + fs::rename(&bootloader_dir.join("bootloader"), &bootloader_bin)?; } Ok(bootloader_bin) } -fn base(bootloader_bin: &Path) -> io::Result<&'static Path> { - let base_bin = Path::new("build/base.bin"); +fn base(bootloader_bin: &Path) -> io::Result<PathBuf> { + let base_bin = redoxer_dir().join("base.bin"); if ! base_bin.is_file() { eprintln!("redoxer: building base"); - let base_dir = Path::new("build/base"); + let base_dir = redoxer_dir().join("base"); if base_dir.is_dir() { fs::remove_dir_all(&base_dir)?; } fs::create_dir_all(&base_dir)?; - let base_partial = Path::new("build/base.bin.partial"); + let base_partial = redoxer_dir().join("base.bin.partial"); Command::new("dd") .arg("if=/dev/zero") .arg(format!("of={}", base_partial.display())) @@ -218,7 +223,7 @@ fn inner() -> io::Result<()> { } let bootloader_bin = bootloader()?; - let base_bin = base(bootloader_bin)?; + let base_bin = base(&bootloader_bin)?; let tempdir = tempfile::tempdir()?; @@ -232,12 +237,6 @@ fn inner() -> io::Result<()> { { let mut redoxfs = RedoxFs::new(&redoxer_bin, &redoxer_dir)?; - //TODO: Use redoxerd package - fs::copy( - "daemon/target/x86_64-unknown-redox/release/redoxerd", - redoxer_dir.join("bin/redoxerd") - )?; - let mut redoxerd_config = String::new(); for (i, arg) in env::args().skip(1).enumerate() { if i == 0 && arg.contains("/") { -- GitLab