Problem
Package-manager detection (apt-get/apk/dnf/yum/brew/pacman/zypper), sudo-escalation checks, and mkdir+chmod permission patterns are duplicated across multiple install scripts rather than living in one shared place, e.g.:
src/gitutils/install-gitflow.sh branches across 6+ package managers.
src/common-utils/install.sh has its own separate apt-get/apk/winget branching.
- Numerous scripts repeat
if [ "$(id -u)" -eq 0 ] / command -v sudo checks before privileged operations.
mkdir -p ... && chmod ... permission-fixing patterns recur in _configure-feature.sh and feature-specific setup scripts.
This duplication is a likely contributor to recurring permission-related fixes in git history, e.g. 5818e42 fix(githooks): use sudo for chmod to ensure proper permissions.
Proposal
Add shared helpers to src/common-utils (alongside the existing _zz_*.sh library):
_zz_pkg-manager.sh — a single install_package <name> function that detects and dispatches to the right package manager.
- A
run_with_sudo wrapper that consistently handles the root/sudo/no-sudo cases in one place.
- An
ensure_dir_perms <dir> [<mode>] helper for the recurring mkdir -p && chmod pattern.
Then migrate gitutils, githooks, and other features' install scripts to call these instead of reimplementing the logic.
Where this lives / sync note
These helpers belong in src/common-utils since it's the shared foundation every other feature already depends on via dependsOn. Because common-utils is redistributed to its own standalone repo via split-monorepo.yml/merge-monorepo.yml, adding helpers here automatically makes them available to every consumer once synced — this must not be done as a one-off copy-paste into individual features. Also verify this repo's own dev environment (which dogfoods common-utils for its own tooling) keeps working against the refactored helpers.
Acceptance criteria
Problem
Package-manager detection (apt-get/apk/dnf/yum/brew/pacman/zypper), sudo-escalation checks, and
mkdir+chmodpermission patterns are duplicated across multiple install scripts rather than living in one shared place, e.g.:src/gitutils/install-gitflow.shbranches across 6+ package managers.src/common-utils/install.shhas its own separate apt-get/apk/winget branching.if [ "$(id -u)" -eq 0 ]/command -v sudochecks before privileged operations.mkdir -p ... && chmod ...permission-fixing patterns recur in_configure-feature.shand feature-specific setup scripts.This duplication is a likely contributor to recurring permission-related fixes in git history, e.g.
5818e42fix(githooks): use sudo for chmod to ensure proper permissions.Proposal
Add shared helpers to
src/common-utils(alongside the existing_zz_*.shlibrary):_zz_pkg-manager.sh— a singleinstall_package <name>function that detects and dispatches to the right package manager.run_with_sudowrapper that consistently handles the root/sudo/no-sudo cases in one place.ensure_dir_perms <dir> [<mode>]helper for the recurringmkdir -p && chmodpattern.Then migrate
gitutils,githooks, and other features' install scripts to call these instead of reimplementing the logic.Where this lives / sync note
These helpers belong in
src/common-utilssince it's the shared foundation every other feature already depends on viadependsOn. Becausecommon-utilsis redistributed to its own standalone repo viasplit-monorepo.yml/merge-monorepo.yml, adding helpers here automatically makes them available to every consumer once synced — this must not be done as a one-off copy-paste into individual features. Also verify this repo's own dev environment (which dogfoodscommon-utilsfor its own tooling) keeps working against the refactored helpers.Acceptance criteria
src/common-utils.gitutils,githooks) migrated to use them instead of inline duplicated logic.common-utils.