WIP: Add nFPM backend for building apk, archlinux, deb, rpm packages#18914
WIP: Add nFPM backend for building apk, archlinux, deb, rpm packages#18914cognifloyd wants to merge 74 commits intopantsbuild:mainfrom
Conversation
kaos
left a comment
There was a problem hiding this comment.
Really nice!
I like the organization with fields in its own submodule, given there are so many of them, and for different targets. Makes for a nice and tidy structure imo.
Haven't read all the docstrings and help texts yet, but that shouldn't impact the structure of the code at all.. :)
| continue | ||
|
|
||
| # handle nested fields (eg: deb.triggers) | ||
| keys = cast(_NfpmField, field).nfpm_alias.split(".") |
There was a problem hiding this comment.
rather than a cast here, aren't mypy satisfied if you declare a required_fields: ClassVar[Collection[_NfpmField]] in this fieldset class? (or does it complain about the type already being defined in the base class then?)
There was a problem hiding this comment.
Ooh. I like that idea. I'll try that
There was a problem hiding this comment.
I could also drop the protocol and do something like:
if not hasattr(field, "nfpm_alias"):
continueThere was a problem hiding this comment.
I couldn't figure out how to make a type hint for required_fields that was compatible with the base class type and added the field. So, I went with hasattr and getattr.
| class GoOS(Enum): | ||
| # GOOS possible values come from `okgoos` var at: | ||
| # https://github.com/golang/go/blob/go1.20.3/src/cmd/dist/build.go#L81-L98 | ||
| # TODO: maybe filter this down to only what nFPM can handle |
There was a problem hiding this comment.
I'm torn. On one hand it would be bad to list a value that we know is going to fail, otoh a newer version of nFPM might add support for a value and then the user is blocked until a new release of this backend is out adding it..
Also, add type hints for some of the field.alias properties because mypy was getting confused.
This is needed for the field_set calculations
A common field that all nfpm packages will share, making it easier to build a common FieldSet base.
Almost all fields are "required" in that, if present, they are used in the generation of the package. Users do not have to supply them, but the fields have to exist on the Nfpm*Package targets.
Includes support for octal strings: '644' and for symoblic representations: 'rw-r--r--'
and the symlink src field the regular file src field is optional because it can be populated from the source field.
This is used for output_path.value_or_default.
|
Closing in favor of #19308 which uses a branch I pushed to pantsbuild/pants instead of to my fork. |
Builds an
nfpmbackend fornFPMaccording to this plan:https://docs.google.com/document/d/1b2ZvP_Ol6bOURHBaZYOD8gxixxHpV22S_zKiHKZw9iY/edit?usp=sharing