Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve installed package verification #67

Merged
merged 1 commit into from
Oct 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[workspace]
default-members = ["crates/cli"]
members = ["crates/*"]
resolver = "2"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
51 changes: 42 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,47 @@ Example of a Crosfile.toml (`crosup init --toml`) for a Debian-based system:

```toml
# Crosfile.toml
[brew.install.pkg.minikube]
preinstall = "sudo apt-get install -y qemu-system libvirt-clients libvirt-daemon-system"
postinstall = """
sudo sed -i 's/#user = \"root\"/user = \"root\"/g' /etc/libvirt/qemu.conf
sudo sed -i 's/#group = \"root\"/group = \"root\"/g' /etc/libvirt/qemu.conf
sudo sed -i 's/#dynamic_ownership = 1/dynamic_ownership = 0/g' /etc/libvirt/qemu.conf
sudo sed -i 's/#remember_owner = 1/remember_owner = 0/g' /etc/libvirt/qemu.conf"""

[brew.install.pkg.tilt]

[brew.install.pkg.kubernetes-cli]
version_check = "kubectl"

[brew.install.pkg.bat]

[brew.install.pkg.direnv]

[brew.install.pkg.exa]

[brew.install.pkg.fd]

[brew.install.pkg.fzf]

[brew.install.pkg.fish]

[brew.install.pkg.glow]

[brew.install.pkg.httpie]
version_check = "http"

[brew.install.pkg.tig]

[brew.install.pkg.zellij]

[brew.install.pkg.zoxide]

[brew.install.pkg.ripgrep]
version_check = "rg"

[brew.install.pkg.neovim]
version_check = "nvim --version"
version_check = "nvim"

[git.install.repo.blesh]
url = "https://github.com/akinomyoga/ble.sh.git"
Expand All @@ -126,7 +165,6 @@ experimental_features = "nix-command flakes"
accept_flake_config = true
preinstall = "echo 'extra-trusted-substituters = https://cache.floxdev.com' | sudo tee -a /etc/nix/nix.conf && echo 'extra-trusted-public-keys = flox-store-public-0:8c/B+kjIaQ+BloCmNkRUKwaVPFWkriSAd0JJvuDu4F0=' | sudo tee -a /etc/nix/nix.conf"
flake = "github:flox/floxpkgs#flox.fromCatalog"
version_check = ". /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh && flox --version"

[nix.install.pkg.cachix]
flake = "github:cachix/cachix"
Expand All @@ -139,11 +177,9 @@ sudo pkill nix-daemon
cachix use devenv"""
flake = "github:cachix/devenv/latest"
depends_on = ["cachix"]
version_check = ". /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh && devenv version"

[curl.install.script.devbox]
url = "https://get.jetpack.io/devbox"
version_check = "devbox version"
shell = "bash"
depends_on = ["nix"]

Expand All @@ -152,19 +188,17 @@ FORCE = "1"

[curl.install.script.atuin]
url = "https://github.com/raw/ellie/atuin/main/install.sh"
version_check = "atuin --version"
shell = "bash"

[curl.install.script.nix]
url = "https://install.determinate.systems/nix"
enable_sudo = true
version_check = ". /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh && nix --version"
args = "install --no-confirm"

[curl.install.script.homebrew]
url = "https://github.com/raw/Homebrew/install/HEAD/install.sh"
postinstall = "echo 'eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)' >> ~/.bashrc"
version_check = "brew --version"
version_check = "brew"
shell = "bash"

[curl.install.script.homebrew.env]
Expand All @@ -188,11 +222,10 @@ depends_on = [
"gnupg",
]
postinstall = "sudo usermod -aG docker $USER && newgrp docker"
version_check = "docker --version"

[apt.install.pkg.vscode]
url = "https://code.visualstudio.com/sha/download?build=stable&os=linux-deb-x64"
version_check = "code --version"
version_check = "code"

```

Expand Down
8 changes: 4 additions & 4 deletions crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ license = "MIT"
name = "crosup"
readme = "../../README.md"
repository = "https://github.com/tsirysndr/crosup"
version = "0.4.10"
version = "0.5.0"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
anyhow = "1.0.71"
clap = "3.2.20"
crosup-core = {path = "../core", version = "0.1.9"}
crosup-core = {path = "../core", version = "0.2.0"}
crosup-entity = {version = "0.1.0", path = "../entity"}
crosup-installers = {path = "../installers", version = "0.1.12"}
crosup-installers = {path = "../installers", version = "0.2.0"}
crosup-migration = {path = "../migration", version = "0.1.0"}
crosup-nix = {path = "../nix", version = "0.1.1"}
crosup-repo = {path = "../repo", version = "0.1.0"}
crosup-ssh = {path = "../ssh", version = "0.1.0"}
crosup-tui = {path = "../tui", version = "0.1.0"}
crosup-types = {path = "../types", version = "0.1.8"}
crosup-types = {path = "../types", version = "0.2.0"}
hcl-rs = "0.14.2"
inquire = "0.6.2"
owo-colors = "3.5.0"
Expand Down
8 changes: 4 additions & 4 deletions crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ keywords = ["chromebook", "chromeos", "homebrew", "docker", "nix"]
license = "MIT"
name = "crosup-core"
repository = "https://github.com/tsirysndr/crosup"
version = "0.1.9"
version = "0.2.0"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
anyhow = "1.0.71"
crosup-installers = {path = "../installers", version = "0.1.12"}
crosup-macros = {path = "../macros", version = "0.1.3"}
crosup-installers = {path = "../installers", version = "0.2.0"}
crosup-macros = {path = "../macros", version = "0.2.0"}
crosup-ssh = {path = "../ssh", version = "0.1.0"}
crosup-types = {path = "../types", version = "0.1.8"}
crosup-types = {path = "../types", version = "0.2.0"}
hcl-rs = "0.14.2"
os-release = "0.1.0"
owo-colors = "3.5.0"
Expand Down
6 changes: 3 additions & 3 deletions crates/installers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ keywords = ["chromebook", "chromeos", "homebrew", "docker", "nix"]
license = "MIT"
name = "crosup-installers"
repository = "https://github.com/tsirysndr/crosup"
version = "0.1.12"
version = "0.2.0"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
anyhow = "1.0.71"
crosup-macros = {path = "../macros", version = "0.1.5"}
crosup-macros = {path = "../macros", version = "0.2.0"}
crosup-nix = {path = "../nix", version = "0.1.1"}
crosup-ssh = {path = "../ssh", version = "0.1.0"}
crosup-types = {path = "../types", version = "0.1.8"}
crosup-types = {path = "../types", version = "0.2.0"}
indexmap = {version = "1.9.3", features = ["serde"]}
owo-colors = "3.5.0"
ssh2 = {version = "0.9.4", features = ["vendored-openssl"]}
12 changes: 7 additions & 5 deletions crates/installers/src/apk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,16 @@ impl Installer for ApkInstaller {
}

