MCPcopy Create free account
hub / github.com/bootc-dev/bootc / impl_package

Function impl_package

crates/xtask/src/xtask.rs:452–491  ·  view source on GitHub ↗
(sh: &Shell)

Source from the content-addressed store, hash-verified

450
451#[context("Packaging")]
452fn impl_package(sh: &Shell) -> Result<Package> {
453 let source_date_epoch = git_source_date_epoch(".".into())?;
454 let v = gitrev(sh)?;
455
456 let namev = format!("{NAME}-{v}");
457 let p = Utf8Path::new("target").join(format!("{namev}.tar"));
458 let prefix = format!("{namev}/");
459 cmd!(sh, "git archive --format=tar --prefix={prefix} -o {p} HEAD").run()?;
460 // Generate the vendor directory now, as we want to embed the generated config to use
461 // it in our source.
462 let vendorpath = Utf8Path::new("target").join(format!("{namev}-vendor.tar.zstd"));
463 let vendor_config = cmd!(
464 sh,
465 "cargo vendor-filterer --prefix=vendor --format=tar.zstd {vendorpath}"
466 )
467 .read()?;
468 let vendor_config = edit_vendor_config(&vendor_config)?;
469 // Append .cargo/vendor-config.toml (a made up filename) into the tar archive.
470 {
471 let tmpdir = tempfile::tempdir_in("target")?;
472 let tmpdir_path = tmpdir.path();
473 let path = tmpdir_path.join("vendor-config.toml");
474 std::fs::write(&path, vendor_config)?;
475 let source_date_epoch = format!("{source_date_epoch}");
476 cmd!(
477 sh,
478 "tar -r -C {tmpdir_path} {TAR_REPRODUCIBLE_OPTS...} --mtime=@{source_date_epoch} --transform=s,^,{prefix}.cargo/, -f {p} vendor-config.toml"
479 )
480 .run()?;
481 }
482 // Compress with zstd
483 let srcpath: Utf8PathBuf = format!("{p}.zstd").into();
484 cmd!(sh, "zstd --rm -f {p} -o {srcpath}").run()?;
485
486 Ok(Package {
487 version: v,
488 srcpath,
489 vendorpath,
490 })
491}
492
493fn package(sh: &Shell) -> Result<()> {
494 let p = impl_package(sh)?.srcpath;

Callers 3

packageFunction · 0.85
update_specFunction · 0.85
impl_srpmFunction · 0.85

Calls 7

git_source_date_epochFunction · 0.85
gitrevFunction · 0.85
edit_vendor_configFunction · 0.85
intoMethod · 0.45
runMethod · 0.45
readMethod · 0.45
pathMethod · 0.45

Tested by

no test coverage detected