i18n
michal 3 years ago
parent 0a0d148d54
commit 94af1ffe75

@ -1,15 +1,12 @@
use crate::{ use crate::{
err_unrec, inf, mods::database::add_pkg, mods::purge::purge, mods::rpc::*, mods::strs::prompt, err_unrec, inf, mods::database::add_pkg, mods::purge::purge, mods::rpc::*, mods::strs::prompt,
mods::strs::sec, mods::strs::succ, mods::strs::sec, mods::strs::succ, inssort
}; };
use moins::Moins; use moins::Moins;
use std::{env, fs, path::Path, process::Command}; use std::{env, fs, path::Path, process::Command};
fn uninstall_make_depend(pkg: &str) { fn uninstall_make_depend(pkg: &str) {
// uninstall make depends of a package // uninstall make depends of a package
// gets the "make_depends" field of the package using rpcinfo()
// let make_depends = rpcinfo(pkg)[0].make_depends;
let make_depends = rpcinfo(pkg).make_depends; let make_depends = rpcinfo(pkg).make_depends;
let explicit_packages = Command::new("pacman") let explicit_packages = Command::new("pacman")
@ -52,6 +49,7 @@ pub fn clone(noconfirm: bool, as_dep: bool, pkg: &str) {
let path = Path::new(&cachedir); let path = Path::new(&cachedir);
let pkgdir = format!("{}/{}", &cachedir, &pkg); let pkgdir = format!("{}/{}", &cachedir, &pkg);
let search = rpcsearch(pkg).results; let search = rpcsearch(pkg).results;
let package = search.first().unwrap();
if search.is_empty() { if search.is_empty() {
err_unrec("No matching AUR packages found".to_string()); err_unrec("No matching AUR packages found".to_string());
} }
@ -99,15 +97,13 @@ pub fn clone(noconfirm: bool, as_dep: bool, pkg: &str) {
} }
sec("Installing AUR package depends".to_string()); sec("Installing AUR package depends".to_string());
// inssort(noconfirm, true, package[0].depends.clone());
let clone = std::process::Command::new("git") let clone = std::process::Command::new("git")
.arg("clone") .arg("clone")
.arg(&url) .arg(&url)
.arg(&pkgdir) .arg(&pkgdir)
.status() .status()
.expect("couldnt clone repository"); .expect("Couldn't clone repository");
match clone.code() { match clone.code() {
Some(0) => { Some(0) => {
inf(format!("Cloning {} into package directory", pkg)); inf(format!("Cloning {} into package directory", pkg));

@ -1,4 +1,4 @@
use crate::{clone, err_unrec, install, mods::strs::sec}; use crate::{clone, err_unrec, install, mods::strs::sec, mods::rpc::*};
use regex::Regex; use regex::Regex;
use std::process::{Command, Stdio}; use std::process::{Command, Stdio};
@ -6,8 +6,8 @@ pub fn inssort(noconfirm: bool, as_dep: bool, pkgs: Vec<String>) {
// TODO: understand what the fuck is actually going on here // TODO: understand what the fuck is actually going on here
let mut repo = vec![]; let mut repo = vec![];
let mut aur = vec![]; let mut aur = vec![];
let re = Regex::new(r"(\S+)((?:>=|<=)\S+$)").unwrap(); let re = Regex::new(r"(\S+)((?:>=|<=|>|<)\S+$)").unwrap();
let reg = Regex::new(r"((?:>=|<=)\S+$)").unwrap(); let reg = Regex::new(r"((?:>=|<=|>|<)\S+$)").unwrap();
for pkg in pkgs { for pkg in pkgs {
match pkg.contains('/') { match pkg.contains('/') {
true => match pkg.split('/').collect::<Vec<&str>>()[0] == "aur" { true => match pkg.split('/').collect::<Vec<&str>>()[0] == "aur" {
@ -83,6 +83,8 @@ pub fn inssort(noconfirm: bool, as_dep: bool, pkgs: Vec<String>) {
for a in aur { for a in aur {
sec(format!("Couldn't find {} in repos. Searching AUR", a)); sec(format!("Couldn't find {} in repos. Searching AUR", a));
let md = &rpcinfo(&a).make_depends;
inssort(noconfirm, true, md.to_vec());
clone(noconfirm, false, &a); clone(noconfirm, false, &a);
} }
} else { } else {
@ -93,6 +95,8 @@ pub fn inssort(noconfirm: bool, as_dep: bool, pkgs: Vec<String>) {
for a in aur { for a in aur {
sec(format!("Couldn't find {} in repos. Searching AUR", a)); sec(format!("Couldn't find {} in repos. Searching AUR", a));
let md = &rpcinfo(&a).make_depends;
inssort(noconfirm, true, md.to_vec());
clone(noconfirm, true, &a); clone(noconfirm, true, &a);
} }
} }
@ -184,6 +188,8 @@ pub fn inssort_from_file(noconfirm: bool, as_dep: bool, file: &str) {
for a in aur { for a in aur {
sec(format!("Couldn't find {} in repos. Searching AUR", a)); sec(format!("Couldn't find {} in repos. Searching AUR", a));
let md = &rpcinfo(&a).make_depends;
inssort(noconfirm, true, md.to_vec());
clone(noconfirm, false, &a); clone(noconfirm, false, &a);
} }
} else { } else {
@ -194,6 +200,8 @@ pub fn inssort_from_file(noconfirm: bool, as_dep: bool, file: &str) {
for a in aur { for a in aur {
sec(format!("Couldn't find {} in repos. Searching AUR", a)); sec(format!("Couldn't find {} in repos. Searching AUR", a));
let md = &rpcinfo(&a).make_depends;
inssort(noconfirm, true, md.to_vec());
clone(noconfirm, true, &a); clone(noconfirm, true, &a);
} }
} }

@ -1,4 +1,4 @@
#[derive(serde::Deserialize, Debug)] #[derive(serde::Deserialize, Debug, Clone)]
pub struct Package { pub struct Package {
#[serde(rename = "Name")] #[serde(rename = "Name")]
pub name: String, pub name: String,
@ -24,18 +24,16 @@ pub fn rpcinfo(pkg: &str) -> Package {
let res = reqwest::blocking::get(&format!( let res = reqwest::blocking::get(&format!(
"https://aur.archlinux.org/rpc/?v=5&type=info&arg={}", "https://aur.archlinux.org/rpc/?v=5&type=info&arg={}",
pkg pkg
)) )).unwrap();
.unwrap();
res.json().unwrap() res.json::<SearchResults>().unwrap().results[0].clone()
} }
pub fn rpcsearch(pkg: &str) -> SearchResults { pub fn rpcsearch(pkg: &str) -> SearchResults {
let res = reqwest::blocking::get(&format!( let res = reqwest::blocking::get(&format!(
"https://aur.archlinux.org/rpc/?v=5&type=search&arg={}", "https://aur.archlinux.org/rpc/?v=5&type=search&arg={}",
pkg pkg
)) )).unwrap();
.unwrap();
res.json().unwrap() res.json().unwrap()
} }

Loading…
Cancel
Save