diff options
| author | Namilskyy <alive6863@gmail.com> | 2025-11-30 20:30:56 +0300 |
|---|---|---|
| committer | Namilskyy <alive6863@gmail.com> | 2025-11-30 20:30:56 +0300 |
| commit | 4c050bce3b93fdebc00ceecae034ddcffc01bde6 (patch) | |
| tree | f18c6fe9893dc3d4104c60401b34cae4e44e9394 /src/pkgtoolkit/pkgtools.rs | |
| parent | 5abbc4394cb5fc3af432fa5177b203018db009a6 (diff) | |
Fixed fmt & the number of threads in CI is limited to 2
Diffstat (limited to 'src/pkgtoolkit/pkgtools.rs')
| -rw-r--r-- | src/pkgtoolkit/pkgtools.rs | 67 |
1 files changed, 22 insertions, 45 deletions
diff --git a/src/pkgtoolkit/pkgtools.rs b/src/pkgtoolkit/pkgtools.rs index 877c8c8..9fe01c6 100644 --- a/src/pkgtoolkit/pkgtools.rs +++ b/src/pkgtoolkit/pkgtools.rs @@ -100,9 +100,9 @@ impl Package { /// /// Returns an error if the build command fails. fn execute_build(&self, build_meta: &Build) -> Result<(), std::io::Error> { - let config = Config::parse() - .map_err(|e| std::io::Error::other(e.to_string()))?; - let build_dir = Path::new(&config.paths.cache_dir).join(format!("{}-{}", self.name, self.version)); + let config = Config::parse().map_err(|e| std::io::Error::other(e.to_string()))?; + let build_dir = + Path::new(&config.paths.cache_dir).join(format!("{}-{}", self.name, self.version)); let mut cmd = match build_meta.build_system { BuildSystems::Make => { @@ -139,17 +139,13 @@ impl Package { } }; - let output = cmd.output().map_err(|e| { - std::io::Error::other( - format!("Build command failed: {}", e), - ) - })?; + let output = cmd + .output() + .map_err(|e| std::io::Error::other(format!("Build command failed: {}", e)))?; if !output.status.success() { let stderr = String::from_utf8_lossy(&output.stderr); - return Err(std::io::Error::other( - format!("Build failed:\n{}", stderr), - )); + return Err(std::io::Error::other(format!("Build failed:\n{}", stderr))); } Ok(()) @@ -433,10 +429,9 @@ impl Package { /// /// Returns an error if the BUILD file is invalid or if the build or install hook fails. pub fn install(&mut self) -> Result<bool, std::io::Error> { - let config = Config::parse() - .map_err(|e| std::io::Error::other( e.to_string()))?; - let (install_meta, _setts_meta, build_meta) = Self::loadmeta(self) - .map_err(|e| std::io::Error::other(e.to_string()))?; + let config = Config::parse().map_err(|e| std::io::Error::other(e.to_string()))?; + let (install_meta, _setts_meta, build_meta) = + Self::loadmeta(self).map_err(|e| std::io::Error::other(e.to_string()))?; let is_build_present_and_not_empty = build_meta.is_some(); @@ -456,17 +451,14 @@ impl Package { .arg("install") .current_dir(&build_dir) .output() - .map_err(|e| { - std::io::Error::other( - format!("'make install' failed: {}", e), - ) - })?; + .map_err(|e| std::io::Error::other(format!("'make install' failed: {}", e)))?; if !output.status.success() { let stderr = String::from_utf8_lossy(&output.stderr); - return Err(std::io::Error::other( - format!("'make install' failed:\n{}", stderr), - )); + return Err(std::io::Error::other(format!( + "'make install' failed:\n{}", + stderr + ))); } } } else { @@ -485,15 +477,11 @@ impl Package { Command::new(script).status() } .map_err(|e| { - std::io::Error::other( - format!("Failed to run custom script: {}", e), - ) + std::io::Error::other(format!("Failed to run custom script: {}", e)) })?; if !status.success() { - return Err(std::io::Error::other( - "Custom install script failed", - )); + return Err(std::io::Error::other("Custom install script failed")); } } else { log::info!( @@ -508,17 +496,12 @@ impl Package { if let Some(parent) = dest_path.parent() { create_dir_all(parent).map_err(|e| { - std::io::Error::other( - format!("Failed to create parent dir: {}", e), - ) + std::io::Error::other(format!("Failed to create parent dir: {}", e)) })?; } - fs::copy(&src_path, dest_path).map_err(|e| { - std::io::Error::other( - format!("Failed to copy file: {}", e), - ) - })?; + fs::copy(&src_path, dest_path) + .map_err(|e| std::io::Error::other(format!("Failed to copy file: {}", e)))?; let mode = u32::from_str_radix(&install_meta.install.mode, 8).map_err(|_| { std::io::Error::new( @@ -528,9 +511,7 @@ impl Package { })?; let perms = PermissionsExt::from_mode(mode); fs::set_permissions(dest_path, perms).map_err(|e| { - std::io::Error::other( - format!("Failed to set permissions: {}", e), - ) + std::io::Error::other(format!("Failed to set permissions: {}", e)) })?; let output = Command::new("chown") @@ -540,11 +521,7 @@ impl Package { )) .arg(dest_path) .output() - .map_err(|e| { - std::io::Error::other( - format!("'chown' command failed: {}", e), - ) - })?; + .map_err(|e| std::io::Error::other(format!("'chown' command failed: {}", e)))?; if !output.status.success() { let stderr = String::from_utf8_lossy(&output.stderr); |
