Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions docs/latest.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ load("@rules_pkg//pkg/private/deb:deb.bzl", "pkg_deb")
pkg_deb(<a href="#pkg_deb-name">name</a>, <a href="#pkg_deb-data">data</a>, <a href="#pkg_deb-out">out</a>, <a href="#pkg_deb-architecture">architecture</a>, <a href="#pkg_deb-architecture_file">architecture_file</a>, <a href="#pkg_deb-breaks">breaks</a>, <a href="#pkg_deb-built_using">built_using</a>,
<a href="#pkg_deb-built_using_file">built_using_file</a>, <a href="#pkg_deb-changelog">changelog</a>, <a href="#pkg_deb-conffiles">conffiles</a>, <a href="#pkg_deb-conffiles_file">conffiles_file</a>, <a href="#pkg_deb-config">config</a>, <a href="#pkg_deb-conflicts">conflicts</a>, <a href="#pkg_deb-depends">depends</a>,
<a href="#pkg_deb-depends_file">depends_file</a>, <a href="#pkg_deb-description">description</a>, <a href="#pkg_deb-description_file">description_file</a>, <a href="#pkg_deb-distribution">distribution</a>, <a href="#pkg_deb-enhances">enhances</a>, <a href="#pkg_deb-homepage">homepage</a>,
<a href="#pkg_deb-installed_size">installed_size</a>, <a href="#pkg_deb-license">license</a>, <a href="#pkg_deb-maintainer">maintainer</a>, <a href="#pkg_deb-md5sums">md5sums</a>, <a href="#pkg_deb-package">package</a>, <a href="#pkg_deb-package_file_name">package_file_name</a>,
<a href="#pkg_deb-package_variables">package_variables</a>, <a href="#pkg_deb-postinst">postinst</a>, <a href="#pkg_deb-postrm">postrm</a>, <a href="#pkg_deb-predepends">predepends</a>, <a href="#pkg_deb-preinst">preinst</a>, <a href="#pkg_deb-prerm">prerm</a>, <a href="#pkg_deb-priority">priority</a>, <a href="#pkg_deb-provides">provides</a>,
<a href="#pkg_deb-provides_file">provides_file</a>, <a href="#pkg_deb-recommends">recommends</a>, <a href="#pkg_deb-replaces">replaces</a>, <a href="#pkg_deb-replaces_file">replaces_file</a>, <a href="#pkg_deb-section">section</a>, <a href="#pkg_deb-suggests">suggests</a>, <a href="#pkg_deb-templates">templates</a>,
<a href="#pkg_deb-triggers">triggers</a>, <a href="#pkg_deb-urgency">urgency</a>, <a href="#pkg_deb-version">version</a>, <a href="#pkg_deb-version_file">version_file</a>)
<a href="#pkg_deb-installed_size">installed_size</a>, <a href="#pkg_deb-installed_size_file">installed_size_file</a>, <a href="#pkg_deb-license">license</a>, <a href="#pkg_deb-maintainer">maintainer</a>, <a href="#pkg_deb-md5sums">md5sums</a>, <a href="#pkg_deb-package">package</a>,
<a href="#pkg_deb-package_file_name">package_file_name</a>, <a href="#pkg_deb-package_variables">package_variables</a>, <a href="#pkg_deb-postinst">postinst</a>, <a href="#pkg_deb-postrm">postrm</a>, <a href="#pkg_deb-predepends">predepends</a>, <a href="#pkg_deb-preinst">preinst</a>, <a href="#pkg_deb-prerm">prerm</a>,
<a href="#pkg_deb-priority">priority</a>, <a href="#pkg_deb-provides">provides</a>, <a href="#pkg_deb-provides_file">provides_file</a>, <a href="#pkg_deb-recommends">recommends</a>, <a href="#pkg_deb-replaces">replaces</a>, <a href="#pkg_deb-replaces_file">replaces_file</a>, <a href="#pkg_deb-section">section</a>,
<a href="#pkg_deb-suggests">suggests</a>, <a href="#pkg_deb-templates">templates</a>, <a href="#pkg_deb-triggers">triggers</a>, <a href="#pkg_deb-urgency">urgency</a>, <a href="#pkg_deb-version">version</a>, <a href="#pkg_deb-version_file">version_file</a>)
</pre>

