pmt: initial 2.0.0 update

This commit is contained in:
2024-05-26 10:49:33 +03:00
parent f771fb7c68
commit f5531fde32
30 changed files with 380 additions and 730 deletions

View File

@@ -1,9 +0,0 @@
#### Version 1.9.0 (code 190):
- New features have been added to the compilation system. pmt can now be built with two mods. One is normal and the other is debugging.
- debugging is no longer the default
- In flashing and backup, completely C features are used instead of dd. The code is dd based. bought from toybox
- option trading logic changed
- more details
| END OF VERSION 1.8.0 CHANGELOG |
|------------------------------------|

4
DISCLAIMER Normal file → Executable file
View File

@@ -1,6 +1,6 @@
WARNING:
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.
- 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.

0
LICENSE Normal file → Executable file
View File

211
Makefile
View File

@@ -1,211 +0,0 @@
# 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.
include config/env.mk
include config/vars.mk
include config/source.mk
-include config/INS_STAT.mk
-include config/UNINS_STAT.mk
# start build (if no custom target)
.PHONY: all
all:
@printf " ---- Building Partition Manager ---- \n\n"; \
printf " - Version: $(VERSION)\n"; \
printf " - Version code: $(VERSION_CODE)\n\n"; \
printf " -------------------------------- \n\n"; \
printf " - Building... Please waith.\n"; \
sleep 2; \
$(CC) $(CFLAGS) -o $(TARGET) $(SRCS) || exit 1; \
mkdir -p $(OUT_DIR); \
mkdir -p $(BINARY_DIR); \
mkdir -p $(PACKAGE_DIR); \
mv pmt $(BINARY_DIR) || exit 1; \
printf " - Generating xz package...\n"; \
cp $(BINARY_DIR)/pmt $(PACKAGE_DIR) || exit 1; \
xz $(PACKAGE_DIR)/pmt; \
mv $(PACKAGE_DIR)/pmt.xz $(PACKAGE_DIR)/pmt-$(TARGET_ARCH)-$(LANG).xz || exit 1; \
printf " - Success\n\n"; \
printf " ------------------------------------ \n";
# cleaner functions
.PHONY: clean
clean:
@printf "Cleaning with rm force mode (builded binary)...\n"; \
sleep 1; \
rm -rf $(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 deb ==> Generate deb (debian) package (compatibility => termux)\n"; \
printf " make clean ==> Clear builded binary.\n"; \
printf " make install ==> 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 ==> If you are using termux, it uninstalls the compiled pmt into termux. So it allows you to use it like a normal command.\n"; \
printf " make help ==> Display help message\n\n";
# deb maker
.PHONY: deb
deb:
@printf " --------- Making deb package ---------\n"; \
printf " - Checking all files and directories (only neededs)...\n"; \
if [ ! -d $(DEBUTILS_DIR) ]; then \
printf " - Not found: $(DEBUTILS_DIR) \n"; \
exit 1; \
fi; \
if [ ! -d $(DEBUTILS_DIR)/DEBIAN ]; then \
printf " - Not found: $(DEBUTILS_DIR)/DEBIAN \n"; \
exit 1; \
fi; \
if [ ! -d $(DEBUTILS_DIR)/mandoc ]; then \
printf " - Not found: $(DEBUTILS_DIR)/mandoc \n"; \
exit 1; \
fi; \
if [ ! -d $(DEBUTILS_DIR)/data/data/com.termux ]; then \
printf " - Not found: $(DEBUTILS_DIR)/data/data/com.termux \n"; \
exit 1; \
fi; \
if [ ! -d $(DEBUTILS_DIR)/data/data/com.termux/files/usr ]; then \
printf " - Not found: $(DEBUTILS_DIR)/data/data/com.termux/files/usr \n"; \
exit 1; \
fi; \
if [ ! -d $(DEBUTILS_DIR)/data/data/com.termux/files/usr/bin ]; then \
printf " - Not found: $(DEBUTILS_DIR)/data/data/com.termux/files/usr/bin \n"; \
exit 1; \
fi; \
if [ ! -d $(DEBUTILS_DIR)/data/data/com.termux/files/usr/share/man/man1 ]; then \
printf " - Not found: $(DEBUTILS_DIR)/data/data/com.termux/files/usr/share/man/man1 \n"; \
exit 1; \
fi; \
if [ ! -f $(DEBUTILS_DIR)/mandoc/pmt.1 ]; then \
printf " - Not found: $(DEBUTILS_DIR)/mandoc/pmt.1 \n"; \
exit 1; \
fi; \
if [ ! -f $(DEBUTILS_DIR)/DEBIAN/control_32 ]; then \
printf " - Not found: $(DEBUTILS_DIR)/DEBIAN/control_32 \n"; \
exit 1; \
fi; \
if [ ! -f $(DEBUTILS_DIR)/DEBIAN/control_64 ]; then \
printf " - Not found: $(DEBUTILS_DIR)/DEBIAN/control_64 \n"; \
exit 1; \
fi; \
if [ ! -f $(BINARY_DIR)/pmt ]; then \
printf " - Package not builded! Please build package and try again \n"; \
exit 1; \
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; \
if [ "$(ARCH)" = "aarch64" ] || [ "$(ARCH)" = "armv8l" ]; then \
printf " - Selected arm-64 package control file.\n"; \
cp $(DEBUTILS_DIR)/DEBIAN/control_64 $(DEBUTILS_DIR)/temp/DEBIAN/control || exit 1; \
elif [ "$(ARCH)" = "aarch32" ] || [ "$(ARCH)" = "armv7l" ]; then \
printf " - Selected arm-32 package control file.\n"; \
cp $(DEBUTILS_DIR)/DEBIAN/control_32 $(DEBUTILS_DIR)/temp/DEBIAN/control || exit 1; \
fi; \
cp $(DEBUTILS_DIR)/mandoc/pmt.1 $(DEBTERMUX_USR)/share/man/man1 || exit 1; \
cp $(BINARY_DIR)/pmt $(DEBTERMUX_USR)/bin || exit 1; \
printf " - Starting dpkg-deb...\n"; \
sleep 2; \
chmod -R 755 *; \
dpkg-deb -b $(DEBUTILS_DIR)/temp $(DEB_DIR)/pmt-$(ARCH)-$(LANG).deb || exit 1; \
rm -r $(DEBUTILS_DIR)/temp || exit 1; \
printf " - Done! Package: $(DEB_DIR)/pmt-$(ARCH)-$(LANG).deb\n"
# installer
.PHONY: install
install:
@if [ -f $(TERMUX_BIN)/termux-open ]; then \
printf " ------------ pmt installer ------------ \n"; \
if [ -f $(TERMUX_BIN)/pmt ]; then \
printf " - pmt already installed\n"; \
exit; \
fi; \
if [ ! "$(INSTALL_SUCCESS)" = "true" ] && [ ! "$(INSTALL_SUCCESS)" = "" ]; then \
printf " - Warning: a previously-stayed failed installation process found\n"; \
fi; \
printf " - Checking files...\n"; \
if [ ! -f $(BINARY_DIR)/pmt ]; then \
printf " - Package not builded! Please build package and try again \n"; \
echo "INSTALL_SUCCESS := false" > $(CUR_DIR)/config/INS_STAT.mk; \
exit 1; \
fi; \
printf " - Copying files...\n"; \
if [ "`cp $(BINARY_DIR)/pmt /data/data/com.termux/files/usr/bin/pmt`" = "" ]; then \
printf " - Setting up permissions...\n"; \
else \
echo "INSTALL_SUCCESS := false" > $(CUR_DIR)/config/INS_STAT.mk; \
exit 1; \
fi; \
if [ "`chmod 777 $(TERMUX_BIN)/pmt`" = "" ]; then \
printf " - Saving current status...\n"; \
echo "INSTALL_SUCCESS := true" > $(CUR_DIR)/config/INS_STAT.mk; \
else \
echo "INSTALL_SUCCESS := false" > $(CUR_DIR)/config/INS_STAT.mk; \
exit 1; \
fi; \
printf " - Success.\n\n"; \
echo "INSTALL_SUCCESS := true" > $(CUR_DIR)/config/INS_STAT.mk; \
echo "UNINSTALLED_SUCCESS := " > $(CUR_DIR)/config/UNINS_STAT.mk; \
else \
printf " - This function is only available on Termux.\n"; \
fi
# uninstaller
.PHONY: uninstall
uninstall:
@if [ -f $(TERMUX_BIN)/termux-open ]; then \
printf " ----------- pmt uninstaller ----------- \n"; \
if [ ! -f $(TERMUX_BIN)/pmt ]; then \
printf " - pmt already uninstalled\n"; \
exit; \
fi; \
if [ ! "$(UNINSTALL_SUCCESS)" = "true" ] && [ ! "$(UNINSTALL_SUCCESS)" = "" ]; then \
printf " - Warning: a previously-stayed failed uninstallation process found\n"; \
fi; \
if [ -f $(TERMUX_USR)/share/man/man1/pmt.1 ]; then \
printf " - It was found to be established by pmt's deb pack. It's removed with apt...\n"; \
apt remove -y pmt || exit 1; \
printf " - Success.\n\n"; \
echo "UNINSTALLED_SUCCESS := true" > $(CUR_DIR)/config/UNINS_STAT.mk; \
echo "INSTALL_SUCCESS := " > $(CUR_DIR)/config/INS_STAT.mk; \
else \
printf " - It was found that pmt was manually established (with this makefile or copying). Manually removed...\n"; \
if [ "`rm $(TERMUX_BIN)/pmt`" = "" ]; then \
printf " - Success.\n\n"; \
echo "UNINSTALLED_SUCCESS := true" > $(CUR_DIR)/config/UNINS_STAT.mk; \
echo "INSTALL_SUCCESS := " > $(CUR_DIR)/config/INS_STAT.mk; \
else \
echo "UNINSTALLED_SUCCESS := false" > $(CUR_DIR)/config/UNINS_STAT.mk; \
exit 1; \
fi; \
fi; \
else \
printf "This function is only available on Termux.\n"; \
fi
# end

2
NOTICE Normal file → Executable file
View File

@@ -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,
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.
limitations under the License.

View File

@@ -1,78 +0,0 @@
## Partition Manager (pmt)
This binary C is for manage partitions of android devices.
It offers a lot of options. I will place these below. But first let me talk about the operation...
```
1. The partition name is obtained (with the -p or --partition argument)
2. Other arguments (if used) are processed.
3. The backup and flashing processes were written according to DD's code. So there is a piece of toybox code
```
#### Presented arguments (options)
```
Usage:
-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
Report bugs to <yagizzengin73@gmail.com>
```
#### Some notes
- Feel free to ask any questions you want.
- 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.
- 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.9.0-en/CHANGELOG.md)
- Let me know your suggestions!
### How is it built?
Android NDK is required to build. [Click for usage information](https://developer.android.com/ndk/guides/other_build_systems). [Click for NDK downloads](https://developer.android.com/ndk/downloads).
- NOTE 1: The current configuration is configured for compilation with NDK. The configuration was configured according to the NDK guide (I gave the link). You may need to replace it depending on the situation. You just need to set the `CC` variable in the compile command.
- NOTE 2: Use NDK 22+
- NOTE 3: The current target architecture is aarch64. You can change this in the configuration or by adding it to the compile command. Be careful. While making this current configuration, the following was considered (directory structure):
```
pmt android-ndk other-directories
```
- The directory structure was thought exactly like this. Be careful.
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.
To build;
```
make
```
Special `make` commands (pmt offers :) ;
```
------- Partition Manager help -------
Commands;
make ==> Build Partition Manager
make deb ==> Generate deb (debian) package (compatibility => termux)
make clean ==> Clear builded binary.
make install ==> 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 ==> If you are using termux, it uninstalls the compiled pmt into termux. So it allows you to use it like a normal command.
make help ==> Display help message
```

View File

@@ -1 +0,0 @@
INSTALL_SUCCESS :=

View File

@@ -1 +0,0 @@
UNINSTALL_SUCCESS :=

View File

@@ -1,53 +0,0 @@
# 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 gcc flags
EXTRA_GCC_FLAGS ?=
# arch config. 32-bit = armv7a | 64-bit = aarch64 | default = aarch64
TARGET_BUILD_ARCH ?= aarch64
# debugging mode (binary)
ENABLE_BINARY_DEBUGGING ?= false
#########################################
#########################################
#########################################
# #
# Apply Configuration #
# #
# Warning: please do not edit #
# #
#########################################
# gcc flag settings
ifeq ($(ENABLE_BINARY_DEBUGGING), true)
CFLAGS ?= -O3 -g -Wall -Wextra $(EXTRA_GCC_FLAGS)
else ifeq ($(ENABLE_BINARY_DEBUGGING), false)
CFLAGS ?= -O3 -Wall $(EXTRA_GCC_FLAGS)
endif
#########################################
#########################################

View File

@@ -1,64 +0,0 @@
# 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.
# speficy
VERSION := 1.9.0
VERSION_CODE := 190
TARGET := pmt
LANG := en
# device arch info
ARCH := $(shell uname -m)
OS := $(shell uname)
# current directory
CUR_DIR := $(shell pwd)
# NDK config
NDK_DIR := $(shell dirname ../android-ndk/file)
$(shell chmod 777 $(CUR_DIR)/config/ndk.sh)
$(shell $(CUR_DIR)/config/ndk.sh)
ifeq ($(OS),Darwin)
TOOLCHAIN := $(NDK_DIR)/toolchains/llvm/prebuilt/darwin-x86_64
else ifeq ($(OS),Linux)
TOOLCHAIN := $(NDK_DIR)/toolchains/llvm/prebuilt/linux-x86_64
endif
ifeq ($(TARGET_BUILD_ARCH),aarch64)
TARGET_ARCH := aarch64-linux-android
else ifeq ($(TARGET_BUILD_ARCH),armv7a)
TARGET_ARCH := armv7a-linux-androideabi
endif
API := 29
# compiler
ifeq "$(origin CC)" "default"
undefine CC
endif
CC ?= $(TOOLCHAIN)/bin/$(TARGET_ARCH)$(API)-clang
# source config
SOURCE_DIR ?= $(CUR_DIR)/src
OUT_DIR := $(CUR_DIR)/out
BINARY_DIR := $(OUT_DIR)/binary
PACKAGE_DIR := $(OUT_DIR)/package
DEB_DIR := $(OUT_DIR)/deb
DEBUTILS_DIR := $(CUR_DIR)/debutils
DEBTERMUX_USR := $(DEBUTILS_DIR)/temp/data/data/com.termux/files/usr
TERMUX_BIN := /data/data/com.termux/files/usr/bin
TERMUX_USR := /data/data/com.termux/files/usr

3
debutils/DEBIAN/control_32 Normal file → Executable file
View File

@@ -1,10 +1,9 @@
Source: pmt
Package: pmt
Version: 1.9.0
Version: 1.2.0
Architecture: arm
Description: pmt is for reading, writing and formatting partitions of android devices
Section: misc
Priority: optional
Maintainer: YZBruh <yagizzengin73@gmail.com>
Build-Depends: debhelper (>= 10), clang, make
Standards-Version: 4.5.0

3
debutils/DEBIAN/control_64 Normal file → Executable file
View File

@@ -1,10 +1,9 @@
Source: pmt
Package: pmt
Version: 1.9.0
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>
Build-Depends: debhelper (>= 10), clang, make
Standards-Version: 4.5.0

1
debutils/data/data/com.termux/files/usr/bin/dummy Normal file → Executable file
View File

@@ -1 +0,0 @@

1
debutils/mandoc/pmt.1 Normal file → Executable file
View File

@@ -22,4 +22,3 @@ EXAMPLES:
BUGS:
Report bugs to <yagizzengin73@gmail.com>

48
jni/Android.mk Executable file
View 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

15
config/ndk.sh → jni/Application.mk Normal file → Executable file
View File

@@ -1,5 +1,3 @@
#!/bin/bash
# By YZBruh
# Copyright 2024 Partition Manager
@@ -16,8 +14,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
if [ ! -d ../android-ndk ]; then
printf "warning; ndk directory not found. And the current configuration may create problems...\n\n"
fi
# architecture
APP_ABI := \
arm64-v8a \
armeabi-v7a
# end of script
APP_PLATFORM := android-21
APP_OPTIM := release
# end

53
src/checkers.c → jni/checkers.c Normal file → Executable file
View File

@@ -16,20 +16,17 @@
* limitations under the License.
*/
#ifdef __cplusplus
#if defined(__cplusplus)
extern "C" {
#endif
#include <stdio.h>
#include <stdint.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <sys/stat.h>
#include <errno.h>
#include "include/pmt.h"
#include <pmt.h>
extern bool pmt_use_cust_cxt;
extern bool pmt_ab;
@@ -40,46 +37,28 @@ extern char *cust_cxt;
/* check parts */
void check_psf()
{
struct stat abinf;
/* true = ab | false = a */
if (pmt_use_cust_cxt)
{
static char cust_cxt_ck_path[150];
sprintf(cust_cxt_ck_path, "%s/boot_a", cust_cxt);
if (stat(cust_cxt_ck_path, &abinf) != 0)
{
pmt_ab = false;
} else {
pmt_ab = true;
}
if (access(cust_cxt_ck_path, F_OK) != 0) pmt_ab = false;
else pmt_ab = true;
} else {
if (stat("/dev/block/by-name/boot_a", &abinf) != 0)
{
pmt_ab = false;
} else {
pmt_ab = true;
}
if (access("/dev/block/by-name/boot_a", F_OK) != 0) pmt_ab = false;
else pmt_ab = true;
}
struct stat logcinf;
/* true = logical | false = classic */
if (pmt_use_cust_cxt)
{
static char cust_cxt_ckl_path[150];
sprintf(cust_cxt_ckl_path, "%s/super", cust_cxt);
if (stat(cust_cxt_ckl_path, &logcinf) != 0)
{
pmt_logical = false;
} else {
pmt_logical = true;
}
if (access(cust_cxt_ckl_path, F_OK) != 0) pmt_logical = false;
else pmt_logical = true;
} else {
if (stat("/dev/block/by-name/super", &logcinf) != 0)
{
pmt_logical = false;
} else {
pmt_logical = true;
}
if (access("/dev/block/by-name/super", F_OK) != 0) pmt_logical = false;
else pmt_logical = true;
}
}
@@ -87,20 +66,18 @@ void check_psf()
void check_root()
{
/* a quick, easy method to verify root :D */
if (chdir("/dev/block") != 0)
if (getuid() != 0)
{
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));
exit(27);
} else {
exit(27);
}
} else exit(27);
}
}
#ifdef __cplusplus
#if defined(__cplusplus)
}
#endif
#endif /* __cplusplus */
/* end of code */
/* end of code */

