MCPcopy Create free account
hub / github.com/archlinux/alpm / try_from

Method try_from

alpm-package/src/input.rs:627–665  ·  view source on GitHub ↗

Creates a [`PackageInput`] from input directory `path`. This function reads [ALPM-MTREE], [BUILDINFO] and [PKGINFO] files in `path`, collects the path of an existing [alpm-install-scriptlet] and validates them. All data files below `path` are then checked against the [ALPM-MTREE] data. # Errors Returns an error if - `value` is not a valid [`InputDir`], - there is no valid [BUILDINFO] file, - t

(value: InputDir)

Source from the content-addressed store, hash-verified

625 /// [PKGINFO]: https://alpm.archlinux.page/specifications/PKGINFO.5.html
626 /// [alpm-install-scriptlet]: https://alpm.archlinux.page/specifications/alpm-install-scriptlet.5.html
627 fn try_from(value: InputDir) -> Result<Self, Self::Error> {
628 debug!("Create PackageInput from path {value:?}");
629
630 // Get Mtree data and file digest.
631 let (mtree, mtree_digest) = get_mtree(&value)?;
632
633 // Get all relative paths in value.
634 let relative_paths = relative_files(&value, &[])?;
635 trace!("Relative files:\n{relative_paths:?}");
636
637 // When comparing with ALPM-MTREE data, exclude the ALPM-MTREE file.
638 let relative_mtree_paths: Vec<PathBuf> = relative_paths
639 .iter()
640 .filter(|path| path.as_os_str() != MetadataFileName::Mtree.as_ref())
641 .cloned()
642 .collect();
643 mtree.validate_paths(&InputPaths::new(value.as_ref(), &relative_mtree_paths)?)?;
644
645 // Get PackageInfo data and file digest.
646 let package_info = get_package_info(&value, &mtree)?;
647 // Get BuildInfo data and file digest.
648 let build_info = get_build_info(&value, &mtree)?;
649
650 // Compare overlapping metadata of BuildInfo and PackageInfo data.
651 compare_build_info_package_info(&build_info, &package_info)?;
652
653 // Get optional scriptlet file.
654 let scriptlet = get_install_scriptlet(&value, &mtree)?;
655
656 Ok(Self {
657 build_info,
658 package_info,
659 mtree,
660 mtree_digest,
661 input_dir: value,
662 scriptlet,
663 relative_paths,
664 })
665 }
666}
667
668#[cfg(test)]

Callers

nothing calls this directly

Calls 8

get_mtreeFunction · 0.85
relative_filesFunction · 0.85
get_package_infoFunction · 0.85
get_build_infoFunction · 0.85
get_install_scriptletFunction · 0.85
validate_pathsMethod · 0.80
as_refMethod · 0.45

Tested by

no test coverage detected