From 169dc549a44a8a45d85b85f85f9905fcdc29f8b6 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Thu, 15 Feb 2024 10:57:20 -0500 Subject: [PATCH] xtask: Fixes for `cargo xtask package` The release process has drifted with xtask; I forget exactly why but I ended up with `.zstd`, not `.zst` in the tarballs and I've been hand-hacking that manually. Fix things up so that `cargo xtask package` generates the source snapshot and the vendor tarball named exactly how we release them now. Signed-off-by: Colin Walters --- contrib/packaging/bootc.spec | 4 ++-- xtask/src/xtask.rs | 34 +++++++++++++++------------------- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/contrib/packaging/bootc.spec b/contrib/packaging/bootc.spec index 57701482..443c295d 100644 --- a/contrib/packaging/bootc.spec +++ b/contrib/packaging/bootc.spec @@ -7,8 +7,8 @@ Summary: Boot containers License: ASL 2.0 URL: https://github.com/containers/bootc -Source0: https://github.com/containers/bootc/releases/download/v%{version}/bootc-%{version}.tar.zst -Source1: https://github.com/containers/bootc/releases/download/v%{version}/bootc-%{version}-vendor.tar.zst +Source0: https://github.com/containers/bootc/releases/download/v%{version}/bootc-%{version}.tar.zstd +Source1: https://github.com/containers/bootc/releases/download/v%{version}/bootc-%{version}-vendor.tar.zstd BuildRequires: make BuildRequires: openssl-devel diff --git a/xtask/src/xtask.rs b/xtask/src/xtask.rs index cf012643..a58fa0d8 100644 --- a/xtask/src/xtask.rs +++ b/xtask/src/xtask.rs @@ -8,7 +8,6 @@ use fn_error_context::context; use xshell::{cmd, Shell}; const NAME: &str = "bootc"; -const VENDORPATH: &str = "target/vendor.tar.zstd"; fn main() { if let Err(e) = try_main() { @@ -19,7 +18,6 @@ fn main() { #[allow(clippy::type_complexity)] const TASKS: &[(&str, fn(&Shell) -> Result<()>)] = &[ - ("vendor", vendor), ("manpages", manpages), ("man2markdown", man2markdown), ("package", package), @@ -42,16 +40,6 @@ fn try_main() -> Result<()> { Ok(()) } -fn vendor(sh: &Shell) -> Result<()> { - let target = VENDORPATH; - cmd!( - sh, - "cargo vendor-filterer --prefix=vendor --format=tar.zstd {target}" - ) - .run()?; - Ok(()) -} - fn gitrev_to_version(v: &str) -> String { let v = v.trim().trim_start_matches('v'); v.replace('-', ".") @@ -153,6 +141,7 @@ fn git_timestamp(sh: &Shell) -> Result { struct Package { version: String, srcpath: Utf8PathBuf, + vendorpath: Utf8PathBuf, } /// Return the timestamp of the latest git commit in seconds since the Unix epoch. @@ -211,10 +200,18 @@ fn impl_package(sh: &Shell) -> Result { if !st.success() { anyhow::bail!("Failed to run {st:?}"); } - cmd!(sh, "zstd -f {p}").run()?; + let srcpath: Utf8PathBuf = format!("{p}.zstd").into(); + cmd!(sh, "zstd --rm -f {p} -o {srcpath}").run()?; + let vendorpath = Utf8Path::new("target").join(format!("{namev}-vendor.tar.zstd")); + cmd!( + sh, + "cargo vendor-filterer --prefix=vendor --format=tar.zstd {vendorpath}" + ) + .run()?; Ok(Package { version: v, - srcpath: format!("{p}.zst").into(), + srcpath, + vendorpath, }) } @@ -236,15 +233,14 @@ fn impl_srpm(sh: &Shell) -> Result { } } let pkg = impl_package(sh)?; - vendor(sh)?; let td = tempfile::tempdir_in("target").context("Allocating tmpdir")?; let td = td.into_path(); let td: &Utf8Path = td.as_path().try_into().unwrap(); - let srcpath = td.join(pkg.srcpath.file_name().unwrap()); - std::fs::rename(pkg.srcpath, srcpath)?; + let srcpath = &pkg.srcpath; + cmd!(sh, "mv {srcpath} {td}").run()?; let v = pkg.version; - let vendorpath = td.join(format!("{NAME}-{v}-vendor.tar.zst")); - std::fs::rename(VENDORPATH, vendorpath)?; + let src_vendorpath = &pkg.vendorpath; + cmd!(sh, "mv {src_vendorpath} {td}").run()?; { let specin = File::open(format!("contrib/packaging/{NAME}.spec")) .map(BufReader::new)