Обновление README.md, исходников, пакетки
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
use std::path::Path;
|
||||
use std::process;
|
||||
use std::fs;
|
||||
use std::os::unix::fs::MetadataExt;
|
||||
|
||||
use crate::utils::parser::{self, pkginfo};
|
||||
use super::run::download::download;
|
||||
@ -8,63 +9,56 @@ use super::run::build::build;
|
||||
use super::run::config::config;
|
||||
|
||||
|
||||
pub fn install(repo: &String, pkgname: &String) -> Result<(), bool> {
|
||||
let pkg_md_path = crate::commands::get_var_path().join(format!("{}/{}.md", &repo, &pkgname));
|
||||
pub fn install(repo: &String, pkgname: &String) {
|
||||
let pkg_md_path = &crate::commands::get_aeropkg_var().join(format!("{}/{}.md", repo, pkgname));
|
||||
let builded_pkg_md_path = crate::commands::get_aeropkg_base().join(repo).join(pkgname).join("build-script.md");
|
||||
if builded_pkg_md_path.exists() {
|
||||
if fs::metadata(builded_pkg_md_path).unwrap().ino() == fs::metadata(pkg_md_path).unwrap().ino() { return }
|
||||
}
|
||||
|
||||
check_build_dependency(&repo, &pkg_md_path)?;
|
||||
check_run_dependency(&pkg_md_path)?;
|
||||
download(&repo, &pkgname)?;
|
||||
patch(&repo, &pkgname)?;
|
||||
build(&repo, &pkgname)?;
|
||||
config(&repo, &pkgname)?;
|
||||
|
||||
println!("Package {} installed successfully from repo {}", pkgname, repo);
|
||||
Ok(())
|
||||
check_build_dependency(repo, pkg_md_path);
|
||||
check_run_dependency(pkg_md_path);
|
||||
download(repo, pkgname);
|
||||
patch(repo, pkgname);
|
||||
build(repo, pkgname);
|
||||
config(repo, pkgname);
|
||||
}
|
||||
|
||||
fn check_build_dependency(repo: &String, pkg_md_path: &Path) -> Result<(), bool> {
|
||||
let deps = match parser::get_build_deps(&pkg_md_path) {
|
||||
fn check_build_dependency(repo: &String, pkg_md_path: &Path) {
|
||||
let deps = match parser::get_build_deps(pkg_md_path) {
|
||||
Ok(deps) => deps,
|
||||
Err(_) => { return Ok(()) }
|
||||
Err(_) => { return }
|
||||
};
|
||||
|
||||
for dependency in deps.lines() {
|
||||
if !dependency.trim().is_empty() {
|
||||
if !super::get_aeropkg_base().join(repo).join(dependency).exists() {
|
||||
match install(repo, &dependency.to_string()) {
|
||||
Ok(()) => {}
|
||||
Err(_) => {process::exit(1) }
|
||||
}
|
||||
install(repo, &dependency.to_string())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn check_run_dependency(pkg_md_path: &Path) -> Result<(), bool> {
|
||||
fn check_run_dependency(pkg_md_path: &Path) {
|
||||
let deps = match parser::get_run_deps(pkg_md_path) {
|
||||
Ok(deps) => deps,
|
||||
Err(_) => { return Ok(()) }
|
||||
Err(_) => { return }
|
||||
};
|
||||
|
||||
let repo_list = parser::repoinfo::get_repo_list();
|
||||
let repo_list = &parser::repoinfo::get_repo_list();
|
||||
|
||||
for pkgname in deps.split_whitespace() {
|
||||
let mut found = false;
|
||||
|
||||
for repo_name in &repo_list {
|
||||
for repo_name in repo_list {
|
||||
let path = super::get_aeropkg_base().join(repo_name).join(pkgname);
|
||||
if path.exists() {
|
||||
found = true;
|
||||
break;
|
||||
found = true; break
|
||||
}
|
||||
}
|
||||
|
||||
if !found {
|
||||
install(&pkginfo::get_priority_repo(pkgname.to_string()), &pkgname.to_string());
|
||||
install(&pkginfo::get_priority_repo(&pkgname.to_string()), &pkgname.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user