upd and patches
This commit is contained in:
@ -6,9 +6,7 @@ pub fn disable(repo: &String, pkgname: &String) {
|
||||
let source = &crate::commands::get_aeropkg_base().join(repo).join(pkgname);
|
||||
if source.join("disabled").exists() { return };
|
||||
|
||||
let destination = &source.parent()
|
||||
.ok_or("Failed to get parent directory for path").unwrap()
|
||||
.to_path_buf();
|
||||
let destination = &crate::commands::get_aeropkg_base().join(repo);
|
||||
|
||||
let dirs_to_copy = vec![
|
||||
("bin"),
|
||||
|
||||
@ -5,9 +5,7 @@ pub fn link(repo: &String, pkgname: &String) {
|
||||
let source = crate::commands::get_aeropkg_base().join(repo).join(pkgname);
|
||||
if source.join("disabled").exists() { println!("Disabled package, no linking: {}\nUse `pkg enable {}` to link", pkgname, pkgname); return }
|
||||
|
||||
let destination = source.parent()
|
||||
.ok_or("Failed to get parent directory for path").unwrap()
|
||||
.to_path_buf();
|
||||
let destination = &crate::commands::get_aeropkg_base().join(repo);
|
||||
|
||||
let dirs_to_copy = vec![
|
||||
("bin"),
|
||||
|
||||
@ -8,7 +8,10 @@ use super::patch::patch;
|
||||
|
||||
|
||||
pub fn build(repo: &String, pkgname: &String) {
|
||||
let src_dir = &crate::commands::get_aeropkg_base().join("src").join(pkgname);
|
||||
let pkgpath = &crate::commands::get_aeropkg_base().join(repo).join(pkgname);
|
||||
fs::create_dir_all(&pkgpath).ok();
|
||||
let src = &pkgpath.join("src");
|
||||
|
||||
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");
|
||||
|
||||
@ -28,19 +31,19 @@ pub fn build(repo: &String, pkgname: &String) {
|
||||
if build_script == builded_script { return }
|
||||
}
|
||||
|
||||
if src_dir.join("aeropkg.applied-build").exists() {
|
||||
let src_build = fs::read_to_string(src_dir.join("aeropkg.applied-build")).unwrap_or("".to_string());
|
||||
if src.join("aeropkg.applied-build").exists() {
|
||||
let src_build = fs::read_to_string(src.join("aeropkg.applied-build")).unwrap_or("".to_string());
|
||||
if build_script == src_build {
|
||||
return
|
||||
} else {
|
||||
fs::remove_dir_all(src_dir).unwrap();
|
||||
fs::remove_dir_all(src).unwrap();
|
||||
download(repo, pkgname);
|
||||
patch(repo, pkgname)
|
||||
}
|
||||
}
|
||||
|
||||
let full_env = get_install_env(repo, pkgname, pkg_md_path, "build");
|
||||
run_install_script(&build_script, src_dir, &full_env);
|
||||
run_install_script(&build_script, src, &full_env);
|
||||
run_install_script_hook(repo, "build", &full_env);
|
||||
|
||||
let dest_dir = crate::commands::get_aeropkg_base().join(repo).join(pkgname);
|
||||
@ -48,12 +51,12 @@ pub fn build(repo: &String, pkgname: &String) {
|
||||
let dest_path = &dest_dir.join("build-script.md");
|
||||
fs::remove_file(dest_path).ok();
|
||||
if let Err(e) = fs::hard_link(pkg_md_path, dest_path) { panic!("Failed to copy build script to destination: {}", e) }
|
||||
fs::write(src_dir.join("aeropkg.build-script"), &build_script).unwrap();
|
||||
fs::write(src.join("aeropkg.build-script"), &build_script).unwrap();
|
||||
|
||||
|
||||
let save_source_flag = full_env.get("save_source").map_or(false, |v| v == "true");
|
||||
if !save_source_flag {
|
||||
if let Err(e) = fs::remove_dir_all(&src_dir) { panic!("Failed to remove source directory: {}", e) }
|
||||
if let Err(e) = fs::remove_dir_all(&src) { panic!("Failed to remove source directory: {}", e) }
|
||||
}
|
||||
|
||||
hook(repo, pkgname);
|
||||
|
||||
@ -18,7 +18,10 @@ pub fn download(repo: &String, pkgname: &String) {
|
||||
}
|
||||
};
|
||||
|
||||
let src = crate::commands::get_aeropkg_base().join("src").join(pkgname);
|
||||
let pkgpath = &crate::commands::get_aeropkg_base().join(repo).join(pkgname);
|
||||
fs::create_dir_all(&pkgpath).ok();
|
||||
|
||||
let src = pkgpath.join("src");
|
||||
if src.exists() {
|
||||
let src_url = fs::read_to_string(src.join("aeropkg.download-url")).unwrap_or("".to_string());
|
||||
if url == src_url { return }
|
||||
@ -29,6 +32,7 @@ pub fn download(repo: &String, pkgname: &String) {
|
||||
|
||||
if url.ends_with(".git") || url.starts_with("git://") {
|
||||
let git_status = Command::new("git")
|
||||
.current_dir(&pkgpath)
|
||||
.arg("clone")
|
||||
.arg(&url)
|
||||
.arg(&src)
|
||||
|
||||
@ -5,21 +5,23 @@ use crate::utils::shell::{run_install_script,run_install_script_hook};
|
||||
use super::download::download;
|
||||
|
||||
pub fn patch(repo: &String, pkgname: &String) {
|
||||
let src_dir = &crate::commands::get_aeropkg_base().join("src").join(pkgname);
|
||||
let pkgpath = &crate::commands::get_aeropkg_base().join(repo).join(pkgname);
|
||||
fs::create_dir_all(&pkgpath).ok();
|
||||
let src = &pkgpath.join("src");
|
||||
|
||||
let pkg_md_path = &crate::commands::get_aeropkg_var().join(format!("{}/{}.md", repo, pkgname));
|
||||
let patch_script = &parser::get_patch_script(pkg_md_path).unwrap_or("".to_string());
|
||||
|
||||
if src_dir.join("aeropkg.applied-patch").exists() {
|
||||
let src_patch = &fs::read_to_string(src_dir.join("aeropkg.applied-patch")).unwrap_or("".to_string());
|
||||
if src.join("aeropkg.applied-patch").exists() {
|
||||
let src_patch = &fs::read_to_string(src.join("aeropkg.applied-patch")).unwrap_or("".to_string());
|
||||
if patch_script == src_patch { return }
|
||||
else if src_patch != "" {
|
||||
fs::remove_dir_all(src_dir).unwrap();
|
||||
fs::remove_dir_all(src).unwrap();
|
||||
download(repo, pkgname)
|
||||
}
|
||||
}
|
||||
|
||||
let full_env = get_install_env(repo, pkgname, pkg_md_path, "patch");
|
||||
run_install_script(patch_script, src_dir, &full_env);
|
||||
run_install_script(patch_script, src, &full_env);
|
||||
run_install_script_hook(repo, "patch", &full_env);
|
||||
fs::write(src_dir.join("aeropkg.applied-patch"), &patch_script).unwrap()
|
||||
fs::write(src.join("aeropkg.applied-patch"), &patch_script).unwrap()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user