pkg download command and patches

This commit is contained in:
2026-09-10 16:59:11 +03:00
parent c6dcbc1ca5
commit 60cf4a2523
110 changed files with 1588 additions and 332 deletions

View File

@ -31,8 +31,8 @@ pub fn build(repo: &String, pkgname: &String) {
if build_script == builded_script { return }
}
if src.join("aeropkg.applied-build").exists() {
let src_build = fs::read_to_string(src.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 {
@ -51,21 +51,21 @@ 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.join("aeropkg.build-script"), &build_script).unwrap();
fs::write(src.join(".aeropkg.applied-build"), &build_script).unwrap();
let save_source_flag = full_env.get("save_source").map_or(false, |v| v == "true");
let save_source_flag = full_env.get("save_source").is_some();
if !save_source_flag {
if let Err(e) = fs::remove_dir_all(&src) { panic!("Failed to remove source directory: {}", e) }
}
hook(repo, pkgname);
let link_flag = full_env.get("disable").map_or(true, |v| v != "true");
if !link_flag {
if !full_env.get("disable").is_some() {
let _ = fs::File::create(crate::commands::get_aeropkg_base().join(repo).join(pkgname).join("disabled"));
} else {
link(repo, pkgname)
}
link(repo, pkgname)
}

View File

@ -23,7 +23,7 @@ pub fn download(repo: &String, pkgname: &String) {
let src = pkgpath.join("src");
if src.exists() {
let src_url = fs::read_to_string(src.join("aeropkg.download-url")).unwrap_or("".to_string());
let src_url = fs::read_to_string(src.join(".aeropkg.download-url")).unwrap_or("".to_string());
if url == src_url { return }
else {
fs::remove_dir_all(&src).unwrap()
@ -137,7 +137,10 @@ pub fn download(repo: &String, pkgname: &String) {
.collect();
if dirs.len() == 1 {
let single_dir = dirs[0].path();
let old_path = dirs[0].path();
let single_dir = old_path.parent().unwrap()
.join(format!("{}.aeropkg.bkp", old_path.file_name().unwrap().to_string_lossy()));
fs::rename(&old_path, &single_dir).unwrap();
for entry in fs::read_dir(&single_dir).unwrap() {
let entry = entry.unwrap();
@ -149,7 +152,7 @@ pub fn download(repo: &String, pkgname: &String) {
}
}
fs::write(src.join("aeropkg.download-url"), &url).unwrap();
fs::write(src.join(".aeropkg.download-url"), &url).unwrap();
run_install_script_hook(repo, "download", &full_env)
}

View File

@ -11,8 +11,8 @@ pub fn patch(repo: &String, pkgname: &String) {
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.join("aeropkg.applied-patch").exists() {
let src_patch = &fs::read_to_string(src.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).unwrap();
@ -23,5 +23,5 @@ pub fn patch(repo: &String, pkgname: &String) {
let full_env = get_install_env(repo, pkgname, pkg_md_path, "patch");
run_install_script(patch_script, src, &full_env);
run_install_script_hook(repo, "patch", &full_env);
fs::write(src.join("aeropkg.applied-patch"), &patch_script).unwrap()
fs::write(src.join(".aeropkg.applied-patch"), &patch_script).unwrap()
}