WIP: Installation Strategy Redesign #15

Draft
sortedcord wants to merge 14 commits from fix/reference-counting into master
Owner

Registry Infrastructure

  • Add lib/registry.sh that provides:

    • ensure_registry

      • Guarantees that registry.json exists.
      • Initializes it with { "tools": {} } if it does not already exist.
    • registry_set <jq_filter> [args...]

      • Thread-safe mutation wrapper.
      • Uses flock -x 200 to acquire an exclusive lock on registry.json.lock before executing the jq filter.
      • Prevents race conditions when multiple installers attempt to modify the registry simultaneously.
    • register_tool <tool_name> <strategy> [version] [source]

      • Registers or updates a tool's primary metadata.
      • Automatically records the installed_at timestamp.
      • If the strategy is binary, automatically stores the binary path as $BOOTSTRAP_DIR/bin/<tool_name>
    • registry_add_sys_deps <tool_name> <dep1> <dep2>...

      • Safely appends one or more system packages (for example ffmpeg, fd-find) to the tool's system_dependencies array.
    • registry_remove_tool <tool_name>

      • Completely removes a tool's entry from registry.json during uninstallation.
    • registry_get_sys_deps <tool_name>

      • Outputs each package in the tool's system_dependencies array, one per line.
      • Used for reference counting during uninstallation.
    • registry_check <tool_name>

      • Validates that a tool is correctly installed according to its declared strategy.
      Strategy Validation
      binary Confirms the registered binary exists and is executable.
      managed Confirms the tool is available via command -v.
      system Retrieves system_dependencies and runs pkg_check on each package. If no dependencies are recorded, falls back to command -v.

      Returns 0 if all checks pass, otherwise 1.

GitHub Release Helper

  • Add a shared lib/github.sh helper to standardize the "download latest GitHub release" pattern that is currently duplicated across many installers.

    # Usage
    github_download_binary "owner/repo" "asset_pattern" "$dest"
    
    github_download_binary \
      "jesseduffield/lazygit" \
      "lazygit*{version}_linux_{arch}.tar.gz" \
      "$TMP_DIR"
    

Installer Migration

  • Migrate installers gradually.
    • Each installer opts into the new system by declaring its installation strategy in its header metadata.
    • Installers use the new registry helpers.
    • Existing installers continue to work unchanged until migrated.
    • Removed redundant curl availability checks
    • Removed Standalone Execution Prevention Blocks

Package Management

  • Simplify pkg_install and pkg_remove.
    • Reference counting only applies to system strategy dependencies.
    • Reduce the overall implementation complexity and API surface.

Other Changes

  • Use jq instead of lib/json.sh.

Closes #1 #14 #16

#### Registry Infrastructure - [x] Add `lib/registry.sh` that provides: - `ensure_registry` - Guarantees that `registry.json` exists. - Initializes it with ` { "tools": {} } ` if it does not already exist. - `registry_set <jq_filter> [args...]` - Thread-safe mutation wrapper. - Uses `flock -x 200` to acquire an exclusive lock on `registry.json.lock` before executing the `jq` filter. - Prevents race conditions when multiple installers attempt to modify the registry simultaneously. - `register_tool <tool_name> <strategy> [version] [source]` - Registers or updates a tool's primary metadata. - Automatically records the `installed_at` timestamp. - If the strategy is `binary`, automatically stores the binary path as `$BOOTSTRAP_DIR/bin/<tool_name>` - `registry_add_sys_deps <tool_name> <dep1> <dep2>...` - Safely appends one or more system packages (for example `ffmpeg`, `fd-find`) to the tool's `system_dependencies` array. - `registry_remove_tool <tool_name>` - Completely removes a tool's entry from `registry.json` during uninstallation. - `registry_get_sys_deps <tool_name>` - Outputs each package in the tool's `system_dependencies` array, one per line. - Used for reference counting during uninstallation. - `registry_check <tool_name>` - Validates that a tool is correctly installed according to its declared strategy. | Strategy | Validation | |----------|------------| | `binary` | Confirms the registered binary exists and is executable. | | `managed` | Confirms the tool is available via `command -v`. | | `system` | Retrieves `system_dependencies` and runs `pkg_check` on each package. If no dependencies are recorded, falls back to `command -v`. | Returns `0` if all checks pass, otherwise `1`. #### GitHub Release Helper - [x] Add a shared `lib/github.sh` helper to standardize the "download latest GitHub release" pattern that is currently duplicated across many installers. ```bash # Usage github_download_binary "owner/repo" "asset_pattern" "$dest" github_download_binary \ "jesseduffield/lazygit" \ "lazygit*{version}_linux_{arch}.tar.gz" \ "$TMP_DIR" ``` #### Installer Migration - [x] Migrate installers gradually. - Each installer opts into the new system by declaring its installation strategy in its header metadata. - Installers use the new registry helpers. - Existing installers continue to work unchanged until migrated. - Removed redundant curl availability checks - Removed Standalone Execution Prevention Blocks #### Package Management - [x] Simplify `pkg_install` and `pkg_remove`. - Reference counting only applies to `system` strategy dependencies. - Reduce the overall implementation complexity and API surface. #### Other Changes - Use `jq` instead of `lib/json.sh`. Closes #1 #14 #16
sortedcord added 1 commit 2026-06-26 08:25:19 +05:30
fix #9: Add validation check for pkg_remove
Some checks failed
Lint / lint (push) Failing after 3m14s
Lint / lint (pull_request) Failing after 17s
780e79364f
sortedcord changed title from WIP: Redesigning Package Registry to WIP: Installation Strategy Redesign 2026-06-26 09:02:52 +05:30
sortedcord added 1 commit 2026-06-26 18:19:37 +05:30
refactor: Use jq instead of custom posix complient json.sh
Some checks failed
Lint / lint (push) Failing after 14s
Lint / lint (pull_request) Failing after 15s
7f3ff45f05
While json.sh worked decently for reading json files, I didn't want to
implement writing to json files as well and make it completely
unreadable due to the added complexity.

