cat-in-136 / cargo-generate-rpm

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

Add --profile command line option #73

Closed jpgrayson closed 1 year ago

jpgrayson commented 1 year ago

When expanding an asset path, currently only the "target/release/" prefix could be remapped. By comprehending the build profile, path expansion can happen for "target/". This enables use of both alternative target-triple and build profiles.

For example, given the following asset configuration in Cargo.toml:

[package.metadata.generate-rpm]
assets = [
  { source = "target/my-profile/my-exe", dest = "/usr/bin/", mode = "755" },
]

rpms can be generated for multiple target triples, such as:

cargo generate-rpm --profile my-profile --target x86_64-unknown-linux-musl
cargo generate-rpm --profile my-profile --target i668-unknown-linux-musl

with the paths for the "my-exe" executable expanded correctly to:

target/x86_64-unknown-linux-musl/my-profile/my-exe
target/i686-unknown-linux-musl/my-profile/my-exe

This behavior is consistent with cargo-deb, which also has a --profile option for the same purpose.

cat-in-136 commented 1 year ago

Thank you for proposing new feature.


In your PR, source in package.metadata.generate-rpm.assets is supposed to be written in with the value of target specified as an argument instead of release, like target/my-profile/my-exe. I think the source in package.metadata.generate-rpm.assets should be written as target/release/my-exe and it should be expanded to target/my-profile/my-exe or target/x 86_64-unknown-linux-musl/my-profile/my-exe. That is, I would prefer that profile be treated the same as target.

What do you think?

Could you please update the README.md in addition to the source code? A short addition to the "Cross compilation" clause would be sufficient.

jpgrayson commented 1 year ago

Yes, good suggestion.

I've updated the patch so that the "target/release/" prefix is preferentially remapped while still also looking for "target/{prefix}". This is how cargo-deb does it.

And I've added a paragraph about the '--profile` option to README.md.

Thanks for reviewing this PR. Much appreciated.