Skip to content

Commit

Permalink
Add tagging (#62)
Browse files Browse the repository at this point in the history
Fixes #61 - this re-adds tagging of individual vendor archives.

---------

Signed-off-by: Soc Virnyl Estela <[email protected]>
Co-authored-by: Soc Virnyl Estela <[email protected]>
  • Loading branch information
Firstyear and uncomfyhalomacro authored Nov 21, 2023
1 parent 7904a15 commit 8b04f5b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
14 changes: 0 additions & 14 deletions cargo/src/bin/cargo_vendor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
info!("🎢 Starting OBS Service Cargo Vendor.");
debug!(?args);

if args.tag.is_some() {
error!("⚠️ tags are no longer supported for vendoring.");
eprintln!(
r#"
When you have multiple Cargo.toml's in a project, you can specify them with
<param name=\"cargotoml\">first/Cargo.toml</param>"
<param name=\"cargotoml\">second/Cargo.toml</param>"
This will create a single vendor.tar that will work with both projects.
"#
);
}

warn!("⚠️ Cargo Vendor has been rewritten in rust!");
eprintln!(
r#"
Expand Down
8 changes: 7 additions & 1 deletion cargo/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,13 @@ pub fn process_src(args: &Opts, prjdir: &Path) -> Result<(), OBSCargoError> {
debug!("All paths to archive {:#?}", paths_to_archive);

if vendor_dir.exists() {
vendor::compress(outdir, prjdir, &paths_to_archive, compression)?;
vendor::compress(
outdir,
prjdir,
&paths_to_archive,
compression,
args.tag.as_deref(),
)?;
} else {
error!("Vendor dir does not exist! This is a bug!");
return Err(OBSCargoError::new(
Expand Down
8 changes: 7 additions & 1 deletion cargo/src/vendor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ pub fn compress(
prjdir: impl AsRef<Path>,
paths_to_archive: &[impl AsRef<Path>],
compression: &Compression,
tag: Option<&str>,
) -> Result<(), OBSCargoError> {
info!("📦 Archiving vendored dependencies...");

Expand All @@ -124,7 +125,12 @@ pub fn compress(
// NOTE: 3. If they are not members, we slap that file into their own compressed vendored
// tarball

let mut vendor_out = outpath.as_ref().join("vendor");
let tar_name = match tag {
Some(t) => format!("vendor-{}", t),
None => "vendor".to_string(),
};

let mut vendor_out = outpath.as_ref().join(tar_name);
match compression {
Compression::Gz => {
vendor_out.set_extension("tar.gz");
Expand Down
9 changes: 9 additions & 0 deletions runtests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,12 @@ echo "# Generating tarball"
"${SCRIPTPATH}"/target/release/cargo_vendor --src /tmp/flux-0.194.4.tar.gz --outdir /tmp --cargotoml libflux/Cargo.toml
echo "# Removing vendored tarball"
rm /tmp/vendor.tar.zst

echo "# Test tagging"
"${SCRIPTPATH}"/target/release/cargo_vendor --src /tmp/s390-tools-2.29.0.tar.gz --outdir /tmp --cargotoml rust/pvsecret/Cargo.toml --cargotoml rust/utils/Cargo.toml --cargotoml rust/pv/Cargo.toml --tag "rust-component"

if [ ! -f "/tmp/vendor-rust-component.tar.zst" ]
then
# Fail
exit 1
fi

0 comments on commit 8b04f5b

Please sign in to comment.