Struct fuchsia_pkg::PackageBuilder
source · pub struct PackageBuilder { /* private fields */ }
Expand description
A builder for Fuchsia Packages
Implementations§
source§impl PackageBuilder
impl PackageBuilder
sourcepub fn from_package_build_manifest(
manifest: &PackageBuildManifest
) -> Result<Self>
pub fn from_package_build_manifest( manifest: &PackageBuildManifest ) -> Result<Self>
Create a PackageBuilder from a PackageBuildManifest.
sourcepub fn from_manifest(
original_manifest: PackageManifest,
outdir: impl AsRef<Path>
) -> Result<Self>
pub fn from_manifest( original_manifest: PackageManifest, outdir: impl AsRef<Path> ) -> Result<Self>
Create a PackageBuilder from an existing manifest. Requires an out directory for temporarily
unpacking meta.far
contents.
sourcepub fn manifest_path(&mut self, manifest_path: impl Into<Utf8PathBuf>)
pub fn manifest_path(&mut self, manifest_path: impl Into<Utf8PathBuf>)
Specify a path to write out the json package manifest to.
pub fn manifest_blobs_relative_to(&mut self, relative_to: RelativeTo)
sourcepub fn overwrite_files(&mut self, overwrite_files: bool)
pub fn overwrite_files(&mut self, overwrite_files: bool)
Specify whether new additions of a file that have already been added should overwrite, or fail
sourcepub fn add_file_to_far(
&mut self,
at_path: impl AsRef<str>,
file: impl AsRef<str>
) -> Result<()>
pub fn add_file_to_far( &mut self, at_path: impl AsRef<str>, file: impl AsRef<str> ) -> Result<()>
Add a file to the package’s far.
Errors
Will return an error if the path for the file is already being used. Will return an error if any special package metadata paths are used.
sourcepub fn remove_file_from_far(&mut self, at_path: impl AsRef<str>) -> Result<()>
pub fn remove_file_from_far(&mut self, at_path: impl AsRef<str>) -> Result<()>
Remove a file from the package’s meta.far.
Errors
Will return an error if the file is not already in the meta.far
sourcepub fn add_file_as_blob(
&mut self,
at_path: impl AsRef<str>,
file: impl AsRef<str>
) -> Result<()>
pub fn add_file_as_blob( &mut self, at_path: impl AsRef<str>, file: impl AsRef<str> ) -> Result<()>
Add a file to the package as a blob itself.
Errors
Will return an error if the path for the file is already being used. Will return an error if any special package metadata paths are used.
sourcepub fn remove_blob_file(&mut self, at_path: impl AsRef<str>) -> Result<()>
pub fn remove_blob_file(&mut self, at_path: impl AsRef<str>) -> Result<()>
Remove a file currently in the package as a blob
Errors
Will return an error if the file is not already in the package contents
sourcepub fn add_contents_as_blob<C: AsRef<[u8]>>(
&mut self,
at_path: impl AsRef<str>,
contents: C,
gendir: impl AsRef<Path>
) -> Result<()>
pub fn add_contents_as_blob<C: AsRef<[u8]>>( &mut self, at_path: impl AsRef<str>, contents: C, gendir: impl AsRef<Path> ) -> Result<()>
Write the contents to a file, and add that file as a blob at the given path within the package.
sourcepub fn add_contents_to_far<C: AsRef<[u8]>>(
&mut self,
at_path: impl AsRef<str>,
contents: C,
gendir: impl AsRef<Path>
) -> Result<()>
pub fn add_contents_to_far<C: AsRef<[u8]>>( &mut self, at_path: impl AsRef<str>, contents: C, gendir: impl AsRef<Path> ) -> Result<()>
Write the contents to a file, and add that file to the metafar at the given path within the package.
sourcepub fn add_subpackage(
&mut self,
url: &RelativePackageUrl,
package_hash: Hash,
package_manifest_path: PathBuf
) -> Result<()>
pub fn add_subpackage( &mut self, url: &RelativePackageUrl, package_hash: Hash, package_manifest_path: PathBuf ) -> Result<()>
Helper fn to include a subpackage into this package.
sourcepub fn api_level(&mut self, api_level: u64) -> Result<()>
pub fn api_level(&mut self, api_level: u64) -> Result<()>
Set the API Level that should be included in the package. This will return an error if there is no ABI revision that corresponds with this API Level.
sourcepub fn abi_revision(&mut self, abi_revision: u64)
pub fn abi_revision(&mut self, abi_revision: u64)
Set the ABI Revision that should be included in the package.
sourcepub fn published_name(&mut self, published_name: impl AsRef<str>)
pub fn published_name(&mut self, published_name: impl AsRef<str>)
Set a different name for the package to be published by (and to be included in the generated PackageManifest), than the one embedded in the package itself.
sourcepub fn repository(&mut self, repository: impl AsRef<str>)
pub fn repository(&mut self, repository: impl AsRef<str>)
Set a repository for the package to be included in the generated PackageManifest.
sourcepub fn read_contents_from_far(&self, file_path: &str) -> Result<Vec<u8>>
pub fn read_contents_from_far(&self, file_path: &str) -> Result<Vec<u8>>
Read the contents of a file already added to the builder’s meta.far.
sourcepub fn build(
self,
gendir: impl AsRef<Path>,
metafar_path: impl AsRef<Path>
) -> Result<PackageManifest>
pub fn build( self, gendir: impl AsRef<Path>, metafar_path: impl AsRef<Path> ) -> Result<PackageManifest>
Build the package, using the specified dir, returning the PackageManifest.
If a path for the manifest was specified, the PackageManifest will also be written to there.
The gendir
param is assumed to be a path to folder which is only used
by this package’s creation, so this fn does not try to create paths
within it that are unique across different packages.