So, I think its better to just use jq and keep things relatively simple
with the tradeoff of a lightweight dependency
sortedcord added 1 commit 2026-06-26 18:37:10 +05:30
feat: Added registry helpers for installers
Some checks failed
Lint / lint (push) Failing after 13s
Lint / lint (pull_request) Failing after 13s
c42687a710
sortedcord added 2 commits 2026-06-26 20:12:01 +05:30
refactor: Installers use github_get_latest_release helpers
Some checks failed
Lint / lint (push) Failing after 14s
Lint / lint (pull_request) Failing after 13s
4eec27570e
sortedcord added 1 commit 2026-06-26 20:19:32 +05:30
refactor: Unify fragmented install strategies within installers
Some checks failed
Lint / lint (push) Failing after 33s
Lint / lint (pull_request) Failing after 17s
0eaea2c997
bat and yazi installers use latest binary releases from github over
package manager for arch and fedora
sortedcord added 2 commits 2026-06-26 21:37:53 +05:30
refactor: Remove legacy backwards compat code
Some checks failed
Lint / lint (push) Failing after 37s
Lint / lint (pull_request) Failing after 47s
a4e5bc1175
Remove the configure shell code blocks
sortedcord added 1 commit 2026-06-26 21:41:18 +05:30
refactor: Remove standalone exec prevention code blocks from installers
Some checks failed
Lint / lint (push) Failing after 16s
Lint / lint (pull_request) Failing after 35s
29de051b7d
sortedcord added 1 commit 2026-06-26 21:53:26 +05:30
refactor: Remove redundant curl availability checks
Some checks failed
Lint / lint (push) Failing after 56s
Lint / lint (pull_request) Failing after 1m5s
4c1c7de0b7
sortedcord added 1 commit 2026-06-26 23:52:21 +05:30
refactor: Use XDG compliant isolated directory structure
Some checks failed
Lint / lint (push) Failing after 21s
Lint / lint (pull_request) Failing after 16s
d5c90d6e85
- Using $BOOTSTRAP_BIN, $BOOTSTRAP_OPT, etc
- Add defensive fallback for undefined vars in common.sh
Author
Owner

Bootstrap is now using XDG Compliant and Isolated directory structure

Environment Variables

Variable Default Purpose
BOOTSTRAP_DIR ~/.config/bootstrap Config, shell snippets, libs
BOOTSTRAP_DATA_DIR ~/.local/share/bootstrap Binaries, runtimes, opt
BOOTSTRAP_STATE_DIR ~/.local/state/bootstrap Registry, logs, rollback
BOOTSTRAP_CACHE_DIR ~/.cache/bootstrap Download cache, temp dirs
BOOTSTRAP_BIN $BOOTSTRAP_DATA_DIR/bin Binary executables
BOOTSTRAP_OPT $BOOTSTRAP_DATA_DIR/opt Multi-file installs
BOOTSTRAP_RUNTIMES $BOOTSTRAP_DATA_DIR/runtimes Managed tool homes

closes #18

Bootstrap is now using XDG Compliant and Isolated directory structure ## Environment Variables | Variable | Default | Purpose | |---|---|---| | `BOOTSTRAP_DIR` | `~/.config/bootstrap` | Config, shell snippets, libs | | `BOOTSTRAP_DATA_DIR` | `~/.local/share/bootstrap` | Binaries, runtimes, opt | | `BOOTSTRAP_STATE_DIR` | `~/.local/state/bootstrap` | Registry, logs, rollback | | `BOOTSTRAP_CACHE_DIR` | `~/.cache/bootstrap` | Download cache, temp dirs | | `BOOTSTRAP_BIN` | `$BOOTSTRAP_DATA_DIR/bin` | Binary executables | | `BOOTSTRAP_OPT` | `$BOOTSTRAP_DATA_DIR/opt` | Multi-file installs | | `BOOTSTRAP_RUNTIMES` | `$BOOTSTRAP_DATA_DIR/runtimes` | Managed tool homes | closes #18
sortedcord added 3 commits 2026-06-27 00:39:41 +05:30
`pkg_install` and `pkg_remove` are just wrappers that map aliases and
directly invooke the system package manager.

- They do not manage state or inject rollback commands
- Removed `BOOTSTRAP_PACKAGES_DIR`
b rb <tool> can now uninstall that particular tool
fix #19: Prevent Checkpoint from having same bug as
Some checks failed
Lint / lint (push) Failing after 14s
Lint / lint (pull_request) Failing after 13s
83c524441c
Author
Owner

Improved rollback command to also act as an uninstall command for individual tools.

  • Added checks preventing savepoints from being named as tools
  • Multi tool uninstall (b rb tool_a,tool_b,tool_c)
Improved rollback command to also act as an uninstall command for individual tools. - [x] Added checks preventing savepoints from being named as tools - [ ] Multi tool uninstall (`b rb tool_a,tool_b,tool_c`)
Some checks failed
Lint / lint (push) Failing after 14s
Lint / lint (pull_request) Failing after 13s
This pull request has changes conflicting with the target branch.
  • lib/registry.sh
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin fix/reference-counting:fix/reference-counting
git checkout fix/reference-counting
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sortedcord/bootstrap#15