mmstick / cargo-deb

A cargo subcommand that generates Debian packages from information in Cargo.toml
615 stars 50 forks source link

Add `--deb-version` argument to CLI #95

Closed acfoltzer closed 5 years ago

acfoltzer commented 5 years ago

This allows changing the version string used in the Debian package without having to modify the Cargo manifest of a project. Since Cargo versions must be formatted according to semver, this was preventing valid Debian version string conventions from being used.

kornelski commented 5 years ago

Thanks for the PR!

Can you explain more about the problem? Why is the arg is different from revision in Cargo.toml? (if revision is not sufficient, should we change the metadata too?)

What's the mismatch between debian and semver? Can we automatically sanitize versions?

acfoltzer commented 5 years ago

So, the overall scenario I have is that our CI system generates a version string for all of our packages based on git history and commit hashes. The format is a valid Debian version, but not a valid semver version as Cargo expects.

I think it'd be reasonable to add an optional metadata field as well, it just hadn't occurred to me for this PR because of the generated nature of our versions.

I don't think we can automatically sanitize things, because it's the Cargo version that's more restrictive than the Debian one. If it was the other way around we could, though; I'm actually not sure what the restrictions are on the Debian side.

kornelski commented 5 years ago

So is your Cargo.toml version invalid/incomplete?

Semver is pretty flexible as long as you add a - or + before your suffix. For example, git describe --tags output is a valid semver accepted by Cargo.

acfoltzer commented 5 years ago

Well, the Cargo.toml version is a normal semver, but our continuous integration generates a version string like 11.19g96633ae4d2ce, which due to the lack of - or + is not valid semver.

Even if it was a valid semver, this model where the string is determined at runtime based on things other than the Cargo.toml version means that we currently have to sed it into the Cargo.toml, which is gross :(

kornelski commented 5 years ago

Thanks for the explanation and the PR.

acfoltzer commented 5 years ago

And thank you again for the useful project, and for merging so quickly :heart: