|
|
|
@ -1,12 +1,13 @@
|
|
|
|
|
use git2::Repository;
|
|
|
|
|
use std::{fs, path::Path};
|
|
|
|
|
use std::{fs, path::Path, process::Command};
|
|
|
|
|
|
|
|
|
|
pub fn clone(pkg: &str) {
|
|
|
|
|
let cachedir = format!("{}/.cache/ame/{}", std::env::var("HOME").unwrap(), pkg);
|
|
|
|
|
let error = format!("Package {} not found.", &pkg);
|
|
|
|
|
let error = format!("Couldn't install {}", &pkg);
|
|
|
|
|
let path = Path::new(&cachedir);
|
|
|
|
|
let results = raur::search(&pkg).expect(&error);
|
|
|
|
|
let url = format!("https://aur.archlinux.org/{}.git", &pkg);
|
|
|
|
|
let mkpkg = format!("{}{}/PKGBUILD", cachedir, pkg);
|
|
|
|
|
|
|
|
|
|
if path.exists() {
|
|
|
|
|
fs::remove_dir_all(path).unwrap();
|
|
|
|
@ -15,6 +16,12 @@ pub fn clone(pkg: &str) {
|
|
|
|
|
for _res in results.first() {
|
|
|
|
|
println!("Cloning {} ...", pkg);
|
|
|
|
|
Repository::clone(&url, &path).unwrap();
|
|
|
|
|
println!("Installing {} ...", pkg);
|
|
|
|
|
Command::new("makepkg")
|
|
|
|
|
.arg(&mkpkg)
|
|
|
|
|
.spawn()
|
|
|
|
|
.expect(&error);
|
|
|
|
|
println!("{}", mkpkg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|