• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pantsbuild / pants / 19015773527

02 Nov 2025 05:33PM UTC coverage: 17.872% (-62.4%) from 80.3%
19015773527

Pull #22816

github

web-flow
Merge a12d75757 into 6c024e162
Pull Request #22816: Update Pants internal Python to 3.14

4 of 5 new or added lines in 3 files covered. (80.0%)

28452 existing lines in 683 files now uncovered.

9831 of 55007 relevant lines covered (17.87%)

0.18 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/python/pants/backend/nfpm/fields/archlinux.py
1
# Copyright 2023 Pants project contributors (see CONTRIBUTORS.md).
2
# Licensed under the Apache License, Version 2.0 (see LICENSE).
3

UNCOV
4
from __future__ import annotations
×
5

UNCOV
6
from typing import ClassVar
×
7

UNCOV
8
from pants.backend.nfpm.fields._relationships import NfpmPackageRelationshipsField
×
UNCOV
9
from pants.backend.nfpm.fields.all import NfpmDependencies
×
UNCOV
10
from pants.backend.nfpm.fields.scripts import NfpmPackageScriptsField
×
UNCOV
11
from pants.engine.target import StringField
×
UNCOV
12
from pants.util.frozendict import FrozenDict
×
UNCOV
13
from pants.util.strutil import help_text
×
14

15
# These fields are used by the `nfpm_archlinux_package` target
16
# Some fields will be duplicated by other package types which
17
# allows the help string to be packager-specific.
18

19

UNCOV
20
class NfpmArchlinuxPackagerField(StringField):
×
UNCOV
21
    nfpm_alias = "archlinux.packager"
×
UNCOV
22
    alias: ClassVar[str] = "packager"
×
UNCOV
23
    help = help_text(
×
24
        # based in part on the docs at:
25
        # https://nfpm.goreleaser.com/configuration/#reference
26
        lambda: f"""
27
        The name and email address of the packager or packager organization.
28

29
        The '{NfpmArchlinuxPackagerField.alias}' is used to identify who actually
30
        packaged the software, as opposed to the author of the software, or the
31
        maintainer of an archlinux PKGBUILD.
32

33
        The name is first, then the email address inside angle brackets `<>`
34
        (in RFC5322 format). For example: "Foo Bar <maintainer@example.com>"
35
        This format is the conventional format; it not a hard requirement.
36

37
        If not set, nFPM uses "Unknown Packager" by default (as does `makepkg`).
38

39
        See:
40
        https://man.archlinux.org/man/BUILDINFO.5
41
        https://wiki.archlinux.org/title/Makepkg#Packager_information
42
        """
43
    )
44
    # nFPM embeds this string as-is in the archlinux package.
45

46

UNCOV
47
class NfpmArchlinuxPkgbaseField(StringField):
×
UNCOV
48
    nfpm_alias = "archlinux.pkgbase"
×
UNCOV
49
    alias: ClassVar[str] = "pkgbase"
×
UNCOV
50
    help = help_text(
×
51
        # based in part on the docs at:
52
        # https://nfpm.goreleaser.com/configuration/#reference
53
        lambda: f"""
54
        The base name of an Archlinux package.
55

56
        For split packages, '{NfpmArchlinuxPkgbaseField.alias}' specifies the
57
        name of the group of packages. For all other packages, this is the same
58
        as package name (known as 'pkgname' by Archlinux packaging tools).
59
        If unset, nFPM will use the package name as the default value for the
60
        '{NfpmArchlinuxPkgbaseField.alias}' field.
61

62
        See:
63
        https://man.archlinux.org/man/BUILDINFO.5
64
        https://wiki.archlinux.org/title/PKGBUILD#pkgbase
65
        """
66
    )
67

68

UNCOV
69
class NfpmArchlinuxReplacesField(NfpmPackageRelationshipsField):
×
UNCOV
70
    nfpm_alias = "replaces"
×
UNCOV
71
    alias: ClassVar[str] = nfpm_alias
×
UNCOV
72
    help = help_text(
×
73
        """
74
        A list of packages that this package replaces or obsoletes.
75

76
        This allows for combining packages or splitting them up. When pacman
77
        does a `sysupgrade` operation, it will immediately replace the listed
78
        packages with this package. This option is ignored during pacman
79
        `sync` or `upgrade` operations.
80

81
        See:
82
        https://wiki.archlinux.org/title/PKGBUILD#replaces
83
        https://man.archlinux.org/man/core/pacman/PKGBUILD.5.en
84
        """
85
    )
86

87

UNCOV
88
class NfpmArchlinuxProvidesField(NfpmPackageRelationshipsField):
×
UNCOV
89
    nfpm_alias = "provides"
×
UNCOV
90
    alias: ClassVar[str] = nfpm_alias
×
UNCOV
91
    help = help_text(
×
92
        lambda: f"""
93
        A list of (virtual) packages or shared libraries that this package provides.
94

95
        Each entry can be either a package name or a shared library (which ends
96
        with ".so"). You can specify a version on both package names and shared
97
        libraries. If specified, the version must use `=` (not `<`, `<=`, etc).
98

99
        Make sure to include any shared libraries (.so files) that this package
100
        installs if they provide an external API for other packages to use.
101

102
        Do not include the 'package_name' (known by 'pkgname' in Archlinux) in
103
        the list of '{NfpmArchlinuxProvidesField.alias}' as that is implicit.
104

105
        For example, package "baz" could declare that it also provides virtual
106
        packages "foo" and "bar" as well as the "libbaz.so" v2 shared object.
107
        Because the "baz" package implicitly provides its own name, this list
108
        should not include "baz".
109

110
          - "foo"
111
          - "bar=1.0.0"
112
          - "libbaz.so=2"
113

114
        If several packages declare the same '{NfpmArchlinuxProvidesField.alias}',
115
        then they might need to declare that they conflict with each other
116
        using '{NfpmArchlinuxConflictsField.alias}' if, for example, they also
117
        install a binary with the same path. Packages that have the same package
118
        (or virtual package) in both '{NfpmArchlinuxProvidesField.alias}' and
119
        '{NfpmArchlinuxConflictsField.alias}' are considered alternative packages
120
        that cannot be installed at the same time. If those package only include
121
        an entry in '{NfpmArchlinuxProvidesField.alias}' and not in
122
        '{NfpmArchlinuxConflictsField.alias}', then they CAN be installed at the
123
        same time.
124

125
        See:
126
        https://wiki.archlinux.org/title/PKGBUILD#provides
127
        https://man.archlinux.org/man/core/pacman/PKGBUILD.5.en
128
        https://wiki.archlinux.org/title/Arch_package_guidelines#Package_relations
129
        """
130
    )
131

132

UNCOV
133
class NfpmArchlinuxDependsField(NfpmPackageRelationshipsField):
×
UNCOV
134
    nfpm_alias = "depends"
×
UNCOV
135
    alias: ClassVar[str] = nfpm_alias
×
UNCOV
136
    help = help_text(
×
137
        lambda: f"""
138
        List of package dependencies (for package installers).
139

140
        The '{NfpmArchlinuxDependsField.alias}' field has install-time dependencies
141
        that can use version selectors (with one of `<`, `<=`, `=`, `>=`, `>`).
142

143
          - "git"
144
          - "tcpdump<5"
145
          - "foobar>=1.8.0"
146

147
        WARNING: This is NOT the same as the 'dependencies' field!
148
        It does not accept pants-style dependencies like target addresses.
149

150
        See:
151
        https://wiki.archlinux.org/title/PKGBUILD#depends
152
        https://man.archlinux.org/man/core/pacman/PKGBUILD.5.en
153
        https://wiki.archlinux.org/title/Arch_package_guidelines#Package_dependencies
154
        """
155
    )
156

157

UNCOV
158
class NfpmArchlinuxConflictsField(NfpmPackageRelationshipsField):
×
UNCOV
159
    nfpm_alias = "conflicts"
×
UNCOV
160
    alias: ClassVar[str] = nfpm_alias
×
UNCOV
161
    help = help_text(
×
162
        lambda: f"""
163
        A list of (virtual) packages that this package conflicts with.
164

165
        Packages that conflict with each other cannot be installed at the same time.
166

167
        The '{NfpmArchlinuxConflictsField.alias}' field has the same syntax as the
168
        '{NfpmArchlinuxDependsField.alias}' field.
169

170
        See:
171
        https://wiki.archlinux.org/title/PKGBUILD#conflicts
172
        https://man.archlinux.org/man/core/pacman/PKGBUILD.5.en
173
        """
174
    )
175

176

UNCOV
177
class NfpmArchlinuxScriptsField(NfpmPackageScriptsField):
×
UNCOV
178
    nfpm_aliases: ClassVar[FrozenDict[str, str]] = FrozenDict(
×
179
        {
180
            **NfpmPackageScriptsField.nfpm_aliases,
181
            "preupgrade": "archlinux.scripts.preupgrade",
182
            "postupgrade": "archlinux.scripts.postupgrade",
183
        }
184
    )
UNCOV
185
    help = help_text(
×
186
        f"""
187
        Map of install script source files for the Archlinux package.
188

189
        This maps the script type (key) to the script source file (value).
190
        Each of the script source file(s) must be provided via '{NfpmDependencies.alias}'.
191
        nFPM will package all of these scripts in a single `.INSTALL` scriptlet file
192
        by adding a shell function for each of your script files where your script becomes
193
        the body of that function. These functions are:
194

195
        | nFPM script | `.INSTALL` function |
196
        +-------------+---------------------+
197
        | preinstall  | pre_install         |
198
        | postinstall | post_install        |
199
        | preupgrade  | pre_upgrade         |
200
        | postupgrade | post_upgrade        |
201
        | preremove   | pre_remove          |
202
        | postremove  | post_remove         |
203

204
        So, if you provide a `preinstall` script, the `.INSTALL` scriptlet would contain:
205

206
            ```
207
            function pre_install() {{
208
            # Your preinstall script's contents get embedded here.
209
            }}
210
            ```
211

212
        Here are several things to keep in mind when writing your scripts:
213

214
        * Your scripts are actually functions, so use `return` instead of `exit`.
215
        * `pacman` uses `/bin/sh` to source `.INSTALL` and run the function(s).
216
        * `pacman` runs these in a chroot.
217
        * The current directory is the root of the chroot.
218

219
        Please consult the Archlinux docs to understand when `pacman` will run
220
        each of these functions and what arguments the functions will receive.
221

222
        See:
223
        https://wiki.archlinux.org/title/pacman#What_happens_during_package_install/upgrade/removal
224
        https://man.archlinux.org/man/core/pacman/PKGBUILD.5.en#INSTALL/UPGRADE/REMOVE_SCRIPTING
225
        https://wiki.archlinux.org/title/PKGBUILD#install
226
        """
227
    )
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc