Function apple_codesign::copy_bundle
source · pub fn copy_bundle(
bundle: &DirectoryBundle,
dest_dir: &Path
) -> Result<(), AppleCodesignError>
Expand description
Copy a bundle’s contents to a destination directory.
Examples found in repository?
src/bundle_signing.rs (line 126)
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
pub fn write_signed_bundle(
&self,
dest_dir: impl AsRef<Path>,
settings: &SigningSettings,
) -> Result<DirectoryBundle, AppleCodesignError> {
let dest_dir = dest_dir.as_ref();
// We need to sign the leaf-most bundles first since a parent bundle may need
// to record information about the child in its signature.
let mut bundles = self
.bundles
.iter()
.filter_map(|(rel, bundle)| rel.as_ref().map(|rel| (rel, bundle)))
.collect::<Vec<_>>();
// This won't preserve alphabetical order. But since the input was stable, output
// should be deterministic.
bundles.sort_by(|(a, _), (b, _)| b.len().cmp(&a.len()));
warn!(
"signing {} nested bundles in the following order:",
bundles.len()
);
for bundle in &bundles {
warn!("{}", bundle.0);
}
for (rel, nested) in bundles {
let nested_dest_dir = dest_dir.join(rel);
info!(
"entering nested bundle {}",
nested.bundle.root_dir().display(),
);
// If we excluded this bundle from signing, just copy all the files.
if settings
.path_exclusion_patterns()
.iter()
.any(|pattern| pattern.matches(rel))
{
warn!("bundle is in exclusion list; it will be copied instead of signed");
copy_bundle(&nested.bundle, &nested_dest_dir)?;
} else {
nested.write_signed_bundle(
nested_dest_dir,
&settings.as_nested_bundle_settings(rel),
)?;
}
info!(
"leaving nested bundle {}",
nested.bundle.root_dir().display()
);
}
let main = self
.bundles
.get(&None)
.expect("main bundle should have a key");
main.write_signed_bundle(dest_dir, settings)
}