feat(install,remove,upgrade): export CORAL_ROOT to maintainer scripts
Author:
Chris Tusa <chris.tusa@leafscale.com>
Date:
Jul 05, 2026 17:04
Changeset:
6c9f234773280cd884bc443805f9167f929bf8bb
Branch:
default
Changed files:
Diff
diff -r 8a166e02c975 -r 6c9f23477328 src/commands/install.reef --- a/src/commands/install.reef Sun Jul 05 17:04:35 2026 -0500 +++ b/src/commands/install.reef Sun Jul 05 17:04:52 2026 -0500 @@ -384,6 +384,9 @@ end if let install_root = get_root(cfg) + // Phase 1: chroot disabled (chroot_scripts=false), so ctx.do_chroot is always false; + // this exports $CORAL_ROOT to scripts. Phase 2 replaces the args with cfg + is_root(). + let script_ctx = package.resolve_script_ctx(install_root, false, true) if is_upgrade // Upgrade flow: pre-upgrade → remove old files → install new files → post-upgrade @@ -392,7 +395,7 @@ let old_scripts = database.get_scripts_dir(info.name) if database.has_stored_scripts(info.name) color.print_info("Running pre-upgrade script...") - if not package.run_stored_pre_upgrade(old_scripts, old_version, info.version) + if not package.run_stored_pre_upgrade(script_ctx, old_scripts, old_version, info.version) color.print_error("Pre-upgrade script failed, aborting") cleanup_extract_dir(extract_dir) return false @@ -430,7 +433,7 @@ // Run post-upgrade from new package's scripts if package.has_scripts(extract_dir) color.print_info("Running post-upgrade script...") - if not package.run_post_upgrade(extract_dir, old_version, info.version) + if not package.run_post_upgrade(script_ctx, extract_dir, old_version, info.version) color.print_warning("Post-upgrade script failed") end if end if @@ -440,7 +443,7 @@ // Run pre-install script (abort on failure) if package.has_scripts(extract_dir) color.print_info("Running pre-install script...") - if not package.run_pre_install(extract_dir, info.version) + if not package.run_pre_install(script_ctx, extract_dir, info.version) color.print_error("Pre-install script failed") cleanup_extract_dir(extract_dir) return false @@ -458,7 +461,7 @@ // Run post-install script (warn on failure, don't abort) if package.has_scripts(extract_dir) color.print_info("Running post-install script...") - if not package.run_post_install(extract_dir, info.version) + if not package.run_post_install(script_ctx, extract_dir, info.version) color.print_warning("Post-install script failed") end if end if diff -r 8a166e02c975 -r 6c9f23477328 src/commands/remove.reef --- a/src/commands/remove.reef Sun Jul 05 17:04:35 2026 -0500 +++ b/src/commands/remove.reef Sun Jul 05 17:04:52 2026 -0500 @@ -189,6 +189,11 @@ color.print_action("Removing " + pkg_name + "...") + // Phase 1: chroot disabled (chroot_scripts=false), so ctx.do_chroot is always false; + // this exports $CORAL_ROOT to scripts. Phase 2 replaces the args with cfg + is_root(). + let install_root = get_actual_root(root_path) + let script_ctx = package.resolve_script_ctx(install_root, false, true) + // Get package info (use rooted version if root is set) let pkg = get_installed_pkg(pkg_name, root_path) color.print_info("Package: " + pkg.info.name + " " + pkg.info.version) @@ -207,7 +212,7 @@ let scripts_dir = database.get_scripts_dir(pkg_name) if database.has_stored_scripts(pkg_name) color.print_info("Running pre-remove script...") - if not package.run_stored_pre_remove(scripts_dir, pkg.info.version) + if not package.run_stored_pre_remove(script_ctx, scripts_dir, pkg.info.version) color.print_error("Pre-remove script failed, aborting removal of " + pkg_name) return false end if @@ -237,7 +242,7 @@ // Run post-remove script if present (warn on failure, don't abort) if database.has_stored_scripts(pkg_name) color.print_info("Running post-remove script...") - if not package.run_stored_post_remove(scripts_dir, pkg.info.version) + if not package.run_stored_post_remove(script_ctx, scripts_dir, pkg.info.version) color.print_warning("Post-remove script failed") end if end if