From 0c16640593ee0ce035cf724d000ccfead339cdc4 Mon Sep 17 00:00:00 2001 From: Aditya Gupta Date: Sat, 27 Jun 2026 00:19:14 +0530 Subject: [PATCH] refactor: Simplified `pkg_install` and `pkg_remove` `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 --- lib/platform.sh | 31 +------------------------------ 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/lib/platform.sh b/lib/platform.sh index d12e708..9cd8a10 100644 --- a/lib/platform.sh +++ b/lib/platform.sh @@ -86,18 +86,7 @@ pkg_install() { if ! pkg_check "$pkg"; then to_install+=("$pkg") fi - - # Reference counting logic - if [ -n "${BOOTSTRAP_CURRENT_TOOL:-}" ] && [ -n "${BOOTSTRAP_PACKAGES_DIR:-}" ]; then - local ref_file="$BOOTSTRAP_PACKAGES_DIR/$pkg" - if ! grep -q "^${BOOTSTRAP_CURRENT_TOOL}$" "$ref_file" 2>/dev/null; then - echo "$BOOTSTRAP_CURRENT_TOOL" >> "$ref_file" - # Register rollback command - if type add_rollback_cmd >/dev/null 2>&1; then - add_rollback_cmd "pkg_remove $pkg" - fi - fi - fi + done if [ ${#to_install[@]} -eq 0 ]; then @@ -174,24 +163,6 @@ pkg_remove() { is_installed=1 fi - if [ -n "${BOOTSTRAP_CURRENT_TOOL:-}" ] && [ -n "${BOOTSTRAP_PACKAGES_DIR:-}" ]; then - local ref_file="$BOOTSTRAP_PACKAGES_DIR/$pkg" - if [ -f "$ref_file" ]; then - if [ "$is_installed" -eq 0 ]; then - log_info "Package '$pkg' is no longer installed system-wide. Cleaning up stale reference." - rm -f "$ref_file" - else - # Remove this tool from the reference file - sed -i "/^${BOOTSTRAP_CURRENT_TOOL}$/d" "$ref_file" - if [ -s "$ref_file" ]; then - log_info "Skipping removal of '$pkg'; it is required by other tools." - continue - else - rm -f "$ref_file" - fi - fi - fi - fi if [ "$is_installed" -eq 1 ]; then to_remove+=("$pkg")