21
config/source.mk → jni/config/env.mk Normal file → Executable file
View File

@@ -1,6 +1,6 @@
# By YZBruh
# Copyright 2024 YZBruh - Partition Manager
# 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.
@@ -14,11 +14,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# sources
SRCS := \
$(wildcard $(SOURCE_DIR)/*.c)
#########################################
# #
# Configuration Flags #
# #
# Warning: you can edit #
# #
#########################################
# only the reason why the resource list is available is that:
# construction of a code was made with a different make sub-process in the old compilation logic. And then the built files were saved. And the main structure was created. But no longer needs it. According to new logic...
# addionital compiler flags
EXTRA_COMPILER_FLAGS ?=
# end
# debugging mode (binary)
ENABLE_DEBUGGING ?= false
# end of environment configuration

11
src/docs.c → jni/docs.c Normal file → Executable file
View File

@@ -16,15 +16,12 @@
* limitations under the License.
*/
#ifdef __cplusplus
#if defined(__cplusplus)
extern "C" {
#endif
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include "include/pmt.h"
#include <pmt-docs.h>
void licenses()
{
@@ -62,8 +59,8 @@ void help()
printf("Report bugs to <yagizzengin73@gmail.com>\n");
}
#ifdef __cplusplus
#if defined(__cplusplus)
}
#endif
#endif /* __cplusplus */
/* end of code */

25
src/error.c → jni/include/pmt-docs.h Normal file → Executable file
View File

@@ -16,26 +16,15 @@
* limitations under the License.
*/
#ifdef __cplusplus
#if defined(__cplusplus)
extern "C" {
#endif
#endif /* __cplusplus */
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
void help();
void licenses();
#include "include/pmt.h"
/* 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);
#if defined(__cplusplus)
}
#endif /* __cplusplus */
#ifdef __cplusplus
}
#endif
/* end of code */
/* end */

32
jni/include/pmt-versioning.h Executable file
View 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 */

23
src/include/pmt.h → jni/include/pmt.h Normal file → Executable file
View File

@@ -16,24 +16,20 @@
* limitations under the License.
*/
#ifdef __cplusplus
#if defined(__cplusplus)
extern "C" {
#endif
#ifndef _PMT_H
#define _PMT_H
#if !defined(__PMT_H_)
#define __PMT_H_
/* color definations */
/* some 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.9.0"
#define PMT_VERSION_CODE "190"
#define PMT_PACKAGE_NAME "Partition Manager"
#define PMT_PACKAGE_LANG "en"
/* variable definations */
extern char *out;
@@ -54,18 +50,15 @@ 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 pmt(short progress_code);
void pmt(unsigned short progress_code);
void version();
void help();
void licenses();
#endif /* _PMT_H */
#endif /* __PMT_H_ */
#ifdef __cplusplus
#if defined(__cplusplus)
}
#endif
#endif /* __cplusplus */
/* end of code */

31
src/listpart.c → jni/listpart.c Normal file → Executable file
View File

@@ -16,20 +16,18 @@
* limitations under the License.
*/
#ifdef __cplusplus
#if defined(__cplusplus)
extern "C" {
#endif
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdbool.h>
#include <errno.h>
#include <dirent.h>
#include <string.h>
#include "include/pmt.h"
#include <pmt.h>
extern bool pmt_use_cust_cxt;
extern bool pmt_ab;
@@ -50,9 +48,7 @@ void listpart() {
if (!pmt_force_mode) {
fprintf(stderr, "Could not open: `%s`. Error reason: %s\n", cust_cxt, strerror(errno));
exit(62);
} else {
exit(62);
}
} else exit(62);
}
} else {
dir = opendir("/dev/block/by-name");
@@ -62,9 +58,7 @@ void listpart() {
{
fprintf(stderr, "Could not open: `/dev/block/by-name`. Error reason: %s\n", strerror(errno));
exit(63);
} else {
exit(63);
}
} else exit(63);
}
}
@@ -79,23 +73,18 @@ void listpart() {
printf("List of logical partitions (/dev/block/mapper): \n");
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)
{
printf("%sWarning: device using A/B partition style.%s\n", ANSI_YELLOW, ANSI_RESET);
}
if (pmt_ab && !pmt_force_mode) printf("%sWarning: device using A/B partition style.%s\n", ANSI_YELLOW, ANSI_RESET);
if (pmt_logical && !pmt_force_mode)
{
printf("%sWarning: device using logical partition type.%s\n", ANSI_YELLOW, ANSI_RESET);
}
if (pmt_logical && !pmt_force_mode) printf("%sWarning: device using logical partition type.%s\n", ANSI_YELLOW, ANSI_RESET);
}
#ifdef __cplusplus
#if defined(__cplusplus)
}
#endif
#endif /* __cplusplus */
/* end of code */

