fixed aurdepends

i18n
jnats 3 years ago
parent 8c5eadbe0d
commit 8fd94a8eb5

@ -1,6 +1,6 @@
[package]
name = "ame"
version = "2.1.2"
version = "2.2.0"
authors = [ "jnats <jnats@salyut.one>", "axtlos <axtlos@salyut.one>" ]
edition = "2018"
description = "a fast and efficient aur helper."

@ -1,7 +1,7 @@
mod mods;
use mods::{clearcache::clearcache, clone::clone, help::help, install::install, search::{a_search, r_search}, uninstall::uninstall, upgrade::upgrade, update::update, ver::ver, strs::inf, strs::err_unrec, strs::err_rec};
use std::{env, process::exit, process::Command, process::Stdio};
use mods::{clearcache::clearcache, clone::clone, help::help, install::install, inssort::inssort, search::{a_search, r_search}, uninstall::uninstall, upgrade::upgrade, update::update, ver::ver, strs::inf, strs::err_unrec, strs::err_rec};
use std::{env, process::exit, process::Command};
fn main() {
// let statements
@ -19,47 +19,12 @@ fn main() {
// install
if oper == "-S" || oper == "-Sn" || oper == "ins" {
let pkgs = env::args().skip(2);
let mut repo = vec![];
let mut aur = vec![];
for pkg in pkgs {
let out = Command::new("pacman")
.arg("-Ss")
.arg(&pkg)
.stdout(Stdio::null())
.status()
.expect("Something has gone wrong.");
match out.code() {
Some(0) => {
repo.push(pkg)
}
Some(1) => {
aur.push(pkg)
}
Some(_) => {
err_unrec(format!("Something has gone terribly wrong"))
}
None => {
err_unrec(format!("Process terminated"))
}}}
if repo.len() != 0 {
inf(format!("Installing repo packages: {}", &repo.join(", ")));
if oper == "-Sn" {
install(true, &repo.join(" "));
} else {
install(false, &repo.join(" "));
}
}
for a in aur {
inf(format!("Installing AUR package: {}", a));
if oper == "-Sn" {
clone(true, &a);
} else {
clone(false, &a);
}
}
let pkgs = env::args().skip(2).collect();
if oper == "-Sn" {
inssort(true, pkgs);
} else {
inssort(false, pkgs);
}
// remove
} else if oper == "-R" || oper == "-Rn " || oper == "-Rsn" || oper == "-Rs" || oper == "rm" {

@ -8,3 +8,4 @@ pub mod upgrade;
pub mod update;
pub mod strs;
pub mod ver;
pub mod inssort;

@ -1,12 +1,11 @@
use git2::Repository;
use std::{env, fs, path::Path, process::Command};
use crate::mods::strs::{err_unrec, inf};
use crate::{err_unrec, inf, inssort};
pub fn clone(noconfirm: bool, pkg: &str) {
let cachedir = format!("{}/.cache/ame", std::env::var("HOME").unwrap());
let path = Path::new(&cachedir);
let pkgdir = format!("{}/{}", &cachedir, &pkg);
let pkgpath = Path::new(&pkgdir);
let results = raur::search(&pkg).unwrap();
if results.len() == 0 {
@ -28,8 +27,8 @@ pub fn clone(noconfirm: bool, pkg: &str) {
inf(format!("Cloning {} ...", pkg));
if pkgpath.is_dir() {
let rm_result = fs::remove_dir_all(&pkgpath);
if Path::new(&pkgdir).is_dir() {
let rm_result = fs::remove_dir_all(&pkgdir);
match rm_result {
Ok(_) => {
inf(format!("Package path for {} already found. Removing to reinstall", pkg))
@ -57,16 +56,15 @@ pub fn clone(noconfirm: bool, pkg: &str) {
err_unrec(format!("Could not enter package directory"))
}}
Repository::clone(&url, &pkgpath).unwrap();
let cd2_result = env::set_current_dir(&pkgpath);
match cd2_result {
Ok(_) => {
inf(format!("Entering package directory for {}", pkg))
let aurpkgname = results[0].name.to_string();
let depends = raur::info(&[&aurpkgname]).unwrap()[0].depends.clone();
if noconfirm == true {
inssort(true, depends);
} else {
inssort(false, depends);
}
Err(_) => {
err_unrec(format!("Couldn't enter package directory for {}", pkg))
}}
Repository::clone(&url, Path::new(&pkgdir)).unwrap();
if noconfirm == true {
inf(format!("Installing {} ...", pkg));

@ -0,0 +1,45 @@
use crate::{clone, install, inf, err_unrec};
use std::process::{Stdio, Command};
pub fn inssort(noconfirm: bool, pkgs: Vec<String>) {
let mut repo = vec![];
let mut aur = vec![];
for pkg in pkgs {
let out = Command::new("pacman")
.arg("-Ss")
.arg(&pkg)
.stdout(Stdio::null())
.status()
.expect("Something has gone wrong.");
match out.code() {
Some(0) => {
repo.push(pkg)
}
Some(1) => {
aur.push(pkg)
}
Some(_) => {
err_unrec(format!("Something has gone terribly wrong"))
}
None => {
err_unrec(format!("Process terminated"))
}}}
if repo.len() != 0 {
inf(format!("Installing repo packages: {}", &repo.join(", ")));
if noconfirm == true {
install(true, &repo.join(" "));
} else {
install(false, &repo.join(" "));
}
}
for a in aur {
inf(format!("Installing AUR package: {}", a));
if noconfirm == true {
clone(true, &a);
} else {
clone(false, &a);
}
}
}
Loading…
Cancel
Save