Skip to content

Commit

Permalink
Merge pull request #74 from rami3l/scoop
Browse files Browse the repository at this point in the history
feat: add support for `scoop`
  • Loading branch information
rami3l authored Feb 6, 2021
2 parents 5e5df44 + 7a48abb commit 70adeb0
Show file tree
Hide file tree
Showing 21 changed files with 379 additions and 116 deletions.
37 changes: 27 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,48 @@ on:
- master

jobs:
windows-test:
choco-test:
runs-on: windows-latest

steps:
- uses: actions/checkout@v2
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
run: cargo test chocolatey --verbose
- name: Run heavy tests
run: cargo test --verbose -- --ignored
run: cargo test chocolatey --verbose -- --ignored

macos-test:
scoop-test:
runs-on: windows-latest

steps:
- uses: actions/checkout@v2
- uses: MinoruSekine/setup-scoop@v1
- name: Verity scoop installation
run: |
powershell scoop help
Get-Command scoop
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test scoop --verbose
- name: Run heavy tests
run: cargo test scoop --verbose -- --ignored

homebrew-test:
runs-on: macos-latest

steps:
- uses: actions/checkout@v2
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
run: cargo test homebrew --verbose
- name: Run heavy tests
run: cargo test --verbose -- --ignored
run: cargo test homebrew --verbose -- --ignored

debian-test:
apt-test:
runs-on: ubuntu-latest
container:
image: docker://rust:latest
Expand All @@ -49,7 +66,7 @@ jobs:
- name: Run heavy tests
run: cargo test apt --verbose -- --ignored

fedora-test:
dnf-test:
runs-on: ubuntu-latest
container:
image: docker://fedora:latest
Expand All @@ -67,7 +84,7 @@ jobs:
- name: Run heavy tests
run: cargo test dnf --verbose -- --ignored

opensuse-test:
zypper-test:
runs-on: ubuntu-latest
container:
image: docker://opensuse/leap:latest
Expand All @@ -90,7 +107,7 @@ jobs:
- name: Run heavy tests
run: $HOME/.cargo/bin/cargo test zypper --verbose -- --ignored --test-threads=1