fn is_installed(&self) -> Result<bool, Error> {
println!(
"-> Checking if {} is already installed",
self.name.bright_green()
);
if let Some(command) = self.version_check.clone() {
println!(
"-> Checking if {} is already installed",
self.name.bright_green()
);
check_version!(self, command, self.session.clone());
return Ok(true);
return Ok(false);
}
let command = self.name.clone();
check_version!(self, command, self.session.clone());
Ok(false)
}

Expand Down
11 changes: 7 additions & 4 deletions crates/installers/src/apt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,13 +242,16 @@ impl Installer for AptInstaller {
}

fn is_installed(&self) -> Result<bool, Error> {
println!(
"-> Checking if {} is already installed",
self.name.bright_green()
);
if let Some(command) = self.version_check.clone() {
println!(
"-> Checking if {} is already installed",
self.name.bright_green()
);
check_version!(self, command, self.session.clone());
return Ok(false);
}
let command = self.name.clone();
check_version!(self, command, self.session.clone());
Ok(false)
}

Expand Down
14 changes: 8 additions & 6 deletions crates/installers/src/brew.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ impl From<BrewConfiguration> for BrewInstaller {
version: "latest".to_string(),
dependencies: vec!["homebrew".into()],
pkgs: config.pkgs.unwrap_or(vec![]),
provider: "brew".into(),
..Default::default()
}
}
Expand Down Expand Up @@ -94,14 +93,17 @@ impl Installer for BrewInstaller {
}

fn is_installed(&self) -> Result<bool, Error> {
println!(
"-> Checking if {} is already installed",
self.name.bright_green()
);
if let Some(command) = self.version_check.clone() {
println!(
"-> Checking if {} is already installed",
self.name.bright_green()
);
check_version!(self, command, self.session.clone());
return Ok(false);
}
Ok(true)
let command = self.name.clone();
check_version!(self, command, self.session.clone());
Ok(false)
}

fn name(&self) -> &str {
Expand Down
11 changes: 7 additions & 4 deletions crates/installers/src/curl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,16 @@ impl Installer for CurlInstaller {
}

fn is_installed(&self) -> Result<bool, Error> {
println!(
"-> Checking if {} is already installed",
self.name.bright_green()
);
if let Some(command) = self.version_check.clone() {
println!(
"-> Checking if {} is already installed",
self.name.bright_green()
);
check_version!(self, command, self.session.clone());
return Ok(false);
}
let command = self.name.clone();
check_version!(self, command, self.session.clone());
Ok(false)
}

Expand Down
12 changes: 7 additions & 5 deletions crates/installers/src/dnf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,16 @@ impl Installer for DnfInstaller {
}

fn is_installed(&self) -> Result<bool, Error> {
println!(
"-> Checking if {} is already installed",
self.name.bright_green()
);
if let Some(command) = self.version_check.clone() {
println!(
"-> Checking if {} is already installed",
self.name.bright_green()
);
check_version!(self, command, self.session.clone());
return Ok(true);
return Ok(false);
}
let command = self.name.clone();
check_version!(self, command, self.session.clone());
Ok(false)
}

Expand Down
12 changes: 7 additions & 5 deletions crates/installers/src/emerge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,16 @@ impl Installer for EmergeInstaller {
}

fn is_installed(&self) -> Result<bool, Error> {
println!(
"-> Checking if {} is already installed",
self.name.bright_green()
);
if let Some(command) = self.version_check.clone() {
println!(
"-> Checking if {} is already installed",
self.name.bright_green()
);
check_version!(self, command, self.session.clone());
return Ok(true);
return Ok(false);
}
let command = self.name.clone();
check_version!(self, command, self.session.clone());
Ok(false)
}

Expand Down
12 changes: 7 additions & 5 deletions crates/installers/src/fleek.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,16 @@ impl Installer for FleekInstaller {
}

fn is_installed(&self) -> Result<bool, Error> {
println!(
"-> Checking if {} is already installed",
self.name.bright_green()
);
if let Some(command) = self.version_check.clone() {
println!(
"-> Checking if {} is already installed",
self.name.bright_green()
);
check_version!(self, command, self.session.clone());
return Ok(true);
return Ok(false);
}
let command = self.name.clone();
check_version!(self, command, self.session.clone());
Ok(false)
}

Expand Down
Loading