Skip to content

Packaging: Add distro_id field to nfpm_deb_package and nfpm_rpm_package targets #6324

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 27, 2025

Conversation

cognifloyd
Copy link
Member

@cognifloyd cognifloyd commented Mar 25, 2025

This PR is working towards doing packaging via pantsbuild. Eventually, I hope to archive and stop using st2-packages.git.

This is a follow-up to #6323, resolving the TODO explained in #6323 (comment).

In pants-plugins/release, a new distro_id field is defined here:

class DistroIDField(StringField):
nfpm_alias = "" # Not an nFPM field
alias = "distro_id"

This field basically accepts an enum of valid_choices. These valid_choices should be a list of supported or soon-to-be-supported distros:

valid_choices = ( # officially supported (or planned future support)
# ubuntu
"focal",
"jammy",
"noble",
# el
"el8",
"el9",
)

And mark the field as required so that all BUILD targets have this field defined (if the field is registered for that target).

This registers the new field on the nfpm_deb_package and nfpm_rpm_package targets:

def rules():
return [
NfpmDebPackage.register_plugin_field(DistroIDField),
NfpmRpmPackage.register_plugin_field(DistroIDField),
]

To finish the field registration, the field rules get added to pants-plugins/release/register.py:

from release.rules import rules as release_rules
from release.target_types import rules as release_target_types_rules
def rules():
return [
*release_target_types_rules(),
*release_rules(),
]

Finally, replace the TODO with the value of the distro_id field here:

distro_id=target[DistroIDField].value,

@cognifloyd cognifloyd added this to the pants milestone Mar 25, 2025
@cognifloyd cognifloyd self-assigned this Mar 25, 2025
@pull-request-size pull-request-size bot added the size/M PR that changes 30-99 lines. Good size to review. label Mar 25, 2025
…rgets

This should also be included in the output_path and possibly other fields.
@cognifloyd cognifloyd force-pushed the packaging-nfpm_distro_id branch from 3b16d02 to 00ff205 Compare March 25, 2025 19:09
@cognifloyd cognifloyd enabled auto-merge March 25, 2025 19:39
@cognifloyd cognifloyd requested a review from a team March 26, 2025 14:32
@cognifloyd cognifloyd merged commit 1b81f88 into master Mar 27, 2025
80 checks passed
@cognifloyd cognifloyd deleted the packaging-nfpm_distro_id branch March 27, 2025 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement pantsbuild size/M PR that changes 30-99 lines. Good size to review. st2-packages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants