Move pkg_deb documentation from .md file to .bzl (#445)

This commit is contained in:
aiuto 2021-11-04 15:36:24 -04:00 committed by GitHub
parent 0236150182
commit 036362cd91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 238 additions and 49 deletions

83
docs/pkg_deb.md Executable file
View File

@ -0,0 +1,83 @@
<!-- Generated with Stardoc: http://skydoc.bazel.build -->
<a name="#pkg_deb_impl"></a>
## pkg_deb_impl
<pre>
pkg_deb_impl(<a href="#pkg_deb_impl-name">name</a>, <a href="#pkg_deb_impl-architecture">architecture</a>, <a href="#pkg_deb_impl-architecture_file">architecture_file</a>, <a href="#pkg_deb_impl-breaks">breaks</a>, <a href="#pkg_deb_impl-built_using">built_using</a>, <a href="#pkg_deb_impl-built_using_file">built_using_file</a>,
<a href="#pkg_deb_impl-conffiles">conffiles</a>, <a href="#pkg_deb_impl-conffiles_file">conffiles_file</a>, <a href="#pkg_deb_impl-config">config</a>, <a href="#pkg_deb_impl-conflicts">conflicts</a>, <a href="#pkg_deb_impl-data">data</a>, <a href="#pkg_deb_impl-depends">depends</a>, <a href="#pkg_deb_impl-depends_file">depends_file</a>, <a href="#pkg_deb_impl-description">description</a>,
<a href="#pkg_deb_impl-description_file">description_file</a>, <a href="#pkg_deb_impl-distribution">distribution</a>, <a href="#pkg_deb_impl-enhances">enhances</a>, <a href="#pkg_deb_impl-homepage">homepage</a>, <a href="#pkg_deb_impl-maintainer">maintainer</a>, <a href="#pkg_deb_impl-out">out</a>, <a href="#pkg_deb_impl-package">package</a>,
<a href="#pkg_deb_impl-package_file_name">package_file_name</a>, <a href="#pkg_deb_impl-package_variables">package_variables</a>, <a href="#pkg_deb_impl-postinst">postinst</a>, <a href="#pkg_deb_impl-postrm">postrm</a>, <a href="#pkg_deb_impl-predepends">predepends</a>, <a href="#pkg_deb_impl-preinst">preinst</a>, <a href="#pkg_deb_impl-prerm">prerm</a>,
<a href="#pkg_deb_impl-priority">priority</a>, <a href="#pkg_deb_impl-provides">provides</a>, <a href="#pkg_deb_impl-recommends">recommends</a>, <a href="#pkg_deb_impl-replaces">replaces</a>, <a href="#pkg_deb_impl-section">section</a>, <a href="#pkg_deb_impl-suggests">suggests</a>, <a href="#pkg_deb_impl-templates">templates</a>, <a href="#pkg_deb_impl-triggers">triggers</a>,
<a href="#pkg_deb_impl-urgency">urgency</a>, <a href="#pkg_deb_impl-version">version</a>, <a href="#pkg_deb_impl-version_file">version_file</a>)
</pre>
**ATTRIBUTES**
| Name | Description | Type | Mandatory | Default |
| :-------------: | :-------------: | :-------------: | :-------------: | :-------------: |
| name | A unique name for this target. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | |
| architecture | Package architecture. Must not be used with architecture_file. | String | optional | "all" |
| architecture_file | File that contains the package architecture. Must not be used with architecture. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
| breaks | See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | List of strings | optional | [] |
| built_using | The tool that were used to build this package provided either inline (with built_using) or from a file (with built_using_file). | String | optional | "" |
| built_using_file | The tool that were used to build this package provided either inline (with built_using) or from a file (with built_using_file). | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
| conffiles | The list of conffiles or a file containing one conffile per line. Each item is an absolute path on the target system where the deb is installed. See https://www.debian.org/doc/debian-policy/ch-files.html#s-config-files. | List of strings | optional | [] |
| conffiles_file | The list of conffiles or a file containing one conffile per line. Each item is an absolute path on the target system where the deb is installed. See https://www.debian.org/doc/debian-policy/ch-files.html#s-config-files. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
| config | config file used for debconf integration. See https://www.debian.org/doc/debian-policy/ch-binary.html#prompting-in-maintainer-scripts. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
| conflicts | See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | List of strings | optional | [] |
| data | A tar file that contains the data for the debian package. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | required | |
| depends | See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | List of strings | optional | [] |
| depends_file | File that contains a list of package dependencies. Must not be used with <code>depends</code>. See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
| description | The package description. Must not be used with <code>description_file</code>. | String | optional | "" |
| description_file | The package description. Must not be used with <code>description</code>. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
| distribution | TBD | String | optional | "unstable" |
| enhances | See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | List of strings | optional | [] |
| homepage | The homepage of the project. | String | optional | "" |
| maintainer | The maintainer of the package. | String | required | |
| out | See Common Attributes | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | required | |
| package | The name of the package | String | required | |
| package_file_name | See Common Attributes. Default: "%{package}-%{version}-%{architecture}.deb | String | optional | "" |
| package_variables | See Common Attributes | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
| postinst | The post-install script for the package. See http://www.debian.org/doc/debian-policy/ch-maintainerscripts.html. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
| postrm | The post-remove script for the package. See http://www.debian.org/doc/debian-policy/ch-maintainerscripts.html. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
| predepends | See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | List of strings | optional | [] |
| preinst | "The pre-install script for the package. See http://www.debian.org/doc/debian-policy/ch-maintainerscripts.html. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
| prerm | The pre-remove script for the package. See http://www.debian.org/doc/debian-policy/ch-maintainerscripts.html. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
| priority | The priority of the package. See http://www.debian.org/doc/debian-policy/ch-archive.html#s-priorities. | String | optional | "" |
| provides | See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | List of strings | optional | [] |
| recommends | See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | List of strings | optional | [] |
| replaces | See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | List of strings | optional | [] |
| section | The section of the package. See http://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections. | String | optional | "" |
| suggests | See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | List of strings | optional | [] |
| templates | templates file used for debconf integration. See https://www.debian.org/doc/debian-policy/ch-binary.html#prompting-in-maintainer-scripts. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
| triggers | triggers file for configuring installation events exchanged by packages. See https://wiki.debian.org/DpkgTriggers. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
| urgency | TBD | String | optional | "medium" |
| version | Package version. Must not be used with <code>version_file</code>. | String | optional | "" |
| version_file | File that contains the package version. Must not be used with <code>version</code>. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
<a name="#pkg_deb"></a>
## pkg_deb
<pre>
pkg_deb(<a href="#pkg_deb-name">name</a>, <a href="#pkg_deb-archive_name">archive_name</a>, <a href="#pkg_deb-kwargs">kwargs</a>)
</pre>
Creates a deb file. See pkg_deb_impl.
**PARAMETERS**
| Name | Description | Default Value |
| :-------------: | :-------------: | :-------------: |
| name | <p align="center"> - </p> | none |
| archive_name | <p align="center"> - </p> | <code>None</code> |
| kwargs | <p align="center"> - </p> | none |

View File

@ -142,8 +142,9 @@ def _pkg_tar_impl(ctx):
if ctx.attr.include_runfiles:
runfiles = src[DefaultInfo].default_runfiles
if runfiles:
file_deps.append(runfiles.files)
src_files.extend(runfiles.files.to_list())
file_deps.append(runfiles.files)
src_files.extend(runfiles.files.to_list())
# Add in the files of srcs which are not pkg_* types
for f in src_files:
d_path = dest_path(f, data_path, data_path_without_prefix)
@ -376,7 +377,7 @@ def _pkg_deb_impl(ctx):
ctx.actions.run(
mnemonic = "MakeDeb",
executable = ctx.executable.make_deb,
executable = ctx.executable._make_deb,
arguments = args,
inputs = files,
outputs = [output_file, changes_file],
@ -502,69 +503,173 @@ def pkg_tar(name, **kwargs):
# A rule for creating a deb file, see README.md
pkg_deb_impl = rule(
implementation = _pkg_deb_impl,
# @unsorted-dict-items
attrs = {
"data": attr.label(mandatory = True, allow_single_file = tar_filetype),
"package": attr.string(
doc = "Package name",
"data": attr.label(
doc = """A tar file that contains the data for the debian package.""",
mandatory = True,
allow_single_file = tar_filetype,
),
"package": attr.string(
doc = "The name of the package",
mandatory = True,
),
"architecture": attr.string(
default = "all",
doc = """Package architecture. Must not be used with architecture_file.""",
),
"architecture_file": attr.label(
doc = """File that contains the package architecture.
Must not be used with architecture.""",
allow_single_file = True,
),
"architecture": attr.string(
default = "all",
doc = """Package architecture. Must not be used with architecture_file.""",
),
"distribution": attr.string(default = "unstable"),
"urgency": attr.string(default = "medium"),
"maintainer": attr.string(mandatory = True),
"preinst": attr.label(allow_single_file = True),
"postinst": attr.label(allow_single_file = True),
"prerm": attr.label(allow_single_file = True),
"postrm": attr.label(allow_single_file = True),
"config": attr.label(allow_single_file = True),
"templates": attr.label(allow_single_file = True),
"triggers": attr.label(allow_single_file = True),
"conffiles_file": attr.label(allow_single_file = True),
"conffiles": attr.string_list(default = []),
"version_file": attr.label(
doc = """File that contains the package version.
Must not be used with version.""",
allow_single_file = True,
"maintainer": attr.string(
doc = "The maintainer of the package.",
mandatory = True,
),
"version": attr.string(
doc = """Package version. Must not be used with version_file.""",
doc = """Package version. Must not be used with `version_file`.""",
),
"version_file": attr.label(
doc = """File that contains the package version.
Must not be used with `version`.""",
allow_single_file = True,
),
"config": attr.label(
doc = """config file used for debconf integration.
See https://www.debian.org/doc/debian-policy/ch-binary.html#prompting-in-maintainer-scripts.""",
allow_single_file = True,
),
"description": attr.string(
doc = """The package description. Must not be used with `description_file`.""",
),
"description_file": attr.label(
doc = """The package description. Must not be used with `description`.""",
allow_single_file = True
),
"distribution": attr.string(
doc = """"distribution: See http://www.debian.org/doc/debian-policy.""",
default = "unstable",
),
"urgency": attr.string(
doc = """"urgency: See http://www.debian.org/doc/debian-policy.""",
default = "medium",
),
"preinst": attr.label(
doc = """"The pre-install script for the package.
See http://www.debian.org/doc/debian-policy/ch-maintainerscripts.html.""",
allow_single_file = True,
),
"postinst": attr.label(
doc = """The post-install script for the package.
See http://www.debian.org/doc/debian-policy/ch-maintainerscripts.html.""",
allow_single_file = True,
),
"prerm": attr.label(
doc = """The pre-remove script for the package.
See http://www.debian.org/doc/debian-policy/ch-maintainerscripts.html.""",
allow_single_file = True,
),
"postrm": attr.label(
doc = """The post-remove script for the package.
See http://www.debian.org/doc/debian-policy/ch-maintainerscripts.html.""",
allow_single_file = True,
),
"templates": attr.label(
doc = """templates file used for debconf integration.
See https://www.debian.org/doc/debian-policy/ch-binary.html#prompting-in-maintainer-scripts.""",
allow_single_file = True,
),
"triggers": attr.label(
doc = """triggers file for configuring installation events exchanged by packages.
See https://wiki.debian.org/DpkgTriggers.""",
allow_single_file = True,
),
"built_using": attr.string(
doc="""The tool that were used to build this package provided either inline (with built_using) or from a file (with built_using_file)."""
),
"built_using_file": attr.label(
doc="""The tool that were used to build this package provided either inline (with built_using) or from a file (with built_using_file).""",
allow_single_file = True
),
"conffiles": attr.string_list(
doc = """The list of conffiles or a file containing one conffile per line. Each item is an absolute path on the target system where the deb is installed.
See https://www.debian.org/doc/debian-policy/ch-files.html#s-config-files.""",
default = [],
),
"conffiles_file": attr.label(
doc = """The list of conffiles or a file containing one conffile per line. Each item is an absolute path on the target system where the deb is installed.
See https://www.debian.org/doc/debian-policy/ch-files.html#s-config-files.""",
allow_single_file = True,
),
"priority": attr.string(
doc = """The priority of the package.
See http://www.debian.org/doc/debian-policy/ch-archive.html#s-priorities.""",
),
"section": attr.string(
doc = """The section of the package.
See http://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections.""",
),
"homepage": attr.string(doc = """The homepage of the project."""),
"breaks": attr.string_list(
doc = """See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps.""",
default = [],
),
"conflicts": attr.string_list(
doc = """See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps.""",
default = [],
),
"depends": attr.string_list(
doc = """See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps.""",
default = [],
),
"depends_file": attr.label(
doc = """File that contains a list of package dependencies. Must not be used with `depends`.
See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps.""",
allow_single_file = True,
),
"enhances": attr.string_list(
doc = """See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps.""",
default = [],
),
"provides": attr.string_list(
doc = """See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps.""",
default = [],
),
"predepends": attr.string_list(
doc = """See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps.""",
default = [],
),
"recommends": attr.string_list(
doc = """See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps.""",
default = [],
),
"replaces": attr.string_list(
doc = """See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps.""",
default = [],
),
"suggests": attr.string_list(
doc = """See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps.""",
default = [],
),
"description_file": attr.label(allow_single_file = True),
"description": attr.string(),
"built_using_file": attr.label(allow_single_file = True),
"built_using": attr.string(),
"priority": attr.string(),
"section": attr.string(),
"homepage": attr.string(),
"depends": attr.string_list(default = []),
"depends_file": attr.label(allow_single_file = True),
"suggests": attr.string_list(default = []),
"enhances": attr.string_list(default = []),
"breaks": attr.string_list(default = []),
"conflicts": attr.string_list(default = []),
"predepends": attr.string_list(default = []),
"recommends": attr.string_list(default = []),
"replaces": attr.string_list(default = []),
"provides": attr.string_list(default = []),
# Common attributes
"out": attr.output(mandatory = True),
"package_file_name": attr.string(doc = "See Common Attributes"),
"out": attr.output(
doc = """See Common Attributes""",
mandatory = True
),
"package_file_name": attr.string(
doc = """See Common Attributes.
Default: "{package}-{version}-{architecture}.deb""",
),
"package_variables": attr.label(
doc = "See Common Attributes",
doc = """See Common Attributes""",
providers = [PackageVariablesInfo],
),
# Implicit dependencies.
"make_deb": attr.label(
"_make_deb": attr.label(
default = Label("//pkg/private:make_deb"),
cfg = "exec",
executable = True,
@ -605,6 +710,7 @@ def _pkg_zip_impl(ctx):
data_path_without_prefix = compute_data_path(ctx, ".")
content_map = {} # content handled in the manifest
# TODO(aiuto): Refactor this loop out of pkg_tar and pkg_zip into a helper
# that both can use.
for src in ctx.attr.srcs:
@ -627,7 +733,7 @@ def _pkg_zip_impl(ctx):
# Tree artifacts need a name, but the name is never really
# the important part. The likely behavior people want is
# just the content, so we strip the directory name.
dest = '/'.join(d_path.split('/')[0:-1])
dest = "/".join(d_path.split("/")[0:-1])
add_tree_artifact(content_map, dest, f, src.label)
else:
add_single_file(content_map, d_path, f, src.label)