MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / cbm_cmd_update

Function cbm_cmd_update

src/cli/cli.c:11459–11663  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11457#endif /* CBM_CLI_ENABLE_TEST_API */
11458
11459int cbm_cmd_update(int argc, char **argv) {
11460 parse_auto_answer(argc, argv);
11461
11462 bool dry_run = false;
11463 bool force = false;
11464 int variant_flag = 0; /* 0 = ask, 1 = standard, 2 = ui */
11465 for (int i = 0; i < argc; i++) {
11466 if (strcmp(argv[i], "--dry-run") == 0) {
11467 dry_run = true;
11468 } else if (strcmp(argv[i], "--standard") == 0) {
11469 variant_flag = VARIANT_A;
11470 } else if (strcmp(argv[i], "--ui") == 0) {
11471 variant_flag = VARIANT_B;
11472 } else if (strcmp(argv[i], "--force") == 0) {
11473 force = true;
11474 } else if (strcmp(argv[i], "-y") != 0 && strcmp(argv[i], "--yes") != 0 &&
11475 strcmp(argv[i], "-n") != 0 && strcmp(argv[i], "--no") != 0) {
11476 (void)fprintf(stderr, "error: unknown update option: %s\n", argv[i]);
11477 return CLI_TRUE;
11478 }
11479 }
11480
11481 /* Updates run from the install script, not from this process — on every
11482 * platform.
11483 *
11484 * Windows forced the split first: a running .exe cannot replace itself, so
11485 * an in-process updater needed a second resident binary to swap the first
11486 * one out, and that launcher stub was exactly the shape Defender's ML
11487 * scores as a dropper.
11488 *
11489 * The rest followed for the same reason rather than a different one. An
11490 * in-process updater is, structurally, a downloader: it fetches a remote
11491 * archive, extracts it, marks the result executable and runs it. That is
11492 * the behaviour Microsoft's Wacatac family describes almost verbatim, and
11493 * carrying it in the product binary put download/extract/chmod/exec in
11494 * every shipped artifact for a command most users run a handful of times.
11495 *
11496 * The install script already does all of it, is idempotent -- so re-running
11497 * it IS the update -- and runs while cbm is NOT running. Print the exact
11498 * command instead of feigning self-update. */
11499#ifndef CBM_CLI_ENABLE_TEST_API
11500 /* A release build has nothing to do but hand off. The flags are still
11501 * parsed and validated above, so `update --dry-run` and friends keep
11502 * rejecting typos instead of silently accepting them. */
11503 (void)dry_run;
11504 (void)force;
11505 (void)variant_flag;
11506#endif
11507#ifdef CBM_CLI_ENABLE_TEST_API
11508 if (g_cli_activation_test_ops_set) {
11509 (void)fprintf(stderr, "*** cbm test seam: portable update flow engaged; the "
11510 "script-update handoff is bypassed (test builds only) ***\n");
11511 } else
11512#endif
11513 {
11514 char self_dir[CLI_BUF_1K] = {0};
11515 bool have_dir = false;
11516 /* cbm_detect_self_path resolves wide on Windows (non-ASCII install

Callers 2

handle_subcommandFunction · 0.85
test_cli.cFile · 0.85

Calls 12

parse_auto_answerFunction · 0.85
cbm_detect_self_pathFunction · 0.85
cbm_get_home_dirFunction · 0.85
check_already_latestFunction · 0.85
select_update_variantFunction · 0.85
detect_osFunction · 0.85
detect_archFunction · 0.85
build_update_urlFunction · 0.85
cbm_mkdir_pFunction · 0.85
download_verify_installFunction · 0.85
cbm_exec_no_shellFunction · 0.85

Tested by

no test coverage detected