Skip to content

fix(matrix): flatten inner make targets to valid shell fragment#12

Draft
troglodyne wants to merge 1 commit into
masterfrom
koan.trogbot/fix-matrix-inner-targets
Draft

fix(matrix): flatten inner make targets to valid shell fragment#12
troglodyne wants to merge 1 commit into
masterfrom
koan.trogbot/fix-matrix-inner-targets

Conversation

@troglodyne

Copy link
Copy Markdown
Contributor

What

Rewrite matrix.tt from inner-make-target format to a flat shell fragment, and extract the admin registration script to a proper template file.

Why

matrix.tt defined its own make sub-targets ($(state_dir)/matrix:, $(state_dir)/matrix-admin:, etc.) inside the recipe fragment. makefile.tt wraps every fragment with tabinate, which prefixes each line with a tab — converting those target-definition lines into tab-indented shell commands. Make then tries to execute them as shell, producing a command-not-found error. Every matrix deployment would fail immediately.

A second bug compounded this: the admin registration script was generated via a heredoc (cat > file <<'EOF'), which also fails in make because each recipe line runs in a separate subshell — the heredoc open and its content land in different shells and never connect.

How

  • templates/matrix.tt — remove all inner make targets; flatten to a sequential series of shell commands inside the single outer $(state_dir)/matrix: target that makefile.tt provides
  • templates/files/matrix.register_admin.sh.tt — extract the admin registration script to a proper template file (rendered with admin credentials at provisioning time)
  • lib/Provisioner/Recipe/matrix.pm — register the new template file in template_files() so it lands in the work dir as matrix_register_admin.sh
  • All systemctl calls moved to queue_postrun_task, consistent with PRs fix: make letsencrypt and mail recipes idempotent on redeploy #5fix: defer service restarts to postrun in mail, pdns, roundcube #10

The signing-key generation guard ([ ! -f signing.key ]) is preserved as-is.

Testing

No automated test suite. Verified by diff review — the rendered output will now be a valid flat make recipe matching the pattern of every other recipe in the codebase (see redis.tt, tpsgi.tt, etc.).

matrix.tt defined its own make targets (state_dir/matrix:, state_dir/matrix-admin:, etc.)
inside the recipe fragment. makefile.tt wraps all fragments with tabinate, turning those
target lines into tab-prefixed shell commands — invalid syntax that would cause make to
fail with a command-not-found error on every matrix deployment.

Flatten to a sequential shell script matching the pattern used by every other recipe:
- All operations run in the outer state_dir/matrix: target (idempotent via touch $@)
- Signing key generation retains its existing guard ([ ! -f ... ])
- Admin registration script extracted to matrix.register_admin.sh.tt template file
  and registered in template_files() — replaces the broken heredoc which would also
  have failed (make runs each recipe line in a separate subshell)
- All systemctl calls deferred to queue_postrun_task, consistent with PRs #5-#10

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yawn. Diff noise

'matrix.nginx.tt' => 'matrix.nginx.conf',
'matrix.admin.nginx.tt' => 'matrix-admin.nginx.conf',
'matrix.synapse.service.tt' => 'matrix-synapse.service',
'matrix.register_admin.sh.tt' => 'matrix_register_admin.sh',

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

actual change

Comment thread templates/matrix.tt

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Looks like the bot forgot these are makefile fragments?

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