From 934d1b0112e53647f8f269005d1fe9ab748c71f6 Mon Sep 17 00:00:00 2001 From: YZ-Bruh Date: Thu, 4 Jul 2024 14:57:06 +0300 Subject: [PATCH] pmt: fix some 2.3.0 missings --- README.md | 91 +++++++++++++++++++ debutils/DEBIAN/control_32 | 2 +- debutils/DEBIAN/control_64 | 2 +- jni/Android.mk | 13 ++- jni/Makefile | 102 ++++++++++++++++++++++ jni/include/pmt-versioning.h | 14 +++ jni/languages.c | 4 +- jni/{partition_tool.c => partitiontool.c} | 0 jni/pmt.c | 2 +- jni/versioner.c | 4 +- 10 files changed, 225 insertions(+), 9 deletions(-) create mode 100755 README.md create mode 100755 jni/Makefile rename jni/{partition_tool.c => partitiontool.c} (100%) diff --git a/README.md b/README.md new file mode 100755 index 0000000..8309158 --- /dev/null +++ b/README.md @@ -0,0 +1,91 @@ +## Partition Manager (pmt) + +This binary C is for manage partitions of android devices. +It offers a lot of options. I will place these below. But first let me talk about the operation... + +#### Presented arguments (options) + +``` +Usage: pmt [OPTIONS] backup PARTITION [OUTPUT] [OPTIONS]... + or: pmt [OPTIONS] flash FILE PARTITION [OPTIONS]... + or: pmt [OPTIONS] format FILE_SYSTEM[ext/2/3/4] PARTITION [OPTIONS]... + +Options: + -l, --logical It is meant to determine whether the target partition is logical. + -c, --context It is meant to specify a custom /dev context. Only classic partitions (default: /dev/block/by-name). + -p, --list List partitions. + -s, --silent Information and warning messages are silenced in normal work. + -f, --force Force mode. Some things are ignored. + -S, --set-lang Set current language. + -v, --version See version. + --help See this help message. + -L, --license See license. + +Examples: + pmt backup boot_a -c /dev/block/platform/bootdevice/by-name + pmt flash /sdcard/twrp/boot.img boot_a -c /dev/block/platform/bootdevice/by-name + pmt format ext4 system_a --logical + pmt -c /dev/block/platform/bootdevice/by-name --list + +Report bugs to +``` + +#### Some notes + +- Feel free to ask any questions you want. +- Packages are available in publications. +- If the logical partition flag is not used, a classic partition is tried to be processing by default. +- [Click to see special version changes](https://github.com/YZBruh/pbt/blob/2.3.0/CHANGELOG.md) +- Let me know your suggestions! + +### How is it built? +Android NDK is required to build. + - [Download](https://developer.android.com/ndk/downloads) and extract the NDK package. + - Clone this repository. And get access to it. +``` +git clone https://github.com/YZBruh/pbt -b 2.3.0 ./pmt +cd pmt +``` + - Set the NDK working directory variable. +``` +export NDK_PROJECT_PATH=$(pwd) +``` + - Go to the NDK directory and start the construction +``` +./ndk-build +``` + - The output files will be inside the `pmt` folder. Binaries are available in two architectures within the `libs` folder. `arm64-v8a` (64-bit) and `armeabi-v7a` (32-bit). +``` + pmt/ + | + ________________|________________ + | | | | + jni/ debutils/ obj/ libs/ + | + __________|__________ + | | + arm64-v8a/ armeabi-v7a/ + | | + pmt pmt +``` + - For the make installable debian package make-deb.sh use the script. It can be created within two architectures. Use the script flags correctly: arm64-v8a, armeabi-v7a. If you want to process with root, add sudo as the second argument. If you don't want, use no-sudo or leave it blank + +``` +--Usage-- + +./make-deb.sh [arm64-v8a, armeabi-v7a] [sudo, no-sudo, ] +``` + +``` +chmod 777 utils.sh + +# for making 64-bit package +./utils.sh make-deb arm64-v8a + +# for making 32-bit package +./utils.sh make-deb armeabi-v7a +``` + +### Notes +If you want to change something, take a look at the configuration. You can change him. +it is located in the `jni/config` folder. His name is `env.mk`. I gave the information in the file. You can ask more. diff --git a/debutils/DEBIAN/control_32 b/debutils/DEBIAN/control_32 index 3507018..c274952 100755 --- a/debutils/DEBIAN/control_32 +++ b/debutils/DEBIAN/control_32 @@ -1,6 +1,6 @@ Source: pmt Package: pmt -Version: 2.1.0 +Version: 2.3.0 Architecture: arm Description: pmt is for reading, writing and formatting partitions of android devices Section: misc diff --git a/debutils/DEBIAN/control_64 b/debutils/DEBIAN/control_64 index a1c3da3..3ec8203 100755 --- a/debutils/DEBIAN/control_64 +++ b/debutils/DEBIAN/control_64 @@ -1,6 +1,6 @@ Source: pmt Package: pmt -Version: 2.1.0 +Version: 2.3.0 Architecture: aarch64 Description: pmt is for reading, writing and formatting partitions of android devices Section: misc diff --git a/jni/Android.mk b/jni/Android.mk index 301e077..dd04916 100755 --- a/jni/Android.mk +++ b/jni/Android.mk @@ -38,8 +38,17 @@ include $(BUILD_STATIC_LIBRARY) include $(CLEAR_VARS) +LOCAL_MODULE := libpmt_error +LOCAL_SRC_FILES := error.c +LOCAL_C_INCLUDES := $(LOCAL_PATH)/include +LOCAL_CFLAGS := $(PMT_CFLAGS) + +include $(BUILD_STATIC_LIBRARY) + +include $(CLEAR_VARS) + LOCAL_MODULE := libpmt_partitiontool -LOCAL_SRC_FILES := partition_tool.c +LOCAL_SRC_FILES := partitiontool.c LOCAL_C_INCLUDES := $(LOCAL_PATH)/include LOCAL_CFLAGS := $(PMT_CFLAGS) @@ -61,13 +70,13 @@ LOCAL_SRC_FILES := \ pmt.c \ versioner.c \ tools.c \ - error.c \ lang_tools.c \ languages.c \ docs.c LOCAL_C_INCLUDES := $(LOCAL_PATH)/include LOCAL_STATIC_LIBRARIES := \ libpmt_root \ + libpmt_error \ libpmt_partitiontool \ libpmt_list LOCAL_CFLAGS := $(PMT_CFLAGS) diff --git a/jni/Makefile b/jni/Makefile new file mode 100755 index 0000000..ff73533 --- /dev/null +++ b/jni/Makefile @@ -0,0 +1,102 @@ +# 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. + +##### +# sub-make for building package +##### + +THIS_IS = src + +include ../Makefile.inc + +ifeq ($(INC_OLDENV),true) + include ../config/oldenv.mk +endif + +define make_obj + $(eval OBJ := $(1:.c=.o)) + $(call m_stat,`basename $(SOURCE_DIR)`/`basename $(OBJ)`) + $(CC) $(CFLAGS) -c $1 || exit 1; +endef + +define make_executable + printf " - Making executable file...\n"; \ + $(CC) $(CFLAGS) -L$(SOURCE_DIR) -lpmt_root -lpmt_lister -lpmt_partitiontool -o $(TARGET) pmt.o error.o docs.o versioner.o lang_tools.o languages.o || exit 1; +endef + +define make_staticlib + $(call m_stat,$(1)) + $(AR) rcs "$1" "$2" || exit 1; +endef + +# all target for building +all: + @rm -f ../config/oldenv.mk; \ + printf " ---- Partition Manager Builder ---- \n\n"; \ + printf " - Version: $(VERSION)\n"; \ + printf " - Version code: $(VERSION_CODE)\n\n"; \ + printf " -------------------------------- \n\n"; \ + abort_build() { \ + if [ -d "$(PACKAGE_DIR)" ]; then \ + rm -rf "$(PACKAGE_DIR)"; \ + fi; \ + if [ -d "$(BINARY_DIR)" ]; then \ + rm -rf "$(BINARY_DIR)"; \ + fi; \ + if [ -d "$(STATICLIB_DIR)" ]; then \ + rm -rf "$(STATICLIB_DIR)"; \ + fi; \ + exit 1; \ + }; \ + if [ -f $(SOURCE_DIR)/docs.o ]; then \ + printf " - Please clean up before you build it.\n\n"; \ + printf " ----------------------------------- \n"; \ + exit 1; \ + fi; \ + printf " - Building objects...\n"; \ + sleep 2; \ + $(foreach csrc,$(SRCS),$(call make_obj, $(csrc))) + $(call mdir,$(OUT_DIR)) + $(call mdir,$(BINARY_DIR)) + $(call mdir,$(PACKAGE_DIR)) + $(call mdir,$(STATICLIB_DIR)) + printf " - Building static libraries...\n"; + $(call make_staticlib,libpmt_root.a,root.o) + $(call make_staticlib,libpmt_lister.a,listpart.o) + $(call make_staticlib,libpmt_partitiontool.a,partition_tool.o) + sleep 1; + $(call make_executable) + sleep 1; + mv pmt $(BINARY_DIR) || abort_build; \ + mv *.a $(STATICLIB_DIR) || abort_build; \ + printf " - Generating xz package...\n"; \ + cp $(BINARY_DIR)/pmt $(PACKAGE_DIR) || abort_build; \ + xz $(PACKAGE_DIR)/pmt || abort_build; \ + sleep 1; \ + mv $(PACKAGE_DIR)/pmt.xz $(PACKAGE_DIR)/pmt-$(ARCH).xz || abort_build; \ + printf " - Success\n\n"; \ + sleep 1; \ + printf " ----------------------------------- \n" + +.PHONY: clean +clean: + $(eval STATICLIBS = $(wildcard $(SOURCE_DIR)/*.a)) + $(eval OBJS = $(wildcard $(SOURCE_DIR)/*.o)) + $(info Cleaning files...) + $(foreach obj,$(OBJS), $(call m_stat_nn,src/$(shell basename $(obj))) $(call erase,$(obj))) + $(foreach lib,$(STATICLIBS),$(call m_stat_nn,src/$(shell basename $(lib))) $(call erase,$(lib))) + +# end \ No newline at end of file diff --git a/jni/include/pmt-versioning.h b/jni/include/pmt-versioning.h index eef5094..1f17acc 100755 --- a/jni/include/pmt-versioning.h +++ b/jni/include/pmt-versioning.h @@ -18,6 +18,20 @@ __BEGIN_DECLS +#include + +#if __NDK_MINOR__ == 1 +#define __NDK_MINOR_STATUS__ "b" +#else +#define __NDK_MINOR_STATUS__ "" +#endif + +#if __NDK_BETA__ == 1 || __NDK_BETA__ == 2 +#define __NDK_BETA_STATUS__ "beta" +#else +#define __NDK_BETA_STATUS__ "" +#endif + /* versioning */ #define PMT_MAJOR 2 #define PMT_MINOR 3 diff --git a/jni/languages.c b/jni/languages.c index 34cfd68..28d0482 100755 --- a/jni/languages.c +++ b/jni/languages.c @@ -43,7 +43,7 @@ struct pmt_langdb_general en = { .expected_flash_arg = "Expected flash argument 2, retrieved", .expected_format_arg = "Expected format argument 2, retrieved", .missing_operand = "missing operand", - .multiple_wiewers = "Multiple wiewers cannot be used at the same line.", + .multiple_wiewers = "Multiple viewers cannot be used at the same line.", .common_symbol_rule = "When entering the attached argument of an option, an argument of another option type cannot be used. In short, the rule is: there can be no '-' at the beginning of the attached argument.", .req_part_name = "Required partition name.", .part_not_found = "Partition not found!", @@ -155,7 +155,7 @@ struct pmt_langdb_docs tr_docs = { .docs_strs_l2 = "[SEÇENEKLER] flash DOSYA BÖLÜM [SEÇENEKLER]...", .docs_strs_l3 = "[SEÇENEKLER] format DOSYA_SİSTEMİ[ext/2/3/4] BÖLÜM [SEÇENEKLER]...", .docs_strs_l4 = "Seçenekler", - .docs_strs_l5 = "Bu seçeneği kullanarak mantıksal (logical) bir bölümün yedekleneceğini belirtebilirsiniz.", + .docs_strs_l5 = "Bu seçeneği kullanarak mantıksal (logical) bir bölümle işlem yapılacağını belirtebilirsiniz.", .docs_strs_l6 = "Bu seçeneği kullanarak özel /dev bağlamı belirtebilirsiniz. Sadece normal (mantıksal olmayan) bölümler içindir (Varsayılan: /dev/block/by-name).", .docs_strs_l7 = "Bölümler listelenir.", .docs_strs_l8 = "Bilgi ve uyarı mesajları susturulur.", diff --git a/jni/partition_tool.c b/jni/partitiontool.c similarity index 100% rename from jni/partition_tool.c rename to jni/partitiontool.c diff --git a/jni/pmt.c b/jni/pmt.c index f8843ab..f0c58e1 100755 --- a/jni/pmt.c +++ b/jni/pmt.c @@ -231,7 +231,7 @@ int main(int argc, char* argv[]) return 1; break; default: - printf("%s: %s [backup] flash] [format] [-l | --logical] [-c | --context] [-D | --list] [-v | --version] [--help] [-L | --license]\n", current->usage_head, argv[0]); + printf("%s: %s [backup] [flash] [format] [-l | --logical] [-c | --context] [-D | --list] [-v | --version] [--help] [-L | --license]\n", current->usage_head, argv[0]); return 1; } } diff --git a/jni/versioner.c b/jni/versioner.c index 13b0864..909c496 100755 --- a/jni/versioner.c +++ b/jni/versioner.c @@ -44,7 +44,7 @@ void version(void) #endif #if defined(__clang__) - printf("%s: clang %d.%d.%d\n", current->compiler_str, __clang_major__, __clang_minor__, __clang_patchlevel__); + printf("%s: clang %d.%d.%d (NDK r%d%s %s)\n", current->compiler_str, __clang_major__, __clang_minor__, __clang_patchlevel__, __NDK_MAJOR__, __NDK_MINOR_STATUS__, __NDK_BETA_STATUS__); #endif printf("%s\n", current->see_license); @@ -54,4 +54,4 @@ void version(void) } #endif -/* end of code */ +/* end of code */ \ No newline at end of file