Hammer out a bunch of Mac support
This commit is contained in:
parent
fcc200b9d0
commit
c75a4ed511
36
Cargo.lock
generated
36
Cargo.lock
generated
|
@ -754,6 +754,7 @@ dependencies = [
|
|||
"glob",
|
||||
"nix",
|
||||
"owo-colors",
|
||||
"plist",
|
||||
"reqwest",
|
||||
"serde",
|
||||
"serde_json",
|
||||
|
@ -1007,6 +1008,15 @@ version = "0.2.132"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8371e4e5341c3a96db127eb2465ac681ced4c433e01dd0e938adbef26ba93ba5"
|
||||
|
||||
[[package]]
|
||||
name = "line-wrap"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f30344350a2a51da54c1d53be93fade8a237e545dbcc4bdbe635413f2117cab9"
|
||||
dependencies = [
|
||||
"safemem",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "link-cplusplus"
|
||||
version = "1.0.7"
|
||||
|
@ -1248,6 +1258,20 @@ version = "0.3.25"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae"
|
||||
|
||||
[[package]]
|
||||
name = "plist"
|
||||
version = "1.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bd39bc6cdc9355ad1dc5eeedefee696bb35c34caf21768741e81826c0bbd7225"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"indexmap",
|
||||
"line-wrap",
|
||||
"serde",
|
||||
"time",
|
||||
"xml-rs",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "polling"
|
||||
version = "2.3.0"
|
||||
|
@ -1477,6 +1501,12 @@ version = "1.0.11"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09"
|
||||
|
||||
[[package]]
|
||||
name = "safemem"
|
||||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072"
|
||||
|
||||
[[package]]
|
||||
name = "same-file"
|
||||
version = "1.0.6"
|
||||
|
@ -2306,6 +2336,12 @@ dependencies = [
|
|||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "xml-rs"
|
||||
version = "0.8.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d2d7d3948613f75c98fd9328cfdcc45acc4d360655289d0a7d4ec931392200a3"
|
||||
|
||||
[[package]]
|
||||
name = "xz2"
|
||||
version = "0.1.7"
|
||||
|
|
|
@ -38,3 +38,4 @@ walkdir = "2.3.2"
|
|||
sxd-xpath = "0.4.2"
|
||||
xz2 = { version = "0.1.7", features = ["static", "tokio"] }
|
||||
sxd-document = "0.3.2"
|
||||
plist = "1.3.1"
|
||||
|
|
|
@ -62,12 +62,13 @@ impl Actionable for CreateGroup {
|
|||
tracing::debug!("Creating group");
|
||||
|
||||
use target_lexicon::OperatingSystem;
|
||||
match target_lexicon::HOST.operating_system {
|
||||
match target_lexicon::OperatingSystem::host() {
|
||||
OperatingSystem::MacOSX {
|
||||
major: _,
|
||||
minor: _,
|
||||
patch: _,
|
||||
} => {
|
||||
}
|
||||
| OperatingSystem::Darwin => {
|
||||
execute_command(Command::new("/usr/sbin/dseditgroup").args([
|
||||
"-o",
|
||||
"create",
|
||||
|
@ -131,9 +132,24 @@ impl Actionable for CreateGroup {
|
|||
}
|
||||
tracing::debug!("Deleting group");
|
||||
|
||||
execute_command(Command::new("groupdel").arg(&name))
|
||||
.await
|
||||
.map_err(CreateGroupError::Command)?;
|
||||
use target_lexicon::OperatingSystem;
|
||||
match target_lexicon::OperatingSystem::host() {
|
||||
OperatingSystem::MacOSX {
|
||||
major: _,
|
||||
minor: _,
|
||||
patch: _,
|
||||
}
|
||||
| OperatingSystem::Darwin => {
|
||||
execute_command(Command::new("groupdel").arg(&name))
|
||||
.await
|
||||
.map_err(CreateGroupError::Command)?;
|
||||
},
|
||||
_ => {
|
||||
execute_command(Command::new("userdel").args([&name.to_string()]))
|
||||
.await
|
||||
.map_err(Self::Error::Command)?;
|
||||
},
|
||||
};
|
||||
|
||||
tracing::trace!("Deleted group");
|
||||
*action_state = ActionState::Uncompleted;
|
||||
|
|
|
@ -68,12 +68,13 @@ impl Actionable for CreateUser {
|
|||
tracing::debug!("Creating user");
|
||||
|
||||
use target_lexicon::OperatingSystem;
|
||||
match target_lexicon::HOST.operating_system {
|
||||
match target_lexicon::OperatingSystem::host() {
|
||||
OperatingSystem::MacOSX {
|
||||
major: _,
|
||||
minor: _,
|
||||
patch: _,
|
||||
} => {
|
||||
}
|
||||
| OperatingSystem::Darwin => {
|
||||
execute_command(Command::new("/usr/bin/dscl").args([
|
||||
".",
|
||||
"create",
|
||||
|
@ -155,12 +156,13 @@ impl Actionable for CreateUser {
|
|||
tracing::debug!("Deleting user");
|
||||
|
||||
use target_lexicon::OperatingSystem;
|
||||
match target_lexicon::HOST.operating_system {
|
||||
match target_lexicon::OperatingSystem::host() {
|
||||
OperatingSystem::MacOSX {
|
||||
major: _,
|
||||
minor: _,
|
||||
patch: _,
|
||||
} => {
|
||||
}
|
||||
| OperatingSystem::Darwin => {
|
||||
todo!()
|
||||
},
|
||||
_ => {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use std::io::Cursor;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use serde::Serialize;
|
||||
|
@ -6,6 +7,7 @@ use tokio::process::Command;
|
|||
use crate::execute_command;
|
||||
|
||||
use crate::actions::{Action, ActionDescription, ActionState, Actionable};
|
||||
use crate::os::darwin::DiskUtilOutput;
|
||||
|
||||
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone)]
|
||||
pub struct EnableOwnership {
|
||||
|
@ -58,17 +60,9 @@ impl Actionable for EnableOwnership {
|
|||
.await
|
||||
.unwrap()
|
||||
.stdout;
|
||||
let package = sxd_document::parser::parse(&String::from_utf8(buf).unwrap()).unwrap();
|
||||
let the_plist: DiskUtilOutput = plist::from_reader(Cursor::new(buf)).unwrap();
|
||||
|
||||
match sxd_xpath::evaluate_xpath(
|
||||
&package.as_document(),
|
||||
"(/plist/dict/key[text()='GlobalPermissionsEnabled'])/following-sibling::*[1]",
|
||||
)
|
||||
.unwrap()
|
||||
{
|
||||
sxd_xpath::Value::Boolean(bool) => bool,
|
||||
_ => panic!("At the other disk i/o!!!"),
|
||||
}
|
||||
the_plist.global_permissions_enabled
|
||||
};
|
||||
|
||||
if should_enable_ownership {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
mod actions;
|
||||
mod error;
|
||||
mod os;
|
||||
mod plan;
|
||||
mod planner;
|
||||
mod settings;
|
||||
|
|
6
src/os/darwin.rs
Normal file
6
src/os/darwin.rs
Normal file
|
@ -0,0 +1,6 @@
|
|||
#[derive(serde::Deserialize)]
|
||||
#[serde(rename_all = "PascalCase")]
|
||||
pub struct DiskUtilOutput {
|
||||
pub parent_whole_disk: String,
|
||||
pub global_permissions_enabled: bool,
|
||||
}
|
1
src/os/mod.rs
Normal file
1
src/os/mod.rs
Normal file
|
@ -0,0 +1 @@
|
|||
pub mod darwin;
|
|
@ -1,3 +1,5 @@
|
|||
use std::io::Cursor;
|
||||
|
||||
use tokio::process::Command;
|
||||
|
||||
use crate::{
|
||||
|
@ -6,6 +8,7 @@ use crate::{
|
|||
Action, ActionError,
|
||||
},
|
||||
execute_command,
|
||||
os::darwin::DiskUtilOutput,
|
||||
planner::{Plannable, PlannerError},
|
||||
InstallPlan, Planner,
|
||||
};
|
||||
|
@ -22,23 +25,14 @@ impl Plannable for DarwinMultiUser {
|
|||
settings: crate::InstallSettings,
|
||||
) -> Result<crate::InstallPlan, crate::planner::PlannerError> {
|
||||
let root_disk = {
|
||||
let root_disk_buf =
|
||||
let buf =
|
||||
execute_command(Command::new("/usr/sbin/diskutil").args(["info", "-plist", "/"]))
|
||||
.await
|
||||
.unwrap()
|
||||
.stdout;
|
||||
let package =
|
||||
sxd_document::parser::parse(&String::from_utf8(root_disk_buf).unwrap()).unwrap();
|
||||
let the_plist: DiskUtilOutput = plist::from_reader(Cursor::new(buf)).unwrap();
|
||||
|
||||
match sxd_xpath::evaluate_xpath(
|
||||
&package.as_document(),
|
||||
"/plist/dict/key[text()='ParentWholeDisk']/following-sibling::string[1]/text()",
|
||||
)
|
||||
.unwrap()
|
||||
{
|
||||
sxd_xpath::Value::String(s) => s,
|
||||
_ => panic!("At the disk i/o!!!"),
|
||||
}
|
||||
the_plist.parent_whole_disk
|
||||
};
|
||||
|
||||
let volume_label = "Nix Store".into();
|
||||
|
|
|
@ -31,10 +31,12 @@ impl InstallSettings {
|
|||
(Architecture::Aarch64(_), OperatingSystem::Linux) => {
|
||||
url = "https://releases.nixos.org/nix/nix-2.11.0/nix-2.11.0-aarch64-linux.tar.xz";
|
||||
},
|
||||
(Architecture::X86_64, OperatingSystem::MacOSX { .. }) => {
|
||||
(Architecture::X86_64, OperatingSystem::MacOSX { .. })
|
||||
| (Architecture::X86_64, OperatingSystem::Darwin) => {
|
||||
url = "https://releases.nixos.org/nix/nix-2.11.0/nix-2.11.0-x86_64-darwin.tar.xz";
|
||||
},
|
||||
(Architecture::Aarch64(_), OperatingSystem::MacOSX { .. }) => {
|
||||
(Architecture::Aarch64(_), OperatingSystem::MacOSX { .. })
|
||||
| (Architecture::Aarch64(_), OperatingSystem::Darwin) => {
|
||||
url = "https://releases.nixos.org/nix/nix-2.11.0/nix-2.11.0-aarch64-darwin.tar.xz";
|
||||
},
|
||||
_ => {
|
||||
|
|
Loading…
Reference in a new issue