cat-in-136 / cargo-generate-rpm

Cargo helper command to generate a binary RPM package
MIT License
87 stars 19 forks source link

Conditional dependecies #42

Closed BKSalman closed 2 years ago

BKSalman commented 2 years ago

Hello,

I'm making an rpm package for an app that depends on ffmpeg,

but since ffmpeg is removed from fedora's default repos, I want to check if the user already has ffmpeg or has access to it from a different repo, and download it,

if NOT then install ffmpeg-free since it does what I need

something similar to Requires: (ffmpeg or ffmpeg-free) in the spec file

I want to do that because if I just download ffmpeg-free regardless, it will conflict with ffmpeg as I tested on my machine,

how do I do conditional dependencies in this situation?

cat-in-136 commented 2 years ago

As you know, currently rpm-rs does not support rich/boolean dependency. So it is difficult to support it.

In your case, how about just specify file dependency : /usr/bin/ffmpeg ?

BKSalman commented 2 years ago

ah, I see,

you mean adding ffmpeg as an asset? if so, don't I need to add all of it's dependencies too?

BKSalman commented 2 years ago

welp, after slamming my head for a bit, I opened the rpm file in a hex editor and found out that they just append (ffmpeg or ffmpeg-free) as plain text, so I just needed to do something like this

[package.metadata.generate-rpm.requires]
"(ffmpeg or ffmpeg-free)" = "*"
cat-in-136 commented 2 years ago

I intended to do the following:

[package.metadata.generate-rpm.requires]
"/usr/bin/ffmpeg" = "*"

Anyway, your investigation clearly that conditional dependency also supported in current implement. Thank you so much!

BKSalman commented 2 years ago

no problem! I was even trying to read the source code for rpmbuild to figure out how they store that information, and do a PR on rpm-rs, but my very first simple guess was right, but I didn't trust my guts XD

love your crate btw, thank you for making it!