/* * OmniNX Installer - Installation Logic */ #include "install.h" #include "fs.h" #include "version.h" #include "gfx.h" #include #include #include #include #define GROUPED_DELETE_MAX_ENTRIES 512 #ifndef VERSION #define VERSION "1.0.0" #endif // Color definitions (some already defined in types.h, but we override for consistency) #undef COLOR_CYAN #undef COLOR_WHITE #undef COLOR_GREEN #undef COLOR_YELLOW #undef COLOR_ORANGE #undef COLOR_RED #define COLOR_CYAN 0xFF00FFFF #define COLOR_WHITE 0xFFFFFFFF #define COLOR_GREEN 0xFF00FF00 #define COLOR_YELLOW 0xFFFFDD00 #define COLOR_ORANGE 0xFF00A5FF #define COLOR_RED 0xFFFF0000 void install_set_color(u32 color) { gfx_con_setcol(color, gfx_con.fillbg, gfx_con.bgcol); } // Check if we need to clear screen (when getting close to bottom) void install_check_and_clear_screen_if_needed(void) { // In the gfx system: // - gfx_con.x is the vertical position (line number, increments by 16 per line) // - gfx_con.y is the horizontal position (pixels from left) // - Screen is 720px wide, 1280px tall // - Font is 16px, so we have 720/16 = 45 lines before wrapping // - When gfx_con.x > 720-16, it wraps to x=0, causing overwrite // Clear when we're past ~35 lines (35 * 16 = 560 pixels) to leave room if (gfx_con.x > 35 * 16) { // Clear screen and reset position gfx_clear_grey(0x1B); gfx_con_setpos(0, 0); // Reprint same header as initial launch install_set_color(COLOR_CYAN); gfx_printf("===================================\n"); gfx_printf(" OmniNX Installer Payload v%s\n", VERSION); gfx_printf("===================================\n\n"); install_set_color(COLOR_WHITE); } } // Check if file/directory exists bool install_path_exists(const char *path) { FILINFO fno; return (f_stat(path, &fno) == FR_OK); } // Count total items (files + directories) in a directory tree recursively int install_count_directory_items(const char *path) { DIR dir; FILINFO fno; int res; int count = 0; res = f_opendir(&dir, path); if (res != FR_OK) { return 0; } while (1) { res = f_readdir(&dir, &fno); if (res != FR_OK || fno.fname[0] == 0) break; // Skip . and .. if (fno.fname[0] == '.' && (fno.fname[1] == '\0' || (fno.fname[1] == '.' && fno.fname[2] == '\0'))) { continue; } count++; // Count this item // If it's a directory, recursively count its contents if (fno.fattrib & AM_DIR) { char sub_path[256]; s_printf(sub_path, "%s/%s", path, fno.fname); count += install_count_directory_items(sub_path); } } f_closedir(&dir); return count; } // Helper to combine paths (handles trailing slashes properly) void install_combine_path(char *result, size_t size, const char *base, const char *add) { size_t base_len = strlen(base); if (base_len > 0 && base[base_len - 1] == '/') { // Base has trailing slash, just append s_printf(result, "%s%s", base, add); } else { // No trailing slash, add one s_printf(result, "%s/%s", base, add); } } // Recursive folder copy with progress tracking static int folder_copy_progress_recursive(const char *src, const char *dst, int *copied, int total, u32 start_x, u32 start_y, const char *display_name, int *last_percent) { DIR dir; FILINFO fno; int res; char src_full[256]; char dst_full[256]; char dst_dir[256]; res = f_opendir(&dir, src); if (res != FR_OK) { return res; } // Get folder name from src path const char *folder_name = strrchr(src, '/'); if (folder_name) { folder_name++; } else { folder_name = src; } // Create destination folder path (handle trailing slash in dst) install_combine_path(dst_dir, sizeof(dst_dir), dst, folder_name); // Try to create the directory (ignore if it already exists) res = f_mkdir(dst_dir); if (res == FR_EXIST) { res = FR_OK; // Directory already exists, that's fine } else if (res != FR_OK) { // If mkdir fails, check if it's actually a file (shouldn't happen, but be safe) FILINFO fno; if (f_stat(dst_dir, &fno) == FR_OK && !(fno.fattrib & AM_DIR)) { // Destination exists but is a file, not a directory - this is an error f_closedir(&dir); return FR_DENIED; } // If it's a directory, continue (might have been created between check and mkdir) if (f_stat(dst_dir, &fno) == FR_OK && (fno.fattrib & AM_DIR)) { res = FR_OK; } else { f_closedir(&dir); return res; } } // Copy contents while (1) { res = f_readdir(&dir, &fno); if (res != FR_OK || fno.fname[0] == 0) break; // Skip . and .. if (fno.fname[0] == '.' && (fno.fname[1] == '\0' || (fno.fname[1] == '.' && fno.fname[2] == '\0'))) { continue; } // Build source and destination paths install_combine_path(src_full, sizeof(src_full), src, fno.fname); install_combine_path(dst_full, sizeof(dst_full), dst_dir, fno.fname); if (fno.fattrib & AM_DIR) { res = folder_copy_progress_recursive(src_full, dst_dir, copied, total, start_x, start_y, display_name, last_percent); // Increment counter for directory (it was counted in total) (*copied)++; } else { res = file_copy(src_full, dst_full); (*copied)++; } // Update progress every 10 items or when percentage changes if ((*copied % 10 == 0 || total == 0) && res == FR_OK) { int percent = total > 0 ? (*copied * 100) / total : 0; if (percent != *last_percent || *copied % 50 == 0) { gfx_con_setpos(start_x, start_y); install_set_color(COLOR_CYAN); gfx_printf(" Kopiere: %s [%3d%%] (%d/%d)", display_name, percent, *copied, total); install_set_color(COLOR_WHITE); *last_percent = percent; } } if (res != FR_OK) break; } f_closedir(&dir); return res; } // Progress-aware folder copy (improved version) int folder_copy_with_progress_v2(const char *src, const char *dst, const char *display_name) { int copied = 0; int total = 0; int last_percent = -1; u32 start_x, start_y; int res; // Check if source exists if (!install_path_exists(src)) { install_set_color(COLOR_ORANGE); gfx_printf(" Ueberspringe: %s (nicht gefunden)\n", display_name); install_set_color(COLOR_WHITE); return FR_NO_FILE; } // Count total items first total = install_count_directory_items(src); if (total == 0) { // Empty directory, just create destination const char *folder_name = strrchr(src, '/'); if (folder_name) folder_name++; else folder_name = src; char dst_path[256]; install_combine_path(dst_path, sizeof(dst_path), dst, folder_name); res = f_mkdir(dst_path); if (res == FR_OK || res == FR_EXIST) { return FR_OK; } return res; } // Save cursor position gfx_con_getpos(&start_x, &start_y); // Show initial status install_set_color(COLOR_CYAN); gfx_printf(" Kopiere: %s [ 0%%] (0/%d)", display_name, total); install_set_color(COLOR_WHITE); // Perform the copy with progress updates res = folder_copy_progress_recursive(src, dst, &copied, total, start_x, start_y, display_name, &last_percent); // Final update - overwrite the same line gfx_con_setpos(start_x, start_y); if (res == FR_OK) { install_set_color(COLOR_GREEN); gfx_printf(" Kopiere: %s [100%%] (%d/%d) - Fertig!\n", display_name, copied, total); install_set_color(COLOR_WHITE); } else { install_set_color(COLOR_RED); gfx_printf(" Kopiere: %s - Fehlgeschlagen!\n", display_name); gfx_printf(" Fehler: %s (Code=%d)\n", fs_error_str(res), res); gfx_printf(" Quelle: %s\n", src); gfx_printf(" Ziel: %s\n", dst); install_set_color(COLOR_WHITE); // Fallback: try using the original folder_copy function install_set_color(COLOR_ORANGE); gfx_printf(" Versuche alternative Kopiermethode...\n"); install_set_color(COLOR_WHITE); int fallback_res = folder_copy(src, dst); if (fallback_res == FR_OK) { install_set_color(COLOR_GREEN); gfx_printf(" Alternative Kopie erfolgreich!\n"); install_set_color(COLOR_WHITE); return FR_OK; } } return res; } // Copy one directory (e.g. .overlays or .packages) with .offload awareness: if the same // name exists in dst_offload, copy pack's version into dst_offload (update in place); // otherwise copy to dst_parent. Used only for update mode to preserve UltraHand hide state. static int copy_dir_offload_aware(const char *src_parent, const char *dst_parent, const char *dst_offload, const char *display_name, int *copied, int total, u32 start_x, u32 start_y, int *last_percent) { DIR dir; FILINFO fno; int res; char src_full[256]; char dst_main[256]; char dst_off[256]; res = f_opendir(&dir, src_parent); if (res != FR_OK) return res; while (1) { res = f_readdir(&dir, &fno); if (res != FR_OK || fno.fname[0] == 0) break; if (fno.fname[0] == '.' && (fno.fname[1] == '\0' || (fno.fname[1] == '.' && fno.fname[2] == '\0'))) continue; if (strcmp(fno.fname, ".offload") == 0) continue; install_combine_path(src_full, sizeof(src_full), src_parent, fno.fname); install_combine_path(dst_off, sizeof(dst_off), dst_offload, fno.fname); if (install_path_exists(dst_off)) { res = (fno.fattrib & AM_DIR) ? folder_copy(src_full, dst_offload) : file_copy(src_full, dst_off); } else { install_combine_path(dst_main, sizeof(dst_main), dst_parent, fno.fname); res = (fno.fattrib & AM_DIR) ? folder_copy(src_full, dst_parent) : file_copy(src_full, dst_main); } (*copied)++; if (total > 0) { int percent = (*copied * 100) / total; if (percent != *last_percent || *copied % 20 == 0) { gfx_con_setpos(start_x, start_y); install_set_color(COLOR_CYAN); gfx_printf(" Kopiere: %s [%3d%%] (%d/%d)", display_name, percent, *copied, total); install_set_color(COLOR_WHITE); *last_percent = percent; } } if (res != FR_OK) { f_closedir(&dir); return res; } } f_closedir(&dir); return FR_OK; } // Copy switch/ folder for update mode only: preserve SD's .overlays/.offload and // .packages/.offload; for items that exist there, update in place instead of main area. int folder_copy_switch_update_offload_aware(const char *src_switch, const char *dst_base, const char *display_name) { char dst_switch[256]; char src_overlays[256], src_packages[256]; char dst_overlays[256], dst_offload_ovl[256], dst_packages[256], dst_offload_pkg[256]; DIR dir; FILINFO fno; int res; int copied = 0; int total; int last_percent = -1; u32 start_x, start_y; install_combine_path(dst_switch, sizeof(dst_switch), dst_base, "switch"); if (!install_path_exists(src_switch)) { install_set_color(COLOR_ORANGE); gfx_printf(" Ueberspringe: %s (nicht gefunden)\n", display_name); install_set_color(COLOR_WHITE); return FR_NO_FILE; } total = install_count_directory_items(src_switch); if (total == 0) { f_mkdir(dst_switch); return FR_OK; } gfx_con_getpos(&start_x, &start_y); install_set_color(COLOR_CYAN); gfx_printf(" Kopiere: %s [ 0%%] (0/%d)", display_name, total); install_set_color(COLOR_WHITE); res = f_mkdir(dst_switch); if (res != FR_OK && res != FR_EXIST) return res; res = f_opendir(&dir, src_switch); if (res != FR_OK) return res; while (1) { res = f_readdir(&dir, &fno); if (res != FR_OK || fno.fname[0] == 0) break; if (fno.fname[0] == '.' && (fno.fname[1] == '\0' || (fno.fname[1] == '.' && fno.fname[2] == '\0'))) continue; if (strcmp(fno.fname, ".overlays") == 0) { install_combine_path(src_overlays, sizeof(src_overlays), src_switch, ".overlays"); install_combine_path(dst_overlays, sizeof(dst_overlays), dst_switch, ".overlays"); install_combine_path(dst_offload_ovl, sizeof(dst_offload_ovl), dst_overlays, ".offload"); if (!install_path_exists(src_overlays)) { f_closedir(&dir); continue; } f_mkdir(dst_overlays); f_mkdir(dst_offload_ovl); res = copy_dir_offload_aware(src_overlays, dst_overlays, dst_offload_ovl, display_name, &copied, total, start_x, start_y, &last_percent); } else if (strcmp(fno.fname, ".packages") == 0) { install_combine_path(src_packages, sizeof(src_packages), src_switch, ".packages"); install_combine_path(dst_packages, sizeof(dst_packages), dst_switch, ".packages"); install_combine_path(dst_offload_pkg, sizeof(dst_offload_pkg), dst_packages, ".offload"); if (!install_path_exists(src_packages)) { f_closedir(&dir); continue; } f_mkdir(dst_packages); f_mkdir(dst_offload_pkg); { /* package.ini into main area */ char src_ini[256], dst_ini[256]; s_printf(src_ini, "%s/package.ini", src_packages); s_printf(dst_ini, "%s/package.ini", dst_packages); if (install_path_exists(src_ini)) { res = file_copy(src_ini, dst_ini); if (res == FR_OK) copied++; } } res = copy_dir_offload_aware(src_packages, dst_packages, dst_offload_pkg, display_name, &copied, total, start_x, start_y, &last_percent); } else { char src_full[256], dst_full[256]; install_combine_path(src_full, sizeof(src_full), src_switch, fno.fname); install_combine_path(dst_full, sizeof(dst_full), dst_switch, fno.fname); if (fno.fattrib & AM_DIR) res = folder_copy(src_full, dst_switch); else res = file_copy(src_full, dst_full); copied++; } if (res != FR_OK) break; if (total > 0 && (copied % 20 == 0 || copied == total)) { int percent = (copied * 100) / total; gfx_con_setpos(start_x, start_y); install_set_color(COLOR_CYAN); gfx_printf(" Kopiere: %s [%3d%%] (%d/%d)", display_name, percent, copied, total); install_set_color(COLOR_WHITE); } } f_closedir(&dir); gfx_con_setpos(start_x, start_y); if (res == FR_OK) { install_set_color(COLOR_GREEN); gfx_printf(" Kopiere: %s [100%%] (%d/%d) - Fertig!\n", display_name, copied, total); install_set_color(COLOR_WHITE); } else { install_set_color(COLOR_RED); gfx_printf(" Kopiere: %s - Fehlgeschlagen!\n", display_name); install_set_color(COLOR_WHITE); } return res; } // Recursive folder delete with progress tracking (shared implementation) int folder_delete_progress_recursive(const char *path, int *deleted, int total, u32 start_x, u32 start_y, const char *display_name, int *last_percent) { DIR dir; FILINFO fno; int res; res = f_opendir(&dir, path); if (res != FR_OK) { // Maybe it's a file, try to delete it res = f_unlink(path); if (res == FR_OK || res == FR_NO_FILE) { (*deleted)++; } return res; } while (1) { res = f_readdir(&dir, &fno); if (res != FR_OK || fno.fname[0] == 0) break; // Skip . and .. if (fno.fname[0] == '.' && (fno.fname[1] == '\0' || (fno.fname[1] == '.' && fno.fname[2] == '\0'))) { continue; } char full_path[256]; install_combine_path(full_path, sizeof(full_path), path, fno.fname); if (fno.fattrib & AM_DIR) { res = folder_delete_progress_recursive(full_path, deleted, total, start_x, start_y, display_name, last_percent); (*deleted)++; } else { // Clear read-only attribute if set if (fno.fattrib & AM_RDO) { f_chmod(full_path, fno.fattrib & ~AM_RDO, AM_RDO); } res = f_unlink(full_path); if (res == FR_OK || res == FR_NO_FILE) { (*deleted)++; } } // Update progress every 10 items or when percentage changes if ((*deleted % 10 == 0 || total == 0) && (res == FR_OK || res == FR_NO_FILE)) { int percent = total > 0 ? (*deleted * 100) / total : 0; if (percent != *last_percent || *deleted % 50 == 0) { gfx_con_setpos(start_x, start_y); install_set_color(COLOR_CYAN); gfx_printf(" Loesche: %s [%3d%%] (%d/%d)", display_name, percent, *deleted, total); install_set_color(COLOR_WHITE); *last_percent = percent; } } if (res != FR_OK && res != FR_NO_FILE) break; } f_closedir(&dir); if (res == FR_OK || res == FR_NO_FILE) { // Check and clear read-only attribute on directory if set FILINFO dir_info; if (f_stat(path, &dir_info) == FR_OK && (dir_info.fattrib & AM_RDO)) { f_chmod(path, dir_info.fattrib & ~AM_RDO, AM_RDO); } res = f_unlink(path); } return res; } // Progress-aware delete for a single directory (used for large directories) int folder_delete_single_with_progress(const char *path, const char *display_name) { int deleted = 0; int total = 0; int last_percent = -1; u32 start_x, start_y; int res; // Count total items first total = install_count_directory_items(path); if (total == 0) { // Empty directory, just delete it FILINFO fno; if (f_stat(path, &fno) == FR_OK) { if (fno.fattrib & AM_RDO) { f_chmod(path, fno.fattrib & ~AM_RDO, AM_RDO); } res = f_unlink(path); } else { res = FR_NO_FILE; } return res; } // Save cursor position gfx_con_getpos(&start_x, &start_y); // Show initial status install_set_color(COLOR_CYAN); gfx_printf(" Loesche: %s [ 0%%] (0/%d)", display_name, total); install_set_color(COLOR_WHITE); // Use the shared recursive progress function res = folder_delete_progress_recursive(path, &deleted, total, start_x, start_y, display_name, &last_percent); // Final update gfx_con_setpos(start_x, start_y); if (res == FR_OK || res == FR_NO_FILE) { install_set_color(COLOR_GREEN); gfx_printf(" Loesche: %s [100%%] (%d/%d) - Fertig!\n", display_name, deleted, total); install_set_color(COLOR_WHITE); } else { install_set_color(COLOR_RED); gfx_printf(" Loesche: %s - Fehlgeschlagen!\n", display_name); install_set_color(COLOR_WHITE); } return res; } // Delete a list of paths with progress tracking // Delete multiple path lists under one label; one progress line "Bereinige: folder/ [p%] (d/t)". // Varargs: path lists (const char**), terminated by NULL. int delete_path_lists_grouped(const char *folder_display_name, ...) { va_list ap; const char *entries[GROUPED_DELETE_MAX_ENTRIES]; int n_entries = 0; int deleted = 0; int failed = 0; u32 start_x, start_y; int last_percent = -1; int res; va_start(ap, folder_display_name); const char **list; while (n_entries < GROUPED_DELETE_MAX_ENTRIES && (list = va_arg(ap, const char **)) != NULL) { for (int i = 0; list[i] != NULL && n_entries < GROUPED_DELETE_MAX_ENTRIES; i++) { if (install_path_exists(list[i])) entries[n_entries++] = list[i]; } } va_end(ap); if (n_entries == 0) return FR_OK; int total_paths = n_entries; gfx_con_getpos(&start_x, &start_y); install_set_color(COLOR_CYAN); gfx_printf(" Bereinige: %s [ 0%%] (0/%d)", folder_display_name, total_paths); install_set_color(COLOR_WHITE); for (int i = 0; i < n_entries; i++) { const char *path = entries[i]; FILINFO fno; if (f_stat(path, &fno) != FR_OK) continue; const char *item_name = strrchr(path, '/'); if (item_name) item_name++; else item_name = path; if (fno.fattrib & AM_DIR) { int item_count = install_count_directory_items(path); if (item_count > 50) { gfx_printf("\n"); res = folder_delete_single_with_progress(path, item_name); } else { res = folder_delete(path); } } else { if (fno.fattrib & AM_RDO) f_chmod(path, fno.fattrib & ~AM_RDO, AM_RDO); res = f_unlink(path); } if (res == FR_OK || res == FR_NO_FILE) deleted++; else failed++; int percent = (deleted * 100) / total_paths; if (percent != last_percent || deleted % 5 == 0) { gfx_con_setpos(start_x, start_y); install_set_color(COLOR_CYAN); gfx_printf(" Bereinige: %s [%3d%%] (%d/%d)", folder_display_name, percent, deleted, total_paths); install_set_color(COLOR_WHITE); last_percent = percent; } } gfx_con_setpos(start_x, start_y); if (failed == 0) { install_set_color(COLOR_GREEN); gfx_printf(" Bereinige: %s [100%%] (%d/%d) - Fertig!\n", folder_display_name, deleted, total_paths); install_set_color(COLOR_WHITE); } else { install_set_color(COLOR_ORANGE); gfx_printf(" Bereinige: %s [%3d%%] (%d/%d) - %d Fehler\n", folder_display_name, last_percent, deleted, total_paths, failed); install_set_color(COLOR_WHITE); } return (failed == 0) ? FR_OK : FR_DISK_ERR; } int delete_path_list(const char* paths[], const char* description) { int res; int deleted = 0; int failed = 0; int total_paths = 0; u32 start_x, start_y; int last_percent = -1; // Count total paths first for (int i = 0; paths[i] != NULL; i++) { if (install_path_exists(paths[i])) { total_paths++; } } if (total_paths == 0) { return FR_OK; // Nothing to delete } // Save cursor position gfx_con_getpos(&start_x, &start_y); // Show initial status install_set_color(COLOR_CYAN); gfx_printf(" Loesche: %s [ 0%%] (0/%d)", description, total_paths); install_set_color(COLOR_WHITE); for (int i = 0; paths[i] != NULL; i++) { if (install_path_exists(paths[i])) { FILINFO fno; f_stat(paths[i], &fno); // Extract just the folder/file name for display const char *item_name = strrchr(paths[i], '/'); if (item_name) { item_name++; // Skip the '/' } else { item_name = paths[i]; } if (fno.fattrib & AM_DIR) { // Check if directory has many items - if so, show detailed progress int item_count = install_count_directory_items(paths[i]); if (item_count > 50) { // Large directory - show individual progress // Move to new line for the detailed progress gfx_printf("\n"); res = folder_delete_single_with_progress(paths[i], item_name); } else { // Small directory - use regular delete res = folder_delete(paths[i]); } } else { // Clear read-only attribute if set if (fno.fattrib & AM_RDO) { f_chmod(paths[i], fno.fattrib & ~AM_RDO, AM_RDO); } res = f_unlink(paths[i]); } if (res == FR_OK || res == FR_NO_FILE) { deleted++; } else { failed++; } // Update list-level progress (only if not showing detailed progress) if (fno.fattrib & AM_DIR && install_count_directory_items(paths[i]) <= 50) { int percent = (deleted * 100) / total_paths; if (percent != last_percent || deleted % 5 == 0) { gfx_con_setpos(start_x, start_y); install_set_color(COLOR_CYAN); gfx_printf(" Loesche: %s [%3d%%] (%d/%d)", description, percent, deleted, total_paths); install_set_color(COLOR_WHITE); last_percent = percent; } } else if (!(fno.fattrib & AM_DIR)) { // Update for files int percent = (deleted * 100) / total_paths; if (percent != last_percent || deleted % 5 == 0) { gfx_con_setpos(start_x, start_y); install_set_color(COLOR_CYAN); gfx_printf(" Loesche: %s [%3d%%] (%d/%d)", description, percent, deleted, total_paths); install_set_color(COLOR_WHITE); last_percent = percent; } } } } // Final update gfx_con_setpos(start_x, start_y); if (failed == 0) { install_set_color(COLOR_GREEN); gfx_printf(" Loesche: %s [100%%] (%d/%d) - Fertig!\n", description, deleted, total_paths); install_set_color(COLOR_WHITE); } else { install_set_color(COLOR_ORANGE); gfx_printf(" Loesche: %s [%3d%%] (%d/%d) - %d Fehler\n", description, last_percent, deleted, total_paths, failed); install_set_color(COLOR_WHITE); } return (failed == 0) ? FR_OK : FR_DISK_ERR; } // Main installation function int perform_installation(omninx_variant_t pack_variant, install_mode_t mode) { int res; if (mode == INSTALL_MODE_UPDATE) { // Update mode: selective cleanup then install install_set_color(COLOR_YELLOW); gfx_printf("Schritt 1: Bereinigung...\n"); install_set_color(COLOR_WHITE); res = update_mode_cleanup(pack_variant); if (res != FR_OK) return res; install_check_and_clear_screen_if_needed(); gfx_printf("\n"); install_set_color(COLOR_YELLOW); gfx_printf("Schritt 2: Dateien kopieren...\n"); install_set_color(COLOR_WHITE); res = update_mode_install(pack_variant); if (res != FR_OK) return res; install_check_and_clear_screen_if_needed(); // Remove staging directory (installed pack) res = cleanup_staging_directory(pack_variant); if (res != FR_OK) return res; // Remove other detected install directories (Standard/Light/OC) that were on SD res = cleanup_other_staging_directories(pack_variant); return res; } else { // Clean mode: backup, wipe, restore, install install_set_color(COLOR_YELLOW); gfx_printf("Schritt 1: Sichere Benutzerdaten...\n"); install_set_color(COLOR_WHITE); res = clean_mode_backup(); if (res != FR_OK) return res; install_check_and_clear_screen_if_needed(); gfx_printf("\n"); install_set_color(COLOR_YELLOW); gfx_printf("Schritt 2: Bereinige alte Installation...\n"); install_set_color(COLOR_WHITE); res = clean_mode_wipe(); if (res != FR_OK) return res; install_check_and_clear_screen_if_needed(); gfx_printf("\n"); install_set_color(COLOR_YELLOW); gfx_printf("Schritt 3: Stelle Benutzerdaten wieder her...\n"); install_set_color(COLOR_WHITE); res = clean_mode_restore(); if (res != FR_OK) return res; install_check_and_clear_screen_if_needed(); gfx_printf("\n"); install_set_color(COLOR_YELLOW); gfx_printf("Schritt 4: Dateien kopieren...\n"); install_set_color(COLOR_WHITE); res = clean_mode_install(pack_variant); if (res != FR_OK) return res; install_check_and_clear_screen_if_needed(); // Remove staging directory (installed pack) res = cleanup_staging_directory(pack_variant); if (res != FR_OK) return res; // Remove other detected install directories (Standard/Light/OC) that were on SD res = cleanup_other_staging_directories(pack_variant); return res; } }