alpine-test:
apk-test:
runs-on: ubuntu-latest
container:
image: docker://rust:alpine
Expand Down
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"printf",
"proto",
"rdepends",
"refreshenv",
"repoquery",
"rmtree",
"rustfmt",
Expand Down
16 changes: 8 additions & 8 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ lazy_static = "1.4.0"
regex = { version = "1.4.3", default-features = false, features = ["std", "perf"] }
serde = { version = "1.0.123", features = ["derive"] }
thiserror = "1.0.23"
tokio = { version = "1.1.1", features = [
tokio = { version = "1.2.0", features = [
"io-std",
"io-util",
"macros",
"process",
"rt-multi-thread",
"sync",
] }
tokio-stream = "0.1.2"
tokio-stream = "0.1.3"
tokio-util = { version = "0.6.3", features = ["codec"] }
which = "4.0.2"

Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ Run `pacman -Syu` on the OS of your choice!

`pacaptr` supports the following package managers:

- Windows: `chocolatey`
- Windows: `chocolatey`, `scoop`
- As for now, if both `scoop` and `choco` are installed, `scoop` will be the default.
- You can edit the default package manager in your [config](#configuration) if you would like to change this behavior.
- macOS: `homebrew`, `macports`
- Linux: `apt`, `apk`, `dnf`, `zypper`
- External: `conda`, `linuxbrew`, `pip`, `tlmgr`
Expand Down
1 change: 1 addition & 0 deletions docs/compatibility_table.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
homebrew.rs * * * * * * * * * * * * * * * * * *
macports.rs * * * * * * * * * * * * * * * * *
pip.rs * * * * * * * * * *
scoop.rs * * * * * * * * * * * * * *
tlmgr.rs * * * * * * * * * * * *
zypper.rs * * * * * * * * * * * * * * * * * * * * * *
```
7 changes: 5 additions & 2 deletions src/dispatch/opt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl Opts {
/// Automatically detect the name of the package manager in question.
pub fn detect_pm_str<'s>() -> &'s str {
let pairs: &[(&str, &str)] = match () {
_ if cfg!(target_os = "windows") => &[("choco", "")],
_ if cfg!(target_os = "windows") => &[("scoop", ""), ("choco", "")],

_ if cfg!(target_os = "macos") => &[
("brew", "/usr/local/bin/brew"),
Expand All @@ -154,7 +154,7 @@ impl Opts {
_ if cfg!(target_os = "linux") => &[
("apk", "/sbin/apk"),
("apt", "/usr/bin/apt"),
("apt-get", "/usr/bin/apt-get"),
// ("apt-get", "/usr/bin/apt-get"),
("dnf", "/usr/bin/dnf"),
("zypper", "/usr/bin/zypper"),
],
Expand Down Expand Up @@ -210,6 +210,9 @@ impl Opts {
// Chocolatey
"choco" => Box::new(chocolatey::Chocolatey { cfg }),

// Scoop
"scoop" => Box::new(scoop::Scoop { cfg }),

// Homebrew/Linuxbrew
"brew" => Box::new(homebrew::Homebrew { cfg }),

Expand Down
24 changes: 11 additions & 13 deletions src/package_manager/apk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl PackageManager for Apk {
print::print_cmd(&cmd, PROMPT_RUN);
}
let out_bytes = self
.run(cmd, PmMode::Mute, Default::default())
.run(cmd, PmMode::Mute, &Default::default())
.await?
.contents;
search(&String::from_utf8(out_bytes)?);
Expand All @@ -99,7 +99,7 @@ impl PackageManager for Apk {
self.just_run(
Cmd::new_sudo(&["apk", "del"]).kws(kws).flags(flags),
Default::default(),
PROMPT_STRAT.clone(),
&PROMPT_STRAT,
)
.await
}
Expand All @@ -111,7 +111,7 @@ impl PackageManager for Apk {
.kws(kws)
.flags(flags),
Default::default(),
PROMPT_STRAT.clone(),
&PROMPT_STRAT,
)
.await
}
Expand All @@ -123,7 +123,7 @@ impl PackageManager for Apk {
.kws(kws)
.flags(flags),
Default::default(),
PROMPT_STRAT.clone(),
&PROMPT_STRAT,
)
.await
}
Expand All @@ -139,7 +139,7 @@ impl PackageManager for Apk {
self.just_run(
Cmd::new_sudo(&["apk", "add"]).kws(kws).flags(flags),
Default::default(),
INSTALL_STRAT.clone(),
&INSTALL_STRAT,
)
.await
}
Expand All @@ -149,7 +149,7 @@ impl PackageManager for Apk {
self.just_run(
Cmd::new_sudo(&["apk", "cache", "-v", "clean"]).flags(flags),
Default::default(),
PROMPT_STRAT.clone(),
&PROMPT_STRAT,
)
.await
}
Expand All @@ -159,7 +159,7 @@ impl PackageManager for Apk {
self.just_run(
Cmd::new_sudo(&["rm", "-vrf", "/var/cache/apk/*"]).flags(flags),
Default::default(),
PROMPT_STRAT.clone(),
&PROMPT_STRAT,
)
.await
}
Expand Down Expand Up @@ -195,8 +195,7 @@ impl PackageManager for Apk {
} else {
Cmd::new_sudo(&["apk", "add", "-u"]).kws(kws).flags(flags)
};
self.just_run(cmd, Default::default(), INSTALL_STRAT.clone())
.await
self.just_run(cmd, Default::default(), &INSTALL_STRAT).await
}

/// Suy refreshes the local package database, then updates outdated packages.
Expand All @@ -210,16 +209,15 @@ impl PackageManager for Apk {
.kws(kws)
.flags(flags)
};
self.just_run(cmd, Default::default(), INSTALL_STRAT.clone())
.await
self.just_run(cmd, Default::default(), &INSTALL_STRAT).await
}

/// Sw retrieves all packages from the server, but does not install/upgrade anything.
async fn sw(&self, kws: &[&str], flags: &[&str]) -> Result<()> {
self.just_run(
Cmd::new(&["apk", "fetch"]).kws(kws).flags(flags),
Default::default(),
PROMPT_STRAT.clone(),
&PROMPT_STRAT,
)
.await
}
Expand All @@ -241,7 +239,7 @@ impl PackageManager for Apk {
.kws(kws)
.flags(flags),
Default::default(),
INSTALL_STRAT.clone(),
&INSTALL_STRAT,
)
.await
}
Expand Down
18 changes: 9 additions & 9 deletions src/package_manager/apt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl PackageManager for Apt {
self.just_run(
Cmd::new_sudo(&["apt", "remove"]).kws(kws).flags(flags),
Default::default(),
PROMPT_STRAT.clone(),
&PROMPT_STRAT,
)
.await
}
Expand All @@ -81,7 +81,7 @@ impl PackageManager for Apt {
self.just_run(
Cmd::new_sudo(&["apt", "purge"]).kws(kws).flags(flags),
Default::default(),
PROMPT_STRAT.clone(),
&PROMPT_STRAT,
)
.await
}
Expand All @@ -93,7 +93,7 @@ impl PackageManager for Apt {
.kws(kws)
.flags(flags),
Default::default(),
PROMPT_STRAT.clone(),
&PROMPT_STRAT,
)
.await
}
Expand All @@ -104,7 +104,7 @@ impl PackageManager for Apt {
self.just_run(
Cmd::new_sudo(&["apt", "autoremove"]).kws(kws).flags(flags),
Default::default(),
PROMPT_STRAT.clone(),
&PROMPT_STRAT,
)
.await
}
Expand All @@ -119,7 +119,7 @@ impl PackageManager for Apt {
self.just_run(
Cmd::new_sudo(cmd).kws(kws).flags(flags),
Default::default(),
INSTALL_STRAT.clone(),
&INSTALL_STRAT,
)
.await
}
Expand All @@ -129,7 +129,7 @@ impl PackageManager for Apt {
self.just_run(
Cmd::new_sudo(&["apt", "clean"]).kws(kws).flags(flags),
Default::default(),
PROMPT_STRAT.clone(),
&PROMPT_STRAT,
)
.await
}
Expand All @@ -139,7 +139,7 @@ impl PackageManager for Apt {
self.just_run(
Cmd::new_sudo(&["apt", "autoclean"]).kws(kws).flags(flags),
Default::default(),
PROMPT_STRAT.clone(),
&PROMPT_STRAT,
)
.await
}
Expand Down Expand Up @@ -168,13 +168,13 @@ impl PackageManager for Apt {
self.just_run(
Cmd::new_sudo(&["apt", "upgrade"]).flags(flags),
Default::default(),
PROMPT_STRAT.clone(),
&PROMPT_STRAT,
)
.await?;
self.just_run(
Cmd::new_sudo(&["apt", "dist-upgrade"]).flags(flags),
Default::default(),
INSTALL_STRAT.clone(),
&INSTALL_STRAT,
)
.await
} else {
Expand Down
Loading

0 comments on commit 70adeb0

Please sign in to comment.