added aur updates, no idea why this wasnt there earlier

i18n
axtloss 3 years ago
parent 2433054833
commit 27b5367dee
No known key found for this signature in database
GPG Key ID: CB97071D2AF98474

3
.gitignore vendored

@ -1,3 +1,4 @@
target/
Cargo.lock
ame
ame
.vscode

@ -12,4 +12,5 @@ git2 = "*"
raur = "2.0.2"
runas = "*"
toml = "*"
serde = "*"
serde = "*"
walkdir = "*"

@ -51,8 +51,9 @@ fn main() {
help();
exit(1);
}
let oper = &args[1];
let clone_path=configfile.cache.unwrap();
let cache_path=configfile.cache.unwrap();
if oper == "-S" || oper == "ins" || oper == "install" {
for arg in env::args().skip(2) {
if configfile.backends.pacman.unwrap() == true {
@ -62,7 +63,7 @@ fn main() {
install(configoption_noconfirm, &arg);
} else {
if configfile.backends.aur.unwrap() == true {
clone(&arg, &clone_path);
clone(&arg, &cache_path);
} else {
println!("ERROR: the package wasn't found in the repos and aur support is disabled");
println!("Please enable aur support if you wish to check if this package exists in the aur");
@ -70,7 +71,7 @@ fn main() {
}
}
} else if configfile.backends.aur.unwrap() == true {
clone(&arg, &clone_path)
clone(&arg, &cache_path)
} else {
println!("ERROR: it seems like neither pacman, nor aur support is enabled!");
println!("Please enable either one of those option and try again");
@ -84,7 +85,7 @@ fn main() {
}
} else if oper == "-Syu" || oper=="upg" || oper=="upgrade" {
let configoption_noconfirm = configfile.pacman.noconfirm.unwrap();
upgrade(configoption_noconfirm);
upgrade(configoption_noconfirm, &cache_path);
} else if oper == "-Ss" || oper=="sear" || oper=="search" {
for arg in env::args().skip(2) {
r_search(&arg);

@ -1,19 +1,21 @@
use git2::Repository;
use std::{fs, path::Path, process::Command};
use std::{env, fs, path::Path, process::Command};
pub fn clone(pkg: &str, cachedir: &str) {
let error = format!("Couldn't install {}", &pkg);
let path = Path::new(&cachedir);
let pkgdir=format!("{}/{}", &cachedir, &pkg);
let pkgpath = Path::new(&pkgdir);
env::set_current_dir(&pkgdir);
fs::create_dir(&pkg);
let results = raur::search(&pkg).expect(&error);
let url = format!("https://aur.archlinux.org/{}.git", results[0].name);
if path.exists() {
fs::remove_dir_all(path).unwrap();
}
println!("Cloning {} ...", pkg);
Repository::clone(&url, &path).unwrap();
println!("{}", &cachedir);
Repository::clone(&url, &pkgpath).unwrap();
env::set_current_dir(&pkgpath);
println!("Installing {} ...", pkg);
Command::new("makepkg")
.current_dir(&cachedir)
.arg("-si")
.status()
.expect(&error);

@ -1,6 +1,9 @@
use runas::Command;
use walkdir::WalkDir;
use git2::Repository;
use std::{path, env};
pub fn upgrade(noconfirm: bool) {
pub fn upgrade(noconfirm: bool, cachedir: &str){
let errstr = format!("Something happened");
if noconfirm == true {
Command::new("pacman")
@ -14,4 +17,18 @@ pub fn upgrade(noconfirm: bool) {
.status()
.expect(&errstr);
}
}
for file in std::fs::read_dir(&cachedir).unwrap() {
let dir = &file.unwrap().path();
env::set_current_dir(&dir);
let output = std::process::Command::new("git").arg("pull").output().unwrap();
let update_available = String::from_utf8(output.stdout).unwrap();
if update_available != "Already up to date." {
let path_as_str = &dir.display().to_string();
let pkg: Vec<&str> = path_as_str.split("/").collect();
println!("{} is up to date", pkg[pkg.len()-1]);
} else {
env::set_current_dir(&dir);
std::process::Command::new("makepkg").arg("-si");
}
}
}

Loading…
Cancel
Save