mmstick / cargo-deb

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

[question] specify revision number from cli #79

Closed eldesh closed 6 years ago

eldesh commented 6 years ago

Hi cargo-deb maintainers. I have a question.

motivation

I want to specify a revision number from cargo deb commnad line like:

$ cargo deb --revision=1234

Because I want to updating package version(+revision) automatically using commit hash (or build number).

design choice

But supporting only revision (not support any other metadata fields dependes, assets, etc) seems to be unnatural ? I have the option of accepting metadata from an external file like below:

$ cat debian.toml  # include [package.metadata.deb]
assets = ...
revision = ...
...
$ cargo deb --metadata=debian.toml

question

  1. Can the cargo-deb support replacing revision nubmer from cli command ?
  2. Which approach is better ? Is there a better design ?
JDemler commented 6 years ago

I use a perl one-liner in my build script to achieve this:

perl -i -p -lne 'if (s{deb\.variants\.live}{"deb.variants.live"}e){$a=true;}; if ($a && !$b && s{^revision = "(\d+)"}{"revision = \"".($1+1)."\""}e) { $b=true; }' Cargo.toml

Not very pretty... but I didn't touch it for over a year. So seems to be working.

The $1+1 part just increments the revision, but you could of course insert anything you want. This targets a specific variant, so if you do not use variants you might need to change the script.

kornelski commented 6 years ago

One way to do it would be to use a separate TOML editor. I don't know if there's one already, but if not, someone should make it :)

some-toml-editor Cargo.toml package.metadata.deb.revision=123

This would be generally useful for bumping versions, editing all metadata.

I guess Debian packages have separate roles of author and package maintainer, and Cargo.toml is generally created by the package author, so it would make sense to allow maintainers to have their own way of specifying metadata. In that regard debian.toml (or probably Cargo-deb.toml to avoid squatting Debian's name) would make sense.

Is your use case more caused by difficulty of editing TOML, or separation of responsibilities and packaging someone else's project?

eldesh commented 6 years ago

@JDemler Thank you for an example. I think so too :| > Not very pretty

@kornelski

Is your use case more caused by difficulty of editing TOML,

No. I am a main maintainer of my objective program and the debian package of it. So, I can edit the build script to changing Cargo.toml. But I wanted to do it in a valid (, rust or cargo-deb) way.

However, editing TOML in a valid way don't seem bad. I will search tools for editing TOML first. Thank you.