remove libgit2 and switch to using git itself for cloning

i18n
Amy 3 years ago
parent 5d73021e3a
commit 4d7899c45b
No known key found for this signature in database
GPG Key ID: 6672E6DD65BEA50B

@ -8,7 +8,6 @@ description = "a fast and efficient aur helper."
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
git2 = "*"
raur = "3.0.1" raur = "3.0.1"
runas = "*" runas = "*"
ansi_term = "*" ansi_term = "*"

@ -1,6 +1,6 @@
mod mods; mod mods;
use mods::{clearcache::{clearcache}, clone::clone, help::help, inssort::{inssort, inssort_from_file}, install::install, purge::{purge, purge_from_file}, search::{a_search, r_search}, strs::err_rec, strs::err_unrec, strs::inf, uninstall::{uninstall, uninstall_from_file}, update::{update}, upgrade::{upgrade}, ver::ver, xargs::*}; use mods::{clearcache::{clearcache}, clone::clone, help::help, inssort::{inssort, inssort_from_file}, install::install, purge::{purge, purge_from_file}, search::{a_search, r_search}, strs::err_rec, strs::err_unrec, strs::inf, uninstall::{uninstall, uninstall_from_file}, update::{update}, upgrade::{upgrade}, ver::ver, xargs::*};
use std::{env, process::exit, process::Command}; use std::{env, process::exit};
use nix::unistd::Uid; use nix::unistd::Uid;
fn main() { fn main() {
@ -9,7 +9,7 @@ fn main() {
err_unrec(format!("Do not run ame as root! this can cause serious damage to your system!")); err_unrec(format!("Do not run ame as root! this can cause serious damage to your system!"));
} }
let args: Vec<String> = env::args().collect(); let args: Vec<String> = env::args().skip(1).collect();
let mut pkgs: Vec<String> = env::args().skip(2).collect(); let mut pkgs: Vec<String> = env::args().skip(2).collect();
if args.len() <= 1 { if args.len() <= 1 {
@ -17,7 +17,7 @@ fn main() {
exit(1); exit(1);
} }
let oper = &args[1]; let oper = &args[0];
let noconfirm: bool = noconf(&args); let noconfirm: bool = noconf(&args);
argssort(&mut pkgs); argssort(&mut pkgs);
@ -48,14 +48,14 @@ fn main() {
update(); // update update(); // update
} }
"-Ss" | "sea" => { "-Ss" | "sea" => {
r_search(&args[2]); // search for packages in the repository r_search(&args[1]); // search for packages in the repository
a_search(&args[2]); // search for packages in the aur a_search(&args[1]); // search for packages in the aur
} }
"-Sa" | "aursea" => { "-Sa" | "aursea" => {
a_search(&args[2]); // search for packages in the aur a_search(&args[1]); // search for packages in the aur
} }
"-Sr" | "repsea" => { "-Sr" | "repsea" => {
r_search(&args[2]); // search for packages in the repository r_search(&args[1]); // search for packages in the repository
} }
"-Cc" | "clr" => { "-Cc" | "clr" => {
clearcache(); // clear cache clearcache(); // clear cache
@ -67,8 +67,8 @@ fn main() {
help(); // help help(); // help
} }
_ => { // if oper is not valid it either passes the args to pacman or prints an error _ => { // if oper is not valid it either passes the args to pacman or prints an error
let pass = Command::new("pacman") let pass = runas::Command::new("pacman")
.args(env::args().skip(1)) .args(&args)
.status() .status()
.expect("Something has gone wrong."); .expect("Something has gone wrong.");

@ -2,7 +2,6 @@ use crate::{
err_unrec, inf, inssort, mods::database::add_pkg, mods::strs::prompt, mods::strs::sec, err_unrec, inf, inssort, mods::database::add_pkg, mods::strs::prompt, mods::strs::sec,
mods::strs::succ, mods::purge::purge, mods::strs::succ, mods::purge::purge,
}; };
use git2::Repository;
use moins::Moins; use moins::Moins;
use std::{env, fs, path::Path, process::Command}; use std::{env, fs, path::Path, process::Command};
@ -102,12 +101,18 @@ pub fn clone(noconfirm: bool, as_dep: bool, pkg: &str) { // clone a package from
inssort(noconfirm, true, package[0].depends.clone()); inssort(noconfirm, true, package[0].depends.clone());
let clone = Repository::clone(&url, Path::new(&pkgdir)); let clone = std::process::Command::new("git")
match clone { .arg("clone")
Ok(_) => { .arg(&url)
.arg(&pkgdir)
.status()
.expect("couldnt clone repository");
match clone.code() {
Some(0) => {
inf(format!("Cloning {} into package directory", pkg)); inf(format!("Cloning {} into package directory", pkg));
} }
Err(_) => err_unrec(format!("Failed cloning {} into package directory", pkg)), Some(_) => err_unrec(format!("Failed cloning {} into package directory", pkg)),
_ => err_unrec(format!("Failed cloning {} into package directory", pkg)),
} }
if as_dep == false { if as_dep == false {
if noconfirm == false { if noconfirm == false {

@ -1,7 +1,6 @@
use crate::{ use crate::{
err_rec, err_unrec, inf, inssort, mods::strs::prompt, mods::strs::sec, mods::strs::succ, uninstall, mods::database::get_value, err_rec, err_unrec, inf, inssort, mods::strs::prompt, mods::strs::sec, mods::strs::succ, uninstall, mods::database::get_value,
}; };
use git2::Repository;
use runas::Command; use runas::Command;
use std::{env, fs, path::Path}; use std::{env, fs, path::Path};
use toml; use toml;
@ -160,14 +159,18 @@ pub fn upgrade(noconfirm: bool) { // upgrade all packages
inssort(true, true, package[0].depends.clone()); inssort(true, true, package[0].depends.clone());
let clone = Repository::clone(&url, Path::new(&keydir)); let clone = std::process::Command::new("git")
match clone { .arg("clone")
Ok(_) => { .arg(&url)
.arg(&keydir)
.status()
.expect("Couldn't clone repo");
match clone.code() {
Some(0) => {
inf(format!("Cloning {} into package directory", &key)); inf(format!("Cloning {} into package directory", &key));
} }
Err(_) => { Some(_) => err_unrec(format!("Failed cloning {} into package directory", &key)),
err_unrec(format!("Failed cloning {} into package directory", &key)) _ => err_unrec(format!("Failed cloning {} into package directory", &key)),
}
} }
} }
@ -208,4 +211,4 @@ pub fn upgrade(noconfirm: bool) { // upgrade all packages
} }
} }
} }
} }
Loading…
Cancel
Save