|
24 | 24 | // generate postinst or prerm files.
|
25 | 25 |
|
26 | 26 | use super::freedesktop;
|
27 |
| -use crate::{bundle::settings::Arch, utils::fs_utils, Settings}; |
28 |
| -use anyhow::Context; |
| 27 | +use crate::{ |
| 28 | + bundle::settings::Arch, |
| 29 | + error::{Context, ErrorExt}, |
| 30 | + utils::fs_utils, |
| 31 | + Settings, |
| 32 | +}; |
29 | 33 | use flate2::{write::GzEncoder, Compression};
|
30 | 34 | use tar::HeaderMode;
|
31 | 35 | use walkdir::WalkDir;
|
@@ -64,30 +68,32 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
|
64 | 68 | let base_dir = settings.project_out_directory().join("bundle/deb");
|
65 | 69 | let package_dir = base_dir.join(&package_base_name);
|
66 | 70 | if package_dir.exists() {
|
67 |
| - fs::remove_dir_all(&package_dir) |
68 |
| - .with_context(|| format!("Failed to remove old {package_base_name}"))?; |
| 71 | + fs::remove_dir_all(&package_dir).fs_context( |
| 72 | + "Failed to Remove old package directory", |
| 73 | + package_dir.clone(), |
| 74 | + )?; |
69 | 75 | }
|
70 | 76 | let package_path = base_dir.join(&package_name);
|
71 | 77 |
|
72 | 78 | log::info!(action = "Bundling"; "{} ({})", package_name, package_path.display());
|
73 | 79 |
|
74 |
| - let (data_dir, _) = generate_data(settings, &package_dir) |
75 |
| - .with_context(|| "Failed to build data folders and files")?; |
| 80 | + let (data_dir, _) = |
| 81 | + generate_data(settings, &package_dir).context("Failed to build data folders and files")?; |
76 | 82 | fs_utils::copy_custom_files(&settings.deb().files, &data_dir)
|
77 |
| - .with_context(|| "Failed to copy custom files")?; |
| 83 | + .context("Failed to copy custom files")?; |
78 | 84 |
|
79 | 85 | // Generate control files.
|
80 | 86 | let control_dir = package_dir.join("control");
|
81 | 87 | generate_control_file(settings, arch, &control_dir, &data_dir)
|
82 |
| - .with_context(|| "Failed to create control file")?; |
83 |
| - generate_scripts(settings, &control_dir).with_context(|| "Failed to create control scripts")?; |
84 |
| - generate_md5sums(&control_dir, &data_dir).with_context(|| "Failed to create md5sums file")?; |
| 88 | + .context("Failed to create control file")?; |
| 89 | + generate_scripts(settings, &control_dir).context("Failed to create control scripts")?; |
| 90 | + generate_md5sums(&control_dir, &data_dir).context("Failed to create md5sums file")?; |
85 | 91 |
|
86 | 92 | // Generate `debian-binary` file; see
|
87 | 93 | // http://www.tldp.org/HOWTO/Debian-Binary-Package-Building-HOWTO/x60.html#AEN66
|
88 | 94 | let debian_binary_path = package_dir.join("debian-binary");
|
89 | 95 | create_file_with_data(&debian_binary_path, "2.0\n")
|
90 |
| - .with_context(|| "Failed to create debian-binary file")?; |
| 96 | + .context("Failed to create debian-binary file")?; |
91 | 97 |
|
92 | 98 | // Apply tar/gzip/ar to create the final package file.
|
93 | 99 | let control_tar_gz_path =
|
|
0 commit comments