107
src/pmt.c → jni/pmt.c Normal file → Executable file
View File

@@ -17,13 +17,12 @@
*/
/* force use C std (if default is C++) */
#ifdef __cplusplus
#if defined(__cplusplus)
extern "C" {
#endif
/* include needed libs (headers) */
#include <stdio.h>
#include <stdint.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/stat.h>
@@ -31,9 +30,8 @@ extern "C" {
#include <stdbool.h>
#include <getopt.h>
#include <errno.h>
/* include custom pmt header */
#include "include/pmt.h"
#include <pmt.h>
#include <pmt-docs.h>
/* add value to variables that are added globally and are not worth */
char *out = NULL;
@@ -89,7 +87,7 @@ int main(int argc, char *argv[])
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.\n";
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;
@@ -110,10 +108,9 @@ int main(int argc, char *argv[])
{
if (!pmt_force_mode)
{
error(common_symbol_rule, 19);
} else {
fprintf(stderr, "%s%s%s\n", ANSI_RED, common_symbol_rule, ANSI_RESET);
exit(19);
}
} else exit(19);
}
pmt_flash = true;
break;
@@ -124,11 +121,9 @@ int main(int argc, char *argv[])
{
if (!pmt_force_mode)
{
fprintf(stderr, "%s", common_symbol_rule);
exit(71);
} else {
exit(71);
}
fprintf(stderr, "%s%s%s\n", ANSI_RED, common_symbol_rule, ANSI_RESET);
exit(19);
} else exit(19);
}
pmt_format = true;
break;
@@ -139,10 +134,9 @@ int main(int argc, char *argv[])
{
if (!pmt_force_mode)
{
error(common_symbol_rule, 19);
} else {
fprintf(stderr, "%s%s%s\n", ANSI_RED, common_symbol_rule, ANSI_RESET);
exit(19);
}
} else exit(19);
}
break;
/* logical partitions option */
@@ -155,10 +149,9 @@ int main(int argc, char *argv[])
} else {
if (!pmt_force_mode)
{
error("This device does not have logical partitions!\n", 17);
} else {
fprintf(stderr, "This device does not have logical partitions!\n");
exit(17);
}
} else exit(17);
}
break;
/* output file option */
@@ -168,10 +161,9 @@ int main(int argc, char *argv[])
{
if (!pmt_force_mode)
{
error(common_symbol_rule, 19);
} else {
fprintf(stderr, "%s%s%s\n", ANSI_RED, common_symbol_rule, ANSI_RESET);
exit(19);
}
} else exit(19);
}
break;
/* output dir option */
@@ -187,20 +179,16 @@ int main(int argc, char *argv[])
{
if (!pmt_force_mode)
{
error(common_symbol_rule, 19);
} else {
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;
}
if (wiew_version || wiew_help || wiew_licenses) combo_wiewers = true;
break;
/* force mode option */
case 'f':
@@ -210,28 +198,19 @@ int main(int argc, char *argv[])
case 'v':
wiew_version = true;
/* check combo wiewer options and progress */
if (list_partitions || wiew_help || wiew_licenses)
{
combo_wiewers = true;
}
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;
}
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;
}
if (wiew_version || wiew_help || list_partitions) combo_wiewers = true;
break;
/* for invalid options */
case '?':
@@ -283,10 +262,9 @@ int main(int argc, char *argv[])
{
if (!pmt_force_mode)
{
error("Backup and flash functions cannot be used in the same command.\n", 9);
} else {
fprintf(stderr, "Backup and flash functions cannot be used in the same command.\n");
exit(9);
}
} else exit(9);
}
/* checks */
@@ -301,9 +279,7 @@ int main(int argc, char *argv[])
{
fprintf(stderr, "%s: formatter: unsupported filesystem: %s", argv[0], format_fs);
exit(41);
} else {
exit(41);
}
} else exit(41);
}
}
@@ -313,10 +289,9 @@ int main(int argc, char *argv[])
{
if (!pmt_force_mode)
{
error(common_symbol_rule, 19);
} else {
fprintf(stderr, "%s\n", common_symbol_rule);
exit(19);
}
} else exit(19);
}
struct stat out_info;
if (stat(outdir, &out_info) != 0)
@@ -325,9 +300,7 @@ int main(int argc, char *argv[])
{
fprintf(stderr, "%s: cannot stat '%s': %s\n", argv[0], outdir, strerror(errno));
exit(18);
} else {
exit(18);
}
} else exit(18);
} else {
if (!S_ISDIR(out_info.st_mode))
{
@@ -335,9 +308,7 @@ int main(int argc, char *argv[])
{
fprintf(stderr, "%s: %s: is a not directory.\n", argv[0], outdir);
exit(20);
} else {
exit(20);
}
} else exit(20);
}
}
}
@@ -351,9 +322,7 @@ int main(int argc, char *argv[])
{
fprintf(stderr, "%s: cannot stat '%s': %s\n", argv[0], target_flash_file, strerror(errno));
exit(15);
} else {
exit(15);
}
} else exit(15);
} else {
if (!S_ISREG(flashf_info.st_mode))
{
@@ -361,9 +330,7 @@ int main(int argc, char *argv[])
{
fprintf(stderr, "%s: %s: is a not file.\n", argv[0], target_flash_file);
exit(16);
} else {
exit(16);
}
} else exit(16);
}
}
}
@@ -380,18 +347,14 @@ int main(int argc, char *argv[])
{
fprintf(stderr, "%s: %s: is a not directory.\n", argv[0], cust_cxt);
exit(8);
} else {
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);
}
} else exit(6);
}
if (strstr(cust_cxt, "/dev") == NULL && !pmt_force_mode)
{
@@ -406,9 +369,7 @@ int main(int argc, char *argv[])
{
fprintf(stderr, "%s: required partition name.\nTry `%s --help' for more information.\n", argv[0], argv[0]);
exit(5);
} else {
exit(5);
}
} else exit(5);
} else {
/**
*
@@ -436,7 +397,7 @@ int main(int argc, char *argv[])
}
}
#ifdef __cplusplus
#if defined(__cplusplus)
}
#endif

171
src/tools.c → jni/tools.c Normal file → Executable file
View File

@@ -16,12 +16,11 @@
* limitations under the License.
*/
#ifdef __cplusplus
#if defined(__cplusplus)
extern "C" {
#endif
#include <stdio.h>
#include <stdint.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/stat.h>
@@ -31,8 +30,7 @@ extern "C" {
#include <stddef.h>
#include <errno.h>
#include <fcntl.h>
#include "include/pmt.h"
#include <pmt.h>
#define BFSIZE 1024
@@ -60,7 +58,22 @@ extern bool pmt_force_mode;
* 3 = format mode
*/
void pmt(short progress_code)
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;
@@ -78,61 +91,46 @@ void pmt(short progress_code)
{
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_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)
{
error("İnvalid partition type!\n", 28);
} else {
fprintf(stderr, "İnvalid partition type!\n");
exit(28);
}
} else exit(28);
}
if (access(backupper_path, F_OK) == -1)
{
if (!pmt_force_mode)
{
error("Partition not found!\n", 29);
} else {
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);
}
} 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);
}
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);
}
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);
@@ -141,9 +139,7 @@ void pmt(short progress_code)
{
fprintf(stderr, "Couldn't generate: %s: %s", outf, strerror(errno));
exit(37);
} else {
exit(37);
}
} else exit(37);
}
@@ -169,19 +165,11 @@ void pmt(short progress_code)
/* 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);
}
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);
}
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)
{
@@ -189,23 +177,16 @@ void pmt(short progress_code)
/* 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);
}
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 {
} else if (pmt_use_logical) sprintf(flasher_path, "/dev/block/mapper/%s", target_partition);
else {
if (!pmt_force_mode)
{
error("İnvalid partition type!\n", 30);
} else {
fprintf(stderr, "İnvalid partition type!\n");
exit(30);
}
} else exit(30);
}
/* check partition */
@@ -213,21 +194,24 @@ void pmt(short progress_code)
{
if (!pmt_force_mode)
{
error("Partition not found!\n", 31);
} else {
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);
}
} else exit(39);
}
targetf = open(target_partition, O_WRONLY | O_CREAT | O_TRUNC, 0666);
@@ -236,9 +220,7 @@ void pmt(short progress_code)
{
fprintf(stderr, "Couldn't read: %s: %s", target_partition, strerror(errno));
exit(37);
} else {
exit(37);
}
} else exit(37);
}
/* start writing */
@@ -257,32 +239,22 @@ void pmt(short progress_code)
close(srcf);
close(targetf);
if (!pmt_force_mode)
{
printf("%sSuccess.%s\n", ANSI_GREEN, ANSI_RESET);
}
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);
}
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 {
} else if (pmt_use_logical) sprintf(ppath, "/dev/block/mapper/%s", target_partition);
else {
if (!pmt_force_mode)
{
error("İnvalid partition type!\n", 30);
} else {
fprintf(stderr, "İnvalid partition type!\n");
exit(49);
}
} else exit(49);
}
/* check partition */
@@ -290,10 +262,8 @@ void pmt(short progress_code)
{
if (!pmt_force_mode)
{
error("Partition not found!\n", 31);
} else {
exit(31);
}
fprintf(stderr, "Partition not found!\n");
} else exit(31);
}
/* get target partition block size */
@@ -304,9 +274,7 @@ void pmt(short progress_code)
{
fprintf(stderr, "The partition block size could not be obtained!\n");
exit(49);
} else {
exit(49);
}
} else exit(49);
}
/* generate mke2fs command */
@@ -317,16 +285,15 @@ void pmt(short progress_code)
{
if (!pmt_force_mode)
{
error("Formatting failed! There may be a chance that something has been damaged!\n", 71);
} else {
fprintf(stderr, "Formatting failed! There may be a chance that something has been damaged!\n");
exit(71);
}
} else exit(71);
}
}
}
#ifdef __cplusplus
#if defined(__cplusplus)
}
#endif
#endif /* __cplusplus */
/* end of code */

25
src/versioner.c → jni/versioner.c Normal file → Executable file
View File

@@ -16,19 +16,16 @@
* limitations under the License.
*/
#ifdef __cplusplus
#if defined(__cplusplus)
extern "C" {
#endif
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include "include/pmt.h"
#include <pmt-versioning.h>
void version()
{
printf("Version: %s (code %s) ", PMT_VERSION, PMT_VERSION_CODE);
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");
@@ -38,21 +35,17 @@ void version()
printf("\n");
#endif
#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");
#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");
}
#ifdef __cplusplus
#if defined(__cplusplus)
}
#endif
#endif /* __cplusplus */
/* end of code */

116
make-deb.sh Executable file
View 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

BIN
pmt-2.0.0-ndk.zip Executable file

Binary file not shown.