pmt: add interrupt signal handler etc.
This commit is contained in:
12
manager.sh
12
manager.sh
@@ -39,9 +39,9 @@ select_variant()
|
||||
if getprop ro.product.cpu.abi | grep "arm64-v8a" &>/dev/null; then ARCH="arm64-v8a";
|
||||
else ARCH="armeabi-v7a"
|
||||
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()
|
||||
@@ -105,15 +105,15 @@ case $1 in
|
||||
is_installed
|
||||
checks
|
||||
select_variant $(grep "static" <<< $2 &>/dev/null && echo static)
|
||||
download
|
||||
setup
|
||||
download
|
||||
setup
|
||||
;;
|
||||
"uninstall")
|
||||
uninstall && echo "Uninstalled successfully."
|
||||
;;
|
||||
"reinstall")
|
||||
uninstall
|
||||
checks
|
||||
uninstall
|
||||
checks
|
||||
select_variant $(grep "static" <<< $2 &>/dev/null && echo static)
|
||||
download
|
||||
setup
|
||||
|
||||
@@ -16,12 +16,13 @@
|
||||
|
||||
#include "functions/functions.hpp"
|
||||
#include <PartitionManager/PartitionManager.hpp>
|
||||
#include <unistd.h>
|
||||
#include <cstdarg>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <csignal>
|
||||
#include <generated/buildInfo.hpp>
|
||||
#include <string>
|
||||
#include <unistd.h>
|
||||
|
||||
namespace PartitionManager {
|
||||
|
||||
@@ -30,10 +31,16 @@ void init() {
|
||||
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>();
|
||||
|
||||
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),
|
||||
forceProcess(false) {
|
||||
try {
|
||||
@@ -45,6 +52,15 @@ basic_variables::basic_variables()
|
||||
int Main(int argc, char **argv) {
|
||||
try {
|
||||
// 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"};
|
||||
FunctionManager FuncManager;
|
||||
|
||||
@@ -77,13 +93,6 @@ int Main(int argc, char **argv) {
|
||||
AppMain.add_flag("-v,--version", Variables->viewVersion,
|
||||
"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<flashFunction>(), AppMain);
|
||||
FuncManager.registerFunction(std::make_unique<eraseFunction>(), AppMain);
|
||||
|
||||
@@ -42,7 +42,7 @@ struct _entry {
|
||||
* The main type of the library. The Builder class is designed
|
||||
* to be easily manipulated and modified only on this class.
|
||||
*/
|
||||
class basic_partition_map final {
|
||||
class basic_partition_map {
|
||||
private:
|
||||
void _resize_map();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user