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

Function impl_srpm

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

Source from the content-addressed store, hash-verified

531 Ok(())
532}
533fn impl_srpm(sh: &Shell) -> Result<Utf8PathBuf> {
534 {
535 let _g = sh.push_dir("target");
536 for name in sh.read_dir(".")? {
537 if let Some(name) = name.to_str() {
538 if name.ends_with(".src.rpm") {
539 sh.remove_path(name)?;
540 }
541 }
542 }
543 }
544 let pkg = impl_package(sh)?;
545 let td = tempfile::tempdir_in("target").context("Allocating tmpdir")?;
546 let td = td.keep();
547 let td: &Utf8Path = td.as_path().try_into().unwrap();
548 let srcpath = &pkg.srcpath;
549 cmd!(sh, "mv {srcpath} {td}").run()?;
550 let v = pkg.version;
551 let src_vendorpath = &pkg.vendorpath;
552 cmd!(sh, "mv {src_vendorpath} {td}").run()?;
553 {
554 let specin = File::open(format!("contrib/packaging/{NAME}.spec"))
555 .map(BufReader::new)
556 .context("Opening spec")?;
557 let mut o = File::create(td.join(format!("{NAME}.spec"))).map(BufWriter::new)?;
558 for line in specin.lines() {
559 let line = line?;
560 if line.starts_with("Version:") {
561 writeln!(o, "# Replaced by cargo xtask package-srpm")?;
562 writeln!(o, "Version: {v}")?;
563 } else {
564 writeln!(o, "{line}")?;
565 }
566 }
567 }
568 let d = sh.push_dir(td);
569 let mut cmd = cmd!(sh, "rpmbuild");
570 for k in [
571 "_sourcedir",
572 "_specdir",
573 "_builddir",
574 "_srcrpmdir",
575 "_rpmdir",
576 ] {
577 cmd = cmd.arg("--define");
578 cmd = cmd.arg(format!("{k} {td}"));
579 }
580 cmd.arg("--define")
581 .arg(format!("_buildrootdir {td}/.build"))
582 .args(["-bs", "bootc.spec"])
583 .run()?;
584 drop(d);
585 let mut srpm = None;
586 for e in std::fs::read_dir(td)? {
587 let e = e?;
588 let n = e.file_name();
589 let Some(n) = n.to_str() else {
590 continue;

Callers 1

package_srpmFunction · 0.85

Calls 5

impl_packageFunction · 0.85
to_strMethod · 0.80
argMethod · 0.80
argsMethod · 0.80
runMethod · 0.45

Tested by

no test coverage detected