pmt: add interrupt signal handler etc.

This commit is contained in:
2025-08-18 22:24:42 +03:00
parent 58330fddf4
commit 366bb28612
3 changed files with 25 additions and 16 deletions

View File

@@ -39,9 +39,9 @@ select_variant()
if getprop ro.product.cpu.abi | grep "arm64-v8a" &>/dev/null; then ARCH="arm64-v8a"; if getprop ro.product.cpu.abi | grep "arm64-v8a" &>/dev/null; then ARCH="arm64-v8a";
else ARCH="armeabi-v7a" else ARCH="armeabi-v7a"
fi fi
grep "static" <<< $1 &>/dev/null && VARIANT="static-" grep "static" <<< $1 &>/dev/null && VARIANT="static-"
LINK="https://github.com/ShawkTeam/pmt-renovated/releases/download/${RELEASE}/pmt-${VARIANT}${ARCH}.zip" LINK="https://github.com/ShawkTeam/pmt-renovated/releases/download/${RELEASE}/pmt-${VARIANT}${ARCH}.zip"
} }
download() download()
@@ -105,15 +105,15 @@ case $1 in
is_installed is_installed
checks checks
select_variant $(grep "static" <<< $2 &>/dev/null && echo static) select_variant $(grep "static" <<< $2 &>/dev/null && echo static)
download download
setup setup
;; ;;
"uninstall") "uninstall")
uninstall && echo "Uninstalled successfully." uninstall && echo "Uninstalled successfully."
;; ;;
"reinstall") "reinstall")
uninstall uninstall
checks checks
select_variant $(grep "static" <<< $2 &>/dev/null && echo static) select_variant $(grep "static" <<< $2 &>/dev/null && echo static)
download download
setup setup

View File

@@ -16,12 +16,13 @@
#include "functions/functions.hpp" #include "functions/functions.hpp"
#include <PartitionManager/PartitionManager.hpp> #include <PartitionManager/PartitionManager.hpp>
#include <unistd.h>
#include <cstdarg> #include <cstdarg>
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
#include <csignal>
#include <generated/buildInfo.hpp> #include <generated/buildInfo.hpp>
#include <string> #include <string>
#include <unistd.h>
namespace PartitionManager { namespace PartitionManager {
@@ -30,10 +31,16 @@ void init() {
Helper::LoggingProperties::setLogFile("/sdcard/Documents/last_pmt_logs.log"); Helper::LoggingProperties::setLogFile("/sdcard/Documents/last_pmt_logs.log");
} }
static void sigHandler(const int sig) {
// Even if only SIGINT is to be captured for now, this is still a more appropriate code
if (sig == SIGINT) println("\n%sInterrupted.%s", YELLOW, STYLE_RESET);
exit(sig);
}
auto Variables = std::make_unique<VariableTable>(); auto Variables = std::make_unique<VariableTable>();
basic_variables::basic_variables() basic_variables::basic_variables()
: logFile("/sdcard/Documents/last_pmt_logs.log"), onLogical(false), : logFile(Helper::LoggingProperties::FILE), onLogical(false),
quietProcess(false), verboseMode(false), viewVersion(false), quietProcess(false), verboseMode(false), viewVersion(false),
forceProcess(false) { forceProcess(false) {
try { try {
@@ -45,6 +52,15 @@ basic_variables::basic_variables()
int Main(int argc, char **argv) { int Main(int argc, char **argv) {
try { try {
// try-catch start // try-catch start
if (argc < 2) {
println(
"Usage: %s [OPTIONS] [SUBCOMMAND]\nUse --help for more information.",
argv[0]);
return EXIT_FAILURE;
}
signal(SIGINT, sigHandler);
CLI::App AppMain{"Partition Manager Tool"}; CLI::App AppMain{"Partition Manager Tool"};
FunctionManager FuncManager; FunctionManager FuncManager;
@@ -77,13 +93,6 @@ int Main(int argc, char **argv) {
AppMain.add_flag("-v,--version", Variables->viewVersion, AppMain.add_flag("-v,--version", Variables->viewVersion,
"Print version and exit"); "Print version and exit");
if (argc < 2) {
println(
"Usage: %s [OPTIONS] [SUBCOMMAND]\nUse --help for more information.",
argv[0]);
return EXIT_FAILURE;
}
FuncManager.registerFunction(std::make_unique<backupFunction>(), AppMain); FuncManager.registerFunction(std::make_unique<backupFunction>(), AppMain);
FuncManager.registerFunction(std::make_unique<flashFunction>(), AppMain); FuncManager.registerFunction(std::make_unique<flashFunction>(), AppMain);
FuncManager.registerFunction(std::make_unique<eraseFunction>(), AppMain); FuncManager.registerFunction(std::make_unique<eraseFunction>(), AppMain);

View File

@@ -42,7 +42,7 @@ struct _entry {
* The main type of the library. The Builder class is designed * The main type of the library. The Builder class is designed
* to be easily manipulated and modified only on this class. * to be easily manipulated and modified only on this class.
*/ */
class basic_partition_map final { class basic_partition_map {
private: private:
void _resize_map(); void _resize_map();