Create a Debian package.
Expand Down Expand Up @@ -137,7 +137,8 @@ include both. If you need downstream rule to specifically depend on only the .de
| <a id="pkg_deb-distribution"></a>distribution | "distribution: See http://www.debian.org/doc/debian-policy. | String | optional | `"unstable"` |
| <a id="pkg_deb-enhances"></a>enhances | See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | List of strings | optional | `[]` |
| <a id="pkg_deb-homepage"></a>homepage | The homepage of the project. | String | optional | `""` |
| <a id="pkg_deb-installed_size"></a>installed_size | The approximate total size (in KiB) of the package's installed files. Corresponds to the Installed-Size field in the control file. See https://www.debian.org/doc/debian-policy/ch-controlfields.html#installed-size. | String | optional | `""` |
| <a id="pkg_deb-installed_size"></a>installed_size | The approximate total size (in KiB) of the package's installed files. Corresponds to the Installed-Size field in the control file. See https://www.debian.org/doc/debian-policy/ch-controlfields.html#installed-size. Mutually exclusive with `installed_size_file`. | String | optional | `""` |
| <a id="pkg_deb-installed_size_file"></a>installed_size_file | File that contains the approximate total size (in KiB) of the package's installed files. Mutually exclusive with `installed_size`. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` |
| <a id="pkg_deb-license"></a>license | The license of the project. | String | optional | `""` |
| <a id="pkg_deb-maintainer"></a>maintainer | The maintainer of the package. | String | required | |
| <a id="pkg_deb-md5sums"></a>md5sums | A file listing md5 checksums of files in the data archive. This file is optional. See https://manpages.debian.org/bookworm/dpkg-dev/deb-md5sums.5.en.html. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` |
Expand Down
15 changes: 13 additions & 2 deletions pkg/private/deb/deb.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,12 @@ def _pkg_deb_impl(ctx):
for d in ctx.attr.depends:
args.add("--depends", substitute_package_variables(ctx, d))

if ctx.attr.installed_size:
if ctx.attr.installed_size_file:
if ctx.attr.installed_size:
fail("Both installed_size and installed_size_file attributes were specified")
args.add("--installed_size", "@" + ctx.file.installed_size_file.path)
files.append(ctx.file.installed_size_file)
elif ctx.attr.installed_size:
args.add("--installed_size", substitute_package_variables(ctx, ctx.attr.installed_size))
if ctx.attr.priority:
args.add("--priority", substitute_package_variables(ctx, ctx.attr.priority))
Expand Down Expand Up @@ -346,7 +351,13 @@ See https://www.debian.org/doc/debian-policy/ch-files.html#s-config-files.""",
"installed_size": attr.string(
doc = """The approximate total size (in KiB) of the package's installed files.
Corresponds to the Installed-Size field in the control file.
See https://www.debian.org/doc/debian-policy/ch-controlfields.html#installed-size.""",
See https://www.debian.org/doc/debian-policy/ch-controlfields.html#installed-size.
Mutually exclusive with `installed_size_file`.""",
),
"installed_size_file": attr.label(
doc = """File that contains the approximate total size (in KiB) of the
package's installed files. Mutually exclusive with `installed_size`.""",
allow_single_file = True,
),
"license": attr.string(doc = """The license of the project."""),
"breaks": attr.string_list(
Expand Down
11 changes: 11 additions & 0 deletions tests/deb/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,16 @@ pkg_deb(
version = "4.5.6",
)

pkg_deb(
name = "test_deb_installed_size_file",
data = ":tar_input",
description = "installed_size_file test package",
installed_size_file = "installed_size_file",
maintainer = "someone@somewhere.com",
package = "fizzbuzz-installed-size-file",
version = "1.0.0",
)

py_test(
name = "pkg_deb_test",
size = "medium",
Expand All @@ -110,6 +120,7 @@ py_test(
data = [
# The target includes both the .deb and .changes files in DefaultInfo
":test_deb",
":test_deb_installed_size_file",
],
imports = ["../.."],
python_version = "PY3",
Expand Down
1 change: 1 addition & 0 deletions tests/deb/installed_size_file
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5678
8 changes: 8 additions & 0 deletions tests/deb/pkg_deb_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ def setUp(self):
# Note: Rlocation requires forward slashes. os.path.join() will not work.
self.deb_path = self.runfiles.Rlocation('rules_pkg/tests/deb/fizzbuzz_4.5.6_all.deb')
self.deb_file = DebInspect(self.deb_path)
self.installed_size_file_deb_path = self.runfiles.Rlocation(
'rules_pkg/tests/deb/fizzbuzz-installed-size-file_1.0.0_all.deb')
self.installed_size_file_deb_file = DebInspect(self.installed_size_file_deb_path)

def assert_control_content(self, expected, match_order=False):
self.assert_tar_stream_content(
Expand Down Expand Up @@ -172,6 +175,11 @@ def test_description(self):
if control.find(field) < 0:
self.fail('Missing control field: <%s> in <%s>' % (field, control))

def test_installed_size_file(self):
control = self.installed_size_file_deb_file.get_deb_ctl_file('control')
if control.find('Installed-Size: 5678') < 0:
self.fail('Missing control field: <Installed-Size: 5678> in <%s>' % control)

def test_control_files(self):
expected = [
{'name': './changelog', 'mode': 0o644},
Expand Down
Loading