Compare commits
3 Commits
1a44154287
...
4a4147686e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4a4147686e | ||
|
|
fdad061616 | ||
|
|
3d3489f1e6 |
@@ -272,7 +272,7 @@ Creates/overwrites `sd:/config/omninx/manifest.ini`:
|
|||||||
**Content Structure**:
|
**Content Structure**:
|
||||||
```ini
|
```ini
|
||||||
[OmniNX]
|
[OmniNX]
|
||||||
current_pack={variant} # "standard", "light", or "oc"
|
current_pack={variant} # "Standard", "Light", or "OC"
|
||||||
version={VERSION} # e.g., "1.0.0"
|
version={VERSION} # e.g., "1.0.0"
|
||||||
update_channel={0|1|2} # light=0, oc=1, standard=2
|
update_channel={0|1|2} # light=0, oc=1, standard=2
|
||||||
channel_pack={variant} # Same as current_pack
|
channel_pack={variant} # Same as current_pack
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
# HATS Tools Universal Config
|
|
||||||
# Location: sd:/config/hats-tools/config.ini
|
|
||||||
# Shared between HATS Tools GUI and hats-installer payload
|
|
||||||
|
|
||||||
[hats]
|
|
||||||
install_mode=default ; options: replace, default, clean
|
|
||||||
|
|
||||||
# Mode descriptions:
|
|
||||||
# replace - Only replace files, no deletion (old files may remain)
|
|
||||||
# default - Delete /atmosphere only, keep /bootloader and /switch
|
|
||||||
# clean - Delete /atmosphere, /bootloader, and /switch (fresh install)
|
|
||||||
#
|
|
||||||
# All modes will remove HATS-*.txt version files from SD root
|
|
||||||
@@ -521,8 +521,11 @@ int perform_installation(omninx_variant_t pack_variant, install_mode_t mode) {
|
|||||||
if (res != FR_OK) return res;
|
if (res != FR_OK) return res;
|
||||||
|
|
||||||
install_check_and_clear_screen_if_needed();
|
install_check_and_clear_screen_if_needed();
|
||||||
// Remove staging directory
|
// Remove staging directory (installed pack)
|
||||||
res = cleanup_staging_directory(pack_variant);
|
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;
|
return res;
|
||||||
} else {
|
} else {
|
||||||
// Clean mode: backup, wipe, restore, install
|
// Clean mode: backup, wipe, restore, install
|
||||||
@@ -557,8 +560,11 @@ int perform_installation(omninx_variant_t pack_variant, install_mode_t mode) {
|
|||||||
if (res != FR_OK) return res;
|
if (res != FR_OK) return res;
|
||||||
|
|
||||||
install_check_and_clear_screen_if_needed();
|
install_check_and_clear_screen_if_needed();
|
||||||
// Remove staging directory
|
// Remove staging directory (installed pack)
|
||||||
res = cleanup_staging_directory(pack_variant);
|
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;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ int perform_installation(omninx_variant_t pack_variant, install_mode_t mode);
|
|||||||
int update_mode_cleanup(omninx_variant_t variant);
|
int update_mode_cleanup(omninx_variant_t variant);
|
||||||
int update_mode_install(omninx_variant_t variant);
|
int update_mode_install(omninx_variant_t variant);
|
||||||
int cleanup_staging_directory(omninx_variant_t pack_variant);
|
int cleanup_staging_directory(omninx_variant_t pack_variant);
|
||||||
|
// Remove other OmniNX staging directories (Standard/Light/OC) that exist, except the one just installed
|
||||||
|
int cleanup_other_staging_directories(omninx_variant_t installed_variant);
|
||||||
|
|
||||||
// Clean install operations (install_clean.c)
|
// Clean install operations (install_clean.c)
|
||||||
int clean_mode_backup(void);
|
int clean_mode_backup(void);
|
||||||
|
|||||||
@@ -9,20 +9,27 @@
|
|||||||
#include "deletion_lists_clean.h"
|
#include "deletion_lists_clean.h"
|
||||||
#include "fs.h"
|
#include "fs.h"
|
||||||
#include "gfx.h"
|
#include "gfx.h"
|
||||||
|
#include "version.h"
|
||||||
#include <libs/fatfs/ff.h>
|
#include <libs/fatfs/ff.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#undef COLOR_CYAN
|
#undef COLOR_CYAN
|
||||||
#undef COLOR_WHITE
|
#undef COLOR_WHITE
|
||||||
#undef COLOR_GREEN
|
#undef COLOR_GREEN
|
||||||
#undef COLOR_RED
|
#undef COLOR_RED
|
||||||
|
#undef COLOR_YELLOW
|
||||||
|
#undef COLOR_ORANGE
|
||||||
#define COLOR_CYAN 0xFF00FFFF
|
#define COLOR_CYAN 0xFF00FFFF
|
||||||
#define COLOR_WHITE 0xFFFFFFFF
|
#define COLOR_WHITE 0xFFFFFFFF
|
||||||
#define COLOR_GREEN 0xFF00FF00
|
#define COLOR_GREEN 0xFF00FF00
|
||||||
#define COLOR_RED 0xFFFF0000
|
#define COLOR_RED 0xFFFF0000
|
||||||
|
#define COLOR_YELLOW 0xFFFFDD00
|
||||||
|
#define COLOR_ORANGE 0xFF00A5FF
|
||||||
|
|
||||||
#define set_color install_set_color
|
#define set_color install_set_color
|
||||||
#define check_and_clear_screen_if_needed install_check_and_clear_screen_if_needed
|
#define check_and_clear_screen_if_needed install_check_and_clear_screen_if_needed
|
||||||
#define path_exists install_path_exists
|
#define path_exists install_path_exists
|
||||||
|
#define count_directory_items install_count_directory_items
|
||||||
|
|
||||||
// Clean mode: Backup user data
|
// Clean mode: Backup user data
|
||||||
int clean_mode_backup(void) {
|
int clean_mode_backup(void) {
|
||||||
@@ -109,3 +116,55 @@ int clean_mode_restore(void) {
|
|||||||
int clean_mode_install(omninx_variant_t variant) {
|
int clean_mode_install(omninx_variant_t variant) {
|
||||||
return update_mode_install(variant);
|
return update_mode_install(variant);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove other staging directories (OmniNX Standard/Light/OC) that exist on SD
|
||||||
|
int cleanup_other_staging_directories(omninx_variant_t installed_variant) {
|
||||||
|
static const omninx_variant_t all_variants[] = { VARIANT_STANDARD, VARIANT_LIGHT, VARIANT_OC };
|
||||||
|
const int n = sizeof(all_variants) / sizeof(all_variants[0]);
|
||||||
|
int last_res = FR_OK;
|
||||||
|
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
omninx_variant_t v = all_variants[i];
|
||||||
|
if (v == installed_variant)
|
||||||
|
continue;
|
||||||
|
const char *staging = get_staging_path(v);
|
||||||
|
if (!staging || !path_exists(staging))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
check_and_clear_screen_if_needed();
|
||||||
|
set_color(COLOR_YELLOW);
|
||||||
|
gfx_printf("\nEntferne weiteren Installationsordner...\n");
|
||||||
|
set_color(COLOR_WHITE);
|
||||||
|
|
||||||
|
int total = count_directory_items(staging);
|
||||||
|
u32 start_x, start_y;
|
||||||
|
gfx_con_getpos(&start_x, &start_y);
|
||||||
|
|
||||||
|
const char *folder_name = strrchr(staging, '/');
|
||||||
|
if (folder_name) folder_name++;
|
||||||
|
else folder_name = staging;
|
||||||
|
|
||||||
|
set_color(COLOR_CYAN);
|
||||||
|
gfx_printf(" Loesche: %s [ 0%%] (0/%d)", folder_name, total);
|
||||||
|
set_color(COLOR_WHITE);
|
||||||
|
|
||||||
|
int deleted = 0;
|
||||||
|
int last_percent = -1;
|
||||||
|
int res = folder_delete_progress_recursive(staging, &deleted, total, start_x, start_y, folder_name, &last_percent);
|
||||||
|
|
||||||
|
gfx_con_setpos(start_x, start_y);
|
||||||
|
if (res == FR_OK) {
|
||||||
|
set_color(COLOR_GREEN);
|
||||||
|
gfx_printf(" Loesche: %s [100%%] (%d/%d) - Fertig!\n", folder_name, deleted, total);
|
||||||
|
set_color(COLOR_WHITE);
|
||||||
|
} else {
|
||||||
|
set_color(COLOR_ORANGE);
|
||||||
|
gfx_printf(" Loesche: %s - Fehlgeschlagen!\n", folder_name);
|
||||||
|
gfx_printf(" [WARN] Ordner konnte nicht entfernt werden (err=%d)\n", res);
|
||||||
|
set_color(COLOR_WHITE);
|
||||||
|
}
|
||||||
|
last_res = res;
|
||||||
|
}
|
||||||
|
|
||||||
|
return last_res;
|
||||||
|
}
|
||||||
|
|||||||
@@ -158,9 +158,9 @@ int update_mode_install(omninx_variant_t variant) {
|
|||||||
const char* pack_name;
|
const char* pack_name;
|
||||||
int update_channel;
|
int update_channel;
|
||||||
switch (variant) {
|
switch (variant) {
|
||||||
case VARIANT_STANDARD: pack_name = "standard"; update_channel = 2; break;
|
case VARIANT_STANDARD: pack_name = "Standard"; update_channel = 2; break;
|
||||||
case VARIANT_LIGHT: pack_name = "light"; update_channel = 0; break;
|
case VARIANT_LIGHT: pack_name = "Light"; update_channel = 0; break;
|
||||||
case VARIANT_OC: pack_name = "oc"; update_channel = 1; break;
|
case VARIANT_OC: pack_name = "OC"; update_channel = 1; break;
|
||||||
default: pack_name = "unknown"; update_channel = 0; break;
|
default: pack_name = "unknown"; update_channel = 0; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
1014
source/main.c
1014
source/main.c
File diff suppressed because it is too large
Load Diff
@@ -50,11 +50,11 @@ static omninx_variant_t read_manifest_variant(const char *manifest_path) {
|
|||||||
LIST_FOREACH_ENTRY(ini_kv_t, kv, &sec->kvs, link) {
|
LIST_FOREACH_ENTRY(ini_kv_t, kv, &sec->kvs, link) {
|
||||||
if (kv->key && !strcmp(kv->key, "current_pack")) {
|
if (kv->key && !strcmp(kv->key, "current_pack")) {
|
||||||
if (kv->val) {
|
if (kv->val) {
|
||||||
if (!strcmp(kv->val, "standard")) {
|
if (!strcmp(kv->val, "Standard")) {
|
||||||
variant = VARIANT_STANDARD;
|
variant = VARIANT_STANDARD;
|
||||||
} else if (!strcmp(kv->val, "light")) {
|
} else if (!strcmp(kv->val, "Light")) {
|
||||||
variant = VARIANT_LIGHT;
|
variant = VARIANT_LIGHT;
|
||||||
} else if (!strcmp(kv->val, "oc")) {
|
} else if (!strcmp(kv->val, "OC")) {
|
||||||
variant = VARIANT_OC;
|
variant = VARIANT_OC;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -156,6 +156,20 @@ omninx_variant_t detect_pack_variant(void) {
|
|||||||
return VARIANT_NONE;
|
return VARIANT_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Detect all pack variants present on SD card; returns count, fills out_variants[]
|
||||||
|
int detect_present_variants(omninx_variant_t *out_variants, int max_count) {
|
||||||
|
int count = 0;
|
||||||
|
if (max_count <= 0 || !out_variants)
|
||||||
|
return 0;
|
||||||
|
if (file_exists(STAGING_STANDARD) && count < max_count)
|
||||||
|
out_variants[count++] = VARIANT_STANDARD;
|
||||||
|
if (file_exists(STAGING_LIGHT) && count < max_count)
|
||||||
|
out_variants[count++] = VARIANT_LIGHT;
|
||||||
|
if (file_exists(STAGING_OC) && count < max_count)
|
||||||
|
out_variants[count++] = VARIANT_OC;
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
// Get human-readable variant name
|
// Get human-readable variant name
|
||||||
const char* get_variant_name(omninx_variant_t variant) {
|
const char* get_variant_name(omninx_variant_t variant) {
|
||||||
switch (variant) {
|
switch (variant) {
|
||||||
|
|||||||
@@ -23,9 +23,12 @@ typedef struct {
|
|||||||
// Detect current OmniNX installation status
|
// Detect current OmniNX installation status
|
||||||
omninx_status_t detect_omninx_installation(void);
|
omninx_status_t detect_omninx_installation(void);
|
||||||
|
|
||||||
// Detect which pack variant is present on SD card
|
// Detect which pack variant is present on SD card (first found in fixed order)
|
||||||
omninx_variant_t detect_pack_variant(void);
|
omninx_variant_t detect_pack_variant(void);
|
||||||
|
|
||||||
|
// Detect all pack variants present on SD card; returns count, fills out_variants[] (max max_count)
|
||||||
|
int detect_present_variants(omninx_variant_t *out_variants, int max_count);
|
||||||
|
|
||||||
// Get human-readable variant name
|
// Get human-readable variant name
|
||||||
const char* get_variant_name(omninx_variant_t variant);
|
const char* get_variant_name(omninx_variant_t variant);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user