From 6e324f1b54d156cdeaee69a0d55b5db8eb0ecf30 Mon Sep 17 00:00:00 2001 From: Nick Chan Date: Sat, 11 Feb 2023 01:25:01 +0800 Subject: [PATCH] allow proceed with no ramdisk or binpack --- include/palerain.h | 5 +++++ src/optparse.c | 22 ++++------------------ src/pongo_helper.c | 20 +++++++++++++++----- 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/include/palerain.h b/include/palerain.h index 527fee9..4152278 100644 --- a/include/palerain.h +++ b/include/palerain.h @@ -17,9 +17,14 @@ #define LOG(loglevel, ...) p1_log(loglevel, __FILE__, __LINE__, __func__, __VA_ARGS__) #define CLEAR() printf("\33[2K\r"); +#define palerain_option_case(x) (512 + x) #define palerain_option_version 129 #define CMD_LEN_MAX 512 #define OVERRIDE_MAGIC 0xd803b376 + +#define palerain_option_case_version palerain_option_case(0) +#define palerain_option_case_force_revert palerain_option_case(1) + #ifdef USE_LIBUSB #include diff --git a/src/optparse.c b/src/optparse.c index 5cd131e..65f8e4d 100644 --- a/src/optparse.c +++ b/src/optparse.c @@ -29,9 +29,9 @@ static struct option longopts[] = { {"rootless", no_argument, NULL, 'l'}, {"jbinit-log-to-file", no_argument, NULL, 'L'}, {"demote", no_argument, NULL, 'd'}, - {"force-revert", no_argument, NULL, checkrain_option_force_revert}, + {"force-revert", no_argument, NULL, palerain_option_case_force_revert}, {"safe-mode", no_argument, NULL, 's'}, - {"version", no_argument, NULL, palerain_option_version}, + {"version", no_argument, NULL, palerain_option_case_version}, {"override-pongo", required_argument, NULL, 'k'}, {"override-overlay", required_argument, NULL, 'o'}, {"override-ramdisk", required_argument, NULL, 'r'}, @@ -233,10 +233,10 @@ int optparse(int argc, char* argv[]) { palerain_flags |= palerain_option_test2; break; #endif - case checkrain_option_force_revert: + case palerain_option_case_force_revert: checkrain_flags |= checkrain_option_force_revert; break; - case palerain_option_version: + case palerain_option_case_version: host_flags |= host_option_palerain_version; break; default: @@ -293,20 +293,6 @@ int optparse(int argc, char* argv[]) { } if (!(checkrain_option_enabled(host_flags, host_option_pongo_exit) || checkrain_option_enabled(host_flags, host_option_pongo_exit))) { -#ifdef NO_BINPACK - if (binpack_dmg_len == 0) - { - LOG(LOG_FATAL, "binpack omitted in build but no override specified"); - return -1; - } -#endif -#ifdef NO_RAMDISK - if (ramdisk_dmg_len == 0) - { - LOG(LOG_FATAL, "ramdisk omitted in build but no override specified"); - return -1; - } -#endif #ifdef NO_KPF if (checkra1n_kpf_pongo_len == 0) { diff --git a/src/pongo_helper.c b/src/pongo_helper.c index 94796e2..c48a7c9 100644 --- a/src/pongo_helper.c +++ b/src/pongo_helper.c @@ -32,7 +32,6 @@ void *pongo_usb_callback(void *arg) { if (get_found_pongo()) return NULL; set_found_pongo(1); - strncat(xargs_cmd, " rootdev=md0", 0x270 - strlen(xargs_cmd) - 1); if (checkrain_option_enabled(palerain_flags, palerain_option_setup_rootful)) { strncat(xargs_cmd, " wdt=-1", 0x270 - strlen(xargs_cmd) - 1); } @@ -50,10 +49,21 @@ void *pongo_usb_callback(void *arg) { { issue_pongo_command(handle, "rootfs"); } - upload_pongo_file(handle, **ramdisk_to_upload, ramdisk_dmg_len); - issue_pongo_command(handle, "ramdisk"); - upload_pongo_file(handle, **overlay_to_upload, binpack_dmg_len); - issue_pongo_command(handle, "overlay"); +#ifdef NO_RAMDISK + if (ramdisk_dmg_len != 0) +#endif + { + strncat(xargs_cmd, " rootdev=md0", 0x270 - strlen(xargs_cmd) - 1); + upload_pongo_file(handle, **ramdisk_to_upload, ramdisk_dmg_len); + issue_pongo_command(handle, "ramdisk"); + } +#ifdef NO_BINPACK + if (binpack_dmg_len != 0) +#endif + { + upload_pongo_file(handle, **overlay_to_upload, binpack_dmg_len); + issue_pongo_command(handle, "overlay"); + } issue_pongo_command(handle, xargs_cmd); if (checkrain_option_enabled(host_flags, host_option_pongo_full)) goto done; issue_pongo_command(handle, "bootx");