Skip to content

refactor: extract shared utility sources into src/bin/common/ - #1136

Merged
dimitri merged 1 commit into
mainfrom
src/bin/common
Jul 9, 2026
Merged

refactor: extract shared utility sources into src/bin/common/#1136
dimitri merged 1 commit into
mainfrom
src/bin/common

Conversation

@dimitri

@dimitri dimitri commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Move 16 .c/.h utility pairs out of src/bin/pg_autoctl/ into a new
src/bin/common/ directory, compiled into a static archive
libpgaf_common.a linked by pg_autoctl (and a future pgaftest
binary).

Motivation

The upcoming pgaftest test runner needs the same pgsql, pgsetup,
pgctl, parsing, ipaddr, and related utilities. Rather than copying
them, they live in one place and both binaries link the same archive.

Changes

New files

  • src/bin/common/Makefile — builds libpgaf_common.a standalone
  • src/bin/common/Makefile.common — shared build variables included
    by both pg_autoctl/Makefile and the upcoming pgaftest/Makefile;
    auto-detects macOS gettext path via brew --prefix gettext

Moved files (pg_autoctl/ → common/)

debian, env_utils, file_utils, ini_file, ini_implementation,
ipaddr, lock_utils, parsing, pgctl, pgsetup, pgsql,
pgtuning, pidfile, signals, string_utils, system_utils

Notable content improvements in the common/ copies

File Change
pgsql.c/h adds pgsql_alter_role_password() for the upcoming --autoctl-node-password feature
pgctl.c adds --checkpoint=fast for pg_basebackup; fixes intToString dangling-pointer use
pgsetup.c, signals.c, ipaddr.c, ini_file.c brace-style fixes from citus_indent

Updated Makefiles

  • src/bin/Makefile — adds common target as a prerequisite for pg_autoctl
  • src/bin/pg_autoctl/Makefile — includes Makefile.common and links $(COMMON_LIB) instead of compiling the moved sources directly

Testing

  • Builds cleanly locally (make -C src/bin/)
  • Style check passes: docker run --rm -v $(pwd):/repo -w /repo citus/stylechecker:no-py citus_indent --check

@dimitri dimitri self-assigned this Jul 9, 2026
@dimitri dimitri added the Developer productivity Enhancements to ability to ship quality code label Jul 9, 2026
Move 16 .c/.h pairs out of src/bin/pg_autoctl/ into the new
src/bin/common/ directory and compile them into libpgaf_common.a,
a static archive linked by pg_autoctl (and, in a future PR, pgaftest).

New files
  src/bin/common/Makefile         — builds libpgaf_common.a standalone
  src/bin/common/Makefile.common  — shared build variables included by
                                    both pg_autoctl/Makefile and the
                                    upcoming pgaftest/Makefile; auto-
                                    detects macOS gettext via brew

Moved files (pg_autoctl → common, superset variants kept)
  debian, env_utils, file_utils, ini_file, ini_implementation,
  ipaddr, lock_utils, parsing, pgctl, pgsetup, pgsql, pgtuning,
  pidfile, signals, string_utils, system_utils

Notable content changes in the common/ copies:
  pgsql.c/h   — adds pgsql_alter_role_password() used by the upcoming
                 --autoctl-node-password feature
  pgctl.c     — adds --checkpoint=fast for pg_basebackup; fixes
                 intToString dangling-pointer use
  pgsetup.c   — minor style / brace fixes from citus_indent
  signals.c   — idem
  ipaddr.c    — idem
  ini_file.c  — idem

src/bin/Makefile updated to build common/ before pg_autoctl.
src/bin/pg_autoctl/Makefile updated to include Makefile.common and
link $(COMMON_LIB) instead of compiling the moved sources directly.
@dimitri
dimitri merged commit 41dca60 into main Jul 9, 2026
26 checks passed
@dimitri
dimitri deleted the src/bin/common branch July 9, 2026 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Developer productivity Enhancements to ability to ship quality code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant