Skip to content

pkg_deb: add support for md5sums control file #960

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
10 changes: 10 additions & 0 deletions pkg/private/deb/deb.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ def _pkg_deb_impl(ctx):
if ctx.attr.triggers:
args.append("--triggers=@" + ctx.file.triggers.path)
files.append(ctx.file.triggers)
if ctx.attr.md5sums:
args.append("--md5sums=@" + ctx.file.md5sums.path)
files.append(ctx.file.md5sums)

# Conffiles can be specified by a file or a string list
if ctx.attr.conffiles_file:
Expand Down Expand Up @@ -276,6 +279,13 @@ pkg_deb_impl = rule(
See https://wiki.debian.org/DpkgTriggers.""",
allow_single_file = True,
),
"md5sums": attr.label(
doc = """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.
""",
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).""",
),
Expand Down
7 changes: 7 additions & 0 deletions pkg/private/deb/make_deb.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ def CreateDeb(output,
config=None,
templates=None,
triggers=None,
md5sums=None,
conffiles=None,
changelog=None,
**kwargs):
Expand All @@ -217,6 +218,8 @@ def CreateDeb(output,
extrafiles['templates'] = (templates, 0o644)
if triggers:
extrafiles['triggers'] = (triggers, 0o644)
if md5sums:
extrafiles['md5sums'] = (md5sums, 0o644)
if conffiles:
extrafiles['conffiles'] = ('\n'.join(conffiles) + '\n', 0o644)
if changelog:
Expand Down Expand Up @@ -366,6 +369,9 @@ def main():
parser.add_argument(
'--triggers',
help='The triggers file (prefix with @ to provide a path).')
parser.add_argument(
'--md5sums',
help='The md5sums file (prefix with @ to provide a path).')
# see
# https://www.debian.org/doc/manuals/debian-faq/ch-pkg_basics.en.html#s-conffile
parser.add_argument(
Expand All @@ -387,6 +393,7 @@ def main():
config=helpers.GetFlagValue(options.config, False),
templates=helpers.GetFlagValue(options.templates, False),
triggers=helpers.GetFlagValue(options.triggers, False),
md5sums=helpers.GetFlagValue(options.md5sums, False),
conffiles=GetFlagValues(options.conffile),
changelog=helpers.GetFlagValue(options.changelog, False),
package=options.package,
Expand Down
8 changes: 8 additions & 0 deletions tests/deb/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ genrule(
cmd = "for i in $(OUTS); do echo 1 >$$i; done",
)

genrule(
name = "generate_md5sums",
srcs = [":generate_files"],
outs = ["md5sums"],
cmd = "md5sum $(SRCS) | sed 's|$(RULEDIR)/||' > $@",
)

my_package_naming(
name = "my_package_variables",
label = "some_value",
Expand Down Expand Up @@ -80,6 +87,7 @@ pkg_deb(
distribution = "trusty",
license = "Apache-2.0",
maintainer = "somé[email protected]",
md5sums = ":generate_md5sums",
package = "fizzbuzz",
preinst = "deb_preinst",
provides = ["hello"],
Expand Down
1 change: 1 addition & 0 deletions tests/deb/pkg_deb_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ def test_control_files(self):
{'name': './config', 'mode': 0o755},
{'name': './control', 'mode': 0o644},
{'name': './preinst', 'mode': 0o755},
{'name': './md5sums', 'mode': 0o644},
{'name': './templates', 'mode': 0o644},
{'name': './triggers', 'mode': 0o644},
]
Expand Down