Merge remote-tracking branch 'origin-crystal/development'

Signed-off-by: trivernis <trivernis@protonmail.com>
i18n
trivernis 2 years ago
commit f763a7aaaf
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -0,0 +1 @@
use flake

1
.gitignore vendored

@ -5,3 +5,4 @@ ame.exe
.idea
result
.DS_Store
.direnv

207
Cargo.lock generated

@ -4,7 +4,7 @@ version = 3
[[package]]
name = "Amethyst"
version = "3.2.0"
version = "3.3.0"
dependencies = [
"clap",
"colored",
@ -77,16 +77,16 @@ checksum = "fff857943da45f546682664a79488be82e69e43c1a7a2307679ab9afb3a66d2e"
[[package]]
name = "clap"
version = "3.1.14"
version = "3.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "535434c063ced786eb04aaf529308092c5ab60889e8fe24275d15de07b01fa97"
checksum = "190814073e85d238f31ff738fcb0bf6910cedeb73376c87cd69291028966fd83"
dependencies = [
"atty",
"bitflags",
"clap_derive",
"clap_lex",
"indexmap",
"lazy_static",
"once_cell",
"strsim",
"termcolor",
"terminal_size",
@ -95,9 +95,9 @@ dependencies = [
[[package]]
name = "clap_derive"
version = "3.1.7"
version = "3.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3aab4734e083b809aaf5794e14e756d1c798d2c69c7f7de7a09a2f5214993c1"
checksum = "759bf187376e1afa7b85b959e6a664a3e7a95203415dba952ad19139e798f902"
dependencies = [
"heck",
"proc-macro-error",
@ -108,9 +108,9 @@ dependencies = [
[[package]]
name = "clap_lex"
version = "0.2.0"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a37c35f1112dad5e6e0b1adaff798507497a18fceeb30cceb3bae7d1427b9213"
checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5"
dependencies = [
"os_str_bytes",
]
@ -190,9 +190,9 @@ dependencies = [
[[package]]
name = "getrandom"
version = "0.2.6"
version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad"
checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6"
dependencies = [
"cfg-if",
"libc",
@ -208,13 +208,19 @@ dependencies = [
"ahash",
]
[[package]]
name = "hashbrown"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db0d4cf898abf0081f964436dc980e96670a0f36863e4b83aaacdb65c9d7ccc3"
[[package]]
name = "hashlink"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7249a3129cbc1ffccd74857f81464a323a152173cdb134e0fd81bc803b29facf"
dependencies = [
"hashbrown",
"hashbrown 0.11.2",
]
[[package]]
@ -245,12 +251,12 @@ dependencies = [
[[package]]
name = "indexmap"
version = "1.8.1"
version = "1.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0f647032dfaa1f8b6dc29bd3edb7bbef4861b8b8007ebb118d6db284fd59f6ee"
checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e"
dependencies = [
"autocfg",
"hashbrown",
"hashbrown 0.12.1",
]
[[package]]
@ -264,9 +270,9 @@ dependencies = [
[[package]]
name = "itoa"
version = "1.0.1"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35"
checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d"
[[package]]
name = "lazy_static"
@ -276,15 +282,15 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
version = "0.2.123"
version = "0.2.126"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb691a747a7ab48abc15c5b42066eaafde10dc427e3b6ee2a1cf43db04c763bd"
checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836"
[[package]]
name = "libmimalloc-sys"
version = "0.1.24"
version = "0.1.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7705fc40f6ed493f73584abbb324e74f96b358ff60dfe5659a0f8fc12c590a69"
checksum = "11ca136052550448f55df7898c6dbe651c6b574fe38a0d9ea687a9f8088a2e2c"
dependencies = [
"cc",
]
@ -301,9 +307,9 @@ dependencies = [
[[package]]
name = "log"
version = "0.4.16"
version = "0.4.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6389c490849ff5bc16be905ae24bc913a9c8892e19b2341dbc175e14c341c2b8"
checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
dependencies = [
"cfg-if",
]
@ -316,15 +322,15 @@ checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f"
[[package]]
name = "memchr"
version = "2.4.1"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a"
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
[[package]]
name = "mimalloc"
version = "0.1.28"
version = "0.1.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b0dfa131390c2f6bdb3242f65ff271fcdaca5ff7b6c08f28398be7f2280e3926"
checksum = "2f64ad83c969af2e732e907564deb0d0ed393cec4af80776f77dd77a1a427698"
dependencies = [
"libmimalloc-sys",
]
@ -349,24 +355,36 @@ dependencies = [
[[package]]
name = "once_cell"
version = "1.10.0"
version = "1.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9"
checksum = "ac8b1a9b2518dc799a2271eff1688707eb315f0d4697aa6b0871369ca4c4da55"
[[package]]
name = "openssl"
version = "0.10.38"
version = "0.10.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c7ae222234c30df141154f159066c5093ff73b63204dcda7121eb082fc56a95"
checksum = "fb81a6430ac911acb25fe5ac8f1d2af1b4ea8a4fdfda0f1ee4292af2e2d8eb0e"
dependencies = [
"bitflags",
"cfg-if",
"foreign-types",
"libc",
"once_cell",
"openssl-macros",
"openssl-sys",
]
[[package]]
name = "openssl-macros"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "openssl-probe"
version = "0.1.5"
@ -375,9 +393,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
[[package]]
name = "openssl-sys"
version = "0.9.72"
version = "0.9.74"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e46109c383602735fa0a2e48dd2b7c892b048e1bf69e5c3b1d804b7d9c203cb"
checksum = "835363342df5fba8354c5b453325b110ffd54044e588c539cf2f20a8014e4cb1"
dependencies = [
"autocfg",
"cc",
@ -388,9 +406,9 @@ dependencies = [
[[package]]
name = "os_str_bytes"
version = "6.0.0"
version = "6.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64"
checksum = "21326818e99cfe6ce1e524c2a805c189a99b5ae555a35d19f9a284b427d86afa"
[[package]]
name = "percent-encoding"
@ -430,18 +448,18 @@ dependencies = [
[[package]]
name = "proc-macro2"
version = "1.0.37"
version = "1.0.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec757218438d5fda206afc041538b2f6d889286160d649a86a24d37e1235afd1"
checksum = "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7"
dependencies = [
"unicode-xid",
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.18"
version = "1.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1"
checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804"
dependencies = [
"proc-macro2",
]
@ -457,18 +475,18 @@ dependencies = [
[[package]]
name = "regex"
version = "1.5.5"
version = "1.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286"
checksum = "d83f127d94bdbcda4c8cc2e50f6f84f4b611f69c902699ca385a39c3a75f9ff1"
dependencies = [
"regex-syntax",
]
[[package]]
name = "regex-syntax"
version = "0.6.25"
version = "0.6.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64"
[[package]]
name = "remove_dir_all"
@ -496,18 +514,18 @@ dependencies = [
[[package]]
name = "ryu"
version = "1.0.9"
version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f"
checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695"
[[package]]
name = "schannel"
version = "0.1.19"
version = "0.1.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75"
checksum = "88d6731146462ea25d9244b2ed5fd1d716d25c52e4d54aa4fb0f3c4e9854dbe2"
dependencies = [
"lazy_static",
"winapi",
"windows-sys",
]
[[package]]
@ -535,18 +553,18 @@ dependencies = [
[[package]]
name = "serde"
version = "1.0.136"
version = "1.0.138"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce31e24b01e1e524df96f1c2fdd054405f8d7376249a5110886fb4b658484789"
checksum = "1578c6245786b9d168c5447eeacfb96856573ca56c9d68fdcf394be134882a47"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.136"
version = "1.0.138"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9"
checksum = "023e9b1467aef8a10fb88f25611870ada9800ef7e22afce356bb0d2387b6f27c"
dependencies = [
"proc-macro2",
"quote",
@ -555,9 +573,9 @@ dependencies = [
[[package]]
name = "serde_json"
version = "1.0.79"
version = "1.0.82"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e8d9fa5c3b304765ce1fd9c4c8a3de2c8db365a5b91be52f186efc675681d95"
checksum = "82c2c1fdcd807d1098552c5b9a36e425e42e9fbd7c6a37a8425f390f781f7fa7"
dependencies = [
"itoa",
"ryu",
@ -566,9 +584,9 @@ dependencies = [
[[package]]
name = "smallvec"
version = "1.8.0"
version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83"
checksum = "2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1"
[[package]]
name = "strsim"
@ -578,13 +596,13 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]]
name = "syn"
version = "1.0.91"
version = "1.0.98"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b683b2b825c8eef438b77c36a06dc262294da3d5a5813fac20da149241dcd44d"
checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd"
dependencies = [
"proc-macro2",
"quote",
"unicode-xid",
"unicode-ident",
]
[[package]]
@ -631,9 +649,9 @@ dependencies = [
[[package]]
name = "tinyvec"
version = "1.5.1"
version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c1c1d5a42b6245520c249549ec267180beaffcc0615401ac8e31853d4b6d8d2"
checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50"
dependencies = [
"tinyvec_macros",
]
@ -646,25 +664,25 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
[[package]]
name = "unicode-bidi"
version = "0.3.7"
version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992"
[[package]]
name = "unicode-ident"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a01404663e3db436ed2746d9fefef640d868edae3cceb81c3b8d5732fda678f"
checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c"
[[package]]
name = "unicode-normalization"
version = "0.1.19"
version = "0.1.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9"
checksum = "854cbdc4f7bc6ae19c820d44abdc3277ac3e1b2b93db20a636825d9322fb60e6"
dependencies = [
"tinyvec",
]
[[package]]
name = "unicode-xid"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
[[package]]
name = "ureq"
version = "2.4.0"
@ -707,9 +725,9 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]]
name = "wasi"
version = "0.10.2+wasi-snapshot-preview1"
version = "0.11.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "winapi"
@ -741,3 +759,46 @@ name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows-sys"
version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2"
dependencies = [
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_msvc",
]
[[package]]
name = "windows_aarch64_msvc"
version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47"
[[package]]
name = "windows_i686_gnu"
version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6"
[[package]]
name = "windows_i686_msvc"
version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024"
[[package]]
name = "windows_x86_64_gnu"
version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1"
[[package]]
name = "windows_x86_64_msvc"
version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680"

@ -1,10 +1,11 @@
[package]
name = "Amethyst"
version = "3.2.0"
version = "3.3.0"
authors = ["michal <michal@tar.black>", "axtlos <axtlos@tar.black>"]
edition = "2021"
description = "A fast and efficient AUR helper"
license-file = "LICENSE.md"
default-run = "ame"
[features]
pkg-warner = []
@ -50,12 +51,12 @@ lto = "fat"
codegen-units = 1
[dependencies]
mimalloc = { version = "0.1.27", default-features = false }
clap = { version = "3.1.9", features = [ "derive", "wrap_help"] }
regex = { version = "1.5.4", default-features = false, features = ["std", "unicode-perl"] }
mimalloc = { version = "0.1.29", default-features = false }
clap = { version = "3.2.8", features = [ "derive", "wrap_help" ] }
regex = { version = "1.5.6", default-features = false, features = [ "std", "unicode-perl" ] }
rusqlite = { version = "0.26.3", default-features = false }
ureq = { version = "2.4.0", default-features = false, features = ["native-tls", "json"] }
serde = { version = "1.0.90", default-features = false, features = ["derive", "serde_derive"] }
native-tls = "0.2.8"
libc = "0.2.123"
colored = "2.0.0"
ureq = { version = "2.4.0", default-features = false, features = [ "native-tls", "json" ] }
serde = { version = "1.0.138", default-features = false, features = [ "derive", "serde_derive" ] }
native-tls = { version = "0.2.10", default-features = false }
libc = { version = "0.2.126", default-features = false }

@ -1,27 +1,37 @@
# Maintainer: Matt C <mdc028[at]bucknell[dot]edu>
# Developer: axtlos <axtlos[at]salyut[dot]one>
# Developer: jnats <jnats[at]salyut[dot]one>
# Maintainer: Matt C <matt[at]tar[dot]black>
# Developer: axtlos <axtlos[at]tar[dot]black>
# Developer: Michal S <michal[at]tar[dot]black>
pkgname=amethyst
pkgver=3.2.0
pkgver=3.3.0
pkgrel=1
pkgdesc="Fast, efficient and lightweight AUR helper/pacman wrapper"
arch=('any')
url="https://git.tar.black/crystal/ame"
pkgdesc="A fast and efficient AUR helper"
arch=('x86_64')
url="https://github.com/crystal-linux/amethyst"
license=('GPL3')
source=("git+https://git.tar.black/crystal/ame")
source=("git+$url")
sha256sums=('SKIP')
depends=('git' 'binutils' 'fakeroot')
makedepends=('cargo' 'make')
depends=('git' 'binutils' 'fakeroot' 'pacman-contrib')
makedepends=('cargo')
conflicts=('ame')
prepare() {
cd "$srcdir/$pkgname"
cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}
build() {
cd ${srcdir}/ame
cargo build --release --all-features
cd "$srcdir/$pkgname"
export RUSTUP_TOOLCHAIN=stable
export CARGO_TARGET_DIR=target
cargo build --frozen --release --all-features
}
package() {
mkdir -p $pkgdir/usr/bin
chmod +x ${srcdir}/ame/target/release/{ame,apt,apt-get,dnf,eopkg,yum,zypper}
cp ${srcdir}/ame/target/release/{ame,apt,apt-get,dnf,eopkg,yum,zypper} $pkgdir/usr/bin/.
cd "$srcdir/$pkgname"
find target/release \
-maxdepth 1 \
-executable \
-type f \
-exec install -Dm0755 -t "${pkgdir}/usr/bin/" {} +
}

@ -63,6 +63,20 @@ Tested on latest Cargo (1.60.0-nightly)
- `cargo build (--release) --all --features=pkg-warner`
### TODO:
#### v3.3.0
- ~~Add clean function~~
- ~~Make flags global~~
- ~~Add pacdiff function~~
- Squash any remaining bugs
#### v3.4.0
- Implement some sort of spinner for longer operations
- Allow editing of PKGBUILDs before install
- Allow to choose provider of package
- Highlight optdepends at the end of an install operation
<!--
echo "AME_UWU=true" >> ~/.zshrc

@ -5,11 +5,11 @@
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1651574473,
"narHash": "sha256-wQhFORvRjo8LB2hTmETmv6cbyKGDPbfWqvZ/0chnDE4=",
"lastModified": 1655042882,
"narHash": "sha256-9BX8Fuez5YJlN7cdPO63InoyBy7dm3VlJkkmTt6fS1A=",
"owner": "nix-community",
"repo": "naersk",
"rev": "f21309b38e1da0d61b881b6b6d41b81c1aed4e1d",
"rev": "cddffb5aa211f50c4b8750adbec0bbbdfb26bb9f",
"type": "github"
},
"original": {
@ -20,11 +20,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1652483617,
"narHash": "sha256-Jxyn3uXFr5LdZNNiippI/obtLXAVBM18uVfiKVP4j9Q=",
"lastModified": 1656755932,
"narHash": "sha256-TGThfOxr+HjFK464+UoUE6rClp2cwxjiKvHcBVdIGSQ=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "ed014c27f4d0ca772fb57d3b8985b772b0503bbd",
"rev": "660ac43ff9ab1f12e28bfb31d4719795777fe152",
"type": "github"
},
"original": {
@ -34,11 +34,11 @@
},
"nixpkgs_2": {
"locked": {
"lastModified": 1652577883,
"narHash": "sha256-2p27P/7EpVStQ1UszTKHi3AiabZqI0fcgvwVFDzfxNI=",
"lastModified": 1656945861,
"narHash": "sha256-L41+pANwxKvhqqGRCKXzugOb81ewFJG95esLobRI1KY=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "1d370bd07399fb52cea6badfbffbc90ac9b0f8f0",
"rev": "4d26010c93091d4cb7fca36b8d3ecb33c89a6f23",
"type": "github"
},
"original": {
@ -56,11 +56,11 @@
},
"utils": {
"locked": {
"lastModified": 1652557277,
"narHash": "sha256-jSes9DaIVMdmwBB78KkFUVrlDzawmD62vrUg0GS2500=",
"lastModified": 1656928814,
"narHash": "sha256-RIFfgBuKz6Hp89yRr7+NR5tzIAbn52h8vT6vXkYjZoM=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "12806d31a381e7cd169a6bac35590e7b36dc5fe5",
"rev": "7e2a3b3dfd9af950a856d66b0a7d01e3c18aa249",
"type": "github"
},
"original": {

@ -22,7 +22,7 @@
];
};
defaultPackage = packages.amethyst;
packages.default = packages.amethyst;
apps.amethyst = utils.lib.mkApp {
drv = packages.amethyst;
@ -30,7 +30,7 @@
apps.default = apps.amethyst;
devShell = pkgs.mkShell {
devShells.default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
rustc
cargo

@ -1,41 +1,45 @@
use clap::{Parser, Subcommand};
#[derive(Debug, Clone, Parser)]
#[clap(name="Amethyst", version=env!("CARGO_PKG_VERSION"), about=env!("CARGO_PKG_DESCRIPTION"))]
#[clap(name = "Amethyst", version = env ! ("CARGO_PKG_VERSION"), about = env ! ("CARGO_PKG_DESCRIPTION"))]
pub struct Args {
#[clap(subcommand)]
pub subcommand: Option<Operation>,
/// Sets the level of verbosity
#[clap(long, short, parse(from_occurrences))]
#[clap(long, short, parse(from_occurrences), global = true)]
pub verbose: usize,
/// Complete operation without prompting user
#[clap(long = "noconfirm")]
#[clap(long = "noconfirm", global = true)]
pub no_confirm: bool,
}
#[derive(Debug, Clone, Subcommand)]
pub enum Operation {
/// Installs a package from either the AUR or the PacMan-defined repositories
#[clap(name="install", aliases=&["ins", "in", "i", "-S"])]
#[clap(name = "install", aliases = & ["ins", "in", "i", "-S"])]
Install(InstallArgs),
/// Removes a previously installed package
#[clap(name="remove", aliases=&["rm", "r", "-R", "-Rs"])]
#[clap(name = "remove", aliases = & ["rm", "r", "-R", "-Rs"])]
Remove(RemoveArgs),
/// Searches for the relevant packages in both the AUR and repos
#[clap(name="search", aliases=&["sea", "se", "s", "-Ss"])]
#[clap(name = "search", aliases = & ["sea", "sear", "se", "s", "-Ss"])]
Search(SearchArgs),
/// Queries installed packages
#[clap(name="query", aliases=&["ls", "l", "-Q"])]
#[clap(name = "query", aliases = & ["q", "qu", "l", "ls", "-Q"])]
Query(QueryArgs),
/// Upgrades locally installed packages to their latest versions
#[clap(name="upgrade", aliases=&["upg", "up", "u", "-Syu"])]
#[clap(name = "upgrade", aliases = & ["upg", "up", "u", "-Syu"])]
Upgrade,
/// Removes all orphaned packages
#[clap(name = "clean", aliases = & ["cln", "cl", "-Sc"])]
Clean,
}
impl Default for Operation {

@ -1,8 +1,7 @@
use rusqlite::Connection;
use std::env;
use std::path::Path;
use rusqlite::Connection;
use crate::internal::exit_code::AppExitCode;
use crate::{crash, log, Options};

@ -1,10 +1,10 @@
mod add;
mod initialise;
mod query;
mod remove;
use std::{env, path::PathBuf};
pub mod add;
pub mod initialise;
pub mod query;
pub mod remove;
pub use add::*;
pub use initialise::*;
pub use query::*;

@ -1,8 +1,7 @@
use rusqlite::Connection;
use std::env;
use std::path::Path;
use rusqlite::Connection;
use crate::internal::rpc::Package;
use crate::{log, Options};

@ -1,8 +1,9 @@
use crate::internal::error::{AppError, AppResult};
use crate::internal::is_tty;
use std::ffi::{OsStr, OsString};
use std::process::{Child, Command, ExitStatus, Stdio};
use crate::internal::error::{AppError, AppResult};
use crate::internal::is_tty;
pub struct StringOutput {
pub stdout: String,
pub stderr: String,
@ -28,6 +29,10 @@ impl ShellCommand {
}
}
pub fn pacdiff() -> Self {
Self::new("pacdiff")
}
pub fn makepkg() -> Self {
Self::new("makepkg")
}

@ -0,0 +1,31 @@
use crate::internal::commands::ShellCommand;
use crate::internal::error::SilentUnwrap;
use crate::internal::exit_code::AppExitCode;
use crate::{prompt, warn};
pub fn detect() {
let mut pacnew = vec![];
for entry in std::fs::read_dir("/etc").unwrap() {
let entry = entry.unwrap();
let path = entry.path();
if path.to_str().unwrap().contains(".pacnew") || path.to_str().unwrap().contains(".pacsave")
{
pacnew.push(path);
}
}
if !pacnew.is_empty() {
let choice = prompt!(default false, "It appears that at least one program you have installed / upgraded has installed a .pacnew/.pacsave config file. Would you like to run pacdiff to deal with this? You can always deal with this later by running `sudo pacdiff`");
if choice {
warn!("Unless you've set an alternative using the DIFFPROG environment variable, pacdiff uses `vimdiff` by default to edit files for merging. Make sure you know how to exit vim before proceeding");
let cont = prompt!(default false, "Continue?");
if cont {
ShellCommand::pacdiff()
.elevated()
.wait()
.silent_unwrap(AppExitCode::PacmanError);
}
}
}
}

@ -1,9 +1,10 @@
use crate::internal::exit_code::AppExitCode;
use crate::log_and_crash;
use std::error::Error;
use std::fmt::{Debug, Display, Formatter};
use std::io;
use crate::crash;
pub type AppResult<T> = Result<T, AppError>;
#[derive(Debug)]
@ -51,7 +52,7 @@ impl<T> SilentUnwrap<T> for AppResult<T> {
fn silent_unwrap(self, exit_code: AppExitCode) -> T {
match self {
Ok(val) => val,
Err(_) => log_and_crash("an error occurred", exit_code),
Err(_) => crash!(exit_code, "an error occurred"),
}
}
}

@ -1,9 +1,8 @@
use crate::internal::exit_code::AppExitCode;
use std::env;
use std::path::Path;
use std::process::Command;
use crate::{crash, log, Options};
use crate::{crash, internal::exit_code::AppExitCode, log, Options};
pub fn init(options: Options) {
let verbosity = options.verbosity;

@ -1,5 +1,12 @@
pub use clean::*;
pub use detect::*;
pub use initialise::*;
pub use sort::*;
use std::env;
mod clean;
pub mod commands;
mod detect;
pub mod error;
pub mod exit_code;
mod initialise;
@ -9,12 +16,6 @@ pub mod structs;
#[macro_use]
pub(crate) mod utils;
pub use clean::*;
pub use initialise::*;
pub use sort::*;
use std::env;
pub use utils::*;
#[macro_export]
macro_rules! uwu {
($x:expr) => {{

@ -9,6 +9,7 @@ use colored::*;
const OK_SYMBOL: &str = "❖";
const ERR_SYMBOL: &str = "❌";
const WARN_SYMBOL: &str = "!";
const PROMPT_SYMBOL: &str = "?";
const PROMPT_YN_DEFAULT_TRUE: &str = "[Y/n]";
@ -21,6 +22,13 @@ macro_rules! info {
}
}
#[macro_export]
macro_rules! warn {
($($arg:tt)+) => {
$crate::internal::utils::log_warn(format!($($arg)+))
}
}
#[macro_export]
macro_rules! crash {
($exit_code:expr, $($arg:tt)+) => {
@ -53,6 +61,17 @@ pub fn log_info<S: ToString>(msg: S) {
println!("{} {}", OK_SYMBOL.purple(), msg.bold())
}
pub fn log_warn<S: ToString>(msg: S) {
let msg = msg.to_string();
let msg = if internal::uwu_enabled() {
uwu!(&msg)
} else {
msg
};
println!("{} {}", WARN_SYMBOL.yellow(), msg.bold())
}
pub fn log_and_crash<S: ToString>(msg: S, exit_code: AppExitCode) -> ! {
let msg = msg.to_string();
let msg = if internal::uwu_enabled() {

@ -1,12 +1,12 @@
use clap::Parser;
use crate::args::{InstallArgs, Operation, QueryArgs, RemoveArgs, SearchArgs};
use args::Args;
use clap::Parser;
use internal::commands::ShellCommand;
use internal::error::SilentUnwrap;
use crate::args::{InstallArgs, Operation, QueryArgs, RemoveArgs, SearchArgs};
use crate::internal::detect;
use crate::internal::exit_code::AppExitCode;
use crate::internal::{init, log_and_crash, log_info, sort, structs::Options};
use crate::internal::{init, sort, structs::Options};
#[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
@ -18,7 +18,7 @@ mod operations;
fn main() {
if unsafe { libc::geteuid() } == 0 {
log_and_crash("Running amethyst as root is disallowed as it can lead to system breakage. Instead, amethyst will prompt you when it needs superuser permissions".to_string(), AppExitCode::RunAsRoot);
crash!( AppExitCode::RunAsRoot, "Running amethyst as root is disallowed as it can lead to system breakage. Instead, amethyst will prompt you when it needs superuser permissions");
}
let args: Args = Args::parse();
@ -40,20 +40,23 @@ fn main() {
Operation::Search(search_args) => cmd_search(search_args, options),
Operation::Query(query_args) => cmd_query(query_args),
Operation::Upgrade => {
log_info("Performing system upgrade".to_string());
info!("Performing system upgrade");
operations::upgrade(options);
}
Operation::Clean => {
info!("Removing orphaned packages");
operations::clean(options);
}
}
detect();
}
fn cmd_install(args: InstallArgs, options: Options) {
let packages = args.packages;
let sorted = sort(&packages, options);
log_info(format!(
"Attempting to install packages: {}",
packages.join(", ")
));
info!("Attempting to install packages: {}", packages.join(", "));
if !sorted.repo.is_empty() {
operations::install(sorted.repo, options);
@ -62,12 +65,10 @@ fn cmd_install(args: InstallArgs, options: Options) {
operations::aur_install(sorted.aur, options);
}
if !sorted.nf.is_empty() {
log_and_crash(
format!(
"Couldn't find packages: {} in repos or the AUR",
sorted.nf.join(", ")
),
crash!(
AppExitCode::PacmanError,
"Couldn't find packages: {} in repos or the AUR",
sorted.nf.join(", ")
);
}
@ -83,29 +84,29 @@ fn cmd_install(args: InstallArgs, options: Options) {
.split_whitespace()
.collect::<Vec<&str>>()
.join(", ");
log_info(format!("You have .pacnew files in /etc ({pacnew_files}) that you haven't removed or acted upon, it is recommended you do that now", ));
info!("You have .pacnew files in /etc ({pacnew_files}) that you haven't removed or acted upon, it is recommended you do that now" );
}
}
fn cmd_remove(args: RemoveArgs, options: Options) {
let packages = args.packages;
log_info(format!("Uninstalling packages: {}", &packages.join(", ")));
info!("Uninstalling packages: {}", &packages.join(", "));
operations::uninstall(packages, options);
}
fn cmd_search(args: SearchArgs, options: Options) {
let query_string = args.search.join(" ");
if args.aur {
log_info(format!("Searching AUR for {}", &query_string));
info!("Searching AUR for {}", &query_string);
operations::aur_search(&query_string, options);
}
if args.repo {
log_info(format!("Searching repos for {}", &query_string));
info!("Searching repos for {}", &query_string);
operations::search(&query_string, options);
}
if !args.aur && !args.repo {
log_info(format!("Searching AUR and repos for {}", &query_string));
info!("Searching AUR and repos for {}", &query_string);
operations::search(&query_string, options);
operations::aur_search(&query_string, options);
}

@ -0,0 +1,113 @@
use std::process::Command;
use crate::crash;
use crate::info;
use crate::internal::commands::ShellCommand;
use crate::internal::error::SilentUnwrap;
use crate::internal::exit_code::AppExitCode;
use crate::log;
use crate::prompt;
use crate::Options;
pub fn clean(options: Options) {
let verbosity = options.verbosity;
let noconfirm = options.noconfirm;
let orphaned_packages = ShellCommand::pacman()
.arg("-Qdtq")
.wait_with_output()
.silent_unwrap(AppExitCode::PacmanError);
if orphaned_packages.stdout.as_str() == "" {
info!("No orphaned packages found");
} else {
info!(
"Removing orphans would uninstall the following packages: \n{}",
&orphaned_packages.stdout
);
let cont = prompt!(default false, "Continue?");
if !cont {
info!("Exiting");
std::process::exit(AppExitCode::PacmanError as i32);
}
let mut pacman_args = vec!["-Rns"];
if noconfirm {
pacman_args.push("--noconfirm");
}
let orphaned_packages_vec = orphaned_packages.stdout.split('\n').collect::<Vec<&str>>();
for package in &orphaned_packages_vec {
if !package.is_empty() {
pacman_args.push(package);
}
}
if verbosity >= 1 {
log!("Removing orphans: {:?}", orphaned_packages_vec);
}
let pacman_result = ShellCommand::pacman()
.elevated()
.args(pacman_args)
.wait()
.silent_unwrap(AppExitCode::PacmanError);
if pacman_result.success() {
info!("Successfully removed orphans");
} else {
crash!(AppExitCode::PacmanError, "Failed to remove orphans",);
}
}
let clear_cache = if !noconfirm {
prompt!(default false, "Also clear pacman's package cache?")
} else {
true
};
if clear_cache {
let mut pacman_args = vec!["-Sc"];
if noconfirm {
pacman_args.push("--noconfirm");
}
let mut paccache_args = vec!["-r"];
if noconfirm {
paccache_args.push("--noconfirm");
}
if verbosity >= 1 {
log!("Clearing using `paccache -r`");
}
Command::new("sudo")
.arg("paccache")
.args(paccache_args)
.spawn()
.unwrap_or_else(|e| {
crash!(
AppExitCode::PacmanError,
"Couldn't clear cache using `paccache -r`, {}",
e,
)
})
.wait()
.unwrap();
if verbosity >= 1 {
log!("Clearing using `pacman -Sc`");
}
let pacman_result = ShellCommand::pacman()
.elevated()
.args(pacman_args)
.wait()
.silent_unwrap(AppExitCode::PacmanError);
if pacman_result.success() {
info!("Successfully cleared package cache");
} else {
crash!(AppExitCode::PacmanError, "Failed to clear package cache",);
}
}
}

@ -1,11 +1,13 @@
mod aur_install;
mod install;
mod search;
mod uninstall;
mod upgrade;
pub use aur_install::*;
pub use clean::*;
pub use install::*;
pub use search::{aur_search, repo_search as search};
pub use uninstall::*;
pub use upgrade::*;
mod aur_install;
mod clean;
mod install;
mod search;
mod uninstall;
mod upgrade;

@ -3,7 +3,7 @@ use crate::internal::error::SilentUnwrap;
use crate::internal::exit_code::AppExitCode;
use crate::internal::rpc::rpcinfo;
use crate::operations::aur_install::aur_install;
use crate::{info, log, Options};
use crate::{info, log, prompt, Options};
pub fn upgrade(options: Options) {
let verbosity = options.verbosity;
@ -18,12 +18,24 @@ pub fn upgrade(options: Options) {
log!("Upgrading repo packages");
}
ShellCommand::pacman()
let pacman_result = ShellCommand::pacman()
.elevated()
.args(pacman_args)
.wait_success()
.wait()
.silent_unwrap(AppExitCode::PacmanError);
if pacman_result.success() {
info!("Successfully upgraded repo packages");
} else {
let cont = prompt!(default false,
"Failed to upgrade repo packages, continue to upgrading AUR packages?",
);
if !cont {
info!("Exiting");
std::process::exit(AppExitCode::PacmanError as i32);
}
}
if verbosity >= 1 {
log!("Upgrading AUR packages");
}

Loading…
Cancel
Save