Returns whether an [alpm-install-scriptlet] exists in an input directory. # Errors Returns an error if - the file contents cannot be read to a buffer, - the hash digest of the file does not match that initially recorded in `mtree`, - or the file contents do not represent valid [alpm-install-scriptlet] data. [alpm-install-scriptlet]: https://alpm.archlinux.page/specifications/alpm-install-scrip
(
input_dir: &InputDir,
mtree: &Mtree,
)
| 257 | /// |
| 258 | /// [alpm-install-scriptlet]: https://alpm.archlinux.page/specifications/alpm-install-scriptlet.5.html |
| 259 | fn get_install_scriptlet( |
| 260 | input_dir: &InputDir, |
| 261 | mtree: &Mtree, |
| 262 | ) -> Result<Option<PathBuf>, crate::Error> { |
| 263 | debug!("Check that an alpm-install-scriptlet is valid if it exists in {input_dir:?}."); |
| 264 | |
| 265 | let path = match compare_digests(mtree, input_dir, INSTALL_SCRIPTLET_FILE_NAME) { |
| 266 | Err(crate::Error::Input(Error::FileIsMissing { .. })) => return Ok(None), |
| 267 | Err(error) => return Err(error), |
| 268 | Ok((path, _buf)) => path, |
| 269 | }; |
| 270 | |
| 271 | // Validate the scriptlet. |
| 272 | check_scriptlet(&path)?; |
| 273 | |
| 274 | Ok(Some(path)) |
| 275 | } |
| 276 | |
| 277 | /// Returns a [`BuildInfo`] from a BUILDINFO file in an input directory. |
| 278 | /// |
no test coverage detected