Skip to content

[deb] Avoid UTF-8 roundtrip for {pre,post}-{inst,rm} hooks#1054

Open
Yannic wants to merge 1 commit intobazelbuild:mainfrom
Yannic:deb-hooks-coding
Open

[deb] Avoid UTF-8 roundtrip for {pre,post}-{inst,rm} hooks#1054
Yannic wants to merge 1 commit intobazelbuild:mainfrom
Yannic:deb-hooks-coding

Conversation

@Yannic
Copy link
Copy Markdown

@Yannic Yannic commented Apr 20, 2026

This change allows the Debian package hooks to be arbitrary files (including executable binary files), which failed with the following error before:

Traceback (most recent call last):
  File "/Users/yannic/Library/Caches/bazel/_bazel_yannic/bb6c3b02ccc98aaca966df445b5024eb/sandbox/darwin-sandbox/3472/execroot/_main/bazel-out/darwin_x86_64-opt-exec/bin/external/rules_pkg+/pkg/private/deb/make_deb.runfiles/rules_pkg+/pkg/private/deb/_make_deb_stage2_bootstrap.py", line 499, in <module>
    main()
    ~~~~^^
  File "/Users/yannic/Library/Caches/bazel/_bazel_yannic/bb6c3b02ccc98aaca966df445b5024eb/sandbox/darwin-sandbox/3472/execroot/_main/bazel-out/darwin_x86_64-opt-exec/bin/external/rules_pkg+/pkg/private/deb/make_deb.runfiles/rules_pkg+/pkg/private/deb/_make_deb_stage2_bootstrap.py", line 493, in main
    _run_py_path(main_filename, args=sys.argv[1:])
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/yannic/Library/Caches/bazel/_bazel_yannic/bb6c3b02ccc98aaca966df445b5024eb/sandbox/darwin-sandbox/3472/execroot/_main/bazel-out/darwin_x86_64-opt-exec/bin/external/rules_pkg+/pkg/private/deb/make_deb.runfiles/rules_pkg+/pkg/private/deb/_make_deb_stage2_bootstrap.py", line 287, in _run_py_path
    runpy.run_path(main_filename, run_name="__main__")
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen runpy>", line 287, in run_path
  File "<frozen runpy>", line 98, in _run_module_code
  File "<frozen runpy>", line 88, in _run_code
  File "/Users/yannic/Library/Caches/bazel/_bazel_yannic/bb6c3b02ccc98aaca966df445b5024eb/sandbox/darwin-sandbox/3472/execroot/_main/bazel-out/darwin_x86_64-opt-exec/bin/external/rules_pkg+/pkg/private/deb/make_deb.runfiles/rules_pkg+/pkg/private/deb/make_deb.py", line 433, in <module>
    main()
    ~~~~^^
  File "/Users/yannic/Library/Caches/bazel/_bazel_yannic/bb6c3b02ccc98aaca966df445b5024eb/sandbox/darwin-sandbox/3472/execroot/_main/bazel-out/darwin_x86_64-opt-exec/bin/external/rules_pkg+/pkg/private/deb/make_deb.runfiles/rules_pkg+/pkg/private/deb/make_deb.py", line 392, in main
    prerm=helpers.GetFlagValue(options.prerm, False),
          ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/yannic/Library/Caches/bazel/_bazel_yannic/bb6c3b02ccc98aaca966df445b5024eb/sandbox/darwin-sandbox/3472/execroot/_main/bazel-out/darwin_x86_64-opt-exec/bin/external/rules_pkg+/pkg/private/deb/make_deb.runfiles/rules_pkg+/pkg/private/helpers.py", line 81, in GetFlagValue
    flagvalue = f.read().decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xcf in position 0: invalid continuation byte

(the example used a go_binary for prerm)

@Yannic Yannic force-pushed the deb-hooks-coding branch 2 times, most recently from 5809ef2 to 9fa0143 Compare April 20, 2026 09:23
This change allows the Debian package hooks to be arbitrary files (including
executable binary files), which failed with the following error before:

```
Traceback (most recent call last):
  File "/Users/yannic/Library/Caches/bazel/_bazel_yannic/bb6c3b02ccc98aaca966df445b5024eb/sandbox/darwin-sandbox/3472/execroot/_main/bazel-out/darwin_x86_64-opt-exec/bin/external/rules_pkg+/pkg/private/deb/make_deb.runfiles/rules_pkg+/pkg/private/deb/_make_deb_stage2_bootstrap.py", line 499, in <module>
    main()
    ~~~~^^
  File "/Users/yannic/Library/Caches/bazel/_bazel_yannic/bb6c3b02ccc98aaca966df445b5024eb/sandbox/darwin-sandbox/3472/execroot/_main/bazel-out/darwin_x86_64-opt-exec/bin/external/rules_pkg+/pkg/private/deb/make_deb.runfiles/rules_pkg+/pkg/private/deb/_make_deb_stage2_bootstrap.py", line 493, in main
    _run_py_path(main_filename, args=sys.argv[1:])
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/yannic/Library/Caches/bazel/_bazel_yannic/bb6c3b02ccc98aaca966df445b5024eb/sandbox/darwin-sandbox/3472/execroot/_main/bazel-out/darwin_x86_64-opt-exec/bin/external/rules_pkg+/pkg/private/deb/make_deb.runfiles/rules_pkg+/pkg/private/deb/_make_deb_stage2_bootstrap.py", line 287, in _run_py_path
    runpy.run_path(main_filename, run_name="__main__")
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen runpy>", line 287, in run_path
  File "<frozen runpy>", line 98, in _run_module_code
  File "<frozen runpy>", line 88, in _run_code
  File "/Users/yannic/Library/Caches/bazel/_bazel_yannic/bb6c3b02ccc98aaca966df445b5024eb/sandbox/darwin-sandbox/3472/execroot/_main/bazel-out/darwin_x86_64-opt-exec/bin/external/rules_pkg+/pkg/private/deb/make_deb.runfiles/rules_pkg+/pkg/private/deb/make_deb.py", line 433, in <module>
    main()
    ~~~~^^
  File "/Users/yannic/Library/Caches/bazel/_bazel_yannic/bb6c3b02ccc98aaca966df445b5024eb/sandbox/darwin-sandbox/3472/execroot/_main/bazel-out/darwin_x86_64-opt-exec/bin/external/rules_pkg+/pkg/private/deb/make_deb.runfiles/rules_pkg+/pkg/private/deb/make_deb.py", line 392, in main
    prerm=helpers.GetFlagValue(options.prerm, False),
          ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/yannic/Library/Caches/bazel/_bazel_yannic/bb6c3b02ccc98aaca966df445b5024eb/sandbox/darwin-sandbox/3472/execroot/_main/bazel-out/darwin_x86_64-opt-exec/bin/external/rules_pkg+/pkg/private/deb/make_deb.runfiles/rules_pkg+/pkg/private/helpers.py", line 81, in GetFlagValue
    flagvalue = f.read().decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xcf in position 0: invalid continuation byte
```

(the example used a `go_binary` for `prerm`)
@Yannic Yannic force-pushed the deb-hooks-coding branch from 9fa0143 to f6e8a72 Compare April 20, 2026 09:32
Copy link
Copy Markdown
Collaborator

@cgrindel cgrindel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable to me. I will leave it open for @aiuto to review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants