Compare commits
110 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d7ddaa8621 | |||
| 62b24d5705 | |||
| 0fca319b29 | |||
| 929150e034 | |||
| 93843a511d | |||
| 0981e70268 | |||
| b214da3cd6 | |||
| 464bfe6e56 | |||
| f5531fde32 | |||
| f771fb7c68 | |||
| 4bc5235952 | |||
| d4b4c91ff4 | |||
| 6fc38eb01d | |||
| 42e5d132e7 | |||
| 39d1411b11 | |||
| 04d6471c86 | |||
| f7d2f313de | |||
| 49a87b0387 | |||
| 5a104e5b22 | |||
| 055213f2f6 | |||
| 7f270e319c | |||
| 6a035f8f41 | |||
| 1b2dda655a | |||
| 07d63944c1 | |||
| 36b7bcf246 | |||
| cd3f65a145 | |||
| 9dd29f96b8 | |||
| 7254637caf | |||
| 2af00a8028 | |||
| b5790af803 | |||
| 8fe1548796 | |||
| 04d8ccdd81 | |||
| 1a790d1d89 | |||
| 1296e488f1 | |||
| 3fea6c73cc | |||
| cf4b590130 | |||
| 352ef6e68a | |||
| 754ebaade2 | |||
| 8a28a8f1ef | |||
| 086a2dd93d | |||
| 383a1efe55 | |||
| b96977a5fc | |||
| 976c10593c | |||
| d45dd67cbe | |||
| 0fa5a546aa | |||
| 0c487c62fe | |||
| 105d92e0ca | |||
| 850d104a1a | |||
| 6d24fb9eae | |||
| ae8c73c4f5 | |||
| 890d93131c | |||
| a33d4e3f16 | |||
| f344d62d4c | |||
| 40c5b155dc | |||
| 0547e18639 | |||
| f34a47889e | |||
| a9fac9e661 | |||
| e8040de436 | |||
| ff6e82c556 | |||
| 0c7da875b2 | |||
| 41565d221f | |||
| 5ba78d860e | |||
| 181125dfca | |||
| 4464c203fd | |||
| b9e58df98f | |||
| e2f8cf4ca3 | |||
| 07e2249ef1 | |||
| fd970be822 | |||
| 45c964997c | |||
| 31b7f16a29 | |||
| 5f83a4476f | |||
| 5438f5210f | |||
| cb7904cd5a | |||
| 9c570d5b02 | |||
| c9736863fe | |||
| d5ce065e8b | |||
| a4bc9e3834 | |||
| ce017e2cbc | |||
| b5daf8a44c | |||
| f125ae760c | |||
| f68f92ade1 | |||
| 3a723446cc | |||
| 1d66a3c21f | |||
| 13e31df7c6 | |||
| 4922ed5a35 | |||
| 3220aace91 | |||
| 7f85d63088 | |||
| 412b697b9c | |||
| afc958aeb4 | |||
| fbd45e0936 | |||
| 0ef8767eb5 | |||
| 9bc871573e | |||
| adad63bbbd | |||
| 0157c886ae | |||
| 076774d9f4 | |||
| 25642cc6f2 | |||
| 16c8654fa2 | |||
| 1fb592a94f | |||
| 5bb26c9eea | |||
| 540dd4fe35 | |||
| 22ef985925 | |||
| 2e81ab9541 | |||
| 112a2986b5 | |||
| 65fd480ba2 | |||
| d31bccd8f6 | |||
| 6c574e9536 | |||
| a4838b24e1 | |||
| 908060219e | |||
| ac06203a2c | |||
| 56976b2bd0 |
12
CHANGELOG.md
12
CHANGELOG.md
@@ -1,9 +1,7 @@
|
|||||||
#### Version 1.7.0 (code 170):
|
### Version 2.0.0 (code 200) changelog
|
||||||
- Force mode added
|
- Instead of make, it was switched to build with NDK
|
||||||
- Compatibility with C++ compilers ensured
|
- File/partition sizes were given during backup/flash operations.
|
||||||
- Code integrity fixed
|
- The use of `fprintf` has started for all error messages.
|
||||||
- Exit codes have meanings. Review the code to understand
|
|
||||||
|
|
||||||
| END OF VERSION 1.7.0 CHANGELOG |
|
| END OF VERSION 2.0.0 CHANGELOG |
|
||||||
|------------------------------------|
|
|------------------------------------|
|
||||||
|
|
||||||
|
|||||||
4
DISCLAIMER
Normal file → Executable file
4
DISCLAIMER
Normal file → Executable file
@@ -1,6 +1,6 @@
|
|||||||
WARNING:
|
WARNING:
|
||||||
Disclaimer of Liability Regarding the Use of the C Library
|
Disclaimer of Liability Regarding the Use of the C Library
|
||||||
- This library is intended for the user to backup the C android partitions. However, we do not accept responsibility for any problems or losses that may arise during its use.
|
- This library is intended for the user to manage the C android partitions. However, we do not accept responsibility for any problems or losses that may arise during its use.
|
||||||
- Users should carefully test the library functions and, if necessary, implement their own error management mechanisms.
|
- Users should carefully test the library functions and, if necessary, implement their own error management mechanisms.
|
||||||
- The authors reserve the right to make any changes or updates related to the library.
|
- The authors reserve the right to make any changes or updates related to the library.
|
||||||
- This library is intended for backing up android partitions and its suitability for any specific project or application is not guaranteed. It is important for users to evaluate the suitability of their own projects.
|
- This library is intended for management android partitions and its suitability for any specific project or application is not guaranteed. It is important for users to evaluate the suitability of their own projects.
|
||||||
132
Makefile
132
Makefile
@@ -1,132 +0,0 @@
|
|||||||
# By YZBruh
|
|
||||||
|
|
||||||
# Copyright 2024 YZBruh - Partition Backupper
|
|
||||||
#
|
|
||||||
# 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.
|
|
||||||
|
|
||||||
include config/env.mk
|
|
||||||
|
|
||||||
# speficy {version}
|
|
||||||
VERSION := 1.7.0
|
|
||||||
VERSION_CODE := 170
|
|
||||||
SOURCE_DIR := binary
|
|
||||||
TARGET := pmt
|
|
||||||
LANG := en
|
|
||||||
ARCH := $(shell uname -m)
|
|
||||||
CUR_DIR := $(shell pwd)
|
|
||||||
|
|
||||||
# sources
|
|
||||||
SRCS := $(SOURCE_DIR)/$(TARGET).c
|
|
||||||
SRCS += $(SOURCE_DIR)/error.c
|
|
||||||
SRCS += $(SOURCE_DIR)/checkers.c
|
|
||||||
SRCS += $(SOURCE_DIR)/listpart.c
|
|
||||||
SRCS += $(SOURCE_DIR)/flash.c
|
|
||||||
SRCS += $(SOURCE_DIR)/backup.c
|
|
||||||
SRCS += $(SOURCE_DIR)/docs.c
|
|
||||||
|
|
||||||
# objects
|
|
||||||
OBJS := $(SOURCE_DIR)/$(TARGET).o
|
|
||||||
OBJS += $(SOURCE_DIR)/error.o
|
|
||||||
OBJS += $(SOURCE_DIR)/checkers.o
|
|
||||||
OBJS += $(SOURCE_DIR)/listpart.o
|
|
||||||
OBJS += $(SOURCE_DIR)/flash.o
|
|
||||||
OBJS += $(SOURCE_DIR)/backup.o
|
|
||||||
OBJS += $(SOURCE_DIR)/docs.o
|
|
||||||
|
|
||||||
OUT_DIR := $(CUR_DIR)/out
|
|
||||||
BINARY_DIR := $(OUT_DIR)/binary
|
|
||||||
PACKAGE_DIR := $(OUT_DIR)/package
|
|
||||||
|
|
||||||
# display
|
|
||||||
all:
|
|
||||||
@printf " --- Building Partition Manager --- \n"; \
|
|
||||||
printf "Version: $(VERSION)\n"; \
|
|
||||||
printf "Version code: $(VERSION_CODE)\n\n"; \
|
|
||||||
printf " ------------------------------------- \n\n"; \
|
|
||||||
printf "Starting build... Please waith.\n"; \
|
|
||||||
sleep 2; \
|
|
||||||
printf "Make running with silent mode...\n"; \
|
|
||||||
make -s pmt;
|
|
||||||
|
|
||||||
# build progress
|
|
||||||
.PHONY: $(TARGET)
|
|
||||||
$(TARGET): $(OBJS)
|
|
||||||
$(CC) $(CFLAGS) -o $@ $(OBJS)
|
|
||||||
@mkdir -p $(OUT_DIR); \
|
|
||||||
mkdir -p $(BINARY_DIR); \
|
|
||||||
mkdir -p $(PACKAGE_DIR); \
|
|
||||||
mv pmt $(BINARY_DIR); \
|
|
||||||
printf "Generating gzip package...\n"; \
|
|
||||||
cp $(BINARY_DIR)/pmt $(PACKAGE_DIR); \
|
|
||||||
gzip -f $(PACKAGE_DIR)/pmt; \
|
|
||||||
mv $(PACKAGE_DIR)/pmt.gz $(PACKAGE_DIR)/pmt-$(ARCH)-$(LANG).gz; \
|
|
||||||
printf " \n"; \
|
|
||||||
printf " ------------------------------------- \n";
|
|
||||||
|
|
||||||
# cleaner functions
|
|
||||||
.PHONY: clean
|
|
||||||
clean:
|
|
||||||
@printf "Cleaning (builded files [.o extended])...\n"; \
|
|
||||||
sleep 2; \
|
|
||||||
rm -rf $(OBJS); \
|
|
||||||
printf "Success\n";
|
|
||||||
|
|
||||||
.PHONY: clean-all
|
|
||||||
clean-all:
|
|
||||||
@printf "Cleaning (builded files [.o extended] and binary)...\n"; \
|
|
||||||
sleep 2; \
|
|
||||||
rm -rf $(OBJS) $(OUT_DIR); \
|
|
||||||
printf "Success\n";
|
|
||||||
|
|
||||||
# helper function
|
|
||||||
.PHONY: help
|
|
||||||
help:
|
|
||||||
@printf " --------- Partition Manager help ---------\n"; \
|
|
||||||
printf " \n"; \
|
|
||||||
printf " Commands;\n"; \
|
|
||||||
printf " make ==> Build Partition Manager\n"; \
|
|
||||||
printf " make clean ==> Clear files (Builded binaries are not deleted)\n"; \
|
|
||||||
printf " make clean-all ==> Clear files (Builded binaries are deleted)\n"; \
|
|
||||||
printf " make install-termux ==> If you are using termux, it installs the compiled pmt into termux. So it allows you to use it like a normal command.\n"; \
|
|
||||||
printf " make uninstall-termux ==> If you are using termux, it uninstalls the compiled pmt into termux.\n"; \
|
|
||||||
printf " make help ==> Display help message\n"; \
|
|
||||||
printf " \n";
|
|
||||||
|
|
||||||
# installer
|
|
||||||
.PHONY: install-termux
|
|
||||||
install-termux:
|
|
||||||
@if [ -f /data/data/com.termux/files/usr/bin/termux-open ]; then \
|
|
||||||
printf " ------------------------------------- \n"; \
|
|
||||||
printf " pmt installer \n"; \
|
|
||||||
printf " ------------------------------------- \n"; \
|
|
||||||
cp $(BINARY_DIR)/pmt /data/data/com.termux/files/usr/bin/pmt || exit 1; \
|
|
||||||
chmod 777 /data/data/com.termux/files/usr/bin/pmt || exit 1; \
|
|
||||||
printf " \n"; \
|
|
||||||
printf "Success.\n\n"; \
|
|
||||||
else \
|
|
||||||
printf "This function is only available on Termux Android devices using aarch64 (64-bit) and armv7l (32-bit)\n"; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
# uninstaller
|
|
||||||
.PHONY: uninstall-termux
|
|
||||||
uninstall-termux:
|
|
||||||
@if [ -f /data/data/com.termux/files/usr/bin/termux-open ]; then \
|
|
||||||
printf " ------------------------------------- \n"; \
|
|
||||||
printf " pmt uninstaller \n"; \
|
|
||||||
printf " ------------------------------------- \n"; \
|
|
||||||
rm /data/data/com.termux/files/usr/bin/pmt || exit 1; \
|
|
||||||
printf " \n"; \
|
|
||||||
printf "Success.\n\n"; \
|
|
||||||
else \
|
|
||||||
printf "This function is only available on Termux Android devices using aarch64 (64-bit) and armv7l (32-bit)\n"; \
|
|
||||||
fi
|
|
||||||
4
NOTICE
Normal file → Executable file
4
NOTICE
Normal file → Executable file
@@ -1,4 +1,4 @@
|
|||||||
Copyright 2024 YZBruh - Partition Manager
|
Copyright 2024 Partition Manager
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -10,4 +10,4 @@ Unless required by applicable law or agreed to in writing, software
|
|||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
72
README.md
72
README.md
@@ -1,12 +1,12 @@
|
|||||||
## Partition Manager (pmt)
|
## Partition Manager (pmt)
|
||||||
|
|
||||||
This binary static C library is for manage partitions of android devices.
|
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...
|
It offers a lot of options. I will place these below. But first let me talk about the operation...
|
||||||
|
|
||||||
```
|
```
|
||||||
1. The partition name is obtained (with the -p or --partition argument)
|
1. The partition name is obtained (with the -p or --partition argument)
|
||||||
2. Other arguments (if used) are processed.
|
2. Other arguments (if used) are processed.
|
||||||
3. It is backed up using DD. If the progress is not a problem, it is not given (DD)
|
3. The backup and flashing processes were written according to DD's code. So there is a piece of toybox code
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Presented arguments (options)
|
#### Presented arguments (options)
|
||||||
@@ -15,6 +15,7 @@ It offers a lot of options. I will place these below. But first let me talk abou
|
|||||||
Usage:
|
Usage:
|
||||||
-b | --backup backup mode
|
-b | --backup backup mode
|
||||||
-F | --flash flash mode
|
-F | --flash flash mode
|
||||||
|
-r | --format format mode (only ext2/3/4 file systems)
|
||||||
-p | --partition name of the partition to be backed up
|
-p | --partition name of the partition to be backed up
|
||||||
-l | --logical know that the partition that will be backed up is logical
|
-l | --logical know that the partition that will be backed up is logical
|
||||||
-o | --out (only backups) the output name of the backed-up partition (default: partition name)
|
-o | --out (only backups) the output name of the backed-up partition (default: partition name)
|
||||||
@@ -23,7 +24,7 @@ Usage:
|
|||||||
-D | --list list partitions
|
-D | --list list partitions
|
||||||
-f | --force force mode. Output is not produced. Even if it's a mistake. But if the target is not a mode, the error is given. If you want to work stable, it is important to specify this option first.
|
-f | --force force mode. Output is not produced. Even if it's a mistake. But if the target is not a mode, the error is given. If you want to work stable, it is important to specify this option first.
|
||||||
-v | --version see version
|
-v | --version see version
|
||||||
--help see help message
|
--help see help message
|
||||||
-L | --license see license
|
-L | --license see license
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
@@ -31,7 +32,7 @@ Examples:
|
|||||||
--flash /sdcard/twrp/boot.img -p boot_a -c /dev/block/platform/bootdevice/by-name
|
--flash /sdcard/twrp/boot.img -p boot_a -c /dev/block/platform/bootdevice/by-name
|
||||||
-c /dev/block/platform/bootdevice/by-name --list
|
-c /dev/block/platform/bootdevice/by-name --list
|
||||||
|
|
||||||
Report bugs to <yagizzengin73@gmail.com>
|
Report bugs to <t.me/YZBruh>
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Some notes
|
#### Some notes
|
||||||
@@ -40,31 +41,48 @@ Report bugs to <yagizzengin73@gmail.com>
|
|||||||
- Packages are available in publications.
|
- Packages are available in publications.
|
||||||
- İt is mandatory to use the `-b` | `--backup` or `-f` | `--flash` and `-p` | `--partition` argument. After all, a partition name and progress type is required to be progress.
|
- İt is mandatory to use the `-b` | `--backup` or `-f` | `--flash` and `-p` | `--partition` argument. After all, a partition name and progress type is required to be progress.
|
||||||
- If the logical partition flag is not used, a classic partition is tried to be processing by default.
|
- 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/1.7.0-en/CHANGELOG.md)
|
- [Click to see special version changes](https://github.com/YZBruh/pbt/blob/2.0.0-en/CHANGELOG.md)
|
||||||
- Let me know your suggestions!
|
- Let me know your suggestions!
|
||||||
|
|
||||||
### How is it built?
|
### How is it built?
|
||||||
Even termux is enough to build the pmt. Or you can compile it with linux if you want. NOTE: Use a custom gcc according to the architecture you want to compile.
|
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.0.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/
|
||||||
|
|
|
||||||
|
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
|
||||||
|
```
|
||||||
|
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
|
||||||
|
```
|
||||||
|
|
||||||
|
### Notes
|
||||||
If you want to change something, take a look at the configuration. You can change him.
|
If you want to change something, take a look at the configuration. You can change him.
|
||||||
it is located in the `config` folder. His name is `env.mk`. I gave the information in the file. You can ask more.
|
it is located in the `jni/config` folder. His name is `env.mk`. I gave the information in the file. You can ask more.
|
||||||
|
|
||||||
To build;
|
|
||||||
```
|
|
||||||
make
|
|
||||||
```
|
|
||||||
|
|
||||||
Special `make` commands (pbt offers :) ;
|
|
||||||
```
|
|
||||||
--------- Partition Manager help ---------
|
|
||||||
|
|
||||||
Commands;
|
|
||||||
make ==> Build Partition Manager
|
|
||||||
make clean ==> Clear files (Builded binaries are not deleted)
|
|
||||||
make clean-all ==> Clear files (Builded binaries are deleted)
|
|
||||||
make install-termux ==> If you are using termux, it installs the compiled pmt into termux. So it allows you to use it like a normal command.
|
|
||||||
make uninstall-termux ==> If you are using termux, it uninstalls the compiled pmt into termux.
|
|
||||||
make help ==> Display help message
|
|
||||||
```
|
|
||||||
|
|
||||||
I compiled it with termux :D. Why should I bother... I compiled it with `GCC 18.0.2` You can look at the version with the viewing option :)
|
|
||||||
|
|||||||
109
binary/backup.c
109
binary/backup.c
@@ -1,109 +0,0 @@
|
|||||||
/* By YZBruh */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright 2024 YZBruh - 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
#include "include/pmt.h"
|
|
||||||
|
|
||||||
extern char *out;
|
|
||||||
extern char *outdir;
|
|
||||||
extern char *cust_cxt;
|
|
||||||
extern bool pmt_use_logical;
|
|
||||||
extern bool pmt_use_cust_cxt;
|
|
||||||
extern bool pmt_force_mode;
|
|
||||||
|
|
||||||
/* backupper func */
|
|
||||||
void backup(char *target_backup_partition, char *backup_partition_style)
|
|
||||||
{
|
|
||||||
static char backupper_path[200];
|
|
||||||
if (strstr(backup_partition_style, "classic") != NULL) {
|
|
||||||
if (pmt_use_cust_cxt) {
|
|
||||||
sprintf(backupper_path, "%s/%s", cust_cxt, target_backup_partition);
|
|
||||||
} else {
|
|
||||||
sprintf(backupper_path, "/dev/block/by-name/%s", target_backup_partition);
|
|
||||||
}
|
|
||||||
} else if (strstr(backup_partition_style, "logical") != NULL) {
|
|
||||||
sprintf(backupper_path, "/dev/block/mapper/%s", target_backup_partition);
|
|
||||||
} else {
|
|
||||||
if (!pmt_force_mode) {
|
|
||||||
error("İnvalid partition type!\n", 28);
|
|
||||||
} else {
|
|
||||||
exit(28);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (access(backupper_path, F_OK) == -1) {
|
|
||||||
if (!pmt_force_mode) {
|
|
||||||
error("Partition not found!\n", 29);
|
|
||||||
} else {
|
|
||||||
exit(29);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static char backupper_cmd[256];
|
|
||||||
if (outdir != NULL) {
|
|
||||||
if (out != NULL) {
|
|
||||||
sprintf(backupper_cmd, "dd if=%s of=%s/%s.img status=none", backupper_path, outdir, out);
|
|
||||||
} else {
|
|
||||||
sprintf(backupper_cmd, "dd if=%s of=%s/%s.img status=none", backupper_path, outdir, target_backup_partition);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (out != NULL) {
|
|
||||||
sprintf(backupper_cmd, "dd if=%s of=/storage/emulated/0/%s.img status=none", backupper_path, out);
|
|
||||||
} else {
|
|
||||||
sprintf(backupper_cmd, "dd if=%s of=/storage/emulated/0/%s.img status=none", backupper_path, target_backup_partition);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (system(backupper_cmd) != 0) {
|
|
||||||
if (!pmt_force_mode) {
|
|
||||||
error("Failed!\n", 99);
|
|
||||||
} else {
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (outdir != NULL) {
|
|
||||||
if (out != NULL) {
|
|
||||||
printf("%sSuccess. Output: %s/%s.img%s\n", ANSI_GREEN, outdir, out, ANSI_RESET);
|
|
||||||
} else {
|
|
||||||
printf("%sSuccess. Output: %s/%s.img%s\n", ANSI_GREEN, outdir, target_backup_partition, ANSI_RESET);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (out != NULL) {
|
|
||||||
printf("%sSuccess. Output: /storage/emulated/0/%s.img%s\n", ANSI_GREEN, out, ANSI_RESET);
|
|
||||||
} else {
|
|
||||||
printf("%sSuccess. Output: /storage/emulated/0/%s.img%s\n", ANSI_GREEN, target_backup_partition, ANSI_RESET);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* end of code */
|
|
||||||
@@ -1,86 +0,0 @@
|
|||||||
/* By YZBruh */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright 2024 YZBruh - 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
#include "include/pmt.h"
|
|
||||||
|
|
||||||
extern char *cust_cxt;
|
|
||||||
extern bool pmt_use_cust_cxt;
|
|
||||||
extern bool pmt_force_mode;
|
|
||||||
|
|
||||||
/* flasher func */
|
|
||||||
void flash(char *target_flash_partition, char *target_file, char *flash_partition_style)
|
|
||||||
{
|
|
||||||
static char flasher_path[200];
|
|
||||||
/* determine device block */
|
|
||||||
/* for classic */
|
|
||||||
if (strstr(flash_partition_style, "classic") != NULL) {
|
|
||||||
if (pmt_use_cust_cxt) {
|
|
||||||
sprintf(flasher_path, "%s/%s", cust_cxt, target_flash_partition);
|
|
||||||
} else {
|
|
||||||
sprintf(flasher_path, "/dev/block/by-name/%s", target_flash_partition);
|
|
||||||
}
|
|
||||||
/* for logical */
|
|
||||||
} else if (strstr(flash_partition_style, "logical") != NULL) {
|
|
||||||
sprintf(flasher_path, "/dev/block/mapper/%s", target_flash_partition);
|
|
||||||
} else {
|
|
||||||
if (!pmt_force_mode) {
|
|
||||||
error("İnvalid partition type!\n", 30);
|
|
||||||
} else {
|
|
||||||
exit(30);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* check partition */
|
|
||||||
if (access(flasher_path, F_OK) == -1) {
|
|
||||||
if (!pmt_force_mode) {
|
|
||||||
error("Partition not found!\n", 31);
|
|
||||||
} else {
|
|
||||||
exit(31);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* setting up */
|
|
||||||
static char flasher_cmd[256];
|
|
||||||
sprintf(flasher_cmd, "dd if=%s of=%s status=none", target_file, flasher_path);
|
|
||||||
|
|
||||||
/* start flash */
|
|
||||||
if (system(flasher_cmd) != 0) {
|
|
||||||
if (!pmt_force_mode) {
|
|
||||||
error("Failed!\n", 98);
|
|
||||||
} else {
|
|
||||||
exit(98);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* end of code */
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
/* By YZBruh */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright 2024 YZBruh - 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* check compiler system */
|
|
||||||
#ifdef _WIN32
|
|
||||||
#error "it can only be compiled in linux or android environment. but current system windows (_WIN32 defined)"
|
|
||||||
#elif ! __linux__ || __android__
|
|
||||||
#error "unknown compiler system founded"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* compiler architecture if arm is not 32-bit or 64-bit, the compilation is stopped */
|
|
||||||
#if ! defined __arm__ || __aarch64__ || __aarch32__ || __armv8__ || __armv7l__
|
|
||||||
#error "only 32-bit or 64-bit arm compilers can be used"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _COMMON_H_
|
|
||||||
#define _COMMON_H_
|
|
||||||
|
|
||||||
/* color definations */
|
|
||||||
#define ANSI_RED "\033[31m"
|
|
||||||
#define ANSI_YELLOW "\033[33m"
|
|
||||||
#define ANSI_GREEN "\033[32m"
|
|
||||||
#define ANSI_RESET "\033[0m"
|
|
||||||
|
|
||||||
/* info */
|
|
||||||
#define PMT_VERSION "1.7.0"
|
|
||||||
#define PMT_VERSION_CODE "170"
|
|
||||||
#define PMT_PACKAGE_NAME "Partition Manager"
|
|
||||||
#define PMT_PACKAGE_LANG "en"
|
|
||||||
|
|
||||||
/* variable definations */
|
|
||||||
extern char *out;
|
|
||||||
extern char *outdir;
|
|
||||||
extern char *cust_cxt;
|
|
||||||
extern char *target_partition;
|
|
||||||
extern char *target_flash_file;
|
|
||||||
extern bool pmt_use_logical;
|
|
||||||
extern bool pmt_use_cust_cxt;
|
|
||||||
extern bool pmt_ab;
|
|
||||||
extern bool pmt_logical;
|
|
||||||
extern bool pmt_flash;
|
|
||||||
extern bool pmt_backup;
|
|
||||||
extern bool pmt_force_mode;
|
|
||||||
|
|
||||||
/* function definations */
|
|
||||||
void listpart();
|
|
||||||
void error(const char *err_msg, uint32_t errcode);
|
|
||||||
void check_psf();
|
|
||||||
void check_root();
|
|
||||||
void backup(char *target_backup_partition, char *backup_partition_style);
|
|
||||||
void flash(char *target_flash_partition, char *target_file, char *flash_partition_style);
|
|
||||||
void help();
|
|
||||||
void licenses();
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
/* end of code */
|
|
||||||
306
binary/pmt.c
306
binary/pmt.c
@@ -1,306 +0,0 @@
|
|||||||
/* By YZBruh */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright 2024 YZBruh - 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <getopt.h>
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
#include "include/pmt.h"
|
|
||||||
|
|
||||||
char *out = NULL;
|
|
||||||
char *outdir = NULL;
|
|
||||||
char *cust_cxt = NULL;
|
|
||||||
char *target_partition = NULL;
|
|
||||||
char *target_flash_file = NULL;
|
|
||||||
bool pmt_use_logical = NULL;
|
|
||||||
bool pmt_use_cust_cxt = NULL;
|
|
||||||
bool pmt_ab = false;
|
|
||||||
bool pmt_logical = false;
|
|
||||||
bool pmt_flash = false;
|
|
||||||
bool pmt_backup = false;
|
|
||||||
bool pmt_force_mode = false;
|
|
||||||
|
|
||||||
/* classic main function (C binary here xd) */
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
/* check argument total */
|
|
||||||
if (argc < 2) {
|
|
||||||
fprintf(stderr, "%s: missing operand\nTry `%s --help` for more information.\n", argv[0], argv[0]);
|
|
||||||
exit(44);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* a structure for long arguments... */
|
|
||||||
struct option long_options[] = {
|
|
||||||
{"backup", no_argument, 0, 'b'},
|
|
||||||
{"flash", required_argument, 0, 'F'},
|
|
||||||
{"partition", required_argument, 0, 'p'},
|
|
||||||
{"logical", no_argument, 0, 'l'},
|
|
||||||
{"out", required_argument, 0, 'o'},
|
|
||||||
{"outdir", required_argument, 0, 'd'},
|
|
||||||
{"context", required_argument, 0, 'c'},
|
|
||||||
{"list", no_argument, 0, 'D'},
|
|
||||||
{"force", no_argument, 0, 'f'},
|
|
||||||
{"version", no_argument, 0, 'v'},
|
|
||||||
{"help", no_argument, 0, 0},
|
|
||||||
{"license", no_argument, 0, 'L'},
|
|
||||||
{0, 0, 0, 0}
|
|
||||||
};
|
|
||||||
|
|
||||||
static char *opt_symbol = "-";
|
|
||||||
static char *common_symbol_rule;
|
|
||||||
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.\n";
|
|
||||||
int opt;
|
|
||||||
/* control for each argument */
|
|
||||||
while ((opt = getopt_long(argc, argv, "bF:p:lo:d:c:DfvL", long_options, NULL)) != -1) {
|
|
||||||
/* process arguments */
|
|
||||||
switch (opt) {
|
|
||||||
case 'b':
|
|
||||||
pmt_backup = true;
|
|
||||||
break;
|
|
||||||
case 'F':
|
|
||||||
target_flash_file = strdup(optarg);
|
|
||||||
if (strncmp(target_flash_file, opt_symbol, 1) == 0) {
|
|
||||||
if (!pmt_force_mode) {
|
|
||||||
error(common_symbol_rule, 19);
|
|
||||||
} else {
|
|
||||||
exit(19);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pmt_flash = true;
|
|
||||||
check_root();
|
|
||||||
check_psf();
|
|
||||||
struct stat flashf_info;
|
|
||||||
if (stat(target_flash_file, &flashf_info) != 0) {
|
|
||||||
if (!pmt_force_mode) {
|
|
||||||
fprintf(stderr, "%s: %s: %s\n", argv[0], target_flash_file, strerror(errno));
|
|
||||||
exit(15);
|
|
||||||
} else {
|
|
||||||
exit(15);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!S_ISREG(flashf_info.st_mode)) {
|
|
||||||
if (!pmt_force_mode) {
|
|
||||||
fprintf(stderr, "%s: %s: is a not file.\n", argv[0], target_flash_file);
|
|
||||||
exit(16);
|
|
||||||
} else {
|
|
||||||
exit(16);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'p':
|
|
||||||
target_partition = strdup(optarg);
|
|
||||||
if (strncmp(target_partition, opt_symbol, 1) == 0) {
|
|
||||||
if (!pmt_force_mode) {
|
|
||||||
error(common_symbol_rule, 19);
|
|
||||||
} else {
|
|
||||||
exit(19);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'l':
|
|
||||||
check_root();
|
|
||||||
check_psf();
|
|
||||||
if (pmt_logical) {
|
|
||||||
pmt_use_logical = true;
|
|
||||||
} else {
|
|
||||||
if (!pmt_force_mode) {
|
|
||||||
error("This device does not have logical partitions!\n", 17);
|
|
||||||
} else {
|
|
||||||
exit(17);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'o':
|
|
||||||
out = strdup(optarg);
|
|
||||||
if (strncmp(out, opt_symbol, 1) == 0) {
|
|
||||||
if (!pmt_force_mode) {
|
|
||||||
error(common_symbol_rule, 19);
|
|
||||||
} else {
|
|
||||||
exit(19);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'd':
|
|
||||||
outdir = strdup(optarg);
|
|
||||||
if (strncmp(outdir, opt_symbol, 1) == 0) {
|
|
||||||
if (!pmt_force_mode) {
|
|
||||||
error(common_symbol_rule, 19);
|
|
||||||
} else {
|
|
||||||
exit(19);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
check_root();
|
|
||||||
check_psf();
|
|
||||||
struct stat out_info;
|
|
||||||
if (stat(outdir, &out_info) != 0) {
|
|
||||||
if (!pmt_force_mode) {
|
|
||||||
fprintf(stderr, "%s: %s: %s\n", argv[0], outdir, strerror(errno));
|
|
||||||
exit(18);
|
|
||||||
} else {
|
|
||||||
exit(18);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!S_ISDIR(out_info.st_mode)) {
|
|
||||||
if (!pmt_force_mode) {
|
|
||||||
fprintf(stderr, "%s: %s: is a not directory.\n", argv[0], outdir);
|
|
||||||
exit(20);
|
|
||||||
} else {
|
|
||||||
exit(20);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'c':
|
|
||||||
pmt_use_cust_cxt = true;
|
|
||||||
cust_cxt = strdup(optarg);
|
|
||||||
if (strncmp(cust_cxt, opt_symbol, 1) == 0) {
|
|
||||||
if (!pmt_force_mode) {
|
|
||||||
error(common_symbol_rule, 19);
|
|
||||||
} else {
|
|
||||||
exit(19);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'D':
|
|
||||||
check_root();
|
|
||||||
listpart();
|
|
||||||
exit(EXIT_SUCCESS);
|
|
||||||
break;
|
|
||||||
case 'f':
|
|
||||||
pmt_force_mode = true;
|
|
||||||
break;
|
|
||||||
case 'v':
|
|
||||||
printf("Version: %s (code %s)\n", PMT_VERSION, PMT_VERSION_CODE);
|
|
||||||
#ifdef __clang__
|
|
||||||
printf("Compiler: clang %s", __clang_version__);
|
|
||||||
#endif
|
|
||||||
#ifdef __GNUC__
|
|
||||||
printf("(GNUC %d.%d.%d)\n", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
|
|
||||||
#else
|
|
||||||
printf("\n");
|
|
||||||
#endif
|
|
||||||
printf("See licenses with -L argument.\n");
|
|
||||||
exit(EXIT_SUCCESS);
|
|
||||||
break;
|
|
||||||
case 0:
|
|
||||||
help();
|
|
||||||
exit(EXIT_SUCCESS);
|
|
||||||
break;
|
|
||||||
case 'L':
|
|
||||||
licenses();
|
|
||||||
exit(EXIT_SUCCESS);
|
|
||||||
break;
|
|
||||||
case '?':
|
|
||||||
printf("Try `%s --help' for more information.\n", argv[0]);
|
|
||||||
exit(43);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
printf("Usage: %s [-b | --backup] [-f | --flash FILE] [-p | --partition PARTITION] [-l | --logical] [-o | --out OUTNAME] [-d | --outdir OUTDIR] [-c | --context] [-D | --list] [-v | --version] [--help] [-L | --license]\n", argv[0]);
|
|
||||||
exit(44);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* minor checks */
|
|
||||||
if (!pmt_backup && !pmt_flash) {
|
|
||||||
fprintf(stderr, "%s: missing operand.\nTry `%s --help` for more information.\n", argv[0], argv[0]);
|
|
||||||
exit(3);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pmt_backup && pmt_flash) {
|
|
||||||
if (!pmt_force_mode) {
|
|
||||||
error("Backup and flash functions cannot be used in the same command\n", 9);
|
|
||||||
} else {
|
|
||||||
exit(9);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* checks */
|
|
||||||
check_root();
|
|
||||||
check_psf();
|
|
||||||
|
|
||||||
/* custom context checker */
|
|
||||||
if (pmt_use_cust_cxt) {
|
|
||||||
struct stat cxtinfo;
|
|
||||||
if (stat(cust_cxt, &cxtinfo) == 0) {
|
|
||||||
if (!S_ISREG(cxtinfo.st_mode)) {
|
|
||||||
if (!pmt_force_mode) {
|
|
||||||
fprintf(stderr, "%s: %s: is a not directory.\n", argv[0], cust_cxt);
|
|
||||||
exit(8);
|
|
||||||
} else {
|
|
||||||
exit(8);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!pmt_force_mode) {
|
|
||||||
fprintf(stderr, "%s: %s: %s\n", argv[0], cust_cxt, strerror(errno));
|
|
||||||
exit(6);
|
|
||||||
} else {
|
|
||||||
exit(6);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (strstr(cust_cxt, "/dev") == NULL && !pmt_force_mode) {
|
|
||||||
printf("%sThis custom context is strange...%s\n", ANSI_YELLOW, ANSI_RESET);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (target_partition == NULL) {
|
|
||||||
if (!pmt_force_mode) {
|
|
||||||
fprintf(stderr, "%s: required partition name.\nTry `%s --help' for more information.\n", argv[0], argv[0]);
|
|
||||||
exit(5);
|
|
||||||
} else {
|
|
||||||
exit(5);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (pmt_backup) {
|
|
||||||
if (pmt_use_logical) {
|
|
||||||
backup(target_partition, "logical");
|
|
||||||
exit(EXIT_SUCCESS);
|
|
||||||
} else {
|
|
||||||
backup(target_partition, "classic");
|
|
||||||
exit(EXIT_SUCCESS);
|
|
||||||
}
|
|
||||||
} else if (pmt_flash) {
|
|
||||||
if (pmt_use_logical) {
|
|
||||||
flash(target_partition, target_flash_file, "logical");
|
|
||||||
exit(EXIT_SUCCESS);
|
|
||||||
} else {
|
|
||||||
flash(target_partition, target_flash_file, "classic");
|
|
||||||
exit(EXIT_SUCCESS);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
fprintf(stderr, "%s: no target (backup or flash).\nTry `%s --help` for more information.\n", argv[0], argv[0]);
|
|
||||||
exit(3);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* end of code */
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
# By YZBruh
|
|
||||||
|
|
||||||
# Copyright 2024 YZBruh - 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.
|
|
||||||
|
|
||||||
#########################################
|
|
||||||
# #
|
|
||||||
# Configuration Flags #
|
|
||||||
# #
|
|
||||||
# Warning: you can edit #
|
|
||||||
# #
|
|
||||||
#########################################
|
|
||||||
|
|
||||||
|
|
||||||
# use custom gcc | true or false
|
|
||||||
USE_CUST_GCC := false
|
|
||||||
|
|
||||||
# custom gcc ext (if used)
|
|
||||||
CUST_GCC :=
|
|
||||||
|
|
||||||
# addionital gcc flags
|
|
||||||
EXTRA_GCC_FLAGS :=
|
|
||||||
|
|
||||||
#########################################
|
|
||||||
#########################################
|
|
||||||
|
|
||||||
#########################################
|
|
||||||
# #
|
|
||||||
# Apply Configuration #
|
|
||||||
# #
|
|
||||||
# Warning: please do not edit #
|
|
||||||
# #
|
|
||||||
#########################################
|
|
||||||
|
|
||||||
# gcc setting
|
|
||||||
ifeq ($(USE_CUST_GCC), true)
|
|
||||||
CC := $(CUST_GCC)
|
|
||||||
LD := $(CUST_GCC)
|
|
||||||
else ifeq ($(USE_CUST_GCC), false)
|
|
||||||
CC := gcc
|
|
||||||
LD := gcc
|
|
||||||
else
|
|
||||||
$(error İnvalid custom gcc config flag: $(USE_CUST_GCC))
|
|
||||||
endif
|
|
||||||
|
|
||||||
# gcc flag settings
|
|
||||||
CFLAGS := -O3 -g -Wall -Wextra $(EXTRA_GCC_FLAGS)
|
|
||||||
|
|
||||||
#########################################
|
|
||||||
#########################################
|
|
||||||
9
debutils/DEBIAN/control_32
Executable file
9
debutils/DEBIAN/control_32
Executable file
@@ -0,0 +1,9 @@
|
|||||||
|
Source: pmt
|
||||||
|
Package: pmt
|
||||||
|
Version: 2.0.0
|
||||||
|
Architecture: arm
|
||||||
|
Description: pmt is for reading, writing and formatting partitions of android devices
|
||||||
|
Section: misc
|
||||||
|
Priority: optional
|
||||||
|
Maintainer: YZBruh <yagizzengin73@gmail.com>
|
||||||
|
Standards-Version: 4.5.0
|
||||||
9
debutils/DEBIAN/control_64
Executable file
9
debutils/DEBIAN/control_64
Executable file
@@ -0,0 +1,9 @@
|
|||||||
|
Source: pmt
|
||||||
|
Package: pmt
|
||||||
|
Version: 2.0.0
|
||||||
|
Architecture: aarch64
|
||||||
|
Description: pmt is for reading, writing and formatting partitions of android devices
|
||||||
|
Section: misc
|
||||||
|
Priority: optional
|
||||||
|
Maintainer: YZBruh <yagizzengin73@gmail.com>
|
||||||
|
Standards-Version: 4.5.0
|
||||||
0
debutils/data/data/com.termux/files/usr/bin/dummy
Executable file
0
debutils/data/data/com.termux/files/usr/bin/dummy
Executable file
0
debutils/data/data/com.termux/files/usr/share/man/man1/dummy
Executable file
0
debutils/data/data/com.termux/files/usr/share/man/man1/dummy
Executable file
24
debutils/mandoc/pmt.1
Executable file
24
debutils/mandoc/pmt.1
Executable file
@@ -0,0 +1,24 @@
|
|||||||
|
PMT Android Partition Manager 1.8.0
|
||||||
|
|
||||||
|
OPTIONS:
|
||||||
|
-b | --backup backup mode
|
||||||
|
-F | --flash flash mode
|
||||||
|
-r | --format format mode (only ext2/3/4 file systems)
|
||||||
|
-p | --partition name of the partition to be backed up
|
||||||
|
-l | --logical know that the partition that will be backed up is logical
|
||||||
|
-o | --out (only backups) the output name of the backed-up partition (default: partition name)
|
||||||
|
-d | --outdir (only backups) directory where the backup partition will be saved (default: /storage/emulated/0)
|
||||||
|
-c | --context it is meant to specify a custom /dev context. Only classic partitions (default: /dev/block/by-name)
|
||||||
|
-D | --list list partitions
|
||||||
|
-f | --force force mode. Output is not produced. Even if it's a mistake. But if the target is not a mode, the error is given. If you want to work stable, it is important to specify this option first.
|
||||||
|
-v | --version see version
|
||||||
|
--help see help message
|
||||||
|
-L | --license see license
|
||||||
|
|
||||||
|
EXAMPLES:
|
||||||
|
-b --partition boot_a -o boot_slot_a_image -d /sdcard/backup -c /dev/block/platform/bootdevice/by-name
|
||||||
|
--flash /sdcard/twrp/boot.img -p boot_a -c /dev/block/platform/bootdevice/by-name
|
||||||
|
-c /dev/block/platform/bootdevice/by-name --list
|
||||||
|
|
||||||
|
BUGS:
|
||||||
|
Report bugs to <yagizzengin73@gmail.com>
|
||||||
48
jni/Android.mk
Executable file
48
jni/Android.mk
Executable file
@@ -0,0 +1,48 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
LOCAL_PATH := $(call my-dir)
|
||||||
|
ENVCONF := $(LOCAL_PATH)/config/env.mk
|
||||||
|
|
||||||
|
include $(CLEAR_VARS)
|
||||||
|
include $(ENVCONF)
|
||||||
|
|
||||||
|
# configration
|
||||||
|
LOCAL_MODULE = pmt
|
||||||
|
LOCAL_SRC_FILES = \
|
||||||
|
pmt.c \
|
||||||
|
versioner.c \
|
||||||
|
tools.c \
|
||||||
|
checkers.c \
|
||||||
|
listpart.c \
|
||||||
|
docs.c
|
||||||
|
|
||||||
|
# include dirs
|
||||||
|
LOCAL_C_INCLUDES = $(LOCAL_PATH)/include
|
||||||
|
|
||||||
|
# compiler flags settings
|
||||||
|
ifeq ($(ENABLE_DEBUGGING), true)
|
||||||
|
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)
|
||||||
|
|
||||||
|
# end
|
||||||
26
jni/Application.mk
Executable file
26
jni/Application.mk
Executable file
@@ -0,0 +1,26 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
# architecture
|
||||||
|
APP_ABI := \
|
||||||
|
arm64-v8a \
|
||||||
|
armeabi-v7a
|
||||||
|
|
||||||
|
APP_PLATFORM := android-21
|
||||||
|
|
||||||
|
APP_OPTIM := release
|
||||||
|
|
||||||
|
# end
|
||||||
61
binary/checkers.c → jni/checkers.c
Normal file → Executable file
61
binary/checkers.c → jni/checkers.c
Normal file → Executable file
@@ -1,7 +1,7 @@
|
|||||||
/* By YZBruh */
|
/* By YZBruh */
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Copyright 2024 YZBruh - Partition Manager
|
* Copyright 2024 Partition Manager
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#if defined(__cplusplus)
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -26,8 +26,7 @@ extern "C" {
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <pmt.h>
|
||||||
#include "include/pmt.h"
|
|
||||||
|
|
||||||
extern bool pmt_use_cust_cxt;
|
extern bool pmt_use_cust_cxt;
|
||||||
extern bool pmt_ab;
|
extern bool pmt_ab;
|
||||||
@@ -39,37 +38,27 @@ extern char *cust_cxt;
|
|||||||
void check_psf()
|
void check_psf()
|
||||||
{
|
{
|
||||||
/* true = ab | false = a */
|
/* true = ab | false = a */
|
||||||
if (pmt_use_cust_cxt) {
|
if (pmt_use_cust_cxt)
|
||||||
|
{
|
||||||
static char cust_cxt_ck_path[150];
|
static char cust_cxt_ck_path[150];
|
||||||
sprintf(cust_cxt_ck_path, "%s/boot_a", cust_cxt);
|
sprintf(cust_cxt_ck_path, "%s/boot_a", cust_cxt);
|
||||||
if (access(cust_cxt_ck_path, F_OK) != 0) {
|
if (access(cust_cxt_ck_path, F_OK) != 0) pmt_ab = false;
|
||||||
pmt_ab = false;
|
else pmt_ab = true;
|
||||||
} else {
|
|
||||||
pmt_ab = true;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (access("/dev/block/by-name/boot_a", F_OK) != 0) {
|
if (access("/dev/block/by-name/boot_a", F_OK) != 0) pmt_ab = false;
|
||||||
pmt_ab = false;
|
else pmt_ab = true;
|
||||||
} else {
|
|
||||||
pmt_ab = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* true = logical | false = classic */
|
/* true = logical | false = classic */
|
||||||
if (pmt_use_cust_cxt) {
|
if (pmt_use_cust_cxt)
|
||||||
|
{
|
||||||
static char cust_cxt_ckl_path[150];
|
static char cust_cxt_ckl_path[150];
|
||||||
sprintf(cust_cxt_ckl_path, "%s/super", cust_cxt);
|
sprintf(cust_cxt_ckl_path, "%s/super", cust_cxt);
|
||||||
if (access(cust_cxt_ckl_path, F_OK) != 0) {
|
if (access(cust_cxt_ckl_path, F_OK) != 0) pmt_logical = false;
|
||||||
pmt_logical = false;
|
else pmt_logical = true;
|
||||||
} else {
|
|
||||||
pmt_logical = true;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (access("/dev/block/by-name/super", F_OK) != 0) {
|
if (access("/dev/block/by-name/super", F_OK) != 0) pmt_logical = false;
|
||||||
pmt_logical = false;
|
else pmt_logical = true;
|
||||||
} else {
|
|
||||||
pmt_logical = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,18 +66,18 @@ void check_psf()
|
|||||||
void check_root()
|
void check_root()
|
||||||
{
|
{
|
||||||
/* a quick, easy method to verify root :D */
|
/* a quick, easy method to verify root :D */
|
||||||
if (chdir("/dev/block") != 0) {
|
if (getuid() != 0)
|
||||||
if (!pmt_force_mode) {
|
{
|
||||||
|
if (!pmt_force_mode)
|
||||||
|
{
|
||||||
fprintf(stderr, ANSI_RED "Root privileges could not be detected! Please run this binary with root. Error reason: %s\n" ANSI_RESET, strerror(errno));
|
fprintf(stderr, ANSI_RED "Root privileges could not be detected! Please run this binary with root. Error reason: %s\n" ANSI_RESET, strerror(errno));
|
||||||
exit(27);
|
exit(27);
|
||||||
} else {
|
} else exit(27);
|
||||||
exit(27);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
/* end of code */
|
/* end of code */
|
||||||
31
jni/config/env.mk
Executable file
31
jni/config/env.mk
Executable file
@@ -0,0 +1,31 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
#########################################
|
||||||
|
# #
|
||||||
|
# Configuration Flags #
|
||||||
|
# #
|
||||||
|
# Warning: you can edit #
|
||||||
|
# #
|
||||||
|
#########################################
|
||||||
|
|
||||||
|
# addionital compiler flags
|
||||||
|
EXTRA_COMPILER_FLAGS ?=
|
||||||
|
|
||||||
|
# debugging mode (binary)
|
||||||
|
ENABLE_DEBUGGING ?= false
|
||||||
|
|
||||||
|
# end of environment configuration
|
||||||
17
binary/docs.c → jni/docs.c
Normal file → Executable file
17
binary/docs.c → jni/docs.c
Normal file → Executable file
@@ -1,7 +1,7 @@
|
|||||||
/* By YZBruh */
|
/* By YZBruh */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2024 YZBruh - Partition Manager
|
* Copyright 2024 Partition Manager
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -16,18 +16,16 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#if defined(__cplusplus)
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdbool.h>
|
#include <pmt-docs.h>
|
||||||
|
|
||||||
#include "include/pmt.h"
|
|
||||||
|
|
||||||
void licenses()
|
void licenses()
|
||||||
{
|
{
|
||||||
printf("Copyright 2024 YZBruh - Partition Manager\n");
|
printf("Copyright 2024 Partition Manager\n");
|
||||||
printf("Licensed under the Apache License, Version 2.0 (the \"License\");\n");
|
printf("Licensed under the Apache License, Version 2.0 (the \"License\");\n");
|
||||||
printf("you may not use this file except in compliance with the License.\n");
|
printf("you may not use this file except in compliance with the License.\n");
|
||||||
printf("You may obtain a copy of the License at\n\n");
|
printf("You may obtain a copy of the License at\n\n");
|
||||||
@@ -43,6 +41,7 @@ void help()
|
|||||||
printf("Usage: \n");
|
printf("Usage: \n");
|
||||||
printf(" -b | --backup backup mode\n");
|
printf(" -b | --backup backup mode\n");
|
||||||
printf(" -F | --flash flash mode\n");
|
printf(" -F | --flash flash mode\n");
|
||||||
|
printf(" -r | --format format mode (only ext2/3/4 file systems)\n");
|
||||||
printf(" -p | --partition name of the partition to be backed up\n");
|
printf(" -p | --partition name of the partition to be backed up\n");
|
||||||
printf(" -l | --logical know that the partition that will be backed up is logical\n");
|
printf(" -l | --logical know that the partition that will be backed up is logical\n");
|
||||||
printf(" -o | --out (only backups) the output name of the backed-up partition (default: partition name)\n");
|
printf(" -o | --out (only backups) the output name of the backed-up partition (default: partition name)\n");
|
||||||
@@ -57,11 +56,11 @@ void help()
|
|||||||
printf(" -b --partition boot_a -o boot_slot_a_image -d /sdcard/backup -c /dev/block/platform/bootdevice/by-name\n");
|
printf(" -b --partition boot_a -o boot_slot_a_image -d /sdcard/backup -c /dev/block/platform/bootdevice/by-name\n");
|
||||||
printf(" --flash /sdcard/twrp/boot.img -p boot_a -c /dev/block/platform/bootdevice/by-name\n");
|
printf(" --flash /sdcard/twrp/boot.img -p boot_a -c /dev/block/platform/bootdevice/by-name\n");
|
||||||
printf(" -c /dev/block/platform/bootdevice/by-name --list\n\n");
|
printf(" -c /dev/block/platform/bootdevice/by-name --list\n\n");
|
||||||
printf("Report bugs to <xda-@YZBruh>\n");
|
printf("Report bugs to <t.me/YZBruh>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
/* end of code */
|
/* end of code */
|
||||||
26
binary/error.c → jni/include/pmt-docs.h
Normal file → Executable file
26
binary/error.c → jni/include/pmt-docs.h
Normal file → Executable file
@@ -1,7 +1,7 @@
|
|||||||
/* By YZBruh */
|
/* By YZBruh */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2024 YZBruh - Partition Manager
|
* Copyright 2024 Partition Manager
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -16,25 +16,15 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#if defined(__cplusplus)
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
#include <stdio.h>
|
void help();
|
||||||
#include <stdlib.h>
|
void licenses();
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
#include "include/pmt.h"
|
#if defined(__cplusplus)
|
||||||
|
|
||||||
/* shorter error messages will be functional xd */
|
|
||||||
void error(const char *err_msg, uint32_t errcode)
|
|
||||||
{
|
|
||||||
fprintf(stderr, ANSI_RED "%s" ANSI_RESET, err_msg);
|
|
||||||
exit(errcode);
|
|
||||||
}
|
}
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
/* end */
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* end of code */
|
|
||||||
32
jni/include/pmt-versioning.h
Executable file
32
jni/include/pmt-versioning.h
Executable file
@@ -0,0 +1,32 @@
|
|||||||
|
/* 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 */
|
||||||
|
|
||||||
|
/* versioning */
|
||||||
|
#define PMT_MAJOR 2
|
||||||
|
#define PMT_LEVEL 0
|
||||||
|
#define PMT_PATCH 0
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
}
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
/* end */
|
||||||
64
jni/include/pmt.h
Executable file
64
jni/include/pmt.h
Executable file
@@ -0,0 +1,64 @@
|
|||||||
|
/* 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
|
||||||
|
|
||||||
|
#if !defined(__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"
|
||||||
|
|
||||||
|
/* variable definations */
|
||||||
|
extern char *out;
|
||||||
|
extern char *outdir;
|
||||||
|
extern char *cust_cxt;
|
||||||
|
extern char *target_partition;
|
||||||
|
extern char *target_flash_file;
|
||||||
|
extern char *format_fs;
|
||||||
|
extern char *partition_type;
|
||||||
|
extern bool pmt_use_logical;
|
||||||
|
extern bool pmt_use_cust_cxt;
|
||||||
|
extern bool pmt_ab;
|
||||||
|
extern bool pmt_logical;
|
||||||
|
extern bool pmt_flash;
|
||||||
|
extern bool pmt_backup;
|
||||||
|
extern bool pmt_format;
|
||||||
|
extern bool pmt_force_mode;
|
||||||
|
|
||||||
|
/* function definations */
|
||||||
|
void listpart();
|
||||||
|
void check_psf();
|
||||||
|
void check_root();
|
||||||
|
void pmt(unsigned short progress_code);
|
||||||
|
void version();
|
||||||
|
|
||||||
|
#endif /* __PMT_H_ */
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
}
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
/* end of code */
|
||||||
51
binary/listpart.c → jni/listpart.c
Normal file → Executable file
51
binary/listpart.c → jni/listpart.c
Normal file → Executable file
@@ -1,7 +1,7 @@
|
|||||||
/* By YZBruh */
|
/* By YZBruh */
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Copyright 2024 YZBruh - Partition Manager
|
* Copyright 2024 Partition Manager
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#if defined(__cplusplus)
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -26,8 +26,8 @@ extern "C" {
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
#include <string.h>
|
||||||
#include "include/pmt.h"
|
#include <pmt.h>
|
||||||
|
|
||||||
extern bool pmt_use_cust_cxt;
|
extern bool pmt_use_cust_cxt;
|
||||||
extern bool pmt_ab;
|
extern bool pmt_ab;
|
||||||
@@ -40,25 +40,25 @@ void listpart() {
|
|||||||
DIR *dir;
|
DIR *dir;
|
||||||
struct dirent *entry;
|
struct dirent *entry;
|
||||||
|
|
||||||
if (pmt_use_cust_cxt) {
|
if (pmt_use_cust_cxt)
|
||||||
|
{
|
||||||
dir = opendir(cust_cxt);
|
dir = opendir(cust_cxt);
|
||||||
if (dir == NULL) {
|
if (dir == NULL)
|
||||||
|
{
|
||||||
if (!pmt_force_mode) {
|
if (!pmt_force_mode) {
|
||||||
fprintf(stderr, "Could not open: `%s`. Error reason: %s\n", cust_cxt, strerror(errno));
|
fprintf(stderr, "Could not open: `%s`. Error reason: %s\n", cust_cxt, strerror(errno));
|
||||||
exit(62);
|
exit(62);
|
||||||
} else {
|
} else exit(62);
|
||||||
exit(62);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dir = opendir("/dev/block/by-name");
|
dir = opendir("/dev/block/by-name");
|
||||||
if (dir == NULL) {
|
if (dir == NULL)
|
||||||
if (!pmt_force_mode) {
|
{
|
||||||
|
if (!pmt_force_mode)
|
||||||
|
{
|
||||||
fprintf(stderr, "Could not open: `/dev/block/by-name`. Error reason: %s\n", strerror(errno));
|
fprintf(stderr, "Could not open: `/dev/block/by-name`. Error reason: %s\n", strerror(errno));
|
||||||
exit(63);
|
exit(63);
|
||||||
} else {
|
} else exit(63);
|
||||||
exit(63);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,24 +68,23 @@ void listpart() {
|
|||||||
|
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
|
|
||||||
if (pmt_logical) {
|
if (pmt_logical)
|
||||||
|
{
|
||||||
printf("List of logical partitions (/dev/block/mapper): \n");
|
printf("List of logical partitions (/dev/block/mapper): \n");
|
||||||
if (system("ls /dev/block/mapper") != 0 && !pmt_force_mode) {
|
if (system("ls /dev/block/mapper") != 0 && !pmt_force_mode)
|
||||||
error("An error occurred when the logical partition list appears!\n", 64);
|
{
|
||||||
|
fprintf(stderr, "%sAn error occurred when the logical partition list appears!%s\n", ANSI_RED, ANSI_RESET);
|
||||||
|
exit(64);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pmt_ab && !pmt_force_mode) {
|
if (pmt_ab && !pmt_force_mode) printf("%sWarning: device using A/B partition style.%s\n", ANSI_YELLOW, ANSI_RESET);
|
||||||
printf("%sWarning: device using A/B partition style.%s\n", ANSI_YELLOW, ANSI_RESET);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pmt_logical && !pmt_force_mode) {
|
if (pmt_logical && !pmt_force_mode) printf("%sWarning: device using logical partition type.%s\n", ANSI_YELLOW, ANSI_RESET);
|
||||||
printf("%sWarning: device using logical partition type.%s\n", ANSI_YELLOW, ANSI_RESET);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
/* end of code */
|
/* end of code */
|
||||||
404
jni/pmt.c
Executable file
404
jni/pmt.c
Executable file
@@ -0,0 +1,404 @@
|
|||||||
|
/* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* force use C std (if default is C++) */
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* include needed libs (headers) */
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <getopt.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <pmt.h>
|
||||||
|
#include <pmt-docs.h>
|
||||||
|
|
||||||
|
/* add value to variables that are added globally and are not worth */
|
||||||
|
char *out = NULL;
|
||||||
|
char *outdir = NULL;
|
||||||
|
char *cust_cxt = NULL;
|
||||||
|
char *target_partition = NULL;
|
||||||
|
char *target_flash_file = NULL;
|
||||||
|
char *partition_type = NULL;
|
||||||
|
char *format_fs = NULL;
|
||||||
|
bool pmt_use_logical = NULL;
|
||||||
|
bool pmt_use_cust_cxt = NULL;
|
||||||
|
bool pmt_ab = false;
|
||||||
|
bool pmt_logical = false;
|
||||||
|
bool pmt_flash = false;
|
||||||
|
bool pmt_backup = false;
|
||||||
|
bool pmt_format = false;
|
||||||
|
bool pmt_force_mode = false;
|
||||||
|
|
||||||
|
/* classic main function (C binary here xd) */
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
/* check argument total */
|
||||||
|
if (argc < 2)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: missing operand\nTry `%s --help' for more information.\n", argv[0], argv[0]);
|
||||||
|
exit(44);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* a structure for long arguments... */
|
||||||
|
struct option long_options[] = {
|
||||||
|
{"backup", no_argument, 0, 'b'},
|
||||||
|
{"flash", required_argument, 0, 'F'},
|
||||||
|
{"format", required_argument, 0, 'r'},
|
||||||
|
{"partition", required_argument, 0, 'p'},
|
||||||
|
{"logical", no_argument, 0, 'l'},
|
||||||
|
{"out", required_argument, 0, 'o'},
|
||||||
|
{"outdir", required_argument, 0, 'd'},
|
||||||
|
{"context", required_argument, 0, 'c'},
|
||||||
|
{"list", no_argument, 0, 'D'},
|
||||||
|
{"force", no_argument, 0, 'f'},
|
||||||
|
{"version", no_argument, 0, 'v'},
|
||||||
|
{"help", no_argument, 0, 0},
|
||||||
|
{"license", no_argument, 0, 'L'},
|
||||||
|
{0, 0, 0, 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
/* boolean statements (only valid in this file) to distinguish. and pointer from a shortcut for the symbol rule */
|
||||||
|
static bool wiew_help = false;
|
||||||
|
static bool wiew_licenses = false;
|
||||||
|
static bool wiew_version = false;
|
||||||
|
static bool list_partitions = false;
|
||||||
|
static bool combo_wiewers = false;
|
||||||
|
static bool use_cust_outdir = false;
|
||||||
|
static char *opt_symbol = "-";
|
||||||
|
static char *common_symbol_rule;
|
||||||
|
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.";
|
||||||
|
|
||||||
|
int opt;
|
||||||
|
|
||||||
|
/* control for each argument */
|
||||||
|
while ((opt = getopt_long(argc, argv, "bF:rp:lo:d:c:DfvL", long_options, NULL)) != -1)
|
||||||
|
{
|
||||||
|
/* process arguments */
|
||||||
|
switch (opt)
|
||||||
|
{
|
||||||
|
/* backup mode */
|
||||||
|
case 'b':
|
||||||
|
pmt_backup = true;
|
||||||
|
break;
|
||||||
|
/* flash mode */
|
||||||
|
case 'F':
|
||||||
|
target_flash_file = strdup(optarg);
|
||||||
|
if (strncmp(target_flash_file, opt_symbol, 1) == 0)
|
||||||
|
{
|
||||||
|
if (!pmt_force_mode)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s%s%s\n", ANSI_RED, common_symbol_rule, ANSI_RESET);
|
||||||
|
exit(19);
|
||||||
|
} else exit(19);
|
||||||
|
}
|
||||||
|
pmt_flash = true;
|
||||||
|
break;
|
||||||
|
/* format mode */
|
||||||
|
case 'r':
|
||||||
|
format_fs = strdup(optarg);
|
||||||
|
if (strncmp(format_fs, opt_symbol, 1) == 0)
|
||||||
|
{
|
||||||
|
if (!pmt_force_mode)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s%s%s\n", ANSI_RED, common_symbol_rule, ANSI_RESET);
|
||||||
|
exit(19);
|
||||||
|
} else exit(19);
|
||||||
|
}
|
||||||
|
pmt_format = true;
|
||||||
|
break;
|
||||||
|
/* partition selector option */
|
||||||
|
case 'p':
|
||||||
|
target_partition = strdup(optarg);
|
||||||
|
if (strncmp(target_partition, opt_symbol, 1) == 0)
|
||||||
|
{
|
||||||
|
if (!pmt_force_mode)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s%s%s\n", ANSI_RED, common_symbol_rule, ANSI_RESET);
|
||||||
|
exit(19);
|
||||||
|
} else exit(19);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
/* logical partitions option */
|
||||||
|
case 'l':
|
||||||
|
check_root();
|
||||||
|
check_psf();
|
||||||
|
if (pmt_logical)
|
||||||
|
{
|
||||||
|
pmt_use_logical = true;
|
||||||
|
} else {
|
||||||
|
if (!pmt_force_mode)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "This device does not have logical partitions!\n");
|
||||||
|
exit(17);
|
||||||
|
} else exit(17);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
/* output file option */
|
||||||
|
case 'o':
|
||||||
|
out = strdup(optarg);
|
||||||
|
if (strncmp(out, opt_symbol, 1) == 0)
|
||||||
|
{
|
||||||
|
if (!pmt_force_mode)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s%s%s\n", ANSI_RED, common_symbol_rule, ANSI_RESET);
|
||||||
|
exit(19);
|
||||||
|
} else exit(19);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
/* output dir option */
|
||||||
|
case 'd':
|
||||||
|
use_cust_outdir = true;
|
||||||
|
outdir = strdup(optarg);
|
||||||
|
break;
|
||||||
|
/* context selector option */
|
||||||
|
case 'c':
|
||||||
|
pmt_use_cust_cxt = true;
|
||||||
|
cust_cxt = strdup(optarg);
|
||||||
|
if (strncmp(cust_cxt, opt_symbol, 1) == 0)
|
||||||
|
{
|
||||||
|
if (!pmt_force_mode)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s%s%s\n", ANSI_RED, common_symbol_rule, ANSI_RESET);
|
||||||
|
exit(19);
|
||||||
|
} else exit(19);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
/* partition lister function */
|
||||||
|
case 'D':
|
||||||
|
list_partitions = true;
|
||||||
|
/* check combo wiewer options and progress */
|
||||||
|
if (wiew_version || wiew_help || wiew_licenses) combo_wiewers = true;
|
||||||
|
break;
|
||||||
|
/* force mode option */
|
||||||
|
case 'f':
|
||||||
|
pmt_force_mode = true;
|
||||||
|
break;
|
||||||
|
/* version info option */
|
||||||
|
case 'v':
|
||||||
|
wiew_version = true;
|
||||||
|
/* check combo wiewer options and progress */
|
||||||
|
if (list_partitions || wiew_help || wiew_licenses) combo_wiewers = true;
|
||||||
|
break;
|
||||||
|
/* help message opption */
|
||||||
|
case 0:
|
||||||
|
wiew_help = true;
|
||||||
|
/* check combo wiewer options and progress */
|
||||||
|
if (wiew_version || list_partitions || wiew_licenses) combo_wiewers = true;
|
||||||
|
break;
|
||||||
|
/* license wiewer option */
|
||||||
|
case 'L':
|
||||||
|
wiew_licenses = true;
|
||||||
|
/* check combo wiewer options and progress */
|
||||||
|
if (wiew_version || wiew_help || list_partitions) combo_wiewers = true;
|
||||||
|
break;
|
||||||
|
/* for invalid options */
|
||||||
|
case '?':
|
||||||
|
printf("Try `%s --help' for more information.\n", argv[0]);
|
||||||
|
exit(43);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
printf("Usage: %s [-b | --backup] [-f | --flash FILE] [-r | --format FS_TYPE] [-p | --partition PARTITION] [-l | --logical] [-o | --out OUTNAME] [-d | --outdir OUTDIR] [-c | --context] [-D | --list] [-v | --version] [--help] [-L | --license]\n", argv[0]);
|
||||||
|
exit(44);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* stop the program if multiple viewer is used */
|
||||||
|
if (combo_wiewers)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: Multiple wiewers cannot be used at the same line.\n", argv[0]);
|
||||||
|
exit(81);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* controller to handle viewer */
|
||||||
|
if (wiew_help)
|
||||||
|
{
|
||||||
|
help();
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
} else if (wiew_version)
|
||||||
|
{
|
||||||
|
version();
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
} else if (wiew_licenses)
|
||||||
|
{
|
||||||
|
licenses();
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
} else if (list_partitions)
|
||||||
|
{
|
||||||
|
check_root();
|
||||||
|
listpart();
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* target control is done */
|
||||||
|
if (!pmt_backup && !pmt_flash && !pmt_format)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: missing operand.\nTry `%s --help` for more information.\n", argv[0], argv[0]);
|
||||||
|
exit(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* prevent multiple mode use */
|
||||||
|
if (pmt_backup && pmt_flash)
|
||||||
|
{
|
||||||
|
if (!pmt_force_mode)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Backup and flash functions cannot be used in the same command.\n");
|
||||||
|
exit(9);
|
||||||
|
} else exit(9);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* checks */
|
||||||
|
check_root();
|
||||||
|
check_psf();
|
||||||
|
|
||||||
|
if (pmt_format)
|
||||||
|
{
|
||||||
|
if (strcmp(format_fs, "ext4") != 0 || strcmp(format_fs, "ext3") != 0 || strcmp(format_fs, "ext2") != 0)
|
||||||
|
{
|
||||||
|
if (!pmt_force_mode)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: formatter: unsupported filesystem: %s", argv[0], format_fs);
|
||||||
|
exit(41);
|
||||||
|
} else exit(41);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (use_cust_outdir)
|
||||||
|
{
|
||||||
|
if (strncmp(outdir, opt_symbol, 1) == 0)
|
||||||
|
{
|
||||||
|
if (!pmt_force_mode)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s\n", common_symbol_rule);
|
||||||
|
exit(19);
|
||||||
|
} else exit(19);
|
||||||
|
}
|
||||||
|
struct stat out_info;
|
||||||
|
if (stat(outdir, &out_info) != 0)
|
||||||
|
{
|
||||||
|
if (!pmt_force_mode)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: cannot stat '%s': %s\n", argv[0], outdir, strerror(errno));
|
||||||
|
exit(18);
|
||||||
|
} else exit(18);
|
||||||
|
} else {
|
||||||
|
if (!S_ISDIR(out_info.st_mode))
|
||||||
|
{
|
||||||
|
if (!pmt_force_mode)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: %s: is a not directory.\n", argv[0], outdir);
|
||||||
|
exit(20);
|
||||||
|
} else exit(20);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pmt_flash)
|
||||||
|
{
|
||||||
|
struct stat flashf_info;
|
||||||
|
if (stat(target_flash_file, &flashf_info) != 0)
|
||||||
|
{
|
||||||
|
if (!pmt_force_mode)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: cannot stat '%s': %s\n", argv[0], target_flash_file, strerror(errno));
|
||||||
|
exit(15);
|
||||||
|
} else exit(15);
|
||||||
|
} else {
|
||||||
|
if (!S_ISREG(flashf_info.st_mode))
|
||||||
|
{
|
||||||
|
if (!pmt_force_mode)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: %s: is a not file.\n", argv[0], target_flash_file);
|
||||||
|
exit(16);
|
||||||
|
} else exit(16);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* custom context checker */
|
||||||
|
if (pmt_use_cust_cxt)
|
||||||
|
{
|
||||||
|
struct stat cxtinfo;
|
||||||
|
if (stat(cust_cxt, &cxtinfo) == 0)
|
||||||
|
{
|
||||||
|
if (!S_ISREG(cxtinfo.st_mode))
|
||||||
|
{
|
||||||
|
if (!pmt_force_mode)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: %s: is a not directory.\n", argv[0], cust_cxt);
|
||||||
|
exit(8);
|
||||||
|
} else exit(8);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!pmt_force_mode)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: %s: %s\n", argv[0], cust_cxt, strerror(errno));
|
||||||
|
exit(6);
|
||||||
|
} else exit(6);
|
||||||
|
}
|
||||||
|
if (strstr(cust_cxt, "/dev") == NULL && !pmt_force_mode)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%sYou're going through my wave? There's nothing about this /dev. Use force mode if you don't want this error%s\n", ANSI_YELLOW, ANSI_RESET);
|
||||||
|
exit(81);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (target_partition == NULL)
|
||||||
|
{
|
||||||
|
if (!pmt_force_mode)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: required partition name.\nTry `%s --help' for more information.\n", argv[0], argv[0]);
|
||||||
|
exit(5);
|
||||||
|
} else exit(5);
|
||||||
|
} else {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 1 = backup mode
|
||||||
|
*
|
||||||
|
* 2 = flash mode
|
||||||
|
*
|
||||||
|
* 3 = format
|
||||||
|
*/
|
||||||
|
if (pmt_backup)
|
||||||
|
{
|
||||||
|
pmt(1);
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
} else if (pmt_flash)
|
||||||
|
{
|
||||||
|
pmt(2);
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
} else if (pmt_format)
|
||||||
|
{
|
||||||
|
pmt(3);
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "%s: no target (backup or flash).\nTry `%s --help` for more information.\n", argv[0], argv[0]);
|
||||||
|
exit(3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* end of code */
|
||||||
299
jni/tools.c
Executable file
299
jni/tools.c
Executable file
@@ -0,0 +1,299 @@
|
|||||||
|
/* 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
|
||||||
|
|
||||||
|
#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 <fcntl.h>
|
||||||
|
#include <pmt.h>
|
||||||
|
|
||||||
|
#define BFSIZE 1024
|
||||||
|
|
||||||
|
extern char *out;
|
||||||
|
extern char *outdir;
|
||||||
|
extern char *format_fs;
|
||||||
|
extern char *cust_cxt;
|
||||||
|
extern char *target_partition;
|
||||||
|
extern char *target_flash_file;
|
||||||
|
extern char *partition_type;
|
||||||
|
extern bool pmt_use_logical;
|
||||||
|
extern bool pmt_use_cust_cxt;
|
||||||
|
extern bool pmt_logical;
|
||||||
|
extern bool pmt_flash;
|
||||||
|
extern bool pmt_backup;
|
||||||
|
extern bool pmt_force_mode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* if progress_code is a
|
||||||
|
* 1 = backup mode
|
||||||
|
*
|
||||||
|
* 2 = flash mode
|
||||||
|
*
|
||||||
|
* 3 = format mode
|
||||||
|
*/
|
||||||
|
|
||||||
|
static double
|
||||||
|
calc_flsz(char *filepath)
|
||||||
|
{
|
||||||
|
static int calc_flsz_file;
|
||||||
|
calc_flsz_file = open(filepath, O_RDONLY);
|
||||||
|
if (calc_flsz_file == -1) return -1;
|
||||||
|
|
||||||
|
off_t flsz = lseek(calc_flsz_file, 0, SEEK_END);
|
||||||
|
close(calc_flsz_file);
|
||||||
|
|
||||||
|
if (flsz == (off_t)-1) return -1;
|
||||||
|
|
||||||
|
return (double)flsz / (1024 * 1024);
|
||||||
|
}
|
||||||
|
|
||||||
|
void pmt(unsigned short progress_code)
|
||||||
|
{
|
||||||
|
/* required variables */
|
||||||
|
static int srcf, targetf;
|
||||||
|
static char backupper_path[512];
|
||||||
|
static char ppath[100];
|
||||||
|
static char formatter_cmd[200];
|
||||||
|
static char outf[512];
|
||||||
|
static char flasher_path[512];
|
||||||
|
static char buffer[BFSIZE];
|
||||||
|
static ssize_t bytesRead;
|
||||||
|
static unsigned long long bytesCopied = 0;
|
||||||
|
static unsigned long long count = 1024 * 1024 * 1024;
|
||||||
|
|
||||||
|
if (progress_code == 1)
|
||||||
|
{
|
||||||
|
if (!pmt_use_logical)
|
||||||
|
{
|
||||||
|
if (pmt_use_cust_cxt) sprintf(backupper_path, "%s/%s", cust_cxt, 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_force_mode)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "İnvalid partition type!\n");
|
||||||
|
exit(28);
|
||||||
|
} else exit(28);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (access(backupper_path, F_OK) == -1)
|
||||||
|
{
|
||||||
|
if (!pmt_force_mode)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Partition not found!\n");
|
||||||
|
exit(29);
|
||||||
|
} else exit(29);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (calc_flsz(backupper_path) != -1 && !pmt_force_mode) printf("Disk size of the partition to be backed up: %.2f\n", calc_flsz(backupper_path));
|
||||||
|
else printf("%sFailed to target partition disk size%s\n", ANSI_YELLOW, ANSI_RESET);
|
||||||
|
|
||||||
|
srcf = open(backupper_path, O_RDONLY);
|
||||||
|
if (srcf == -1) {
|
||||||
|
if (!pmt_force_mode)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Couldn't read: %s: %s", backupper_path, strerror(errno));
|
||||||
|
exit(39);
|
||||||
|
} else exit(39);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* determine output */
|
||||||
|
if (outdir != NULL)
|
||||||
|
{
|
||||||
|
if (out != NULL) sprintf(outf, "%s/%s.img", outdir, out);
|
||||||
|
else sprintf(outf, "%s/%s.img", outdir, target_partition);
|
||||||
|
} else {
|
||||||
|
if (out != NULL) sprintf(outf, "/storage/emulated/0/%s.img", out);
|
||||||
|
else sprintf(outf, "/storage/emulated/0/%s.img", target_partition);
|
||||||
|
}
|
||||||
|
|
||||||
|
targetf = open(outf, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
||||||
|
if (targetf == -1) {
|
||||||
|
if (!pmt_force_mode)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Couldn't generate: %s: %s", outf, strerror(errno));
|
||||||
|
exit(37);
|
||||||
|
} else exit(37);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* start writing */
|
||||||
|
while ((bytesRead = read(srcf, buffer, BFSIZE)) > 0 && bytesCopied < count)
|
||||||
|
{
|
||||||
|
ssize_t bytesWritten = write(targetf, buffer, bytesRead);
|
||||||
|
if (bytesWritten != bytesRead)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Couldn't write: %s: %s", backupper_path, strerror(errno));
|
||||||
|
close(srcf);
|
||||||
|
close(targetf);
|
||||||
|
exit(81);
|
||||||
|
}
|
||||||
|
|
||||||
|
bytesCopied += bytesWritten;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* close files */
|
||||||
|
close(srcf);
|
||||||
|
close(targetf);
|
||||||
|
|
||||||
|
/* Print the output information by evaluating all situations */
|
||||||
|
if (outdir != NULL)
|
||||||
|
{
|
||||||
|
if (out != NULL) printf("%sSuccess. Output: %s/%s.img%s\n", ANSI_GREEN, outdir, out, ANSI_RESET);
|
||||||
|
else printf("%sSuccess. Output: %s/%s.img%s\n", ANSI_GREEN, outdir, target_partition, ANSI_RESET);
|
||||||
|
} else {
|
||||||
|
if (out != NULL) printf("%sSuccess. Output: /storage/emulated/0/%s.img%s\n", ANSI_GREEN, out, ANSI_RESET);
|
||||||
|
else printf("%sSuccess. Output: /storage/emulated/0/%s.img%s\n", ANSI_GREEN, target_partition, ANSI_RESET);
|
||||||
|
}
|
||||||
|
} else if (progress_code == 2)
|
||||||
|
{
|
||||||
|
/* determine device block */
|
||||||
|
/* for classic */
|
||||||
|
if (!pmt_use_logical)
|
||||||
|
{
|
||||||
|
if (pmt_use_cust_cxt) sprintf(flasher_path, "%s/%s", cust_cxt, target_partition);
|
||||||
|
else sprintf(flasher_path, "/dev/block/by-name/%s", target_partition);
|
||||||
|
/* for logical */
|
||||||
|
} else if (pmt_use_logical) sprintf(flasher_path, "/dev/block/mapper/%s", target_partition);
|
||||||
|
else {
|
||||||
|
if (!pmt_force_mode)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "İnvalid partition type!\n");
|
||||||
|
exit(30);
|
||||||
|
} else exit(30);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check partition */
|
||||||
|
if (access(flasher_path, F_OK) == -1)
|
||||||
|
{
|
||||||
|
if (!pmt_force_mode)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Partition not found!\n");
|
||||||
|
exit(31);
|
||||||
|
} else exit(31);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (calc_flsz(target_flash_file) != -1 && !pmt_force_mode) printf("Size of flash file: %.2f\n", calc_flsz(target_flash_file));
|
||||||
|
else printf("%sFailed to get flash file size%s\n", ANSI_YELLOW, ANSI_RESET);
|
||||||
|
|
||||||
|
if (calc_flsz(target_partition) != -1 && !pmt_force_mode) printf("Disk size of the target partition: %.2f\n", calc_flsz(target_partition));
|
||||||
|
else printf("%sFailed to get target partition disk size%s\n", ANSI_YELLOW, ANSI_RESET);
|
||||||
|
|
||||||
|
srcf = open(target_flash_file, O_RDONLY);
|
||||||
|
if (srcf == -1) {
|
||||||
|
if (!pmt_force_mode)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Couldn't read: %s: %s", target_flash_file, strerror(errno));
|
||||||
|
exit(39);
|
||||||
|
} else exit(39);
|
||||||
|
}
|
||||||
|
|
||||||
|
targetf = open(target_partition, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
||||||
|
if (targetf == -1) {
|
||||||
|
if (!pmt_force_mode)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Couldn't read: %s: %s", target_partition, strerror(errno));
|
||||||
|
exit(37);
|
||||||
|
} else exit(37);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* start writing */
|
||||||
|
while ((bytesRead = read(srcf, buffer, BFSIZE)) > 0 && bytesCopied < count) {
|
||||||
|
ssize_t bytesWritten = write(targetf, buffer, bytesRead);
|
||||||
|
if (bytesWritten != bytesRead) {
|
||||||
|
fprintf(stderr, "Couldn't write: %s: %s", backupper_path, strerror(errno));
|
||||||
|
close(srcf);
|
||||||
|
close(targetf);
|
||||||
|
exit(81);
|
||||||
|
}
|
||||||
|
|
||||||
|
bytesCopied += bytesWritten;
|
||||||
|
}
|
||||||
|
|
||||||
|
close(srcf);
|
||||||
|
close(targetf);
|
||||||
|
|
||||||
|
if (!pmt_force_mode) printf("%sSuccess.%s\n", ANSI_GREEN, ANSI_RESET);
|
||||||
|
} else if (progress_code == 3)
|
||||||
|
{
|
||||||
|
/* generate partition extn */
|
||||||
|
if (!pmt_use_logical)
|
||||||
|
{
|
||||||
|
if (pmt_use_cust_cxt) sprintf(ppath, "%s/%s", cust_cxt, target_partition);
|
||||||
|
else sprintf(ppath, "/dev/block/by-name/%s", target_partition);
|
||||||
|
/* for logical */
|
||||||
|
} else if (pmt_use_logical) sprintf(ppath, "/dev/block/mapper/%s", target_partition);
|
||||||
|
else {
|
||||||
|
if (!pmt_force_mode)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "İnvalid partition type!\n");
|
||||||
|
exit(49);
|
||||||
|
} else exit(49);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check partition */
|
||||||
|
if (access(ppath, F_OK) == -1)
|
||||||
|
{
|
||||||
|
if (!pmt_force_mode)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Partition not found!\n");
|
||||||
|
} else exit(31);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* get target partition block size */
|
||||||
|
struct statvfs file_sys_inf;
|
||||||
|
if (statvfs(ppath, &file_sys_inf) != 0)
|
||||||
|
{
|
||||||
|
if (!pmt_force_mode)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "The partition block size could not be obtained!\n");
|
||||||
|
exit(49);
|
||||||
|
} else exit(49);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* generate mke2fs command */
|
||||||
|
sprintf(formatter_cmd, "mke2fs -Fq -t %s -b %lu %s", format_fs, file_sys_inf.f_bsize, ppath);
|
||||||
|
|
||||||
|
/* run command */
|
||||||
|
if (system(formatter_cmd) != 0)
|
||||||
|
{
|
||||||
|
if (!pmt_force_mode)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Formatting failed! There may be a chance that something has been damaged!\n");
|
||||||
|
exit(71);
|
||||||
|
} else exit(71);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
}
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
/* end of code */
|
||||||
51
jni/versioner.c
Executable file
51
jni/versioner.c
Executable file
@@ -0,0 +1,51 @@
|
|||||||
|
/* 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
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <pmt-versioning.h>
|
||||||
|
|
||||||
|
void version()
|
||||||
|
{
|
||||||
|
printf("Version: %d.%d.%d (code %d%d%d) ", PMT_MAJOR, PMT_LEVEL, PMT_PATCH, PMT_MAJOR, PMT_LEVEL, PMT_PATCH);
|
||||||
|
|
||||||
|
#if __SIZEOF_POINTER__ == 4
|
||||||
|
printf("32-bit binary\n");
|
||||||
|
#elif __SIZEOF_POINTER__ == 8
|
||||||
|
printf("64-bit binary\n");
|
||||||
|
#else
|
||||||
|
printf("\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__clang__)
|
||||||
|
printf("Compiler: clang %s\n", __clang_version__);
|
||||||
|
#elif defined(__gcc__)
|
||||||
|
printf("Compiler: gcc %s\n", __gcc_version__)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
printf("See licenses with -L argument.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
}
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
/* end of code */
|
||||||
116
make-deb.sh
Executable file
116
make-deb.sh
Executable file
@@ -0,0 +1,116 @@
|
|||||||
|
#!/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.
|
||||||
|
|
||||||
|
RED='\e[31m'
|
||||||
|
NC='\e[0m'
|
||||||
|
|
||||||
|
abort() {
|
||||||
|
printf "${RED}$1${NC}"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
arm64-v8a)
|
||||||
|
PREFIX="64"
|
||||||
|
;;
|
||||||
|
armeabi-v7a)
|
||||||
|
PREFIX="32"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
abort " - Error: unknown architecture flag: $1. Avaiable: arm64-v8a & armeabi-v7a\n"
|
||||||
|
esac
|
||||||
|
|
||||||
|
VERSION="2.0.0"
|
||||||
|
CUR_DIR=$(pwd)
|
||||||
|
LIB_DIR=${CUR_DIR}/libs
|
||||||
|
ARMV8A_DIR=${OUT_DIR}/arm64-v8a
|
||||||
|
ARMV7A_DIR=${OUT_DIR}/armeabi-v7a
|
||||||
|
DEB_DIR=${OUT_DIR}/deb
|
||||||
|
DEBUTILS_DIR=${CUR_DIR}/debutils
|
||||||
|
DEBTERMUX_USR=${DEBUTILS_DIR}/data/data/com.termux/files/usr
|
||||||
|
|
||||||
|
chmod -R 755 *
|
||||||
|
|
||||||
|
printf " --------- Making pmt deb package ---------\n";
|
||||||
|
printf " - Checking all files and directories (only
|
||||||
|
eededs)...\n";
|
||||||
|
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/man1 ]; then
|
||||||
|
abort " - Not found: ${DEBUTILS_DIR}/data/data/com.termux/files/usr/share/man/man1\n"
|
||||||
|
fi
|
||||||
|
if [ ! -f ${DEBUTILS_DIR}/mandoc/pmt.1 ]; then
|
||||||
|
abort " - Not found: ${DEBUTILS_DIR}/mandoc/pmt.1\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
|
||||||
|
|
||||||
|
printf " - Generating template dir...\n"
|
||||||
|
mkdir -p ${DEBUTILS_DIR}/temp
|
||||||
|
|
||||||
|
printf " - Generating out dir...\n"
|
||||||
|
mkdir -p ${DEB_DIR}
|
||||||
|
|
||||||
|
printf " - Copying files...\n"
|
||||||
|
cp -r ${DEBUTILS_DIR}/data ${DEBUTILS_DIR}/temp || exit 1
|
||||||
|
rm -f ${DEBTERMUX_USR}/share/man/man1/dummy
|
||||||
|
rm -f ${DEBTERMUX_USR}/bin/dummy
|
||||||
|
mkdir -p ${DEBUTILS_DIR}/temp/DEBIAN
|
||||||
|
|
||||||
|
printf " - Selected arm-${PREFIX} package control file.\n"
|
||||||
|
cp ${DEBUTILS_DIR}/DEBIAN/control_${PREFIX} ${DEBUTILS_DIR}/temp/DEBIAN/control || exit 1
|
||||||
|
cp ${DEBUTILS_DIR}/mandoc/pmt.1 ${DEBTERMUX_USR}/share/man/man1 || exit 1
|
||||||
|
if [ "${PREFIX}" = "64" ]; then
|
||||||
|
cp ${ARMV8A_DIR}/pmt ${DEBTERMUX_USR}/bin || exit 1
|
||||||
|
elif [ "${PREFIX}" = "32" ]; then
|
||||||
|
cp ${ARMV7A_DIR}/pmt ${DEBTERMUX_USR}/bin || exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf " - Starting dpkg-deb...\n"
|
||||||
|
sleep 2
|
||||||
|
chmod -R 755 *
|
||||||
|
dpkg-deb -b ${DEBUTILS_DIR}/temp ${DEB_DIR}/pmt-${VERSION}-arm${PREFIX}.deb || exit 1;
|
||||||
|
rm -rf ${DEBUTILS_DIR}/temp || exit 1;
|
||||||
|
|
||||||
|
printf " - Done! Package: ${DEB_DIR}/pmt-${VERSION}.deb\n"
|
||||||
|
|
||||||
|
# end of script
|
||||||
Reference in New Issue
Block a user