pmt: initial 2.3.0 update
Delete jni/Makefile
This commit is contained in:
11
CHANGELOG.md
11
CHANGELOG.md
@@ -1,11 +0,0 @@
|
|||||||
### Version 2.1.0 (code 210) changelog
|
|
||||||
- The main usage structure has been changed.
|
|
||||||
- A more organized and functional code was provided. For example, separate values were not used for the same type of control all the time. Everything was done with a single function.
|
|
||||||
- Smoother error processing was performed.
|
|
||||||
- There were a lot of arguments, it was cleared up. So the usage change I mentioned above has occurred.
|
|
||||||
- The exit codes were organized according to the sysexits library.
|
|
||||||
- Better deb builder script.
|
|
||||||
- In short, a lot of missing and errors that happened in 2.0.0 have been fixed
|
|
||||||
|
|
||||||
| END OF VERSION 2.1.0 CHANGELOG |
|
|
||||||
|------------------------------------|
|
|
||||||
97
README.md
97
README.md
@@ -1,97 +0,0 @@
|
|||||||
## Partition Manager (pmt)
|
|
||||||
|
|
||||||
This binary C is for manage partitions of android devices.
|
|
||||||
It offers a lot of options. I will place these below. But first let me talk about the operation...
|
|
||||||
|
|
||||||
#### Presented arguments (options)
|
|
||||||
|
|
||||||
```
|
|
||||||
Usage:
|
|
||||||
pmt backup PARTITION [OUTPUT] [OPTIONS]...
|
|
||||||
pmt flash FILE PARTITION [OPTIONS]...
|
|
||||||
pmt format FILE_SYSTEM[ext/2/3/4] PARTITION [OPTIONS]...
|
|
||||||
|
|
||||||
Options:
|
|
||||||
-l | --logical it is meant to determine whether the target partition is logical
|
|
||||||
-c | --context it is meant to specify a custom /dev context. Only classic partitions (default: /dev/block/by-name)
|
|
||||||
-p | --list list partitions
|
|
||||||
-s | --silent information and warning messages are silenced in normal work.
|
|
||||||
-f | --force force mode. Error messages are silenced and some things are ignored.
|
|
||||||
-v | --version see version
|
|
||||||
--help see help message
|
|
||||||
-L | --license see license
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
pmt backup boot_a -c /dev/block/platform/bootdevice/by-name
|
|
||||||
pmt flash /sdcard/twrp/boot.img boot_a -c /dev/block/platform/bootdevice/by-name
|
|
||||||
pmt format ext4 system_a --logical
|
|
||||||
pmt -c /dev/block/platform/bootdevice/by-name --list
|
|
||||||
|
|
||||||
Report bugs to <t.me/YZBruh>
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Some notes
|
|
||||||
|
|
||||||
- Feel free to ask any questions you want.
|
|
||||||
- Packages are available in publications.
|
|
||||||
- If the logical partition flag is not used, a classic partition is tried to be processing by default.
|
|
||||||
- [Click to see special version changes](https://github.com/YZBruh/pbt/blob/2.1.0-en/CHANGELOG.md)
|
|
||||||
- Let me know your suggestions!
|
|
||||||
|
|
||||||
### How is it built?
|
|
||||||
Android NDK is required to build.
|
|
||||||
- [Download](https://developer.android.com/ndk/downloads) and extract the NDK package.
|
|
||||||
- Clone this repository. And get access to it.
|
|
||||||
```
|
|
||||||
git clone https://github.com/YZBruh/pbt -b 2.1.0 ./pmt
|
|
||||||
cd pmt
|
|
||||||
```
|
|
||||||
- Set the NDK working directory variable.
|
|
||||||
```
|
|
||||||
export NDK_PROJECT_PATH=$(pwd)
|
|
||||||
```
|
|
||||||
- Go to the NDK directory and start the construction
|
|
||||||
```
|
|
||||||
./ndk-build
|
|
||||||
```
|
|
||||||
- The output files will be inside the `pmt` folder. Binaries are available in two architectures within the `libs` folder. `arm64-v8a` (64-bit) and `armeabi-v7a` (32-bit).
|
|
||||||
```
|
|
||||||
pmt/
|
|
||||||
|
|
|
||||||
________________|________________
|
|
||||||
| | | |
|
|
||||||
jni/ debutils/ obj/ libs/
|
|
||||||
|
|
|
||||||
__________|__________
|
|
||||||
| |
|
|
||||||
arm64-v8a/ armeabi-v7a/
|
|
||||||
| |
|
|
||||||
pmt pmt
|
|
||||||
```
|
|
||||||
- For the make installable debian package make-deb.sh use the script. It can be created within two architectures. Use the script flags correctly: arm64-v8a, armeabi-v7a. If you want to process with root, add sudo as the second argument. If you don't want, use no-sudo or leave it blank
|
|
||||||
|
|
||||||
```
|
|
||||||
--Usage--
|
|
||||||
|
|
||||||
./make-deb.sh [arm64-v8a, armeabi-v7a] [sudo, no-sudo, <blank>]
|
|
||||||
```
|
|
||||||
|
|
||||||
```
|
|
||||||
chmod 777 make-deb.sh
|
|
||||||
|
|
||||||
# for making 64-bit package
|
|
||||||
./make-deb.sh arm64-v8a
|
|
||||||
|
|
||||||
# for making 32-bit package
|
|
||||||
./make-deb.sh armeabi-v7a
|
|
||||||
```
|
|
||||||
|
|
||||||
### Easy install on termux
|
|
||||||
- Just execute this command in termux:
|
|
||||||
```shell
|
|
||||||
curl -LSs "https://raw.githubusercontent.com/YZBruh/pbt/2.1.0/install-termux.sh" | bash -
|
|
||||||
```
|
|
||||||
|
|
||||||
### Notes
|
|
||||||
If you want to change something, take a look at the configuration. You can change him.
|
|
||||||
it is located in the `jni/config` folder. His name is `env.mk`. I gave the information in the file. You can ask more.
|
|
||||||
Binary file not shown.
@@ -1,62 +0,0 @@
|
|||||||
#!/data/data/com.termux/files/usr/bin/env bash
|
|
||||||
#
|
|
||||||
# By YZBruh
|
|
||||||
#
|
|
||||||
|
|
||||||
VERSION="2.1.0"
|
|
||||||
CUR_DIR="$(pwd)"
|
|
||||||
TMP_DIR="${CUR_DIR}/tempinstall"
|
|
||||||
TERMUX_BIN_PREFIX="/data/data/com.termux/files/usr/bin"
|
|
||||||
UNAME="$(uname -m)"
|
|
||||||
|
|
||||||
abort()
|
|
||||||
{
|
|
||||||
rm -rf "${TMP_DIR}"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
echo " ------------ pmt installer ------------"
|
|
||||||
|
|
||||||
if [[ "${UNAME}" == "aarch64" ]] || [[ "${UNAME}" == "armv8a" ]]; then
|
|
||||||
ARCH="aarch64"
|
|
||||||
elif [[ "${UNAME}" == "aarch32" ]] || [[ "${UNAME}" == "armv7a" ]]; then
|
|
||||||
ARCH="armv7a"
|
|
||||||
SUB_PREF="eabi"
|
|
||||||
else
|
|
||||||
echo " - Unsupported arch: ${UNAME}!"
|
|
||||||
abort
|
|
||||||
fi
|
|
||||||
|
|
||||||
REL_LINK="https://github.com/YZBruh/pbt/releases/download/${VERSION}/pmt-${ARCH}-linux-android${SUB_PREF}.xz"
|
|
||||||
|
|
||||||
if [ -f "${TERMUX_BIN_PREFIX}/pmt" ]; then
|
|
||||||
echo " - pmt already installed."
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -f "${TERMUX_BIN_PREFIX}/wget" ]; then
|
|
||||||
echo " - Installing wget..."
|
|
||||||
pkg update || abort
|
|
||||||
pkg install wget || abort
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo " - Downloading latest version of package..."
|
|
||||||
|
|
||||||
mkdir -p "${TMP_DIR}" || abort
|
|
||||||
wget -q -P "${TMP_DIR}" "${REL_LINK}" || abort
|
|
||||||
|
|
||||||
echo " - Extracting downloaded package..."
|
|
||||||
|
|
||||||
cd "${TMP_DIR}" || abort
|
|
||||||
xz -d *.xz || abort
|
|
||||||
cd "${CUR_DIR}" || abort
|
|
||||||
|
|
||||||
echo " - Installing..."
|
|
||||||
|
|
||||||
cp "${TMP_DIR}/pmt-${ARCH}-linux-android${SUB_PREF}" "${TERMUX_BIN_PREFIX}/pmt" || abort
|
|
||||||
chmod 777 "${TERMUX_BIN_PREFIX}/pmt" || abort
|
|
||||||
rm -rf "${TMP_DIR}" || abort
|
|
||||||
|
|
||||||
echo -e " - Success.\n"
|
|
||||||
|
|
||||||
# end of script
|
|
||||||
@@ -15,34 +15,62 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
LOCAL_PATH := $(call my-dir)
|
LOCAL_PATH := $(call my-dir)
|
||||||
ENVCONF := $(LOCAL_PATH)/config/env.mk
|
|
||||||
|
include $(LOCAL_PATH)/config/env.mk
|
||||||
|
|
||||||
|
ifeq ($(ENABLE_DEBUGGING), true)
|
||||||
|
PMT_CFLAGS := -O3 -g -Wall -Wextra $(EXTRA_COMPILER_FLAGS)
|
||||||
|
else ifeq ($(ENABLE_DEBUGGING), false)
|
||||||
|
PMT_CFLAGS := -O3 -Wall $(EXTRA_COMPILER_FLAGS)
|
||||||
|
else
|
||||||
|
$(warning Unknown debugging flag: $(ENABLE_DEBUGGING). Please see: $(PREDIR)/config/env.mk. Using non-debugging flags)
|
||||||
|
PMT_CFLAGS := -O3 -Wall $(EXTRA_COMPILER_FLAGS)
|
||||||
|
endif
|
||||||
|
|
||||||
include $(CLEAR_VARS)
|
include $(CLEAR_VARS)
|
||||||
include $(ENVCONF)
|
|
||||||
|
|
||||||
# configration
|
LOCAL_MODULE := libpmt_root
|
||||||
LOCAL_MODULE = pmt
|
LOCAL_SRC_FILES := root.c
|
||||||
LOCAL_SRC_FILES = \
|
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
|
||||||
|
LOCAL_CFLAGS := $(PMT_CFLAGS)
|
||||||
|
|
||||||
|
include $(BUILD_STATIC_LIBRARY)
|
||||||
|
|
||||||
|
include $(CLEAR_VARS)
|
||||||
|
|
||||||
|
LOCAL_MODULE := libpmt_partitiontool
|
||||||
|
LOCAL_SRC_FILES := partition_tool.c
|
||||||
|
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
|
||||||
|
LOCAL_CFLAGS := $(PMT_CFLAGS)
|
||||||
|
|
||||||
|
include $(BUILD_STATIC_LIBRARY)
|
||||||
|
|
||||||
|
include $(CLEAR_VARS)
|
||||||
|
|
||||||
|
LOCAL_MODULE := libpmt_list
|
||||||
|
LOCAL_SRC_FILES := listpart.c
|
||||||
|
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
|
||||||
|
LOCAL_CFLAGS := $(PMT_CFLAGS)
|
||||||
|
|
||||||
|
include $(BUILD_STATIC_LIBRARY)
|
||||||
|
|
||||||
|
include $(CLEAR_VARS)
|
||||||
|
|
||||||
|
LOCAL_MODULE := pmt
|
||||||
|
LOCAL_SRC_FILES := \
|
||||||
pmt.c \
|
pmt.c \
|
||||||
versioner.c \
|
versioner.c \
|
||||||
tools.c \
|
tools.c \
|
||||||
partition_tool.c \
|
error.c \
|
||||||
root.c \
|
lang_tools.c \
|
||||||
listpart.c \
|
languages.c \
|
||||||
docs.c
|
docs.c
|
||||||
|
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
|
||||||
# include dirs
|
LOCAL_STATIC_LIBRARIES := \
|
||||||
LOCAL_C_INCLUDES = $(LOCAL_PATH)/include
|
libpmt_root \
|
||||||
|
libpmt_partitiontool \
|
||||||
# compiler flags settings
|
libpmt_list
|
||||||
ifeq ($(ENABLE_DEBUGGING), true)
|
LOCAL_CFLAGS := $(PMT_CFLAGS)
|
||||||
LOCAL_CFLAGS = -O3 -g -Wall -Wextra $(EXTRA_COMPILER_FLAGS)
|
|
||||||
else ifeq ($(ENABLE_DEBUGGING), false)
|
|
||||||
LOCAL_CFLAGS = -O3 -Wall $(EXTRA_COMPILER_FLAGS)
|
|
||||||
else
|
|
||||||
$(warning Unknown debugging flag: $(ENABLE_DEBUGGING). Please see: $(PREDIR)/config/env.mk. Using non-debugging flags)
|
|
||||||
LOCAL_CFLAGS = -O3 -Wall $(EXTRA_COMPILER_FLAGS)
|
|
||||||
endif
|
|
||||||
|
|
||||||
include $(BUILD_EXECUTABLE)
|
include $(BUILD_EXECUTABLE)
|
||||||
|
|
||||||
|
|||||||
52
jni/docs.c
52
jni/docs.c
@@ -20,10 +20,27 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#define INC_MAIN_LIBS
|
||||||
#include <pmt-docs.h>
|
#define INC_DOCS_REQS
|
||||||
|
|
||||||
|
#include <pmt.h>
|
||||||
|
|
||||||
extern char* bin_name;
|
extern char* bin_name;
|
||||||
|
extern char* pmt_langdb_langs_docs[];
|
||||||
|
|
||||||
|
struct pmt_langdb_docs* curr_docs = NULL;
|
||||||
|
extern struct pmt_langdb_docs en_docs;
|
||||||
|
extern struct pmt_langdb_docs tr_docs;
|
||||||
|
|
||||||
|
static void
|
||||||
|
prepare_langconf_docs(void)
|
||||||
|
{
|
||||||
|
static char* langctrl_str;
|
||||||
|
langctrl_str = loadlang();
|
||||||
|
|
||||||
|
if (strcmp(langctrl_str, "en") == 0) curr_docs = &en_docs;
|
||||||
|
else if (strcmp(langctrl_str, "tr") == 0) curr_docs = &tr_docs;
|
||||||
|
}
|
||||||
|
|
||||||
void licenses(void)
|
void licenses(void)
|
||||||
{
|
{
|
||||||
@@ -40,25 +57,26 @@ void licenses(void)
|
|||||||
|
|
||||||
void help(void)
|
void help(void)
|
||||||
{
|
{
|
||||||
printf("Usage: \n");
|
prepare_langconf_docs();
|
||||||
printf(" %s backup PARTITION [OUTPUT] [OPTIONS]...\n", bin_name);
|
printf("%s: %s %s\n", curr_docs->usage_docstr, bin_name, curr_docs->docs_strs_l1);
|
||||||
printf(" %s flash FILE PARTITION [OPTIONS]...\n", bin_name);
|
printf(" %s: %s %s\n", curr_docs->or_str, bin_name, curr_docs->docs_strs_l2);
|
||||||
printf(" %s format FILE_SYSTEM[ext/2/3/4] PARTITION [OPTIONS]...\n\n", bin_name);
|
printf(" %s: %s %s\n\n", curr_docs->or_str, bin_name, curr_docs->docs_strs_l3);
|
||||||
printf("Options: \n");
|
printf("%s: \n", curr_docs->docs_strs_l4);
|
||||||
printf(" -l | --logical it is meant to determine whether the target partition is logical\n");
|
printf(" -l, --logical %s\n", curr_docs->docs_strs_l5);
|
||||||
printf(" -c | --context it is meant to specify a custom /dev context. Only classic partitions (default: /dev/block/by-name)\n");
|
printf(" -c, --context %s\n", curr_docs->docs_strs_l6);
|
||||||
printf(" -p | --list list partitions\n");
|
printf(" -p, --list %s\n", curr_docs->docs_strs_l7);
|
||||||
printf(" -s | --silent information and warning messages are silenced in normal work.\n");
|
printf(" -s, --silent %s\n", curr_docs->docs_strs_l8);
|
||||||
printf(" -f | --force force mode. Error messages are silenced and some things are ignored.\n");
|
printf(" -f, --force %s\n", curr_docs->docs_strs_l9);
|
||||||
printf(" -v | --version see version\n");
|
printf(" -S, --set-lang %s\n", curr_docs->docs_strs_l10);
|
||||||
printf(" --help see help message\n");
|
printf(" -v, --version %s\n", curr_docs->docs_strs_l11);
|
||||||
printf(" -L | --license see license\n\n");
|
printf(" --help %s\n", curr_docs->docs_strs_l12);
|
||||||
printf("Examples:\n");
|
printf(" -L, --license %s\n\n", curr_docs->docs_strs_l13);
|
||||||
|
printf("%s:\n", curr_docs->docs_strs_l14);
|
||||||
printf(" %s backup boot_a -c /dev/block/platform/bootdevice/by-name\n", bin_name);
|
printf(" %s backup boot_a -c /dev/block/platform/bootdevice/by-name\n", bin_name);
|
||||||
printf(" %s flash /sdcard/twrp/boot.img boot_a -c /dev/block/platform/bootdevice/by-name\n", bin_name);
|
printf(" %s flash /sdcard/twrp/boot.img boot_a -c /dev/block/platform/bootdevice/by-name\n", bin_name);
|
||||||
printf(" %s format ext4 system_a --logical\n", bin_name);
|
printf(" %s format ext4 system_a --logical\n", bin_name);
|
||||||
printf(" %s -c /dev/block/platform/bootdevice/by-name --list\n\n", bin_name);
|
printf(" %s -c /dev/block/platform/bootdevice/by-name --list\n\n", bin_name);
|
||||||
printf("Report bugs to <t.me/YZBruh>\n");
|
printf("%s <t.me/YZBruh>\n", curr_docs->docs_strs_l15);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
|
|||||||
42
jni/error.c
Executable file
42
jni/error.c
Executable file
@@ -0,0 +1,42 @@
|
|||||||
|
/* By YZBruh */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copyright 2024 Partition Manager
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
#define INC_MAIN_LIBS
|
||||||
|
|
||||||
|
#include <pmt.h>
|
||||||
|
|
||||||
|
__noreturn void error(int __status, const char* _Nullable __fmt, ...)
|
||||||
|
{
|
||||||
|
if (__fmt == NULL) exit(__status);
|
||||||
|
|
||||||
|
va_list err_args;
|
||||||
|
va_start(err_args, __fmt);
|
||||||
|
fprintf(stderr, "%s: ", bin_name);
|
||||||
|
vfprintf(stderr, __fmt, err_args);
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
va_end(err_args);
|
||||||
|
exit(__status);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
}
|
||||||
|
#endif /* __cplusplus */
|
||||||
103
jni/include/pmt-stringkeys.h
Executable file
103
jni/include/pmt-stringkeys.h
Executable file
@@ -0,0 +1,103 @@
|
|||||||
|
/* By YZBruh */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copyright 2024 Partition Manager
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if !defined(__PMT_STRINGKEYS_)
|
||||||
|
#define __PMT_STRINGKEYS_
|
||||||
|
|
||||||
|
__BEGIN_DECLS
|
||||||
|
|
||||||
|
/* The struct is a very good option for setting the languages of texts etc. */
|
||||||
|
struct pmt_langdb_general {
|
||||||
|
const char* _Nonnull lang_by_s;
|
||||||
|
const char* _Nonnull language;
|
||||||
|
const char* _Nonnull lang_prefix;
|
||||||
|
const char* _Nonnull not_logical;
|
||||||
|
const char* _Nonnull not_file;
|
||||||
|
const char* _Nonnull not_dir;
|
||||||
|
const char* _Nonnull not_in_dev;
|
||||||
|
const char* _Nonnull not_open;
|
||||||
|
const char* _Nonnull not_block;
|
||||||
|
const char* _Nonnull not_read;
|
||||||
|
const char* _Nonnull not_write;
|
||||||
|
const char* _Nonnull not_gen;
|
||||||
|
const char* _Nonnull no_root;
|
||||||
|
const char* _Nonnull no_target;
|
||||||
|
const char* _Nonnull expected_backup_arg;
|
||||||
|
const char* _Nonnull expected_flash_arg;
|
||||||
|
const char* _Nonnull expected_format_arg;
|
||||||
|
const char* _Nonnull missing_operand;
|
||||||
|
const char* _Nonnull multiple_wiewers;
|
||||||
|
const char* _Nonnull common_symbol_rule;
|
||||||
|
const char* _Nonnull req_part_name;
|
||||||
|
const char* _Nonnull part_not_found;
|
||||||
|
const char* _Nonnull unsupported_fs;
|
||||||
|
const char* _Nonnull cannot_stat;
|
||||||
|
const char* _Nonnull ffile_more_part;
|
||||||
|
const char* _Nonnull cannot_get_bsz;
|
||||||
|
const char* _Nonnull format_fail;
|
||||||
|
const char* _Nonnull logical_warn;
|
||||||
|
const char* _Nonnull ab_warn;
|
||||||
|
const char* _Nonnull out_not_spec;
|
||||||
|
const char* _Nonnull please_rerun;
|
||||||
|
const char* _Nonnull part_disk_sz;
|
||||||
|
const char* _Nonnull flash_file_sz;
|
||||||
|
const char* _Nonnull part_disk_sz_fail;
|
||||||
|
const char* _Nonnull flash_file_sz_fail;
|
||||||
|
const char* _Nonnull list_of_dir;
|
||||||
|
const char* _Nonnull see_license;
|
||||||
|
const char* _Nonnull success_backup;
|
||||||
|
const char* _Nonnull success_flash;
|
||||||
|
const char* _Nonnull switching_lang;
|
||||||
|
const char* _Nonnull welcome;
|
||||||
|
const char* _Nullable welcome_;
|
||||||
|
const char* _Nonnull for_more;
|
||||||
|
const char* _Nonnull try_h;
|
||||||
|
const char* _Nonnull usage_head;
|
||||||
|
const char* _Nonnull compiler_str;
|
||||||
|
const char* _Nonnull version_str;
|
||||||
|
const char* _Nonnull bin_str;
|
||||||
|
const char* _Nonnull unknw_str;
|
||||||
|
const char* _Nonnull by_str;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* docs, licenses etc. */
|
||||||
|
struct pmt_langdb_docs {
|
||||||
|
const char* _Nonnull docs_strs_l1;
|
||||||
|
const char* _Nonnull docs_strs_l2;
|
||||||
|
const char* _Nonnull docs_strs_l3;
|
||||||
|
const char* _Nonnull docs_strs_l4;
|
||||||
|
const char* _Nonnull docs_strs_l5;
|
||||||
|
const char* _Nonnull docs_strs_l6;
|
||||||
|
const char* _Nonnull docs_strs_l7;
|
||||||
|
const char* _Nonnull docs_strs_l8;
|
||||||
|
const char* _Nonnull docs_strs_l9;
|
||||||
|
const char* _Nonnull docs_strs_l10;
|
||||||
|
const char* _Nonnull docs_strs_l11;
|
||||||
|
const char* _Nonnull docs_strs_l12;
|
||||||
|
const char* _Nonnull docs_strs_l13;
|
||||||
|
const char* _Nonnull docs_strs_l14;
|
||||||
|
const char* _Nonnull docs_strs_l15;
|
||||||
|
const char* _Nonnull or_str;
|
||||||
|
const char* _Nonnull usage_docstr;
|
||||||
|
};
|
||||||
|
|
||||||
|
__END_DECLS
|
||||||
|
|
||||||
|
#endif /* __PMT_STRINGKEYS_ */
|
||||||
|
|
||||||
|
/* end of code */
|
||||||
@@ -20,7 +20,7 @@ __BEGIN_DECLS
|
|||||||
|
|
||||||
/* versioning */
|
/* versioning */
|
||||||
#define PMT_MAJOR 2
|
#define PMT_MAJOR 2
|
||||||
#define PMT_MINOR 1
|
#define PMT_MINOR 3
|
||||||
#define PMT_PATCHLEVEL 0
|
#define PMT_PATCHLEVEL 0
|
||||||
|
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
|
|||||||
@@ -16,27 +16,71 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
#if !defined(__PMT_H_)
|
#if !defined(__PMT_H_)
|
||||||
#define __PMT_H_
|
#define __PMT_H_
|
||||||
|
|
||||||
/* some definations */
|
|
||||||
#define ANSI_RED "\033[31m"
|
|
||||||
#define ANSI_YELLOW "\033[33m"
|
|
||||||
#define ANSI_GREEN "\033[32m"
|
|
||||||
#define ANSI_RESET "\033[0m"
|
|
||||||
|
|
||||||
#define PMT_PACKAGE_NAME "Partition Manager"
|
#define PMT_PACKAGE_NAME "Partition Manager"
|
||||||
|
|
||||||
|
#if defined(INC_MAIN_LIBS)
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <pmt-stringkeys.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(INC_GETOPT)
|
||||||
|
#include <getopt.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(INC_DIRENT)
|
||||||
|
#include <dirent.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(INC_STAT)
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(INC_DEBUGERS)
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
/* from <err.h>. Modified. */
|
||||||
|
__noreturn void error(int __status, const char* _Nullable __fmt, ...);
|
||||||
|
void warning(const char* _Nullable __fmt, ...) __printflike(1, 2);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(INC_PMT_LANGS)
|
||||||
|
#include <pmt-langs.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(INC_DOCS_REQS)
|
||||||
|
#include <pmt-docs.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(INC_VERSIONER_REQS)
|
||||||
|
#include <pmt-versioning.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(INC_TOOLS_REQS)
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <sys/statvfs.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/* variable definations */
|
/* variable definations */
|
||||||
extern char* out;
|
extern char* _Nullable out;
|
||||||
extern char* cust_cxt;
|
extern char* _Nullable cust_cxt;
|
||||||
extern char* target_partition;
|
extern char* _Nullable target_partition;
|
||||||
extern char* target_flash_file;
|
extern char* _Nullable target_flash_file;
|
||||||
extern char* format_fs;
|
extern char* _Nullable format_fs;
|
||||||
extern char* partition_type;
|
extern char* _Nullable partition_type;
|
||||||
extern char* bin_name;
|
extern char* _Nullable bin_name;
|
||||||
extern bool pmt_use_logical;
|
extern bool pmt_use_logical;
|
||||||
extern bool pmt_use_cust_cxt;
|
extern bool pmt_use_cust_cxt;
|
||||||
extern bool pmt_ab;
|
extern bool pmt_ab;
|
||||||
@@ -46,6 +90,15 @@ extern bool pmt_flash;
|
|||||||
extern bool pmt_backup;
|
extern bool pmt_backup;
|
||||||
extern bool pmt_format;
|
extern bool pmt_format;
|
||||||
extern bool pmt_force_mode;
|
extern bool pmt_force_mode;
|
||||||
|
extern bool pmt_inst_on_termux;
|
||||||
|
|
||||||
|
/* language struces configurations */
|
||||||
|
extern struct pmt_langdb_general* _Nullable current;
|
||||||
|
extern struct pmt_langdb_docs* _Nullable curr_docs;
|
||||||
|
extern struct pmt_langdb_general en;
|
||||||
|
extern struct pmt_langdb_general tr;
|
||||||
|
extern struct pmt_langdb_docs en_docs;
|
||||||
|
extern struct pmt_langdb_docs tr_docs;
|
||||||
|
|
||||||
/* function definations */
|
/* function definations */
|
||||||
int listpart(void);
|
int listpart(void);
|
||||||
@@ -53,8 +106,11 @@ void check_dev_point(void);
|
|||||||
void check_root(void);
|
void check_root(void);
|
||||||
int pmt(unsigned short progress_code);
|
int pmt(unsigned short progress_code);
|
||||||
void version(void);
|
void version(void);
|
||||||
|
void setlang(const char* _Nonnull lang);
|
||||||
|
int search_sls(void);
|
||||||
|
char* _Nonnull loadlang(void);
|
||||||
|
|
||||||
#endif /* __PMT_H_ */
|
#endif
|
||||||
|
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
|
|
||||||
|
|||||||
241
jni/lang_tools.c
Executable file
241
jni/lang_tools.c
Executable file
@@ -0,0 +1,241 @@
|
|||||||
|
/* By YZBruh */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copyright 2024 Partition Manager
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define INC_MAIN_LIBS
|
||||||
|
#define INC_DEBUGERS
|
||||||
|
#define INC_STAT
|
||||||
|
|
||||||
|
#include <pmt.h>
|
||||||
|
|
||||||
|
/* pmt's man doc file path on termux */
|
||||||
|
#define TERMUX_PMT_MANDOC "/data/data/com.termux/files/usr/share/man/man8/pmt.8.gz"
|
||||||
|
|
||||||
|
/* language configuration paths */
|
||||||
|
|
||||||
|
/* for termux */
|
||||||
|
#define TERMUX_PMTLANG_CONF "/data/data/com.termux/files/usr/etc/pmtlang.conf"
|
||||||
|
|
||||||
|
/* for internal storage */
|
||||||
|
#define INTRNL_PMTLANG_CONF "/sdcard/.pmtlang.conf"
|
||||||
|
|
||||||
|
/* shortcuts to check that language is changed */
|
||||||
|
|
||||||
|
/* for termux */
|
||||||
|
#define TERMUX_PMT_SW_POINT "/data/data/com.termux/files/usr/etc/pmtlangsw"
|
||||||
|
|
||||||
|
/* for internal storage */
|
||||||
|
#define INTRNL_PMT_SW_POINT "/sdcard/.pmtlangsw"
|
||||||
|
|
||||||
|
extern bool pmt_inst_on_termux;
|
||||||
|
extern char* bin_name;
|
||||||
|
extern char* pmt_langdb_langs[];
|
||||||
|
extern int pmt_langdb_total;
|
||||||
|
extern int pmt_langdb_ctrl;
|
||||||
|
|
||||||
|
FILE *langconf;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The target file is controlled by the stat function.
|
||||||
|
* Files, directories, links and blocks (disks) are for.
|
||||||
|
* If it is never found, it returns 1 value.
|
||||||
|
* If he finds 0 value is returned.
|
||||||
|
* If the desired type is not in -1 value is returned.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
search_stat(const char* _Nonnull filepath, const char* _Nonnull stype)
|
||||||
|
{
|
||||||
|
struct stat search_stat;
|
||||||
|
|
||||||
|
if (stat(filepath, &search_stat) != 0) return 1;
|
||||||
|
|
||||||
|
if (strcmp(stype, "dir") == 0)
|
||||||
|
{
|
||||||
|
if (S_ISDIR(search_stat.st_mode)) return 0;
|
||||||
|
else return -1;
|
||||||
|
}
|
||||||
|
else if (strcmp(stype, "file") == 0)
|
||||||
|
{
|
||||||
|
if (S_ISREG(search_stat.st_mode)) return 0;
|
||||||
|
else return -1;
|
||||||
|
}
|
||||||
|
else if (strcmp(stype, "blk") == 0)
|
||||||
|
{
|
||||||
|
if (S_ISBLK(search_stat.st_mode)) return 0;
|
||||||
|
else return -1;
|
||||||
|
}
|
||||||
|
else if (strcmp(stype, "link") == 0)
|
||||||
|
{
|
||||||
|
if (S_ISLNK(search_stat.st_mode)) return 0;
|
||||||
|
else return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
langctrl(const char* _Nonnull lang_)
|
||||||
|
{
|
||||||
|
if (strcmp(lang_, "en") == 0 || strcmp(lang_, "tr") == 0) return 0;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* loadlang(void)
|
||||||
|
{
|
||||||
|
static char lang_fpr[10] = "en";
|
||||||
|
langconf = NULL;
|
||||||
|
|
||||||
|
if (search_stat(TERMUX_PMT_MANDOC, "file") == 0) pmt_inst_on_termux = true;
|
||||||
|
|
||||||
|
if (pmt_inst_on_termux)
|
||||||
|
{
|
||||||
|
if (search_stat(TERMUX_PMTLANG_CONF, "file") == 0)
|
||||||
|
{
|
||||||
|
langconf = fopen(TERMUX_PMTLANG_CONF, "r+");
|
||||||
|
|
||||||
|
if (langconf == NULL)
|
||||||
|
{
|
||||||
|
langconf = fopen(TERMUX_PMTLANG_CONF, "w+");
|
||||||
|
|
||||||
|
if (langconf == NULL)
|
||||||
|
{
|
||||||
|
setlang("en");
|
||||||
|
return "en";
|
||||||
|
}
|
||||||
|
fclose(langconf);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while (fgets(lang_fpr, sizeof(lang_fpr), langconf) != NULL)
|
||||||
|
{
|
||||||
|
if (strcmp(lang_fpr, "en") == 0)
|
||||||
|
{
|
||||||
|
fclose(langconf);
|
||||||
|
return "en";
|
||||||
|
}
|
||||||
|
else if (strcmp(lang_fpr, "tr") == 0)
|
||||||
|
{
|
||||||
|
fclose(langconf);
|
||||||
|
return "tr";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose(langconf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (search_stat(INTRNL_PMTLANG_CONF, "file") == 0)
|
||||||
|
{
|
||||||
|
langconf = fopen(INTRNL_PMTLANG_CONF, "r");
|
||||||
|
|
||||||
|
if (langconf == NULL)
|
||||||
|
{
|
||||||
|
langconf = fopen(INTRNL_PMTLANG_CONF, "w+");
|
||||||
|
|
||||||
|
if (langconf == NULL)
|
||||||
|
{
|
||||||
|
setlang("en");
|
||||||
|
return "en";
|
||||||
|
}
|
||||||
|
fclose(langconf);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while (fgets(lang_fpr, sizeof(lang_fpr), langconf) != NULL)
|
||||||
|
{
|
||||||
|
if (strcmp(lang_fpr, "en") == 0)
|
||||||
|
{
|
||||||
|
fclose(langconf);
|
||||||
|
return "en";
|
||||||
|
}
|
||||||
|
else if (strcmp(lang_fpr, "tr") == 0)
|
||||||
|
{
|
||||||
|
fclose(langconf);
|
||||||
|
return "tr";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose(langconf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else return "en";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "en";
|
||||||
|
}
|
||||||
|
|
||||||
|
void setlang(const char* _Nonnull lang)
|
||||||
|
{
|
||||||
|
static char* lcf_path;
|
||||||
|
|
||||||
|
if (pmt_inst_on_termux) lcf_path = TERMUX_PMTLANG_CONF;
|
||||||
|
else lcf_path = INTRNL_PMTLANG_CONF;
|
||||||
|
|
||||||
|
if (search_stat(lcf_path, "file") == 0) remove(lcf_path);
|
||||||
|
|
||||||
|
langconf = NULL;
|
||||||
|
if (pmt_inst_on_termux) langconf = fopen(TERMUX_PMTLANG_CONF, "w");
|
||||||
|
else langconf = fopen(INTRNL_PMTLANG_CONF, "w");
|
||||||
|
|
||||||
|
if (langconf == NULL) error(1, "%s: Failed!!! Cannot open/write config file.\n", bin_name);
|
||||||
|
|
||||||
|
if (langctrl(lang) == 0)
|
||||||
|
{
|
||||||
|
if (fprintf(langconf, "%s", lang) < 2) error(1, "Failed!!! Couldn't write config!\n");
|
||||||
|
else fclose(langconf);
|
||||||
|
}
|
||||||
|
else error(1, "Unknown language: %s.", bin_name, lang);
|
||||||
|
|
||||||
|
static int status;
|
||||||
|
|
||||||
|
if (pmt_inst_on_termux)
|
||||||
|
{
|
||||||
|
status = open(TERMUX_PMT_SW_POINT, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
||||||
|
if (status == 0) close(status);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
status = open(INTRNL_PMT_SW_POINT, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
||||||
|
if (status == 0) close(status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int search_sls(void)
|
||||||
|
{
|
||||||
|
static char* sw_point_path;
|
||||||
|
|
||||||
|
if (pmt_inst_on_termux) sw_point_path = TERMUX_PMT_SW_POINT;
|
||||||
|
else sw_point_path = INTRNL_PMT_SW_POINT;
|
||||||
|
|
||||||
|
if (search_stat(sw_point_path, "file") == 0)
|
||||||
|
{
|
||||||
|
remove(sw_point_path);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* end of code */
|
||||||
185
jni/languages.c
Executable file
185
jni/languages.c
Executable file
@@ -0,0 +1,185 @@
|
|||||||
|
/* By YZBruh */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copyright 2024 Partition Manager
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define INC_MAIN_LIBS
|
||||||
|
|
||||||
|
#include <pmt.h>
|
||||||
|
|
||||||
|
struct pmt_langdb_general en = {
|
||||||
|
.lang_by_s = "YZBruh",
|
||||||
|
.language = "English",
|
||||||
|
.lang_prefix = "en",
|
||||||
|
.not_logical = "This device does not have logical partitions!",
|
||||||
|
.not_file = "is a not file.",
|
||||||
|
.not_dir = "is a not directory.",
|
||||||
|
.not_in_dev = "You're going through my wave? There's nothing about this /dev. Use force mode if you don't want this error.",
|
||||||
|
.not_open = "Could not open",
|
||||||
|
.not_block = "The specified partition is not the block. I mean, it's not actually an episode (disc). I'm sure it needs to applaud those mistakes.",
|
||||||
|
.not_read = "Couldn't read",
|
||||||
|
.not_write = "Couldn't write",
|
||||||
|
.not_gen = "Couldn't generate",
|
||||||
|
.no_root = "Root access could not be detected! Please run this binary with root.",
|
||||||
|
.no_target = "No target (backup, flash or format).",
|
||||||
|
.expected_backup_arg = "Expected backup argument 2 (1 of them are not mandatory), retrieved",
|
||||||
|
.expected_flash_arg = "Expected flash argument 2, retrieved",
|
||||||
|
.expected_format_arg = "Expected format argument 2, retrieved",
|
||||||
|
.missing_operand = "missing operand",
|
||||||
|
.multiple_wiewers = "Multiple wiewers cannot be used at the same line.",
|
||||||
|
.common_symbol_rule = "When entering the attached argument of an option, an argument of another option type cannot be used. In short, the rule is: there can be no '-' at the beginning of the attached argument.",
|
||||||
|
.req_part_name = "Required partition name.",
|
||||||
|
.part_not_found = "Partition not found!",
|
||||||
|
.unsupported_fs = "Formatter: unsupported filesystem",
|
||||||
|
.cannot_stat = "Cannot stat",
|
||||||
|
.ffile_more_part = "Size of the file to flash more than the partition size.",
|
||||||
|
.cannot_get_bsz = "The partition block size could not be obtained!",
|
||||||
|
.format_fail = "Formatting failed! There may be a chance that something has been damaged!",
|
||||||
|
.logical_warn = "Warning: device using logical partition type.",
|
||||||
|
.ab_warn = "Warning: device using A/B partition style.",
|
||||||
|
.out_not_spec = "Warning: The output file name was not specified. The output file name will be",
|
||||||
|
.please_rerun = "Please re run",
|
||||||
|
.part_disk_sz = "Disk size of the partition",
|
||||||
|
.flash_file_sz = "Size of flash file",
|
||||||
|
.part_disk_sz_fail = "Warning: failed to get target partition disk size",
|
||||||
|
.flash_file_sz_fail = "Warning: failed to get flash file size.",
|
||||||
|
.list_of_dir = "List of dir",
|
||||||
|
.see_license = "See licenses with -L argument.",
|
||||||
|
.success_backup = "Success. Output",
|
||||||
|
.success_flash = "Success.",
|
||||||
|
.switching_lang = "Switching language...",
|
||||||
|
.welcome = "language!",
|
||||||
|
.welcome_ = "Welcome to ",
|
||||||
|
.for_more = "for more information.",
|
||||||
|
.try_h = "Try",
|
||||||
|
.usage_head = "Usage",
|
||||||
|
.compiler_str = "Compiler",
|
||||||
|
.version_str = "version",
|
||||||
|
.bin_str = "binary",
|
||||||
|
.unknw_str = "unknown",
|
||||||
|
.by_str = "By"
|
||||||
|
};
|
||||||
|
|
||||||
|
struct pmt_langdb_general tr = {
|
||||||
|
.lang_by_s = "YZBruh",
|
||||||
|
.language = "Türkçe",
|
||||||
|
.lang_prefix = "tr",
|
||||||
|
.not_logical = "Bu cihaz mantıksal (logical) bölümlere sahip değil!",
|
||||||
|
.not_file = "Bu bir dosya değil",
|
||||||
|
.not_dir = "Bu bir dizin değil",
|
||||||
|
.not_in_dev = "Bu bir şakamı? Bunun /dev dizini ile bi r ilgisi yok (içermiyor). Bu hatayla karşılaşmak istemiyorsanız zorlama (force) modu kullanın.",
|
||||||
|
.not_open = "Açılamıyor",
|
||||||
|
.not_block = "Belirtilen bölüm bir blok değil. Yani aslında bu bir bölüm bile değil (disk). Bu hatayı almak için şanslı olmak gerek..!",
|
||||||
|
.not_read = "Veri okunamıyor",
|
||||||
|
.not_write = "Veri yazılamıyor",
|
||||||
|
.not_gen = "Oluşturulamıyor",
|
||||||
|
.no_root = "Root erişimi tespit edilemedi! Lütfen root erişimi ile çalıştırın.",
|
||||||
|
.no_target = "Hedef işlem yok (yedek, flaş veya format).",
|
||||||
|
.expected_backup_arg = "Beklenen yedekleme argümanı 2 (bir tanesi zorunlu değil), alınan",
|
||||||
|
.expected_flash_arg = "Beklenen flaş argümanı 2, alınan",
|
||||||
|
.expected_format_arg = "Beklenen format argümanı 2, alınan",
|
||||||
|
.missing_operand = "işlem belirtilmedi",
|
||||||
|
.multiple_wiewers = "Birden fazla görüntüleme işlemi yapan fonksiyonlar bir arada kullanılamaz. Aynı anda sadece bir tanesi kullanılabilir.",
|
||||||
|
.common_symbol_rule = "Bir seçeneğin argümanını verirken argüman önüne '-' sembolü getirilemez. Sembolü kaldırın ve tekrar deneyin.",
|
||||||
|
.req_part_name = "Bölüm adı gereklidir.",
|
||||||
|
.part_not_found = "Bölüm bulunamadı!",
|
||||||
|
.unsupported_fs = "Formatlayıcı: desteklenmeyen dosya sistemi:",
|
||||||
|
.cannot_stat = "Durumu tespit edilemedi",
|
||||||
|
.ffile_more_part = "Flaşlanacak dosyanın boyutu mevcut bölüm boyutundan fazla.",
|
||||||
|
.cannot_get_bsz = "Bölüm blok boyutu tespit edilemedi!",
|
||||||
|
.format_fail = "Formatlama başarısız oldu. Bazı şeyler zarar görmüş olabilir!",
|
||||||
|
.logical_warn = "Uyarı: bu cihaz mantıksal (logical) bölümlere sahip.",
|
||||||
|
.ab_warn = "Uyarı: bu cihazın bazı bölümleri A/B kullanıyor.",
|
||||||
|
.out_not_spec = "Uyarı: çıktı dosya belirtilmedi. Çıktı dosya adı bölüm adına göre belirlenecek.",
|
||||||
|
.please_rerun = "Lütfen yeniden çalıştırın",
|
||||||
|
.part_disk_sz = "Bölümün disk boyutu",
|
||||||
|
.flash_file_sz = "Flaşlanacak dosyanın boyutu",
|
||||||
|
.flash_file_sz_fail = "Uyarı: flaşlanacak dosyanın boyutu tespit edilemedi.",
|
||||||
|
.part_disk_sz_fail = "Uyarı: bölüm boyutunun boyutu tespit edilemedi.",
|
||||||
|
.list_of_dir = "Dizin içeriğinin listesi",
|
||||||
|
.see_license = "Lisansı -L seçeneği ile görüntüleyebilirsiniz.",
|
||||||
|
.success_backup = "Başarılı. Çıktı",
|
||||||
|
.success_flash = "Başarılı.",
|
||||||
|
.switching_lang = "Dil değiştiriliyor...",
|
||||||
|
.welcome = "diline hoş geldiniz!",
|
||||||
|
.welcome_ = NULL,
|
||||||
|
.for_more = "komutunu kullanabilirsiniz",
|
||||||
|
.try_h = "Daha fazla bilgi",
|
||||||
|
.usage_head = "Kullanımı",
|
||||||
|
.compiler_str = "Derleyici",
|
||||||
|
.version_str = "versiyon",
|
||||||
|
.bin_str = "yapı",
|
||||||
|
.unknw_str = "bilinmeyen",
|
||||||
|
.by_str = "Çeviriyi yapan(lar):"
|
||||||
|
};
|
||||||
|
|
||||||
|
struct pmt_langdb_docs en_docs = {
|
||||||
|
.docs_strs_l1 = "[OPTIONS] backup PARTITION [OUTPUT] [OPTIONS]...",
|
||||||
|
.docs_strs_l2 = "[OPTIONS] flash FILE PARTITION [OPTIONS]...",
|
||||||
|
.docs_strs_l3 = "[OPTIONS] format FILE_SYSTEM[ext/2/3/4] PARTITION [OPTIONS]...",
|
||||||
|
.docs_strs_l4 = "Options",
|
||||||
|
.docs_strs_l5 = "It is meant to determine whether the target partition is logical.",
|
||||||
|
.docs_strs_l6 = "It is meant to specify a custom /dev context. Only classic partitions (default: /dev/block/by-name).",
|
||||||
|
.docs_strs_l7 = "List partitions.",
|
||||||
|
.docs_strs_l8 = "Information and warning messages are silenced in normal work.",
|
||||||
|
.docs_strs_l9 = "Force mode. Some things are ignored.",
|
||||||
|
.docs_strs_l10 = "Set current language.",
|
||||||
|
.docs_strs_l11 = "See version.",
|
||||||
|
.docs_strs_l12 = "See this help message.",
|
||||||
|
.docs_strs_l13 = "See license.",
|
||||||
|
.docs_strs_l14 = "Examples",
|
||||||
|
.docs_strs_l15 = "Report bugs to",
|
||||||
|
.or_str = "or",
|
||||||
|
.usage_docstr = "Usage"
|
||||||
|
};
|
||||||
|
|
||||||
|
struct pmt_langdb_docs tr_docs = {
|
||||||
|
.docs_strs_l1 = "[SEÇENEKLER] backup BÖLÜM [ÇIKTI] [SEÇENEKLER]...",
|
||||||
|
.docs_strs_l2 = "[SEÇENEKLER] flash DOSYA BÖLÜM [SEÇENEKLER]...",
|
||||||
|
.docs_strs_l3 = "[SEÇENEKLER] format DOSYA_SİSTEMİ[ext/2/3/4] BÖLÜM [SEÇENEKLER]...",
|
||||||
|
.docs_strs_l4 = "Seçenekler",
|
||||||
|
.docs_strs_l5 = "Bu seçeneği kullanarak mantıksal (logical) bir bölümün yedekleneceğini belirtebilirsiniz.",
|
||||||
|
.docs_strs_l6 = "Bu seçeneği kullanarak özel /dev bağlamı belirtebilirsiniz. Sadece normal (mantıksal olmayan) bölümler içindir (Varsayılan: /dev/block/by-name).",
|
||||||
|
.docs_strs_l7 = "Bölümler listelenir.",
|
||||||
|
.docs_strs_l8 = "Bilgi ve uyarı mesajları susturulur.",
|
||||||
|
.docs_strs_l9 = "Zorlama modu. Bazı şeyler göz ardı edilir.",
|
||||||
|
.docs_strs_l10 = "Mevcut dili ayarlayın.",
|
||||||
|
.docs_strs_l11 = "Sürümü görüntüleyin.",
|
||||||
|
.docs_strs_l12 = "Bu yardım mesajını görüntüleyin.",
|
||||||
|
.docs_strs_l13 = "Lisansı gorüntüleyin.",
|
||||||
|
.docs_strs_l14 = "Örnekler",
|
||||||
|
.docs_strs_l15 = "Sorunları şu adrese bildirin:",
|
||||||
|
.or_str = "yada",
|
||||||
|
.usage_docstr = "Kullanımı"
|
||||||
|
};
|
||||||
|
|
||||||
|
char* pmt_langdb_langs[] = {
|
||||||
|
"en",
|
||||||
|
"tr"
|
||||||
|
};
|
||||||
|
|
||||||
|
int pmt_langdb_total = 2;
|
||||||
|
int pmt_langdb_ctrl = 1;
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* end of code */
|
||||||
110
jni/listpart.c
110
jni/listpart.c
@@ -20,17 +20,18 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#define INC_MAIN_LIBS
|
||||||
#include <stdlib.h>
|
#define INC_DEBUGERS
|
||||||
#include <unistd.h>
|
#define INC_DIRENT
|
||||||
#include <stdbool.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <err.h>
|
|
||||||
#include <sysexits.h>
|
|
||||||
#include <dirent.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <pmt.h>
|
#include <pmt.h>
|
||||||
|
|
||||||
|
/* current /dev context */
|
||||||
|
#define CUR_DEV_CNTX "/dev/block/by-name"
|
||||||
|
|
||||||
|
/* for logical partitions */
|
||||||
|
#define LGC_DEV_CNTX "/dev/block/mapper"
|
||||||
|
|
||||||
extern bool pmt_use_cust_cxt;
|
extern bool pmt_use_cust_cxt;
|
||||||
extern bool pmt_ab;
|
extern bool pmt_ab;
|
||||||
extern bool pmt_logical;
|
extern bool pmt_logical;
|
||||||
@@ -39,57 +40,80 @@ extern bool pmt_force_mode;
|
|||||||
extern char* cust_cxt;
|
extern char* cust_cxt;
|
||||||
extern char* bin_name;
|
extern char* bin_name;
|
||||||
|
|
||||||
/* list existing partitions */
|
extern struct pmt_langdb_general* current;
|
||||||
int listpart(void) {
|
extern struct pmt_langdb_general en;
|
||||||
DIR *dir;
|
extern struct pmt_langdb_general tr;
|
||||||
struct dirent *entry;
|
|
||||||
|
|
||||||
if (pmt_use_cust_cxt)
|
DIR *dir;
|
||||||
|
|
||||||
|
static int
|
||||||
|
list(const char* operation, const char* target_dir)
|
||||||
{
|
{
|
||||||
dir = opendir(cust_cxt);
|
static bool list = false;
|
||||||
if (dir == NULL)
|
struct dirent *entry;
|
||||||
|
dir = NULL;
|
||||||
|
|
||||||
|
if (strcmp(operation, "access") == 0) list = false;
|
||||||
|
else if (strcmp(operation, "print") == 0) list = true;
|
||||||
|
else return -1;
|
||||||
|
|
||||||
|
dir = opendir(target_dir);
|
||||||
|
if (dir != NULL)
|
||||||
{
|
{
|
||||||
if (!pmt_force_mode) errx(EX_OSFILE, "could not open: `%s': %s", cust_cxt, strerror(errno));
|
if (!list)
|
||||||
else return EX_OSFILE;
|
{
|
||||||
}
|
closedir(dir);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dir = opendir("/dev/block/by-name");
|
printf("%s: `%s'\n", current->list_of_dir, target_dir);
|
||||||
if (dir == NULL)
|
|
||||||
{
|
|
||||||
if (!pmt_force_mode) errx(EX_OSFILE, "could not open: `/dev/block/by-name': %s", strerror(errno));
|
|
||||||
else return EX_OSFILE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
while ((entry = readdir(dir)) != NULL) printf("%s\n", entry->d_name);
|
while ((entry = readdir(dir)) != NULL) printf("%s\n", entry->d_name);
|
||||||
|
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
dir = NULL;
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else return -1;
|
||||||
|
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* list existing partitions */
|
||||||
|
int listpart(void) {
|
||||||
|
if (pmt_use_cust_cxt)
|
||||||
|
{
|
||||||
|
if (list("access", cust_cxt) != 0)
|
||||||
|
{
|
||||||
|
if (!pmt_force_mode) error(1, "%s: `%s': %s", current->not_open, cust_cxt, strerror(errno));
|
||||||
|
else return 1;
|
||||||
|
}
|
||||||
|
else list("print", cust_cxt);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (list("access", CUR_DEV_CNTX) != 0)
|
||||||
|
{
|
||||||
|
if (!pmt_force_mode) error(1, "%s: `%s': %s", current->not_open, CUR_DEV_CNTX, strerror(errno));
|
||||||
|
else return 1;
|
||||||
|
}
|
||||||
|
else list("print", CUR_DEV_CNTX);
|
||||||
|
}
|
||||||
|
|
||||||
if (pmt_logical)
|
if (pmt_logical)
|
||||||
{
|
{
|
||||||
dir = opendir("/dev/block/mapper");
|
if (list("access", LGC_DEV_CNTX) != 0)
|
||||||
|
|
||||||
if (dir == NULL)
|
|
||||||
{
|
{
|
||||||
if (!pmt_silent) errx(EX_OSFILE, "could not open: `/dev/block/mapper': %s", strerror(errno));
|
if (!pmt_silent) error(1, "%s: `%s': %s", current->not_open, LGC_DEV_CNTX, strerror(errno));
|
||||||
else return EX_OSFILE;
|
else return 1;
|
||||||
}
|
}
|
||||||
else printf("List of logical partitions (`/dev/block/mapper'):\n");
|
else list("print", LGC_DEV_CNTX);
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((entry = readdir(dir)) != NULL) printf("%s\n", entry->d_name);
|
if (pmt_ab && !pmt_silent) printf("%s: %s\n", bin_name, current->ab_warn);
|
||||||
|
|
||||||
closedir(dir);
|
if (pmt_logical && !pmt_silent) printf("%s: %s\n", bin_name, current->logical_warn);
|
||||||
dir = NULL;
|
|
||||||
|
|
||||||
if (pmt_ab && !pmt_silent) warnx(ANSI_YELLOW "warning: device using A/B partition style." ANSI_RESET);
|
return 0;
|
||||||
|
|
||||||
if (pmt_logical && !pmt_silent) warnx(ANSI_YELLOW "warning: device using logical partition type." ANSI_RESET);
|
|
||||||
|
|
||||||
return EX_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
|
|||||||
@@ -20,10 +20,8 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdbool.h>
|
#define INC_MAIN_LIBS
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <pmt.h>
|
#include <pmt.h>
|
||||||
|
|
||||||
extern bool pmt_use_cust_cxt;
|
extern bool pmt_use_cust_cxt;
|
||||||
|
|||||||
223
jni/pmt.c
223
jni/pmt.c
@@ -21,19 +21,13 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* include needed libs (headers) */
|
#define INC_MAIN_LIBS
|
||||||
#include <stdio.h>
|
#define INC_DEBUGERS
|
||||||
#include <unistd.h>
|
#define INC_STAT
|
||||||
#include <stdlib.h>
|
#define INC_GETOPT
|
||||||
#include <sys/stat.h>
|
#define INC_DOCS_REQS
|
||||||
#include <string.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <getopt.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <err.h>
|
|
||||||
#include <sysexits.h>
|
|
||||||
#include <pmt.h>
|
#include <pmt.h>
|
||||||
#include <pmt-docs.h>
|
|
||||||
|
|
||||||
/* add value to variables that are added globally and are not worth */
|
/* add value to variables that are added globally and are not worth */
|
||||||
char* out = NULL;
|
char* out = NULL;
|
||||||
@@ -43,8 +37,8 @@ char* target_flash_file = NULL;
|
|||||||
char* partition_type = NULL;
|
char* partition_type = NULL;
|
||||||
char* format_fs = NULL;
|
char* format_fs = NULL;
|
||||||
char* bin_name = NULL;
|
char* bin_name = NULL;
|
||||||
bool pmt_use_logical = NULL;
|
bool pmt_use_logical = false;
|
||||||
bool pmt_use_cust_cxt = NULL;
|
bool pmt_use_cust_cxt = false;
|
||||||
bool pmt_ab = false;
|
bool pmt_ab = false;
|
||||||
bool pmt_logical = false;
|
bool pmt_logical = false;
|
||||||
bool pmt_silent = false;
|
bool pmt_silent = false;
|
||||||
@@ -52,10 +46,18 @@ bool pmt_flash = false;
|
|||||||
bool pmt_backup = false;
|
bool pmt_backup = false;
|
||||||
bool pmt_format = false;
|
bool pmt_format = false;
|
||||||
bool pmt_force_mode = false;
|
bool pmt_force_mode = false;
|
||||||
|
bool pmt_inst_on_termux = false;
|
||||||
|
|
||||||
/* variables for use in control of '-' expression */
|
/* import language structs etc. */
|
||||||
|
struct pmt_langdb_general* current = NULL;
|
||||||
|
extern struct pmt_langdb_general en;
|
||||||
|
extern struct pmt_langdb_general tr;
|
||||||
|
extern const char* pmt_langdb_langs[];
|
||||||
|
extern int pmt_langdb_total;
|
||||||
|
|
||||||
|
/* variable for use in control of '-' expression */
|
||||||
static const char* opt_symbol = "-";
|
static const char* opt_symbol = "-";
|
||||||
static const char* common_symbol_rule = "When entering the attached argument of an option, an argument of another option type cannot be used. In short, the rule is: there can be no '-' at the beginning of the attached argument.";
|
static char common_symbol_rule[350];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* He controls whether the '-' sign at
|
* He controls whether the '-' sign at
|
||||||
@@ -66,8 +68,8 @@ check_optsym(const char* _Nonnull mystring)
|
|||||||
{
|
{
|
||||||
if (strncmp(mystring, opt_symbol, 1) == 0)
|
if (strncmp(mystring, opt_symbol, 1) == 0)
|
||||||
{
|
{
|
||||||
if (!pmt_force_mode) errx(EX_USAGE, "%s", common_symbol_rule);
|
if (!pmt_force_mode) error(1, "%s", common_symbol_rule);
|
||||||
else exit(EX_USAGE);
|
else exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,7 +85,7 @@ search_stat(const char* _Nonnull filepath, const char* _Nonnull stype)
|
|||||||
{
|
{
|
||||||
struct stat search_stat;
|
struct stat search_stat;
|
||||||
|
|
||||||
if (stat(filepath, &search_stat) != 0) return 1;
|
if (stat(filepath, &search_stat) != 0) return 0;
|
||||||
|
|
||||||
if (strcmp(stype, "dir") == 0)
|
if (strcmp(stype, "dir") == 0)
|
||||||
{
|
{
|
||||||
@@ -112,11 +114,26 @@ search_stat(const char* _Nonnull filepath, const char* _Nonnull stype)
|
|||||||
/* classic main function (C binary here xd) */
|
/* classic main function (C binary here xd) */
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
/* check argument total */
|
|
||||||
if (argc < 2) errx(EX_USAGE, "missing operand\nTry `%s --help' for more information.", argv[0]);
|
|
||||||
|
|
||||||
bin_name = argv[0];
|
bin_name = argv[0];
|
||||||
|
|
||||||
|
/* load language */
|
||||||
|
static char* langctrl_str;
|
||||||
|
langctrl_str = loadlang();
|
||||||
|
|
||||||
|
if (strcmp(langctrl_str, "en") == 0) current = &en;
|
||||||
|
else if (strcmp(langctrl_str, "tr") == 0) current = &tr;
|
||||||
|
|
||||||
|
sprintf(common_symbol_rule, "%s\n", current->common_symbol_rule);
|
||||||
|
|
||||||
|
if (search_sls() == 0)
|
||||||
|
{
|
||||||
|
if (current->welcome_ != NULL) printf("%s", current->welcome_);
|
||||||
|
printf("%s %s %s %s.\n", current->language, current->welcome, current->by_str, current->lang_by_s);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check argument total */
|
||||||
|
if (argc < 2) error(1, "%s\n%s `%s --help' %s.", current->missing_operand, current->try_h, argv[0], current->for_more);
|
||||||
|
|
||||||
/* a structure for long arguments */
|
/* a structure for long arguments */
|
||||||
struct option long_options[] = {
|
struct option long_options[] = {
|
||||||
{"logical", no_argument, 0, 'l'},
|
{"logical", no_argument, 0, 'l'},
|
||||||
@@ -124,6 +141,7 @@ int main(int argc, char* argv[])
|
|||||||
{"list", no_argument, 0, 'p'},
|
{"list", no_argument, 0, 'p'},
|
||||||
{"silent", no_argument, 0, 's'},
|
{"silent", no_argument, 0, 's'},
|
||||||
{"force", no_argument, 0, 'f'},
|
{"force", no_argument, 0, 'f'},
|
||||||
|
{"set-language", required_argument, 0, 'S'},
|
||||||
{"version", no_argument, 0, 'v'},
|
{"version", no_argument, 0, 'v'},
|
||||||
{"help", no_argument, 0, 0},
|
{"help", no_argument, 0, 0},
|
||||||
{"license", no_argument, 0, 'L'},
|
{"license", no_argument, 0, 'L'},
|
||||||
@@ -136,11 +154,15 @@ int main(int argc, char* argv[])
|
|||||||
static bool wiew_version = false;
|
static bool wiew_version = false;
|
||||||
static bool list_partitions = false;
|
static bool list_partitions = false;
|
||||||
static bool combo_wiewers = false;
|
static bool combo_wiewers = false;
|
||||||
|
static bool pmt_setlang = false;
|
||||||
|
static char* langpr;
|
||||||
static int search_result = 3;
|
static int search_result = 3;
|
||||||
|
static int getvar_temp;
|
||||||
|
static int check_getvar_temp;
|
||||||
static int opt;
|
static int opt;
|
||||||
|
|
||||||
/* control for each argument */
|
/* control for each argument */
|
||||||
while ((opt = getopt_long(argc, argv, "lc:psfvL", long_options, NULL)) != -1)
|
while ((opt = getopt_long(argc, argv, "lc:psfS:vL", long_options, NULL)) != -1)
|
||||||
{
|
{
|
||||||
/* process arguments */
|
/* process arguments */
|
||||||
switch (opt)
|
switch (opt)
|
||||||
@@ -152,8 +174,8 @@ int main(int argc, char* argv[])
|
|||||||
if (pmt_logical) pmt_use_logical = true;
|
if (pmt_logical) pmt_use_logical = true;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!pmt_force_mode) errx(EX_USAGE, "this device does not have logical partitions!");
|
if (!pmt_force_mode) error(1, "%s", current->not_logical);
|
||||||
else return EX_USAGE;
|
else return 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
/* context selector option */
|
/* context selector option */
|
||||||
@@ -162,8 +184,8 @@ int main(int argc, char* argv[])
|
|||||||
cust_cxt = strdup(optarg);
|
cust_cxt = strdup(optarg);
|
||||||
if (strncmp(cust_cxt, opt_symbol, 1) == 0)
|
if (strncmp(cust_cxt, opt_symbol, 1) == 0)
|
||||||
{
|
{
|
||||||
if (!pmt_force_mode) errx(EX_USAGE, "%s", common_symbol_rule);
|
if (!pmt_force_mode) error(1, "%s", common_symbol_rule);
|
||||||
else return EX_USAGE;
|
else return 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
/* partition lister function */
|
/* partition lister function */
|
||||||
@@ -180,6 +202,11 @@ int main(int argc, char* argv[])
|
|||||||
case 's':
|
case 's':
|
||||||
pmt_silent = true;
|
pmt_silent = true;
|
||||||
break;
|
break;
|
||||||
|
/* language setter option */
|
||||||
|
case 'S':
|
||||||
|
pmt_setlang = true;
|
||||||
|
langpr = strdup(optarg);
|
||||||
|
break;
|
||||||
/* version info option */
|
/* version info option */
|
||||||
case 'v':
|
case 'v':
|
||||||
wiew_version = true;
|
wiew_version = true;
|
||||||
@@ -200,33 +227,33 @@ int main(int argc, char* argv[])
|
|||||||
break;
|
break;
|
||||||
/* for invalid options */
|
/* for invalid options */
|
||||||
case '?':
|
case '?':
|
||||||
printf("Try `%s --help' for more information.\n", argv[0]);
|
printf("%s `%s --help' %s\n", current->try_h, argv[0], current->for_more);
|
||||||
return EX_USAGE;
|
return 1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printf("Usage: %s [backup] flash] [format] [-l | --logical] [-c | --context] [-D | --list] [-v | --version] [--help] [-L | --license]\n", argv[0]);
|
printf("%s: %s [backup] flash] [format] [-l | --logical] [-c | --context] [-D | --list] [-v | --version] [--help] [-L | --license]\n", current->usage_head, argv[0]);
|
||||||
return EX_USAGE;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* stop the program if multiple viewer is used */
|
/* stop the program if multiple viewer is used */
|
||||||
if (combo_wiewers) errx(EX_USAGE, "multiple wiewers cannot be used at the same line.");
|
if (combo_wiewers) error(1, "%s", current->multiple_wiewers);
|
||||||
|
|
||||||
/* controller to handle viewer */
|
/* controller to handle viewer */
|
||||||
if (wiew_help)
|
if (wiew_help)
|
||||||
{
|
{
|
||||||
help();
|
help();
|
||||||
return EX_OK;
|
return 0;
|
||||||
}
|
}
|
||||||
else if (wiew_version)
|
else if (wiew_version)
|
||||||
{
|
{
|
||||||
version();
|
version();
|
||||||
return EX_OK;
|
return 0;
|
||||||
}
|
}
|
||||||
else if (wiew_licenses)
|
else if (wiew_licenses)
|
||||||
{
|
{
|
||||||
licenses();
|
licenses();
|
||||||
return EX_OK;
|
return 0;
|
||||||
}
|
}
|
||||||
else if (list_partitions)
|
else if (list_partitions)
|
||||||
{
|
{
|
||||||
@@ -234,79 +261,109 @@ int main(int argc, char* argv[])
|
|||||||
return listpart();
|
return listpart();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pmt_setlang)
|
||||||
|
{
|
||||||
|
printf("%s: %s\n", argv[0], current->switching_lang);
|
||||||
|
setlang(langpr);
|
||||||
|
sleep(2);
|
||||||
|
printf("%s: %s.\n", argv[0], current->please_rerun);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* detect target mode */
|
/* detect target mode */
|
||||||
static char arg1[20];
|
static char arg1[20];
|
||||||
sprintf(arg1, "%s", argv[1]);
|
sprintf(arg1, "%s", argv[1]);
|
||||||
|
|
||||||
if (strcmp(arg1, "backup") == 0)
|
for (int argtest = 2; argtest == argc; argtest++)
|
||||||
{
|
{
|
||||||
if (argc == 2)
|
getvar_temp = argtest;
|
||||||
|
check_getvar_temp = getvar_temp;
|
||||||
|
getvar_temp++;
|
||||||
|
|
||||||
|
if (strcmp(argv[argtest], "backup") == 0)
|
||||||
{
|
{
|
||||||
if (!pmt_force_mode) errx(EX_USAGE, "expected backup argument 2, retrieved 0.");
|
check_getvar_temp++;
|
||||||
else return EX_USAGE;
|
|
||||||
|
if (argc < check_getvar_temp)
|
||||||
|
{
|
||||||
|
if (!pmt_silent) error(1, "%s 0.", current->expected_backup_arg);
|
||||||
|
else return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
target_partition = argv[getvar_temp];
|
||||||
|
|
||||||
|
if (argc == check_getvar_temp) out = target_partition;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
getvar_temp++;
|
||||||
|
out = argv[getvar_temp];
|
||||||
}
|
}
|
||||||
|
|
||||||
target_partition = argv[2];
|
|
||||||
if (argc != 4) out = target_partition;
|
|
||||||
else out = argv[3];
|
|
||||||
check_optsym(target_partition);
|
check_optsym(target_partition);
|
||||||
check_optsym(out);
|
check_optsym(out);
|
||||||
|
|
||||||
pmt_backup = true;
|
pmt_backup = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else if (strcmp(arg1, "flash") == 0)
|
else if (strcmp(argv[argtest], "flash") == 0)
|
||||||
{
|
{
|
||||||
if (argc == 2)
|
check_getvar_temp++;
|
||||||
|
|
||||||
|
if (argc < check_getvar_temp)
|
||||||
{
|
{
|
||||||
if (!pmt_force_mode) errx(EX_USAGE, "expected flash argument 2, retrieved 0.");
|
if (!pmt_force_mode || !pmt_silent) error(1, "%s 0.", current->expected_flash_arg);
|
||||||
else return EX_USAGE;
|
else return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc == 3)
|
if (argc == check_getvar_temp)
|
||||||
{
|
{
|
||||||
if (!pmt_force_mode) errx(EX_USAGE, "expected flash argument 2, retrieved 0.");
|
if (!pmt_force_mode || !pmt_silent) error(1, "%s 1.", current->expected_flash_arg);
|
||||||
else return EX_USAGE;
|
else return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
target_flash_file = argv[2];
|
target_flash_file = argv[getvar_temp];
|
||||||
target_partition = argv[3];
|
|
||||||
|
getvar_temp++;
|
||||||
|
target_partition = argv[getvar_temp];
|
||||||
|
|
||||||
check_optsym(target_flash_file);
|
check_optsym(target_flash_file);
|
||||||
check_optsym(target_partition);
|
check_optsym(target_partition);
|
||||||
|
|
||||||
pmt_flash = true;
|
pmt_flash = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else if (strcmp(arg1, "format") == 0)
|
else if (strcmp(argv[argtest], "format") == 0)
|
||||||
{
|
{
|
||||||
if (argc == 2)
|
check_getvar_temp++;
|
||||||
|
|
||||||
|
if (argc < check_getvar_temp)
|
||||||
{
|
{
|
||||||
if (!pmt_force_mode) errx(EX_USAGE, "expected format argument 2, retrieved 0.");
|
if (!pmt_force_mode) error(1, "%s 0.", current->expected_format_arg);
|
||||||
else return EX_USAGE;
|
else return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc == 3)
|
if (argc == check_getvar_temp)
|
||||||
{
|
{
|
||||||
if (!pmt_force_mode) errx(EX_USAGE, "expected format argument 2, retrieved 1.");
|
if (!pmt_force_mode) error(1, "%s 1.", current->expected_format_arg);
|
||||||
else return EX_USAGE;
|
else return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
format_fs = argv[2];
|
format_fs = argv[getvar_temp];
|
||||||
target_partition = argv[3];
|
|
||||||
|
getvar_temp++;
|
||||||
|
target_partition = argv[getvar_temp];
|
||||||
|
|
||||||
check_optsym(format_fs);
|
check_optsym(format_fs);
|
||||||
check_optsym(target_partition);
|
check_optsym(target_partition);
|
||||||
|
|
||||||
pmt_format = true;
|
pmt_format = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* target control is done */
|
/* target control is done */
|
||||||
if (!pmt_backup && !pmt_flash && !pmt_format && !pmt_silent) errx(EX_USAGE, "missing operand.\nTry `%s --help` for more information.", argv[0]);
|
if (!pmt_backup && !pmt_flash && !pmt_format && !pmt_silent) error(1, "%s\n%s `%s --help` %s", argv[0], current->missing_operand, current->try_h, current->for_more);
|
||||||
else return EX_USAGE;
|
else return 1;
|
||||||
|
|
||||||
/* prevent multiple mode use */
|
|
||||||
if (pmt_backup && pmt_flash && pmt_format)
|
|
||||||
{
|
|
||||||
if (!pmt_force_mode) errx(EX_USAGE, "multi functions cannot be used in the same command.");
|
|
||||||
else return EX_USAGE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* checks */
|
/* checks */
|
||||||
check_root();
|
check_root();
|
||||||
@@ -316,8 +373,8 @@ int main(int argc, char* argv[])
|
|||||||
{
|
{
|
||||||
if (strcmp(format_fs, "ext4") != 0 || strcmp(format_fs, "ext3") != 0 || strcmp(format_fs, "ext2") != 0)
|
if (strcmp(format_fs, "ext4") != 0 || strcmp(format_fs, "ext3") != 0 || strcmp(format_fs, "ext2") != 0)
|
||||||
{
|
{
|
||||||
if (!pmt_force_mode) errx(EX_USAGE, "formatter: unsupported filesystem: %s", format_fs);
|
if (!pmt_force_mode) error(1, "%s: %s", current->unsupported_fs, format_fs);
|
||||||
else return EX_USAGE;
|
else return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -327,13 +384,13 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
if (search_result == 1)
|
if (search_result == 1)
|
||||||
{
|
{
|
||||||
if (!pmt_silent) errx(EX_UNAVAILABLE, "cannot stat `%s': %s", target_flash_file, strerror(errno));
|
if (!pmt_silent) error(1, "%s `%s': %s", current->cannot_stat, target_flash_file, strerror(errno));
|
||||||
else return EX_UNAVAILABLE;
|
else return 1;
|
||||||
}
|
}
|
||||||
else if (search_result == -1)
|
else if (search_result == -1)
|
||||||
{
|
{
|
||||||
if (!pmt_silent) errx(EX_USAGE, "`%s': is a not file.", target_flash_file);
|
if (!pmt_silent) error(1, "`%s': %s", target_flash_file, current->not_file);
|
||||||
else return EX_USAGE;
|
else return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -344,25 +401,25 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
if (search_result == 1)
|
if (search_result == 1)
|
||||||
{
|
{
|
||||||
if (!pmt_silent) errx(EX_UNAVAILABLE, "cannot stat `%s': %s", cust_cxt, strerror(errno));
|
if (!pmt_silent) error(1, "%s `%s': %s", current->cannot_stat, cust_cxt, strerror(errno));
|
||||||
else return EX_UNAVAILABLE;
|
else return 1;
|
||||||
}
|
}
|
||||||
else if (search_result == -1)
|
else if (search_result == -1)
|
||||||
{
|
{
|
||||||
if (!pmt_silent) errx(EX_USAGE, "`%s': is a not directory.", cust_cxt);
|
if (!pmt_silent) error(1, "`%s': %s", cust_cxt, current->not_dir);
|
||||||
else return EX_USAGE;
|
else return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strstr(cust_cxt, "/dev") == NULL && !pmt_force_mode) errx(EX_USAGE, ANSI_YELLOW "you're going through my wave? There's nothing about this /dev. Use force mode if you don't want this error." ANSI_RESET);
|
if (strstr(cust_cxt, "/dev") == NULL && !pmt_force_mode) error(1, "%s", current->not_in_dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target_partition == NULL)
|
if (target_partition == NULL)
|
||||||
{
|
{
|
||||||
if (!pmt_force_mode)
|
if (!pmt_force_mode)
|
||||||
{
|
{
|
||||||
if (!pmt_silent) errx(EX_USAGE, "required partition name.\nTry `%s --help' for more information.\n", argv[0]);
|
if (!pmt_silent) error(1, "%s\n%s `%s --help' %s", current->req_part_name, current->try_h, argv[0], current->for_more);
|
||||||
}
|
}
|
||||||
else return EX_USAGE;
|
else return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -376,7 +433,7 @@ int main(int argc, char* argv[])
|
|||||||
if (pmt_backup) return pmt(1);
|
if (pmt_backup) return pmt(1);
|
||||||
else if (pmt_flash) return pmt(2);
|
else if (pmt_flash) return pmt(2);
|
||||||
else if (pmt_format) return pmt(3);
|
else if (pmt_format) return pmt(3);
|
||||||
else if (!pmt_silent) errx(EX_USAGE, "no target (backup or flash).\nTry `%s --help` for more information.\n", argv[0]);
|
else if (!pmt_silent) error(1, "%s\n%s `%s --help' %s", current->no_target, current->try_h, argv[0], current->for_more);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
19
jni/root.c
19
jni/root.c
@@ -20,22 +20,23 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#define INC_MAIN_LIBS
|
||||||
#include <unistd.h>
|
#define INC_DEBUGERS
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <err.h>
|
|
||||||
#include <sysexits.h>
|
|
||||||
#include <pmt.h>
|
#include <pmt.h>
|
||||||
|
|
||||||
|
extern struct pmt_langdb_general* current;
|
||||||
|
extern struct pmt_langdb_general en;
|
||||||
|
extern struct pmt_langdb_general tr;
|
||||||
|
|
||||||
/* root checker function */
|
/* root checker function */
|
||||||
void check_root(void)
|
void check_root(void)
|
||||||
{
|
{
|
||||||
/* a quick, easy method to verify root */
|
/* a quick, easy method for verifying root */
|
||||||
if (getuid() != 0)
|
if (getuid() != 0)
|
||||||
{
|
{
|
||||||
if (!pmt_force_mode) errx(EX_NOPERM, "root access could not be detected! Please run this binary with root.");
|
if (!pmt_force_mode) error(1, "%s", current->no_root);
|
||||||
else exit(EX_NOPERM);
|
else exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
111
jni/tools.c
111
jni/tools.c
@@ -20,21 +20,13 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/statvfs.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <err.h>
|
|
||||||
#include <sysexits.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <pmt.h>
|
|
||||||
|
|
||||||
#define BFSIZE 1024
|
#define BFSIZE 1024
|
||||||
|
#define INC_MAIN_LIBS
|
||||||
|
#define INC_STAT
|
||||||
|
#define INC_DEBUGERS
|
||||||
|
#define INC_TOOLS_REQS
|
||||||
|
|
||||||
|
#include <pmt.h>
|
||||||
|
|
||||||
extern char* out;
|
extern char* out;
|
||||||
extern char* format_fs;
|
extern char* format_fs;
|
||||||
@@ -50,14 +42,9 @@ extern bool pmt_backup;
|
|||||||
extern bool pmt_silent;
|
extern bool pmt_silent;
|
||||||
extern bool pmt_force_mode;
|
extern bool pmt_force_mode;
|
||||||
|
|
||||||
/**
|
extern struct pmt_langdb_general* current;
|
||||||
* if progress_code is a
|
extern struct pmt_langdb_general en;
|
||||||
* 1 = backup mode
|
extern struct pmt_langdb_general tr;
|
||||||
*
|
|
||||||
* 2 = flash mode
|
|
||||||
*
|
|
||||||
* 3 = format mode
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* it is meant to calculate the size of the quickly given file.
|
* it is meant to calculate the size of the quickly given file.
|
||||||
@@ -86,26 +73,12 @@ calc_flsz(const char* _Nonnull filepath)
|
|||||||
static int
|
static int
|
||||||
partition_not_found(void)
|
partition_not_found(void)
|
||||||
{
|
{
|
||||||
if (!pmt_silent) errx(EX_OSFILE, "partition not found!");
|
if (!pmt_silent) error(1, "%s", current->part_not_found);
|
||||||
else return EX_OSFILE;
|
else return 1;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* unknown partition type error.
|
|
||||||
* It's for quick action.
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
invalid_partition_type(void)
|
|
||||||
{
|
|
||||||
if (!pmt_silent) errx(EX_USAGE, "invalid partition type!");
|
|
||||||
else exit(EX_USAGE);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* to stop use of function type */
|
/* to stop use of function type */
|
||||||
#define partition_not_found partition_not_found()
|
#define partition_not_found partition_not_found()
|
||||||
#define invalid_partition_type invalid_partition_type()
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The target file is controlled by the stat function.
|
* The target file is controlled by the stat function.
|
||||||
@@ -153,8 +126,8 @@ search_partition(const char* _Nonnull partition)
|
|||||||
partition_results = search_stat(partition, "blk");
|
partition_results = search_stat(partition, "blk");
|
||||||
|
|
||||||
if (partition_results == 1) partition_not_found;
|
if (partition_results == 1) partition_not_found;
|
||||||
else if (partition_results == -1 && !pmt_silent) errx(EX_OSFILE, "the specified partition is not the block. I mean, it's not actually an episode (disc). I'm sure it needs to applaud those mistakes.");
|
else if (partition_results == -1 && !pmt_silent) error(1, "%s", current->not_block);
|
||||||
else exit(EX_OSFILE);
|
else exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int pmt(unsigned short progress_code)
|
int pmt(unsigned short progress_code)
|
||||||
@@ -179,33 +152,32 @@ int pmt(unsigned short progress_code)
|
|||||||
else sprintf(backupper_path, "/dev/block/by-name/%s", target_partition);
|
else sprintf(backupper_path, "/dev/block/by-name/%s", target_partition);
|
||||||
}
|
}
|
||||||
else if (pmt_use_logical) sprintf(backupper_path, "/dev/block/mapper/%s", target_partition);
|
else if (pmt_use_logical) sprintf(backupper_path, "/dev/block/mapper/%s", target_partition);
|
||||||
else return invalid_partition_type;
|
|
||||||
|
|
||||||
search_partition(backupper_path);
|
search_partition(backupper_path);
|
||||||
|
|
||||||
if (calc_flsz(backupper_path) != -1 && !pmt_silent) printf("Disk size of the partition to be backed up: %.2f\n", calc_flsz(backupper_path));
|
if (calc_flsz(backupper_path) != -1 && !pmt_silent) printf("%s: %.2f\n", current->part_disk_sz, calc_flsz(backupper_path));
|
||||||
else warnx(ANSI_YELLOW "failed to get target partition disk size" ANSI_RESET);
|
else if (!pmt_silent) warning("%s", current->part_disk_sz_fail);
|
||||||
|
|
||||||
srcf = open(backupper_path, O_RDONLY);
|
srcf = open(backupper_path, O_RDONLY);
|
||||||
if (srcf == -1)
|
if (srcf == -1)
|
||||||
{
|
{
|
||||||
if (!pmt_silent) errx(EX_OSFILE, "couldn't read: %s: %s", backupper_path, strerror(errno));
|
if (!pmt_silent) error(1, "%s: %s: %s", current->not_read, backupper_path, strerror(errno));
|
||||||
else return EX_IOERR;
|
else return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* determine output */
|
/* determine output */
|
||||||
if (strcmp(out, target_partition) == 0)
|
if (strcmp(out, target_partition) == 0)
|
||||||
{
|
{
|
||||||
sprintf(outf, "%s.img", target_partition);
|
sprintf(outf, "%s.img", target_partition);
|
||||||
if (!pmt_silent) warnx(ANSI_YELLOW "warning: The output file name was not specified. The output file name will be: %s" ANSI_RESET, outf);
|
if (!pmt_silent) warning("%s: %s", current->out_not_spec, outf);
|
||||||
}
|
}
|
||||||
else sprintf(outf, "%s", target_partition);
|
else sprintf(outf, "%s", target_partition);
|
||||||
|
|
||||||
targetf = open(outf, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
targetf = open(outf, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
||||||
if (targetf == -1)
|
if (targetf == -1)
|
||||||
{
|
{
|
||||||
if (!pmt_silent) errx(EX_CANTCREAT, "couldn't generate: %s: %s", outf, strerror(errno));
|
if (!pmt_silent) error(1, "%s: %s: %s", current->not_gen, outf, strerror(errno));
|
||||||
else return EX_CANTCREAT;
|
else return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* start writing */
|
/* start writing */
|
||||||
@@ -214,11 +186,11 @@ int pmt(unsigned short progress_code)
|
|||||||
ssize_t writed_data = write(targetf, buffer, readed_data);
|
ssize_t writed_data = write(targetf, buffer, readed_data);
|
||||||
if (writed_data != readed_data)
|
if (writed_data != readed_data)
|
||||||
{
|
{
|
||||||
if (!pmt_silent) warnx("couldn't write: %s: %s", backupper_path, strerror(errno));
|
if (!pmt_silent) warning("%s: %s: %s", current->not_write, backupper_path, strerror(errno));
|
||||||
close(srcf);
|
close(srcf);
|
||||||
close(targetf);
|
close(targetf);
|
||||||
if (search_stat(outf, "file") == 0) remove(outf);
|
if (search_stat(outf, "file") == 0) remove(outf);
|
||||||
return EX_IOERR;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
copied_data += writed_data;
|
copied_data += writed_data;
|
||||||
@@ -228,7 +200,7 @@ int pmt(unsigned short progress_code)
|
|||||||
close(srcf);
|
close(srcf);
|
||||||
close(targetf);
|
close(targetf);
|
||||||
|
|
||||||
if (!pmt_silent) printf("%sSuccess. Output: %s%s\n", ANSI_GREEN, outf, ANSI_RESET);
|
if (!pmt_silent) printf("%s: %s\n", current->success_backup, outf);
|
||||||
}
|
}
|
||||||
else if (progress_code == 2)
|
else if (progress_code == 2)
|
||||||
{
|
{
|
||||||
@@ -241,32 +213,31 @@ int pmt(unsigned short progress_code)
|
|||||||
/* for logical */
|
/* for logical */
|
||||||
}
|
}
|
||||||
else if (pmt_use_logical) sprintf(flasher_path, "/dev/block/mapper/%s", target_partition);
|
else if (pmt_use_logical) sprintf(flasher_path, "/dev/block/mapper/%s", target_partition);
|
||||||
else return invalid_partition_type;
|
|
||||||
|
|
||||||
/* check partition */
|
/* check partition */
|
||||||
search_partition(flasher_path);
|
search_partition(flasher_path);
|
||||||
|
|
||||||
if (calc_flsz(target_flash_file) != -1 && !pmt_force_mode) printf("Size of flash file: %.2f\n", calc_flsz(target_flash_file));
|
if (calc_flsz(target_flash_file) != -1 && !pmt_force_mode) printf("%s: %.2f\n", current->flash_file_sz, calc_flsz(target_flash_file));
|
||||||
else warnx(ANSI_YELLOW "failed to get flash file size" ANSI_RESET);
|
else warning("%s", current->flash_file_sz_fail);
|
||||||
|
|
||||||
if (calc_flsz(target_partition) != -1 && !pmt_force_mode) printf("Disk size of the target partition: %.2f\n", calc_flsz(target_partition));
|
if (calc_flsz(target_partition) != -1 && !pmt_force_mode) printf("%s: %.2f\n", current->part_disk_sz, calc_flsz(target_partition));
|
||||||
else warnx(ANSI_YELLOW "failed to get target partition disk size" ANSI_RESET);
|
else warning("%s", current->part_disk_sz_fail);
|
||||||
|
|
||||||
if (calc_flsz(target_flash_file) > calc_flsz(target_partition) && !pmt_silent) errx(EX__BASE, "size of the file to flash more than the partition size.");
|
if (calc_flsz(target_flash_file) > calc_flsz(target_partition) && !pmt_silent) error(1, "%s", current->ffile_more_part);
|
||||||
else return EX__BASE;
|
else return 1;
|
||||||
|
|
||||||
srcf = open(target_flash_file, O_RDONLY);
|
srcf = open(target_flash_file, O_RDONLY);
|
||||||
if (srcf == -1)
|
if (srcf == -1)
|
||||||
{
|
{
|
||||||
if (!pmt_force_mode) errx(EX_NOINPUT, "couldn't read: %s: %s", target_flash_file, strerror(errno));
|
if (!pmt_force_mode) error(1, "%s: %s: %s", current->not_read, target_flash_file, strerror(errno));
|
||||||
else return EX_IOERR;
|
else return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
targetf = open(target_partition, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
targetf = open(target_partition, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
||||||
if (targetf == -1)
|
if (targetf == -1)
|
||||||
{
|
{
|
||||||
if (!pmt_force_mode) errx(EX_OSFILE, "couldn't read: %s: %s", target_partition, strerror(errno));
|
if (!pmt_force_mode) error(1, "%s: %s: %s", current->not_read, target_partition, strerror(errno));
|
||||||
else return EX_IOERR;
|
else return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* start writing */
|
/* start writing */
|
||||||
@@ -275,10 +246,10 @@ int pmt(unsigned short progress_code)
|
|||||||
ssize_t writed_data = write(targetf, buffer, readed_data);
|
ssize_t writed_data = write(targetf, buffer, readed_data);
|
||||||
if (writed_data != readed_data)
|
if (writed_data != readed_data)
|
||||||
{
|
{
|
||||||
warnx("couldn't write: %s: %s", backupper_path, strerror(errno));
|
warning("%s: %s: %s", current->not_write, backupper_path, strerror(errno));
|
||||||
close(srcf);
|
close(srcf);
|
||||||
close(targetf);
|
close(targetf);
|
||||||
return EX_IOERR;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
copied_data += writed_data;
|
copied_data += writed_data;
|
||||||
@@ -287,7 +258,7 @@ int pmt(unsigned short progress_code)
|
|||||||
close(srcf);
|
close(srcf);
|
||||||
close(targetf);
|
close(targetf);
|
||||||
|
|
||||||
if (!pmt_force_mode) printf("%sSuccess.%s\n", ANSI_GREEN, ANSI_RESET);
|
if (!pmt_force_mode) printf("%s.\n", current->success_flash);
|
||||||
}
|
}
|
||||||
else if (progress_code == 3)
|
else if (progress_code == 3)
|
||||||
{
|
{
|
||||||
@@ -299,7 +270,6 @@ int pmt(unsigned short progress_code)
|
|||||||
/* for logical */
|
/* for logical */
|
||||||
}
|
}
|
||||||
else if (pmt_use_logical) sprintf(ppath, "/dev/block/mapper/%s", target_partition);
|
else if (pmt_use_logical) sprintf(ppath, "/dev/block/mapper/%s", target_partition);
|
||||||
else return invalid_partition_type;
|
|
||||||
|
|
||||||
/* check partition */
|
/* check partition */
|
||||||
search_partition(ppath);
|
search_partition(ppath);
|
||||||
@@ -308,8 +278,8 @@ int pmt(unsigned short progress_code)
|
|||||||
struct statvfs file_sys_inf;
|
struct statvfs file_sys_inf;
|
||||||
if (statvfs(ppath, &file_sys_inf) != 0)
|
if (statvfs(ppath, &file_sys_inf) != 0)
|
||||||
{
|
{
|
||||||
if (!pmt_force_mode) errx(EX_TEMPFAIL, "the partition block size could not be obtained!");
|
if (!pmt_force_mode) error(1, "%s", current->cannot_get_bsz);
|
||||||
else return EX_TEMPFAIL;
|
else return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* generate mke2fs command */
|
/* generate mke2fs command */
|
||||||
@@ -318,10 +288,11 @@ int pmt(unsigned short progress_code)
|
|||||||
/* run command */
|
/* run command */
|
||||||
if (system(formatter_cmd) != 0)
|
if (system(formatter_cmd) != 0)
|
||||||
{
|
{
|
||||||
if (!pmt_force_mode) errx(EX_TEMPFAIL, "formatting failed! There may be a chance that something has been damaged!");
|
if (!pmt_force_mode) error(1, "%s", current->format_fail);
|
||||||
else return EX_TEMPFAIL;
|
else return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,33 +20,38 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#define INC_MAIN_LIBS
|
||||||
#include <android/ndk-version.h>
|
#define INC_VERSIONER_REQS
|
||||||
#include <pmt-versioning.h>
|
|
||||||
|
#include <pmt.h>
|
||||||
|
|
||||||
extern char* bin_name;
|
extern char* bin_name;
|
||||||
|
|
||||||
|
extern struct pmt_langdb_general* current;
|
||||||
|
extern struct pmt_langdb_general en;
|
||||||
|
extern struct pmt_langdb_general tr;
|
||||||
|
|
||||||
void version(void)
|
void version(void)
|
||||||
{
|
{
|
||||||
printf("%s version %d.%d.%d (code %d%d%d) ", bin_name, PMT_MAJOR, PMT_MINOR, PMT_PATCHLEVEL, PMT_MAJOR, PMT_MINOR, PMT_PATCHLEVEL);
|
printf("%s %s %d.%d.%d (%d%d%d) ", bin_name, current->version_str, PMT_MAJOR, PMT_MINOR, PMT_PATCHLEVEL, PMT_MAJOR, PMT_MINOR, PMT_PATCHLEVEL);
|
||||||
|
|
||||||
#if __SIZEOF_POINTER__ == 4
|
#if __SIZEOF_POINTER__ == 4
|
||||||
printf("32-bit binary\n");
|
printf("32-bit %s\n", current->bin_str);
|
||||||
#elif __SIZEOF_POINTER__ == 8
|
#elif __SIZEOF_POINTER__ == 8
|
||||||
printf("64-bit binary\n");
|
printf("64-bit %s\n", current->bin_str);
|
||||||
#else
|
#else
|
||||||
printf("<unknown> binary\n");
|
printf("<%s> %s\n", current->unknw_str, current->bin_str);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
printf("Compiler: clang %d.%d.%d (NDK major r%d)\n", __clang_major__, __clang_minor__, __clang_patchlevel__, __NDK_MAJOR__);
|
printf("%s: clang %d.%d.%d\n", current->compiler_str, __clang_major__, __clang_minor__, __clang_patchlevel__);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
printf("See licenses with -L argument.\n");
|
printf("%s\n", current->see_license);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif
|
||||||
|
|
||||||
/* end of code */
|
/* end of code */
|
||||||
|
|||||||
154
make-deb.sh
154
make-deb.sh
@@ -1,154 +0,0 @@
|
|||||||
#!/usr/bin/bash
|
|
||||||
# By YZBruh
|
|
||||||
|
|
||||||
# Copyright 2024 Partition Manager
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
# ANSI color codes
|
|
||||||
RED='\e[31m'
|
|
||||||
NC='\e[0m'
|
|
||||||
|
|
||||||
# needed variables
|
|
||||||
VERSION="2.1.0"
|
|
||||||
CUR_DIR=$(pwd)
|
|
||||||
LIB_DIR=${CUR_DIR}/libs
|
|
||||||
ARMV8A_DIR=${LIB_DIR}/arm64-v8a
|
|
||||||
ARMV7A_DIR=${LIB_DIR}/armeabi-v7a
|
|
||||||
DEB_DIR=${CUR_DIR}/deb
|
|
||||||
DEBUTILS_DIR=${CUR_DIR}/debutils
|
|
||||||
DEBTERMUX_USR=${DEBUTILS_DIR}/data/data/com.termux/files/usr
|
|
||||||
|
|
||||||
# error messages
|
|
||||||
abort() {
|
|
||||||
if [ ! "$1" = "" ]; then
|
|
||||||
printf "${RED}${1}${NC}\n"
|
|
||||||
fi
|
|
||||||
if [ -d ${DEBUTILS_DIR}/temp ]; then
|
|
||||||
rm -rf ${DEBUTILS_DIR}/temp
|
|
||||||
fi
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# detect arch flag
|
|
||||||
case "$1" in
|
|
||||||
arm64-v8a)
|
|
||||||
PREFIX="64"
|
|
||||||
ARM_PREFIX="-v8a"
|
|
||||||
;;
|
|
||||||
armeabi-v7a)
|
|
||||||
PREFIX="32"
|
|
||||||
ARM_PREFIX=""
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
abort " - Error: unknown architecture flag: $1. Avaiable: arm64-v8a & armeabi-v7a.\n"
|
|
||||||
esac
|
|
||||||
|
|
||||||
case "$2" in
|
|
||||||
sudo)
|
|
||||||
SUDO="sudo"
|
|
||||||
;;
|
|
||||||
no-sudo)
|
|
||||||
SUDO=""
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
SUDO=""
|
|
||||||
esac
|
|
||||||
|
|
||||||
# set file modes (all) to 755
|
|
||||||
${SUDO} chmod -R 755 *
|
|
||||||
|
|
||||||
# start
|
|
||||||
printf " --------- pmt deb package maker ---------\n";
|
|
||||||
printf " - Checking all files and directories (only
|
|
||||||
eededs)...\n";
|
|
||||||
|
|
||||||
# check all important files
|
|
||||||
if [ ! -d ${DEBUTILS_DIR} ]; then
|
|
||||||
abort " - Not found: ${DEBUTILS_DIR}\n"
|
|
||||||
fi
|
|
||||||
if [ ! -d ${DEBUTILS_DIR}/DEBIAN ]; then
|
|
||||||
abort " - Not found: ${DEBUTILS_DIR}/DEBIAN\n"
|
|
||||||
fi
|
|
||||||
if [ ! -d ${DEBUTILS_DIR}/mandoc ]; then
|
|
||||||
abort " - Not found: ${DEBUTILS_DIR}/mandoc\n"
|
|
||||||
fi
|
|
||||||
if [ ! -d ${DEBUTILS_DIR}/data/data/com.termux ]; then
|
|
||||||
abort " - Not found: ${DEBUTILS_DIR}/data/data/com.termux\n"
|
|
||||||
fi
|
|
||||||
if [ ! -d ${DEBUTILS_DIR}/data/data/com.termux/files/usr ]; then
|
|
||||||
abort " - Not found: ${DEBUTILS_DIR}/data/data/com.termux/files/usr\n"
|
|
||||||
fi
|
|
||||||
if [ ! -d ${DEBUTILS_DIR}/data/data/com.termux/files/usr/bin ]; then
|
|
||||||
abort " - Not found: ${DEBUTILS_DIR}/data/data/com.termux/files/usr/bin\n"
|
|
||||||
fi
|
|
||||||
if [ ! -d ${DEBUTILS_DIR}/data/data/com.termux/files/usr/share/man/man8 ]; then
|
|
||||||
abort " - Not found: ${DEBUTILS_DIR}/data/data/com.termux/files/usr/share/man/man8\n"
|
|
||||||
fi
|
|
||||||
if [ ! -f ${DEBUTILS_DIR}/mandoc/pmt.8.gz ]; then
|
|
||||||
abort " - Not found: ${DEBUTILS_DIR}/mandoc/pmt.8.gz\n"
|
|
||||||
fi
|
|
||||||
if [ ! -f ${DEBUTILS_DIR}/DEBIAN/control_32 ]; then
|
|
||||||
abort " - Not found: ${DEBUTILS_DIR}/DEBIAN/control_32\n"
|
|
||||||
fi
|
|
||||||
if [ ! -f ${DEBUTILS_DIR}/DEBIAN/control_64 ]; then
|
|
||||||
abort " - Not found: ${DEBUTILS_DIR}/DEBIAN/control_64\n"
|
|
||||||
fi
|
|
||||||
if [ ! -f ${ARMV8A_DIR}/pmt ]; then
|
|
||||||
abort " - Package not comptely builded! Please build package and try again\n"
|
|
||||||
elif [ ! -f ${ARMV7A_DIR}/pmt ]; then
|
|
||||||
abort " - Package not comptely builded! Please build package and try again\n"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# generate template dir
|
|
||||||
printf " - Generating template dir...\n"
|
|
||||||
${SUDO} mkdir -p ${DEBUTILS_DIR}/temp || abort
|
|
||||||
|
|
||||||
# generate out dir
|
|
||||||
printf " - Generating out dir...\n"
|
|
||||||
${SUDO} mkdir -p ${DEB_DIR} || abort
|
|
||||||
|
|
||||||
# copy files
|
|
||||||
printf " - Copying files...\n"
|
|
||||||
${SUDO} cp -r ${DEBUTILS_DIR}/data ${DEBUTILS_DIR}/temp || abort
|
|
||||||
${SUDO} rm -f ${DEBTERMUX_USR}/share/man/man8/dummy
|
|
||||||
${SUDO} rm -f ${DEBTERMUX_USR}/bin/dummy
|
|
||||||
${SUDO} mkdir -p ${DEBUTILS_DIR}/temp/DEBIAN || abort
|
|
||||||
|
|
||||||
# select control file
|
|
||||||
printf " - Selected arm-${PREFIX} package control file.\n"
|
|
||||||
${SUDO} cp ${DEBUTILS_DIR}/DEBIAN/control_${PREFIX} ${DEBUTILS_DIR}/temp/DEBIAN/control || exit 1
|
|
||||||
${SUDO} cp ${DEBUTILS_DIR}/mandoc/pmt.8.gz ${DEBTERMUX_USR}/share/man/man8 || abort
|
|
||||||
if [ "${PREFIX}" = "64" ]; then
|
|
||||||
${SUDO} cp ${ARMV8A_DIR}/pmt ${DEBTERMUX_USR}/bin || abort
|
|
||||||
elif [ "${PREFIX}" = "32" ]; then
|
|
||||||
${SUDO} cp ${ARMV7A_DIR}/pmt ${DEBTERMUX_USR}/bin || abort
|
|
||||||
fi
|
|
||||||
|
|
||||||
# start dpkg-deb
|
|
||||||
printf " - Starting dpkg-deb...\n"
|
|
||||||
sleep 2
|
|
||||||
${SUDO} chmod -R 755 *
|
|
||||||
|
|
||||||
# if ARM_PREFIX is '-v7a', unset ARM_PREFIX and PREFIX. Re set PREFIX
|
|
||||||
if [ "${PREFIX}" = "32" ]; then
|
|
||||||
unset PREFIX
|
|
||||||
PREFIX="eabi-v7a"
|
|
||||||
fi
|
|
||||||
|
|
||||||
${SUDO} dpkg-deb -b ${DEBUTILS_DIR}/temp ${DEB_DIR}/pmt-${VERSION}-arm${PREFIX}${ARM_PREFIX}.deb || abort
|
|
||||||
${SUDO} rm -rf ${DEBUTILS_DIR}/temp
|
|
||||||
|
|
||||||
printf " - Done! Package: ${DEB_DIR}/pmt-${VERSION}-arm${PREFIX}${ARM_PREFIX}.deb\n"
|
|
||||||
|
|
||||||
# end of script
|
|
||||||
208
utils.sh
Executable file
208
utils.sh
Executable file
@@ -0,0 +1,208 @@
|
|||||||
|
#!/usr/bin/bash
|
||||||
|
# By YZBruh
|
||||||
|
|
||||||
|
# Copyright 2024 Partition Manager
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
# ANSI color codes
|
||||||
|
RED='\e[31m'
|
||||||
|
NC='\e[0m'
|
||||||
|
|
||||||
|
# needed variables
|
||||||
|
VERSION="2.3.0"
|
||||||
|
CUR_DIR=$(pwd)
|
||||||
|
LIB_DIR=${CUR_DIR}/libs
|
||||||
|
ARMV8A_DIR=${LIB_DIR}/arm64-v8a
|
||||||
|
ARMV7A_DIR=${LIB_DIR}/armeabi-v7a
|
||||||
|
DEB_DIR=${CUR_DIR}/deb
|
||||||
|
DEBUTILS_DIR=${CUR_DIR}/debutils
|
||||||
|
DEBTERMUX_USR=${DEBUTILS_DIR}/data/data/com.termux/files/usr
|
||||||
|
|
||||||
|
# set file modes (all) to 755
|
||||||
|
${SUDO} chmod -R 755 *
|
||||||
|
|
||||||
|
# error messages
|
||||||
|
abort()
|
||||||
|
{
|
||||||
|
if [ ! "$1" = "" ]; then
|
||||||
|
printf "${RED}${1}${NC}\n"
|
||||||
|
fi
|
||||||
|
if [ -d ${DEBUTILS_DIR}/temp ]; then
|
||||||
|
rm -rf ${DEBUTILS_DIR}/temp
|
||||||
|
fi
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
gen_deb()
|
||||||
|
{
|
||||||
|
printf " --------- Making pmt deb package ---------\n";
|
||||||
|
printf " - Checking all files and directories (only
|
||||||
|
eededs)...\n";
|
||||||
|
|
||||||
|
# check important files
|
||||||
|
if [ ! -d ${DEBUTILS_DIR} ]; then
|
||||||
|
abort " - Not found: ${DEBUTILS_DIR}\n"
|
||||||
|
fi
|
||||||
|
if [ ! -d ${DEBUTILS_DIR}/DEBIAN ]; then
|
||||||
|
abort " - Not found: ${DEBUTILS_DIR}/DEBIAN\n"
|
||||||
|
fi
|
||||||
|
if [ ! -d ${DEBUTILS_DIR}/mandoc ]; then
|
||||||
|
abort " - Not found: ${DEBUTILS_DIR}/mandoc\n"
|
||||||
|
fi
|
||||||
|
if [ ! -d ${DEBUTILS_DIR}/data/data/com.termux ]; then
|
||||||
|
abort " - Not found: ${DEBUTILS_DIR}/data/data/com.termux\n"
|
||||||
|
fi
|
||||||
|
if [ ! -d ${DEBUTILS_DIR}/data/data/com.termux/files/usr ]; then
|
||||||
|
abort " - Not found: ${DEBUTILS_DIR}/data/data/com.termux/files/usr\n"
|
||||||
|
fi
|
||||||
|
if [ ! -d ${DEBUTILS_DIR}/data/data/com.termux/files/usr/bin ]; then
|
||||||
|
abort " - Not found: ${DEBUTILS_DIR}/data/data/com.termux/files/usr/bin\n"
|
||||||
|
fi
|
||||||
|
if [ ! -d ${DEBUTILS_DIR}/data/data/com.termux/files/usr/share/man/man8 ]; then
|
||||||
|
abort " - Not found: ${DEBUTILS_DIR}/data/data/com.termux/files/usr/share/man/man8\n"
|
||||||
|
fi
|
||||||
|
if [ ! -f ${DEBUTILS_DIR}/mandoc/pmt.8.gz ]; then
|
||||||
|
abort " - Not found: ${DEBUTILS_DIR}/mandoc/pmt.8.gz\n"
|
||||||
|
fi
|
||||||
|
if [ ! -f ${DEBUTILS_DIR}/DEBIAN/control_32 ]; then
|
||||||
|
abort " - Not found: ${DEBUTILS_DIR}/DEBIAN/control_32\n"
|
||||||
|
fi
|
||||||
|
if [ ! -f ${DEBUTILS_DIR}/DEBIAN/control_64 ]; then
|
||||||
|
abort " - Not found: ${DEBUTILS_DIR}/DEBIAN/control_64\n"
|
||||||
|
fi
|
||||||
|
if [ ! -f ${ARMV8A_DIR}/pmt ]; then
|
||||||
|
abort " - Package not comptely builded! Please build package and try again\n"
|
||||||
|
elif [ ! -f ${ARMV7A_DIR}/pmt ]; then
|
||||||
|
abort " - Package not comptely builded! Please build package and try again\n"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# generate template dir
|
||||||
|
printf " - Generating template dir...\n"
|
||||||
|
${SUDO} mkdir -p ${DEBUTILS_DIR}/temp || abort
|
||||||
|
|
||||||
|
# generate out dir
|
||||||
|
printf " - Generating out dir...\n"
|
||||||
|
${SUDO} mkdir -p ${DEB_DIR} || abort
|
||||||
|
|
||||||
|
# copy files
|
||||||
|
printf " - Copying files...\n"
|
||||||
|
${SUDO} cp -r ${DEBUTILS_DIR}/data ${DEBUTILS_DIR}/temp || abort
|
||||||
|
${SUDO} rm -f ${DEBTERMUX_USR}/share/man/man8/dummy
|
||||||
|
${SUDO} rm -f ${DEBTERMUX_USR}/bin/dummy
|
||||||
|
${SUDO} mkdir -p ${DEBUTILS_DIR}/temp/DEBIAN || abort
|
||||||
|
|
||||||
|
# select control file
|
||||||
|
printf " - Selected arm-${PREFIX} package control file.\n"
|
||||||
|
${SUDO} cp ${DEBUTILS_DIR}/DEBIAN/control_${PREFIX} ${DEBUTILS_DIR}/temp/DEBIAN/control || exit 1
|
||||||
|
${SUDO} cp ${DEBUTILS_DIR}/mandoc/pmt.8.gz ${DEBTERMUX_USR}/share/man/man8 || abort
|
||||||
|
if [ "${PREFIX}" = "64" ]; then
|
||||||
|
${SUDO} cp ${ARMV8A_DIR}/pmt ${DEBTERMUX_USR}/bin || abort
|
||||||
|
elif [ "${PREFIX}" = "32" ]; then
|
||||||
|
${SUDO} cp ${ARMV7A_DIR}/pmt ${DEBTERMUX_USR}/bin || abort
|
||||||
|
fi
|
||||||
|
|
||||||
|
# start dpkg-deb
|
||||||
|
printf " - Starting dpkg-deb...\n"
|
||||||
|
sleep 2
|
||||||
|
${SUDO} chmod -R 755 *
|
||||||
|
|
||||||
|
# if ARM_PREFIX is '-v7a', unset ARM_PREFIX and PREFIX. Re set PREFIX
|
||||||
|
if [ "${PREFIX}" = "32" ]; then
|
||||||
|
unset PREFIX
|
||||||
|
PREFIX="eabi-v7a"
|
||||||
|
fi
|
||||||
|
|
||||||
|
${SUDO} dpkg-deb -b ${DEBUTILS_DIR}/temp ${DEB_DIR}/pmt-${VERSION}-arm${PREFIX}${ARM_PREFIX}.deb || abort
|
||||||
|
${SUDO} rm -rf ${DEBUTILS_DIR}/temp
|
||||||
|
|
||||||
|
printf " - Done! Package: ${DEB_DIR}/pmt-${VERSION}-arm${PREFIX}${ARM_PREFIX}.deb\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
gen_modpack()
|
||||||
|
{
|
||||||
|
printf " ----------- Making static lib package -----------\n"
|
||||||
|
printf " - Checking files...\n"
|
||||||
|
|
||||||
|
if [ ! -f $(STATICLIB_DIR)/libpmt_root.a ]; then
|
||||||
|
printf " - Not found: $(STATICLIB_DIR)/libpmt_root.a\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ ! -f $(STATICLIB_DIR)/libpmt_lister.a ]; then
|
||||||
|
printf " - Not found: $(STATICLIB_DIR)/libpmt_lister.a\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ ! -f $(STATICLIB_DIR)/libpmtpartition_tool.a ]; then
|
||||||
|
printf " - Not found: $(STATICLIB_DIR)/libpmtpartition_tool.a\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf " - Compressing...\n"
|
||||||
|
mkdir -p static-lib-pack
|
||||||
|
cd static-lib-pack
|
||||||
|
cp jni/include/pmt.h .
|
||||||
|
mkdir -p include
|
||||||
|
mv pmt.h include/
|
||||||
|
zip -rq pmt-static-lib-pack.zip *.a include || exit 1
|
||||||
|
rm -rf include
|
||||||
|
sleep 1
|
||||||
|
printf " - Success.\n\n"
|
||||||
|
cd ..
|
||||||
|
}
|
||||||
|
|
||||||
|
case "${1}" in
|
||||||
|
make-deb)
|
||||||
|
case "${2}" in
|
||||||
|
arm64-v8a)
|
||||||
|
PREFIX="64"
|
||||||
|
ARM_PREFIX="-v8a"
|
||||||
|
;;
|
||||||
|
armeabi-v7a)
|
||||||
|
PREFIX="32"
|
||||||
|
ARM_PREFIX=""
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
abort " - Error: unknown architecture flag: $2. Avaiable: arm64-v8a & armeabi-v7a.\n"
|
||||||
|
esac
|
||||||
|
|
||||||
|
case "${3}" in
|
||||||
|
sudo)
|
||||||
|
SUDO="sudo"
|
||||||
|
;;
|
||||||
|
no-sudo)
|
||||||
|
SUDO=""
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
SUDO=""
|
||||||
|
esac
|
||||||
|
gen_deb
|
||||||
|
;;
|
||||||
|
modpack)
|
||||||
|
case "${2}" in
|
||||||
|
arm64-v8a)
|
||||||
|
STATICLIB_DIR="${CUR_DIR}/obj/local/${2}"
|
||||||
|
;;
|
||||||
|
armeabi-v7a)
|
||||||
|
STATICLIB_DIR="${CUR_DIR}/obj/local/${2}"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
abort " - Error: unknown architecture flag: ${2}. Avaiable: arm64-v8a & armeabi-v7a.\n"
|
||||||
|
esac
|
||||||
|
|
||||||
|
gen_modpack
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
abort "${0}: invalid operand.\nUse the make-deb flag to create a deb package, and the modpack flag to create packages for static libraries."
|
||||||
|
esac
|
||||||
|
|
||||||
|
# end of script
|
||||||
Reference in New Issue
Block a user