pmt: initial 2.6.0 update
This commit is contained in:
27
.github/workflows/build.yml
vendored
27
.github/workflows/build.yml
vendored
@@ -8,6 +8,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
|
id: checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Cleanup
|
- name: Cleanup
|
||||||
@@ -25,7 +26,7 @@ jobs:
|
|||||||
&& sudo apt install gh -y
|
&& sudo apt install gh -y
|
||||||
|
|
||||||
- name: Update and setup packages
|
- name: Update and setup packages
|
||||||
id: setup-packages
|
id: general-packages-progress
|
||||||
run: |
|
run: |
|
||||||
sudo apt update \
|
sudo apt update \
|
||||||
&& sudo apt upgrade -y \
|
&& sudo apt upgrade -y \
|
||||||
@@ -83,18 +84,18 @@ jobs:
|
|||||||
. ${{ env.PMT_SRCDIR }}/build/workflow/relnotes > /home/pmt/release_body.txt
|
. ${{ env.PMT_SRCDIR }}/build/workflow/relnotes > /home/pmt/release_body.txt
|
||||||
cd ${{ env.PMT_SRCDIR }}
|
cd ${{ env.PMT_SRCDIR }}
|
||||||
zip -rq pmt-objs-local.zip obj/local/arm64-v8a obj/local/armeabi-v7a
|
zip -rq pmt-objs-local.zip obj/local/arm64-v8a obj/local/armeabi-v7a
|
||||||
xz libs/arm64-v8a/pmt
|
for arch in arm64-v8a armeabi-v7a; do
|
||||||
mv libs/arm64-v8a/pmt.xz ${PWD}/pmt-arm64-v8a.xz
|
xz libs/${arch}/pmt
|
||||||
xz libs/armeabi-v7a/pmt
|
mv libs/${arch}/pmt.xz ${PWD}/pmt-${arch}-$(date +%Y%m%d).xz
|
||||||
mv libs/armeabi-v7a/pmt.xz ${PWD}/pmt-armeabi-v7a.xz
|
done
|
||||||
make CC="${CC_64}" AR="${AR}"
|
for CC_COMP in ${CC_64} ${CC_32}; do
|
||||||
make deb FOR_THIS=64
|
make clean
|
||||||
mv out/debpackage/*.deb .
|
make CC="${CC_COMP}" AR="${AR}"
|
||||||
make clean
|
[[ "${CC_COMP}" == *"arm64-v8a"* ]] && make deb FOR_THIS=64
|
||||||
make CC="${CC_32}" AR="${AR}"
|
[[ "${CC_COMP}" == *"armeabi-v7a"* ]] && make deb FOR_THIS=32
|
||||||
make deb FOR_THIS=32
|
mv out/debpackage/*.deb .
|
||||||
mv out/debpackage/*.deb .
|
make clean
|
||||||
make clean
|
done
|
||||||
working-directory: ${{ env.NDK_DIR }}
|
working-directory: ${{ env.NDK_DIR }}
|
||||||
|
|
||||||
- name: Upload to release
|
- name: Upload to release
|
||||||
|
|||||||
8
.github/workflows/check_commits.yml
vendored
8
.github/workflows/check_commits.yml
vendored
@@ -17,17 +17,17 @@ jobs:
|
|||||||
COMM_MSG=$(git log -1 --pretty=%B)
|
COMM_MSG=$(git log -1 --pretty=%B)
|
||||||
if [ "${GITHUB_EVENT_NAME}" == "push" ]; then
|
if [ "${GITHUB_EVENT_NAME}" == "push" ]; then
|
||||||
if [[ "${COMM_MSG}" == *"initial"* ]]; then
|
if [[ "${COMM_MSG}" == *"initial"* ]]; then
|
||||||
echo "build_and_release=true" >> $GITHUB_ENV
|
echo "run_builder=true" >> $GITHUB_ENV
|
||||||
else
|
else
|
||||||
echo "build_and_release=false" >> $GITHUB_ENV
|
echo "run_builder=false" >> $GITHUB_ENV
|
||||||
fi
|
fi
|
||||||
elif [ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]; then
|
elif [ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]; then
|
||||||
echo "build_and_release=true" >> $GITHUB_ENV
|
echo "run_builder=true" >> $GITHUB_ENV
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Run release workflow
|
- name: Run release workflow
|
||||||
id: run-rel-workflow
|
id: run-rel-workflow
|
||||||
if: env.build_and_release == 'true'
|
if: env.run_builder == 'true'
|
||||||
uses: benc-uk/workflow-dispatch@v1
|
uses: benc-uk/workflow-dispatch@v1
|
||||||
with:
|
with:
|
||||||
workflow: 'build.yml'
|
workflow: 'build.yml'
|
||||||
|
|||||||
36
ADD-LANGUAGES.md
Normal file → Executable file
36
ADD-LANGUAGES.md
Normal file → Executable file
@@ -28,7 +28,6 @@ On this page, I will tell you how to add languages to pmt. This is not a difficu
|
|||||||
~ $ echo -n "$missing_operand\n" # for more detail I used the -n argument
|
~ $ echo -n "$missing_operand\n" # for more detail I used the -n argument
|
||||||
missing operand
|
missing operand
|
||||||
~ $
|
~ $
|
||||||
|
|
||||||
|
|
||||||
C / C++
|
C / C++
|
||||||
const char* _Nonnull missing_operand = "missing operand.";
|
const char* _Nonnull missing_operand = "missing operand.";
|
||||||
@@ -51,9 +50,9 @@ On this page, I will tell you how to add languages to pmt. This is not a difficu
|
|||||||
Code pieces (C)
|
Code pieces (C)
|
||||||
struct pmt_langdb_general en = {
|
struct pmt_langdb_general en = {
|
||||||
// other translations
|
// other translations
|
||||||
.missing_operand = "missing operand";
|
.missing_operand = "missing operand",
|
||||||
.try_h = "Try";
|
.try_h = "Try",
|
||||||
.for_more = "for more information";
|
.for_more = "for more information",
|
||||||
// other translations
|
// other translations
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,12 +67,12 @@ In short, there are variables for texts. And I made these dynamic by using [stru
|
|||||||
- Let's open our jni/languages.c source file.
|
- Let's open our jni/languages.c source file.
|
||||||
- Now, let's create the translation with the ready-made struct structure (see jni/include/pmt-stringkeys.h for the structure).
|
- Now, let's create the translation with the ready-made struct structure (see jni/include/pmt-stringkeys.h for the structure).
|
||||||
```
|
```
|
||||||
// main
|
// Main
|
||||||
struct pmt_langdb_general <LANGUAGE_PREFIX> = { // LANGUAGE_PREFIX must be the corresponding abbreviation of the language in English. For example, it's like en in English.
|
struct pmt_langdb_general <LANGUAGE_PREFIX> = { // LANGUAGE_PREFIX must be the corresponding abbreviation of the language in English. For example, it's like en in English.
|
||||||
// translations
|
// translations
|
||||||
}
|
}
|
||||||
|
|
||||||
// example
|
// Example
|
||||||
struct pmt_langdb_general en = {
|
struct pmt_langdb_general en = {
|
||||||
// translation
|
// translation
|
||||||
}
|
}
|
||||||
@@ -87,15 +86,16 @@ In short, there are variables for texts. And I made these dynamic by using [stru
|
|||||||
// other translations
|
// other translations
|
||||||
}
|
}
|
||||||
|
|
||||||
// example
|
// Example
|
||||||
struct pmt_langdb_general en = {
|
struct pmt_langdb_general en = {
|
||||||
.lang_by_s = "YZBruh & r0manas";
|
.lang_by_s = "YZBruh & r0manas",
|
||||||
.language = "English";
|
.language = "English",
|
||||||
.lang_prefix = "en";
|
.lang_prefix = "en",
|
||||||
// other translations
|
// other translations
|
||||||
|
.by_str = "By" // Example for end translate
|
||||||
}
|
}
|
||||||
|
|
||||||
// CRITIC WARNING: Do not add ';' to the end of the last translation text. But others always
|
// CRITIC WARNING: Do not add ',' to the end of the last translation text. But others always...
|
||||||
```
|
```
|
||||||
- Now do the others :)
|
- Now do the others :)
|
||||||
- Now let me explain the documentation...
|
- Now let me explain the documentation...
|
||||||
@@ -109,10 +109,12 @@ In short, there are variables for texts. And I made these dynamic by using [stru
|
|||||||
// translations
|
// translations
|
||||||
}
|
}
|
||||||
|
|
||||||
// example
|
// Example
|
||||||
struct pmt_langdb_docs en_docs = {
|
struct pmt_langdb_docs en_docs = {
|
||||||
// translations
|
// translations
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CRITIC WARNING: Do not add ',' to the end of the last translation text. But others always...
|
||||||
```
|
```
|
||||||
- Make translations by taking examples from existing ones. And definitely do it regularly by getting help message from pmt :D
|
- Make translations by taking examples from existing ones. And definitely do it regularly by getting help message from pmt :D
|
||||||
|
|
||||||
@@ -124,8 +126,18 @@ In short, there are variables for texts. And I made these dynamic by using [stru
|
|||||||
struct pmt_langdb_langs lang[] = {
|
struct pmt_langdb_langs lang[] = {
|
||||||
{"en"},
|
{"en"},
|
||||||
{"tr"},
|
{"tr"},
|
||||||
|
// language prefix. {"<LANGUAGE_PREFIX>"},
|
||||||
{NULL} // PLEASE DO NOT ADD IT UNDER 'NULL'!
|
{NULL} // PLEASE DO NOT ADD IT UNDER 'NULL'!
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Example
|
||||||
|
struct pmt_langdb_langs lang[] = {
|
||||||
|
{"en"},
|
||||||
|
{"tr"},
|
||||||
|
{"az"},
|
||||||
|
{NULL}
|
||||||
|
};
|
||||||
|
|
||||||
// Add the language you are translating into these existing language prefixes. I will fix the errors here (if there is an error)
|
// Add the language you are translating into these existing language prefixes. I will fix the errors here (if there is an error)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
25
CHANGELOG.md
25
CHANGELOG.md
@@ -1,19 +1,12 @@
|
|||||||
### Version 2.5.0 Changelog
|
### Version 2.6.0 Changelog
|
||||||
|
|
||||||
- Fixed serious problems with version 2.4.0.
|
- 'tools.c' cleaned.
|
||||||
- Stabilization was held.
|
- Compilation system (make) was subject to a serious update.
|
||||||
- The size calculation problem that was during flashtime was corrected.
|
- Undefined sanitizer added to debug flags.
|
||||||
- Change in the syntax in flash and formatting processes was made.
|
- Dynamic makefiles with separate targets.
|
||||||
- Problems in file system selection are corrected in formatting process.
|
- Unit was given when the size information was given (M).
|
||||||
- Deprecation system created for deprecated/changed options.
|
- use of other compilers from clang was blocked.
|
||||||
- License display option deprecated.
|
|
||||||
- The language configuration file will now be stored and read entirely in /sdcard.
|
|
||||||
- Enabled C language extention warnings (-pedantic).
|
|
||||||
- Unnecessary codes were cleared and a more neat code was written.
|
|
||||||
- It was passed to make as old in the compilation system
|
|
||||||
- For NDK compilation with iterine make system Android.mk and Application.mk creation support added.
|
|
||||||
- More advanced make build system than before.
|
|
||||||
|
|
||||||
```
|
```
|
||||||
END OF 2.5.0 UPDATE CHANGELOG
|
END OF 2.6.0 UPDATE CHANGELOG
|
||||||
```
|
```
|
||||||
|
|||||||
67
Makefile.inc
67
Makefile.inc
@@ -15,25 +15,23 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
# speficy
|
# speficy
|
||||||
VERSION := 2.5.0
|
VERSION := 2.6.0
|
||||||
VERSION_CODE := 250
|
VERSION_CODE := 260
|
||||||
TARGET := pmt
|
TARGET := pmt
|
||||||
|
|
||||||
# device arch info
|
# device arch info
|
||||||
ARCH := $(shell uname -m)
|
ARCH := $(shell uname -m)
|
||||||
|
|
||||||
# current directory
|
# current directory
|
||||||
CUR_DIR = $(shell pwd)
|
|
||||||
OUT_DIRNAME ?= out
|
OUT_DIRNAME ?= out
|
||||||
SOURCE_DIRNAME ?= jni
|
SOURCE_DIRNAME ?= jni
|
||||||
|
|
||||||
# others needed important variables
|
# others needed important variables
|
||||||
ifeq ($(THIS_IS),src)
|
ifeq ($(THIS_IS),src)
|
||||||
BUILD := ../build
|
BUILD := ../build
|
||||||
SOURCE_DIR := $(CUR_DIR)
|
SOURCE_DIR := $(CURDIR)
|
||||||
OUT_DIR := ../$(OUT_DIRNAME)
|
OUT_DIR := ../$(OUT_DIRNAME)
|
||||||
DEBUTILS_DIR := $(BUILD)/deb
|
DEBUTILS_DIR := $(BUILD)/deb
|
||||||
INCLUDE_DIR := ../include
|
|
||||||
else ifeq ($(THIS_IS),debutils)
|
else ifeq ($(THIS_IS),debutils)
|
||||||
BUILD := ..
|
BUILD := ..
|
||||||
SOURCE_DIR := ../../$(SOURCE_DIRNAME)
|
SOURCE_DIR := ../../$(SOURCE_DIRNAME)
|
||||||
@@ -42,12 +40,12 @@ else ifeq ($(THIS_IS),debutils)
|
|||||||
else ifeq ($(THIS_IS),out)
|
else ifeq ($(THIS_IS),out)
|
||||||
BUILD := ../build
|
BUILD := ../build
|
||||||
SOURCE_DIR := ../$(SOURCE_DIRNAME)
|
SOURCE_DIR := ../$(SOURCE_DIRNAME)
|
||||||
OUT_DIR := $(CUR_DIR)
|
OUT_DIR := $(CURDIR)
|
||||||
DEBUTILS_DIR := $(BÜILD)/deb
|
DEBUTILS_DIR := $(BÜILD)/deb
|
||||||
else ifeq ($(THIS_IS),main)
|
else ifeq ($(THIS_IS),main)
|
||||||
BUILD := $(CUR_DIR)/build
|
BUILD := $(CURDIR)/build
|
||||||
SOURCE_DIR := $(CUR_DIR)/$(SOURCE_DIRNAME)
|
SOURCE_DIR := $(CURDIR)/$(SOURCE_DIRNAME)
|
||||||
OUT_DIR := $(CUR_DIR)/$(OUT_DIRNAME)
|
OUT_DIR := $(CURDIR)/$(OUT_DIRNAME)
|
||||||
DEBUTILS_DIR := $(BUILD)/deb
|
DEBUTILS_DIR := $(BUILD)/deb
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -84,44 +82,11 @@ endif
|
|||||||
SRCS := $(wildcard $(SOURCE_DIR)/*.c)
|
SRCS := $(wildcard $(SOURCE_DIR)/*.c)
|
||||||
OBJS = $(SRCS:.c=.o)
|
OBJS = $(SRCS:.c=.o)
|
||||||
|
|
||||||
# the presence of all source files that are on this list will be checked
|
STATIC_LIBS := \
|
||||||
SRCS_REQ := \
|
lib$(TARGET)_root.a \
|
||||||
$(SOURCE_DIR)/debugging.c \
|
lib$(TARGET)_debugging.a \
|
||||||
$(SOURCE_DIR)/docs.c \
|
lib$(TARGET)_listpart.a \
|
||||||
$(SOURCE_DIR)/get_stat.c \
|
lib$(TARGET)_partitiontool.a
|
||||||
$(SOURCE_DIR)/lang_tools.c \
|
|
||||||
$(SOURCE_DIR)/languages.c \
|
|
||||||
$(SOURCE_DIR)/partitiontool.c \
|
|
||||||
$(SOURCE_DIR)/pmt.c \
|
|
||||||
$(SOURCE_DIR)/root.c \
|
|
||||||
$(SOURCE_DIR)/tools.c \
|
|
||||||
$(SOURCE_DIR)/versioner.c
|
|
||||||
|
|
||||||
ifeq ($(THIS_IS),src)
|
|
||||||
HEADERS_REQ := \
|
|
||||||
$(INCLUDE_DIR)/pmt/deprecates.h \
|
|
||||||
$(INCLUDE_DIR)/pmt/docs.h \
|
|
||||||
$(INCLUDE_DIR)/pmt/pmt.h \
|
|
||||||
$(INCLUDE_DIR)/pmt/stringkeys.h \
|
|
||||||
$(INCLUDE_DIR)/pmt/versioning.h
|
|
||||||
endif
|
|
||||||
|
|
||||||
# objects to be used wgen static library files is created
|
|
||||||
STATICLIB_OBJS := \
|
|
||||||
$(SOURCE_DIR)/root.o \
|
|
||||||
$(SOURCE_DIR)/debugging.o \
|
|
||||||
$(SOURCE_DIR)/listpart.o \
|
|
||||||
$(SOURCE_DIR)/partitiontool.o
|
|
||||||
|
|
||||||
# objects to be used when executable file is created
|
|
||||||
OBJS_EXEC := \
|
|
||||||
$(SOURCE_DIR)/$(TARGET).o \
|
|
||||||
$(SOURCE_DIR)/docs.o \
|
|
||||||
$(SOURCE_DIR)/versioner.o \
|
|
||||||
$(SOURCE_DIR)/get_stat.o \
|
|
||||||
$(SOURCE_DIR)/tools.o \
|
|
||||||
$(SOURCE_DIR)/lang_tools.o \
|
|
||||||
$(SOURCE_DIR)/languages.o
|
|
||||||
|
|
||||||
# other directories in the out directory
|
# other directories in the out directory
|
||||||
IN_OUT_DIR := \
|
IN_OUT_DIR := \
|
||||||
@@ -131,7 +96,7 @@ IN_OUT_DIR := \
|
|||||||
|
|
||||||
# list of file/directory to be checked when the deb pack is created
|
# list of file/directory to be checked when the deb pack is created
|
||||||
DEB_CHECKS := \
|
DEB_CHECKS := \
|
||||||
$(DEBUTILS_DIR) \
|
$(DEBUTILS_DIR)/ \
|
||||||
$(DEBUTILS_DIR)/DEBIAN \
|
$(DEBUTILS_DIR)/DEBIAN \
|
||||||
$(DEBUTILS_DIR)/DEBIAN/control_32 \
|
$(DEBUTILS_DIR)/DEBIAN/control_32 \
|
||||||
$(DEBUTILS_DIR)/DEBIAN/control_64 \
|
$(DEBUTILS_DIR)/DEBIAN/control_64 \
|
||||||
@@ -148,9 +113,11 @@ DEB_CHECKS := \
|
|||||||
$(DEBUTILS_DIR)/data/data/com.termux/files/usr/share/man/man8
|
$(DEBUTILS_DIR)/data/data/com.termux/files/usr/share/man/man8
|
||||||
|
|
||||||
# for running make with silent mode
|
# for running make with silent mode
|
||||||
hide := @
|
MAKE_HIDE := @ $(MAKE)
|
||||||
MAKE_HIDE := $(hide)$(MAKE)
|
|
||||||
SILENT := -s
|
SILENT := -s
|
||||||
|
E := @ echo
|
||||||
|
E_NS := echo
|
||||||
|
P := printf
|
||||||
|
|
||||||
# color definations
|
# color definations
|
||||||
RESET := \033[0m
|
RESET := \033[0m
|
||||||
|
|||||||
@@ -47,6 +47,6 @@ endif
|
|||||||
|
|
||||||
# write current env configuration to oldenv.mk
|
# write current env configuration to oldenv.mk
|
||||||
all:
|
all:
|
||||||
@echo "CC := $(CC)" > oldenv.mk; \
|
@ echo "CC := $(CC)" > oldenv.mk
|
||||||
echo "AR := $(AR)" >> oldenv.mk; \
|
@ echo "AR := $(AR)" >> oldenv.mk
|
||||||
echo "CFLAGS := $(CFLAGS)" >> oldenv.mk
|
@ echo "CFLAGS := $(CFLAGS)" >> oldenv.mk
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
Source: pmt
|
Source: pmt
|
||||||
Package: pmt
|
Package: pmt
|
||||||
Version: 2.5.0
|
Version: 2.6.0
|
||||||
Architecture: arm
|
Architecture: arm
|
||||||
Description: pmt is for reading, writing and formatting partitions of android devices
|
Description: pmt is for reading, writing and formatting partitions of android devices
|
||||||
Section: misc
|
Section: misc
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
Source: pmt
|
Source: pmt
|
||||||
Package: pmt
|
Package: pmt
|
||||||
Version: 2.5.0
|
Version: 2.6.0
|
||||||
Architecture: aarch64
|
Architecture: aarch64
|
||||||
Description: pmt is for reading, writing and formatting partitions of android devices
|
Description: pmt is for reading, writing and formatting partitions of android devices
|
||||||
Section: misc
|
Section: misc
|
||||||
|
|||||||
@@ -32,76 +32,68 @@ else ifeq ($(FOR_THIS),32)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
ifneq ($(wildcard /dev/block/by-name),)
|
ifneq ($(wildcard /dev/block/by-name),)
|
||||||
SUDO := su
|
SUDO := su -c
|
||||||
else ifeq ($(wildcard /system/build.prop),)
|
else ifeq ($(wildcard /system/build.prop),)
|
||||||
SUDO := sudo
|
SUDO := sudo
|
||||||
else
|
else
|
||||||
SUDO :=
|
SUDO :=
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# controls the presence of file/directory. usage: $(call check_local,<FILE_OR_DIRECTORY_PATH>,<PACKAGE_STAT: 1, NULL>)
|
PROGRESS_LIST := \
|
||||||
define check_local
|
startup \
|
||||||
# the first argument is taken and controlled by the file/directory with -e option
|
$(DEB_CHECKS) \
|
||||||
if [ ! -e $1 ]; then \
|
check_binary \
|
||||||
if [ $2 = 1 ]; then \
|
prepare \
|
||||||
printf " - Package not builded! Please build package and try again.\n"; \
|
make_debian_pack
|
||||||
else \
|
|
||||||
printf " ==> Not found: $1\n"; \
|
|
||||||
fi; \
|
|
||||||
if [ -d "$(TEMP_DIR)" ]; then \
|
|
||||||
rm -rf $(TEMP_DIR); \
|
|
||||||
fi; \
|
|
||||||
exit 1; \
|
|
||||||
fi;
|
|
||||||
endef
|
|
||||||
|
|
||||||
# make deb package
|
# make deb package
|
||||||
all:
|
all: $(PROGRESS_LIST)
|
||||||
$(hide)printf " --------- Making deb package ---------\n"
|
|
||||||
# remove template directory
|
startup:
|
||||||
$(call erase,$(TEMP_DIR))
|
$(E) " --------- Making deb package --------- "
|
||||||
$(hide)printf " - Checking files and directories (only neededs)...\n"
|
@ rm -rf $(TEMP_DIR)
|
||||||
# check some files and directories with parsing DEB_CHECKS variable
|
$(E) " - Checking files and directories (only neededs)..."
|
||||||
$(foreach deb_chfile, \
|
|
||||||
$(DEB_CHECKS), \
|
prepare:
|
||||||
$(call check_local,$(deb_chfile)) \
|
$(E) " - Copying files..."
|
||||||
)
|
@ cp -r $(DEBUTILS_DIR)/data $(TEMP_DIR) || exit 1
|
||||||
# check build status
|
@ rm -f $(DEBTERMUX_USR)/share/man/man8/dummy
|
||||||
$(call check_local, \
|
@ rm -f $(DEBTERMUX_USR)/bin/dummy
|
||||||
$(BINARY_DIR)/pmt, \
|
@ mkdir $(TEMP_DIR)/DEBIAN
|
||||||
1 \
|
|
||||||
)
|
check_binary:
|
||||||
# make template and output directories
|
@ if [ ! -f "$(BINARY_DIR)/pmt" ]; then \
|
||||||
$(call mdir,$(TEMP_DIR),"y")
|
$(E_NS) " - pmt not builded! Please build and retry."; \
|
||||||
$(call mdir,$(DEB_DIR),"y")
|
exit 1; \
|
||||||
$(hide)printf " - Copying files...\n"
|
fi
|
||||||
# prepare
|
$(E) " - Generating template directory..."
|
||||||
$(hide)cp -r $(DEBUTILS_DIR)/data $(TEMP_DIR) || exit 1
|
@ mkdir $(TEMP_DIR)
|
||||||
$(hide)rm -f $(DEBTERMUX_USR)/share/man/man8/dummy
|
$(E) " - Generating debian package directory..."
|
||||||
$(hide)rm -f $(DEBTERMUX_USR)/bin/dummy
|
@ mkdir $(DEB_DIR)
|
||||||
$(call mdir,$(TEMP_DIR)/DEBIAN)
|
|
||||||
$(hide)abort() { \
|
make_debian_pack:
|
||||||
if [ -d $(TEMP_DIR) ]; then \
|
@ abort() { \
|
||||||
rm -rf $(TEMP_DIR); \
|
[ -d $(TEMP_DIR) ] \
|
||||||
fi; \
|
&& rm -rf $(TEMP_DIR); \
|
||||||
if [ -d $(DEB_DIR) ]; then \
|
[ -d $(DEB_DIR) ] \
|
||||||
rm -rf $(DEB_DIR); \
|
&& rm -rf $(DEB_DIR); \
|
||||||
fi; \
|
|
||||||
exit 1; \
|
exit 1; \
|
||||||
}; \
|
}; \
|
||||||
if [ ! "$(FOR_THIS)" = "64" ] && [ ! "$(FOR_THIS)" = "32" ]; then \
|
if [ ! "$(FOR_THIS)" = "64" ] && [ ! "$(FOR_THIS)" = "32" ]; then \
|
||||||
printf " - İnvalid arch number: $(FOR_THIS)\n" && abort; \
|
$(E_NS) " - Invalid arch number: $(FOR_THIS) [maybe null]" && abort; \
|
||||||
fi; \
|
fi; \
|
||||||
printf " - Selected arm-$(FOR_THIS) package control file.\n"; \
|
$(E_NS) " - Selected arm-$(FOR_THIS) package control file."; \
|
||||||
cp $(DEBUTILS_DIR)/DEBIAN/control_$(FOR_THIS) $(TEMP_DIR)/DEBIAN/control || abort; \
|
cp $(DEBUTILS_DIR)/DEBIAN/control_$(FOR_THIS) $(TEMP_DIR)/DEBIAN/control || abort; \
|
||||||
cp $(DEBUTILS_DIR)/mandoc/$(TARGET).8.gz $(DEBTERMUX_USR)/share/man/man8 || abort; \
|
cp $(DEBUTILS_DIR)/mandoc/$(TARGET).8.gz $(DEBTERMUX_USR)/share/man/man8 || abort; \
|
||||||
cp $(BINARY_DIR)/$(TARGET) $(DEBTERMUX_USR)/bin || abort; \
|
cp $(BINARY_DIR)/$(TARGET) $(DEBTERMUX_USR)/bin || abort; \
|
||||||
printf " - Starting dpkg-deb...\n"; \
|
$(E_NS) " - Starting dpkg-deb..."; \
|
||||||
sleep 2; \
|
sleep 2; \
|
||||||
$(SUDO) chmod -R 755 *; \
|
$(SUDO) chmod -R 755 *; \
|
||||||
dpkg-deb -b $(TEMP_DIR) $(DEB_DIR)/$(TARGET)-$(DEB_ARCH_NAME).deb || abort; \
|
dpkg-deb -b $(TEMP_DIR) $(DEB_DIR)/$(TARGET)-$(DEB_ARCH_NAME).deb || abort; \
|
||||||
# cleanup template directory
|
|
||||||
rm -rf $(TEMP_DIR); \
|
rm -rf $(TEMP_DIR); \
|
||||||
printf " - Done!\n"
|
$(E_NS) " - Done!"
|
||||||
|
|
||||||
|
$(DEBUTILS_DIR)/%:
|
||||||
|
@ [ ! -e "$@" ] && $(E_NS) " - Check failed! Not found: $@" && exit 1
|
||||||
|
|
||||||
# end
|
# end
|
||||||
|
|||||||
@@ -17,74 +17,67 @@
|
|||||||
UPDATE_MAKEFILES = false
|
UPDATE_MAKEFILES = false
|
||||||
|
|
||||||
all:
|
all:
|
||||||
$(hide)# To save configuration, the makefile in the config directory
|
|
||||||
$(MAKE_HIDE) $(SILENT) -C $(BUILD)/config || exit 1
|
$(MAKE_HIDE) $(SILENT) -C $(BUILD)/config || exit 1
|
||||||
$(hide)# start the main build process
|
|
||||||
$(MAKE_HIDE) $(SILENT) -C $(SOURCE_DIRNAME) INC_OLDENV=true || exit 1
|
$(MAKE_HIDE) $(SILENT) -C $(SOURCE_DIRNAME) INC_OLDENV=true || exit 1
|
||||||
|
|
||||||
# cleaner functions
|
# cleaner functions
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
$(hide)printf "Cleaning directories...\n"; \
|
$(E) "Cleaning directories..."
|
||||||
# cleanup out/binary
|
@ if [ -d $(BINARY_DIR) ]; then \
|
||||||
$(hide)if [ -d $(BINARY_DIR) ]; then \
|
$(E_NS) "==> $(OUT_DIRNAME)/`basename $(BINARY_DIR)`"; \
|
||||||
printf "==> $(OUT_DIRNAME)/`basename $(BINARY_DIR)`\n"; \
|
fi
|
||||||
rm -rf "$(BINARY_DIR)"; \
|
@ if [ -d $(PACKAGE_DIR) ]; then \
|
||||||
fi; \
|
$(E_NS) "==> $(OUT_DIRNAME)/`basename $(PACKAGE_DIR)`"; \
|
||||||
# cleanup out/package
|
fi
|
||||||
$(hide)if [ -d $(PACKAGE_DIR) ]; then \
|
@ if [ -d $(STATICLIB_DIR) ]; then \
|
||||||
printf "==> $(OUT_DIRNAME)/`basename $(PACKAGE_DIR)`\n"; \
|
$(E_NS) "==> $(OUT_DIRNAME)/`basename $(STATICLIB_DIR)`"; \
|
||||||
rm -rf "$(PACKAGE_DIR)"; \
|
fi
|
||||||
fi; \
|
@ if [ -d $(DEB_DIR) ]; then \
|
||||||
# cleanup out/static_libs
|
$(E_NS) "==> $(OUT_DIRNAME)/`basename $(DEB_DIR)`"; \
|
||||||
$(hide)if [ -d $(STATICLIB_DIR) ]; then \
|
fi
|
||||||
printf "==> $(OUT_DIRNAME)/`basename $(STATICLIB_DIR)`\n"; \
|
@ rm -rf $(IN_OUT_DIR)
|
||||||
rm -rf "$(STATICLIB_DIR)"; \
|
@ rm -rf $(DEB_DIR)
|
||||||
fi; \
|
@ sleep 2
|
||||||
# cleanup out/debpackage
|
|
||||||
$(hide)if [ -d $(DEB_DIR) ]; then \
|
|
||||||
printf "==> $(OUT_DIRNAME)/`basename $(DEB_DIR)`\n"; \
|
|
||||||
rm -rf "$(DEB_DIR)"; \
|
|
||||||
fi; \
|
|
||||||
sleep 2; \
|
|
||||||
# clean the objects by calling the receipt in the source directory
|
|
||||||
$(MAKE_HIDE) $(SILENT) -C $(SOURCE_DIRNAME) clean INC_OLDENV=false || exit 1
|
$(MAKE_HIDE) $(SILENT) -C $(SOURCE_DIRNAME) clean INC_OLDENV=false || exit 1
|
||||||
$(hide)sleep 1
|
@ sleep 1
|
||||||
$(hide)printf "Success.\n"
|
$(E) "Success."
|
||||||
|
|
||||||
# helper function
|
# helper function
|
||||||
.PHONY: help
|
.PHONY: help
|
||||||
help:
|
help:
|
||||||
$(hide)printf " ------- Partition Manager help -------\n\n"
|
$(E) " ------- Partition Manager help ------- " && $(E_NS)
|
||||||
$(hide)printf " Commands:\n"
|
$(E) " Commands:"
|
||||||
$(hide)printf " $(MAKE) ==> Build Partition Manager.\n"
|
$(E) " $(MAKE) ==> Build Partition Manager."
|
||||||
$(hide)printf " $(MAKE) deb ==> Generate debian package for termux.\n"
|
$(E) " $(MAKE) deb ==> Generate debian package for termux."
|
||||||
$(hide)printf " $(MAKE) clean ==> Clear builded binary.\n"
|
$(E) " $(MAKE) clean ==> Clear builded binary."
|
||||||
$(hide)printf " $(MAKE) install ==> It installs $(TARGET) into termux.\n"
|
$(E) " $(MAKE) install ==> It installs $(TARGET) into termux."
|
||||||
$(hide)printf " $(MAKE) uninstall ==> It uninstalls $(TARGET) into termux.\n"
|
$(E) " $(MAKE) uninstall ==> It uninstalls $(TARGET) into termux."
|
||||||
$(hide)printf " $(MAKE) gen-makefiles ==> Generate makefiles for build.\n"
|
$(E) " $(MAKE) gen-makefiles ==> Generate makefiles for build."
|
||||||
$(hide)printf " $(MAKE) gen-ndk-makefiles ==> Generate NDK makefiles for build.\n"
|
$(E) " $(MAKE) gen-ndk-makefiles ==> Generate NDK makefiles for build."
|
||||||
$(hide)printf " $(MAKE) clean-makefiles ==> Cleanup makefiles.\n"
|
$(E) " $(MAKE) clean-makefiles ==> Cleanup makefiles."
|
||||||
$(hide)printf " $(MAKE) clean-ndk-makefiles ==> Cleanup NDK makefiles.\n"
|
$(E) " $(MAKE) clean-ndk-makefiles ==> Cleanup NDK makefiles."
|
||||||
$(hide)printf " $(MAKE) update-makefiles ==> Re-generate makefiles.\n"
|
$(E) " $(MAKE) update-makefiles ==> Re-generate makefiles."
|
||||||
$(hide)printf " $(MAKE) update-ndk-makefiles ==> Re-generate NDK makefiles.\n"
|
$(E) " $(MAKE) update-ndk-makefiles ==> Re-generate NDK makefiles."
|
||||||
$(hide)printf " $(MAKE) help ==> Display this help message.\n\n"
|
$(E) " $(MAKE) help ==> Display this help message." && $(E_NS)
|
||||||
|
|
||||||
# deb maker
|
# deb maker
|
||||||
.PHONY: deb
|
.PHONY: deb
|
||||||
deb:
|
deb:
|
||||||
$(MAKE_HIDE) $(SILENT) -C $(DEBUTILS_DIR) -f deb.mk FOR_THIS=$(FOR_THIS) || exit 1
|
$(MAKE_HIDE) $(SILENT) -C $(DEBUTILS_DIR) -f deb.mk FOR_THIS=$(FOR_THIS) || exit 1
|
||||||
$(hide)printf ""
|
$(P) ""
|
||||||
|
|
||||||
# install pmt in to termux
|
# install pmt in to termux
|
||||||
.PHONY: install
|
.PHONY: install
|
||||||
install:
|
install:
|
||||||
$(MAKE_HIDE) $(SILENT) -C $(OUT_DIRNAME) install || exit 1
|
$(eval PROG := $@)
|
||||||
|
$(MAKE_HIDE) $(SILENT) -C $(OUT_DIRNAME) install PROG=$(PROG) || exit 1
|
||||||
|
|
||||||
# uninstall pmt in to termux
|
# uninstall pmt in to termux
|
||||||
.PHONY: uninstall
|
.PHONY: uninstall
|
||||||
uninstall:
|
uninstall:
|
||||||
$(MAKE_HIDE) $(SILENT) -C $(OUT_DIRNAME) uninstall || exit 1
|
$(eval PROG := $@)
|
||||||
|
$(MAKE_HIDE) $(SILENT) -C $(OUT_DIRNAME) uninstall PROG=$(PROG) || exit 1
|
||||||
|
|
||||||
# clean ndk makefiles
|
# clean ndk makefiles
|
||||||
.PHONY: gen-ndk-makefiles
|
.PHONY: gen-ndk-makefiles
|
||||||
@@ -92,44 +85,42 @@ gen-ndk-makefiles:
|
|||||||
$(eval NDK_PROG = true)
|
$(eval NDK_PROG = true)
|
||||||
$(call save-gen-vars)
|
$(call save-gen-vars)
|
||||||
$(call gen-ndk-mfiles)
|
$(call gen-ndk-mfiles)
|
||||||
$(hide)printf ""
|
$(P) ""
|
||||||
|
|
||||||
.PHONY: gen-makefiles
|
.PHONY: gen-makefiles
|
||||||
gen-makefiles:
|
gen-makefiles:
|
||||||
$(call save-gen-vars)
|
$(call save-gen-vars)
|
||||||
$(call gen-mfiles)
|
$(call gen-mfiles)
|
||||||
$(hide)printf ""
|
$(P) ""
|
||||||
|
|
||||||
.PHONY: update-ndk-makefiles
|
.PHONY: update-ndk-makefiles
|
||||||
update-ndk-makefiles:
|
update-ndk-makefiles:
|
||||||
$(hide)printf " ------ Updating NDK makefiles ------ \n"
|
$(E) " ------ Updating NDK makefiles ------ "
|
||||||
$(eval NDK_PROG = true)
|
$(eval NDK_PROG = true)
|
||||||
$(eval UPDATE_MAKEFILES = true)
|
$(eval UPDATE_MAKEFILES = true)
|
||||||
$(call save-gen-vars)
|
$(call save-gen-vars)
|
||||||
$(call clean-ndk-mfiles)
|
$(call clean-ndk-mfiles)
|
||||||
$(call gen-ndk-mfiles)
|
$(call gen-ndk-mfiles)
|
||||||
$(hide)printf ""
|
|
||||||
|
|
||||||
.PHONY: update-makefiles
|
.PHONY: update-makefiles
|
||||||
update-makefiles:
|
update-makefiles:
|
||||||
$(hide)printf " ------ Updating makefiles ------ \n"
|
$(E) " ------ Updating makefiles ------ "
|
||||||
$(eval UPDATE_MAKEFILES = true)
|
$(eval UPDATE_MAKEFILES = true)
|
||||||
$(call save-gen-vars)
|
$(call save-gen-vars)
|
||||||
$(call clean-ndk-mfiles)
|
$(call clean-ndk-mfiles)
|
||||||
$(call gen-mfiles)
|
$(call gen-mfiles)
|
||||||
$(hide)printf ""
|
|
||||||
|
|
||||||
.PHONY: clean-ndk-makefiles
|
.PHONY: clean-ndk-makefiles
|
||||||
clean-ndk-makefiles:
|
clean-ndk-makefiles:
|
||||||
$(eval NDK_PROG = true)
|
$(eval NDK_PROG = true)
|
||||||
$(call save-gen-vars)
|
$(call save-gen-vars)
|
||||||
$(call clean-ndk-mfiles)
|
$(call clean-ndk-mfiles)
|
||||||
$(hide)printf ""
|
$(P) ""
|
||||||
|
|
||||||
.PHONY: clean-makefiles
|
.PHONY: clean-makefiles
|
||||||
clean-makefiles:
|
clean-makefiles:
|
||||||
$(call save-gen-vars)
|
$(call save-gen-vars)
|
||||||
$(call clean-mfiles)
|
$(call clean-mfiles)
|
||||||
$(hide)printf ""
|
$(P) ""
|
||||||
|
|
||||||
# end
|
# end
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
########
|
########
|
||||||
# 2.5.0
|
# 2.6.0
|
||||||
########
|
########
|
||||||
|
|
||||||
LOCAL_PATH := $(call my-dir)
|
LOCAL_PATH := $(call my-dir)
|
||||||
@@ -35,7 +35,7 @@ PMT_CFLAGS = \
|
|||||||
$(EXTRA_COMPILER_FLAGS)
|
$(EXTRA_COMPILER_FLAGS)
|
||||||
|
|
||||||
ifneq ($(PMT_ENABLE_DEBUG),)
|
ifneq ($(PMT_ENABLE_DEBUG),)
|
||||||
PMT_CFLAGS += -gdwarf-5 -fsanitize=address
|
PMT_CFLAGS += -gdwarf-5 -fsanitize=address -fsanitize=undefined
|
||||||
endif
|
endif
|
||||||
|
|
||||||
include $(CLEAR_VARS)
|
include $(CLEAR_VARS)
|
||||||
@@ -79,12 +79,12 @@ include $(CLEAR_VARS)
|
|||||||
LOCAL_MODULE := pmt
|
LOCAL_MODULE := pmt
|
||||||
LOCAL_SRC_FILES := \
|
LOCAL_SRC_FILES := \
|
||||||
pmt.c \
|
pmt.c \
|
||||||
versioner.c \
|
versioning.c \
|
||||||
get_stat.c \
|
get_stat.c \
|
||||||
tools.c \
|
tools.c \
|
||||||
lang_tools.c \
|
lang_tools.c \
|
||||||
languages.c \
|
languages.c \
|
||||||
docs.c
|
help.c
|
||||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include
|
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include
|
||||||
LOCAL_STATIC_LIBRARIES := \
|
LOCAL_STATIC_LIBRARIES := \
|
||||||
libpmt_root \
|
libpmt_root \
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
########
|
########
|
||||||
# 2.5.0
|
# 2.6.0
|
||||||
########
|
########
|
||||||
|
|
||||||
# architecture
|
# architecture
|
||||||
|
|||||||
@@ -25,102 +25,127 @@ include ../Makefile.inc
|
|||||||
-include $(BUILD)/config/INS_STAT.mk
|
-include $(BUILD)/config/INS_STAT.mk
|
||||||
-include $(BUILD)/config/UNINS_STAT.mk
|
-include $(BUILD)/config/UNINS_STAT.mk
|
||||||
|
|
||||||
|
INSTALL_PROGRESS_LIST := \
|
||||||
|
really_termux \
|
||||||
|
welcome \
|
||||||
|
check_ins_stat \
|
||||||
|
deb_installer \
|
||||||
|
really_builded \
|
||||||
|
install_binary
|
||||||
|
|
||||||
|
UNINSTALL_PROGRESS_LIST := \
|
||||||
|
really_termux \
|
||||||
|
welcome \
|
||||||
|
check_unins_stat \
|
||||||
|
uninstall_$(TARGET)
|
||||||
|
|
||||||
# create an empty target
|
# create an empty target
|
||||||
all:
|
all:
|
||||||
$(hide)printf ""
|
$(P) ""
|
||||||
|
|
||||||
# installer
|
# installer
|
||||||
.PHONY: install
|
.PHONY: install
|
||||||
install:
|
install: $(INSTALL_PROGRESS_LIST)
|
||||||
# really termux?
|
|
||||||
$(hide)if [ -f $(TERMUX_BIN)/termux-open ]; then \
|
|
||||||
printf " ------------ $(TARGET) installer ------------ \n"; \
|
|
||||||
if [ -f $(TERMUX_BIN)/$(TARGET) ]; then \
|
|
||||||
printf " - $(TARGET) already installed\n"; \
|
|
||||||
exit; \
|
|
||||||
fi; \
|
|
||||||
if [ ! "$(INSTALL_SUCCESS)" = "true" ] && [ ! "$(INSTALL_SUCCESS)" = "" ]; then \
|
|
||||||
printf " - $(YELLOW)$(BOLD)Warning:$(BOLD_RESET)$(RESET) a previously-stayed failed installation process found\n"; \
|
|
||||||
fi; \
|
|
||||||
if [ -f $(DEB_DIR)/*.deb ]; then \
|
|
||||||
printf " - The created deb pack was found. It's setup...\n"; \
|
|
||||||
cd $(DEB_DIR) || exit 1; \
|
|
||||||
apt install ./*.deb || exit 1; \
|
|
||||||
if [ ! "$?" = "0" ]; then \
|
|
||||||
cd $(CUR_DIR); \
|
|
||||||
printf " - Success.\n\n"; \
|
|
||||||
echo "INSTALL_SUCCESS := true" > $(BUILD)/config/INS_STAT.mk; \
|
|
||||||
echo "UNINSTALLED_SUCCESS := " > $(BUILD)/config/UNINS_STAT.mk; \
|
|
||||||
cd ..; \
|
|
||||||
exit 0; \
|
|
||||||
else \
|
|
||||||
cd $(CUR_DIR); \
|
|
||||||
printf " - $(RED)$(BOLD)Error:$(BOLD_RESET)$(RESET) installing failed!\n"; \
|
|
||||||
echo "INSTALL_SUCCESS := false" > $(BUILD)/config/INS_STAT.mk; \
|
|
||||||
cd ..; \
|
|
||||||
exit 1; \
|
|
||||||
fi; \
|
|
||||||
fi; \
|
|
||||||
if [ ! -f $(BINARY_DIR)/$(TARGET) ]; then \
|
|
||||||
printf " - $(RED)$(BOLD)Error:$(BOLD_RESET)$(RESET) Package not builded! Please build package and try again \n"; \
|
|
||||||
echo "INSTALL_SUCCESS := false" > $(BUILD)/config/INS_STAT.mk; \
|
|
||||||
exit 1; \
|
|
||||||
fi; \
|
|
||||||
printf " - Installing binary...\n"; \
|
|
||||||
if [ "`cp $(BINARY_DIR)/$(TARGET) /data/data/com.termux/files/usr/bin/$(TARGET)`" = "" ]; then \
|
|
||||||
printf " - Setting up permissions...\n"; \
|
|
||||||
else \
|
|
||||||
echo "INSTALL_SUCCESS := false" > $(BUILD)/config/INS_STAT.mk; \
|
|
||||||
exit 1; \
|
|
||||||
fi; \
|
|
||||||
if [ "`chmod 777 $(TERMUX_BIN)/$(TARGET)`" = "" ]; then \
|
|
||||||
printf " - Saving current status...\n"; \
|
|
||||||
echo "INSTALL_SUCCESS := true" > $(BUILD)/config/INS_STAT.mk; \
|
|
||||||
else \
|
|
||||||
echo "INSTALL_SUCCESS := false" > $(BUILD)/config/INS_STAT.mk; \
|
|
||||||
exit 1; \
|
|
||||||
fi; \
|
|
||||||
printf " - Success.\n\n"; \
|
|
||||||
echo "INSTALL_SUCCESS := true" > $(BUILD)/config/INS_STAT.mk; \
|
|
||||||
echo "UNINSTALLED_SUCCESS := " > $(BUILD)/config/UNINS_STAT.mk; \
|
|
||||||
else \
|
|
||||||
printf " - $(RED)$(BOLD)Error:$(BOLD_RESET)$(RESET) This function is only available on Termux.\n"; \
|
|
||||||
exit 1; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
# uninstaller
|
# uninstaller
|
||||||
.PHONY: uninstall
|
.PHONY: uninstall
|
||||||
uninstall:
|
uninstall: $(UNINSTALL_PROGRESS_LIST)
|
||||||
# really termux?
|
|
||||||
$(hide)if [ -f $(TERMUX_BIN)/termux-open ]; then \
|
install_binary:
|
||||||
printf " ----------- $(TARGET) uninstaller ----------- \n"; \
|
$(E) " - Installing binary..."
|
||||||
if [ ! -f $(TERMUX_BIN)/$(TARGET) ]; then \
|
if cp $(BINARY_DIR)/$(TARGET) /data/data/com.termux/files/usr/bin/$(TARGET); then \
|
||||||
printf " - $(TARGET) already uninstalled\n"; \
|
$(E_NS) " - Setting up permissions..."; \
|
||||||
exit; \
|
|
||||||
fi; \
|
|
||||||
if [ ! "$(UNINSTALL_SUCCESS)" = "true" ] && [ ! "$(UNINSTALL_SUCCESS)" = "" ]; then \
|
|
||||||
printf " - $(YELLOW)$(BOLD)Warning:$(BOLD_RESET)$(RESET) a previously-stayed failed uninstallation process found\n"; \
|
|
||||||
fi; \
|
|
||||||
if [ -f $(TERMUX_USR)/share/man/man8/$(TARGET).8.gz ]; then \
|
|
||||||
printf " - It was found to be established by $(TARGET)'s deb pack. It's removed with apt...\n"; \
|
|
||||||
apt remove -y $(TARGET) || exit 1; \
|
|
||||||
printf " - Success.\n\n"; \
|
|
||||||
echo "UNINSTALLED_SUCCESS := true" > $(BUILD)/config/UNINS_STAT.mk; \
|
|
||||||
echo "INSTALL_SUCCESS := " > $(BUILD)/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)/$(TARGET)`" = "" ]; then \
|
|
||||||
printf " - Success.\n\n"; \
|
|
||||||
echo "UNINSTALLED_SUCCESS := true" > $(BUILD)/config/UNINS_STAT.mk; \
|
|
||||||
echo "INSTALL_SUCCESS := " > $(BUILD)/config/INS_STAT.mk; \
|
|
||||||
else \
|
|
||||||
echo "UNINSTALLED_SUCCESS := false" > $(BUILD)/config/UNINS_STAT.mk; \
|
|
||||||
exit 1; \
|
|
||||||
fi; \
|
|
||||||
fi; \
|
|
||||||
else \
|
else \
|
||||||
printf "$(RED)$(BOLD)Error:$(BOLD_RESET)$(RESET) This function is only available on Termux.\n"; \
|
$(E_NS) "INSTALL_SUCCESS := false" > $(BUILD)/config/INS_STAT.mk; \
|
||||||
|
exit 1; \
|
||||||
|
fi; \
|
||||||
|
if chmod 777 $(TERMUX_BIN)/$(TARGET); then \
|
||||||
|
$(E_NS) " - Saving current status..."; \
|
||||||
|
$(E_NS) "INSTALL_SUCCESS := true" > $(BUILD)/config/INS_STAT.mk; \
|
||||||
|
else \
|
||||||
|
$(E_NS) "INSTALL_SUCCESS := false" > $(BUILD)/config/INS_STAT.mk; \
|
||||||
|
exit 1; \
|
||||||
|
fi; \
|
||||||
|
$(P) " - Success.\n\n"; \
|
||||||
|
$(E_NS) "INSTALL_SUCCESS := true" > $(BUILD)/config/INS_STAT.mk; \
|
||||||
|
$(E_NS) "UNINSTALLED_SUCCESS := " > $(BUILD)/config/UNINS_STAT.mk; \
|
||||||
|
|
||||||
|
uninstall_$(TARGET):
|
||||||
|
if [ -f $(TERMUX_USR)/share/man/man8/$(TARGET).8.gz ]; then \
|
||||||
|
$(E_NS) " - It was found to be established by $(TARGET)'s deb pack. It's removed with apt..."; \
|
||||||
|
apt remove -y $(TARGET) || exit 1; \
|
||||||
|
$(P) " - Success.\n\n"; \
|
||||||
|
$(E_NS) "UNINSTALLED_SUCCESS := true" > $(BUILD)/config/UNINS_STAT.mk; \
|
||||||
|
$(E_NS) "INSTALL_SUCCESS := " > $(BUILD)/config/INS_STAT.mk; \
|
||||||
|
else \
|
||||||
|
$(E_NS) " - It was found that pmt was manually established (with this makefile or copying). Manually removed..."; \
|
||||||
|
if rm $(TERMUX_BIN)/$(TARGET); then \
|
||||||
|
$(P) " - Success.\n\n"; \
|
||||||
|
$(E_NS) "UNINSTALLED_SUCCESS := true" > $(BUILD)/config/UNINS_STAT.mk; \
|
||||||
|
$(E_NS) "INSTALL_SUCCESS := " > $(BUILD)/config/INS_STAT.mk; \
|
||||||
|
else \
|
||||||
|
$(E_NS) "UNINSTALLED_SUCCESS := false" > $(BUILD)/config/UNINS_STAT.mk; \
|
||||||
|
exit 1; \
|
||||||
|
fi; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
deb_installer:
|
||||||
|
if [ -f $(DEB_DIR)/*.deb ]; then \
|
||||||
|
$(E_NS) " - The created deb pack was found. It's setup..."; \
|
||||||
|
cd $(DEB_DIR) || exit 1; \
|
||||||
|
apt install ./*.deb || exit 1; \
|
||||||
|
if [ ! "$?" = "0" ]; then \
|
||||||
|
cd $(CUR_DIR); \
|
||||||
|
$(P) " - Success.\n\n"; \
|
||||||
|
$(E_NS) "INSTALL_SUCCESS := true" > $(BUILD)/config/INS_STAT.mk; \
|
||||||
|
$(E_NS) "UNINSTALLED_SUCCESS := " > $(BUILD)/config/UNINS_STAT.mk; \
|
||||||
|
cd ..; \
|
||||||
|
exit 0; \
|
||||||
|
else \
|
||||||
|
cd $(CUR_DIR); \
|
||||||
|
$(P) " - $(RED)$(BOLD)Error:$(BOLD_RESET)$(RESET) installing failed!\n"; \
|
||||||
|
$(E_NS) "INSTALL_SUCCESS := false" > $(BUILD)/config/INS_STAT.mk; \
|
||||||
|
cd ..; \
|
||||||
|
exit 1; \
|
||||||
|
fi; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
check_ins_stat:
|
||||||
|
@ if [ ! "$(INSTALL_SUCCESS)" = "true" ] && [ ! "$(INSTALL_SUCCESS)" = "" ]; then \
|
||||||
|
$(P) " - $(YELLOW)$(BOLD)Warning:$(BOLD_RESET)$(RESET) a previously-stayed failed installation process found\n"; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
check_unins_stat:
|
||||||
|
@ if [ ! "$(UNINSTALL_SUCCESS)" = "true" ] && [ ! "$(UNINSTALL_SUCCESS)" = "" ]; then \
|
||||||
|
$(P) " - $(YELLOW)$(BOLD)Warning:$(BOLD_RESET)$(RESET) a previously-stayed failed uninstallation process found\n"; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
welcome:
|
||||||
|
$(E) " ----------- $(TARGET) $(PROG)er ----------- "
|
||||||
|
@ if [ "$(PROG)" = "uninstall" ]; then \
|
||||||
|
if [ ! -f $(TERMUX_BIN)/$(TARGET) ]; then \
|
||||||
|
$(E_NS) " - $(TARGET) already $(PROG)ed"; \
|
||||||
|
exit 1; \
|
||||||
|
fi; \
|
||||||
|
fi
|
||||||
|
@ if [ "$(PROG)" = "install" ]; then \
|
||||||
|
if [ -f $(TERMUX_BIN)/$(TARGET) ]; then \
|
||||||
|
$(E_NS) " - $(TARGET) already $(PROG)ed"; \
|
||||||
|
exit 1; \
|
||||||
|
fi; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
really_termux:
|
||||||
|
@ if [ ! -f $(TERMUX_BIN)/termux-open ]; then \
|
||||||
|
$(P) "$(RED)$(BOLD)Error:$(BOLD_RESET)$(RESET) This function is only available on Termux.\n"; \
|
||||||
exit 1; \
|
exit 1; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# end
|
really_builded:
|
||||||
|
if [ ! -f $(BINARY_DIR)/$(TARGET) ]; then \
|
||||||
|
$(P) " - $(RED)$(BOLD)Error:$(BOLD_RESET)$(RESET) Package not builded! Please build package and try again \n"; \
|
||||||
|
$(E_NS) "INSTALL_SUCCESS := false" > $(BUILD)/config/INS_STAT.mk; \
|
||||||
|
exit 1; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
# end
|
||||||
|
|||||||
@@ -26,121 +26,149 @@ ifeq ($(INC_OLDENV),true)
|
|||||||
include $(BUILD)/config/oldenv.mk
|
include $(BUILD)/config/oldenv.mk
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# make objects. Usage $(call make_obj,<SRCFILE>)
|
INCLUDE_DIR := $(realpath ../include)
|
||||||
define make_obj
|
PMT_INCDIR := $(INCLUDE_DIR)/pmt
|
||||||
$(eval OBJ := $(1:.c=.o))
|
|
||||||
$(call m_stat,CC,`basename $(SOURCE_DIR)`/`basename $(OBJ)`,n)
|
|
||||||
$(CC) $(CFLAGS) -c "$1" || exit 1;
|
|
||||||
$(hide)printf "\n"
|
|
||||||
endef
|
|
||||||
|
|
||||||
# make executable file with using static libraries and objects. Usage: $(call make_executable)
|
# the presence of all source files that are on this list will be checked
|
||||||
define make_executable
|
SRCS_REQ := \
|
||||||
printf " - Making executable file...\n"; \
|
place-holder/debugging.c \
|
||||||
printf " LD $(TARGET)"; \
|
place-holder/help.c \
|
||||||
$(CC) $(CFLAGS) -L$(SOURCE_DIR) \
|
place-holder/get_stat.c \
|
||||||
$(foreach s_obj_b, \
|
place-holder/lang_tools.c \
|
||||||
$(shell basename -a $(STATICLIB_OBJS)), \
|
place-holder/languages.c \
|
||||||
$(eval s_obj_t_b = $(s_obj_b:.o=)) \
|
place-holder/partitiontool.c \
|
||||||
$(shell echo -lpmt_$(s_obj_t_b)) \
|
place-holder/pmt.c \
|
||||||
) \
|
place-holder/root.c \
|
||||||
-o $(TARGET) $(OBJS_EXEC) || exit 1;
|
place-holder/tools.c \
|
||||||
endef
|
place-holder/versioning.c
|
||||||
|
|
||||||
# make static library. Usage $(call make_staticlib,<LIBRARY_NAME>,<OBJECT(S)>)
|
# objects to be used when executable file is created
|
||||||
define make_staticlib
|
OBJS_EXEC := \
|
||||||
echo -n " AR $1"; \
|
$(SOURCE_DIR)/$(TARGET).o \
|
||||||
$(AR) rcs "$1" "$2" || exit 1; \
|
$(SOURCE_DIR)/help.o \
|
||||||
echo;
|
$(SOURCE_DIR)/versioning.o \
|
||||||
endef
|
$(SOURCE_DIR)/get_stat.o \
|
||||||
|
$(SOURCE_DIR)/tools.o \
|
||||||
|
$(SOURCE_DIR)/lang_tools.o \
|
||||||
|
$(SOURCE_DIR)/languages.o
|
||||||
|
|
||||||
# controls the presence of source file. usage: $(call check_cfile,<SOURCE_FILE>)
|
HEADERS_REQ := \
|
||||||
define check_cfile
|
$(PMT_INCDIR)/pmt/deprecates.h \
|
||||||
# the first argument is taken and controlled by the file with -f option
|
$(PMT_INCDIR)/pmt/help_msgs.h \
|
||||||
printf " CHK src/`basename $1`\n"; \
|
$(PMT_INCDIR)/pmt/pmt.h \
|
||||||
if [ ! -f $1 ]; then \
|
$(PMT_INCDIR)/pmt/stringkeys.h \
|
||||||
printf " ==> Couldn't found required source file: src/`basename $1`\n"; \
|
$(PMT_INCDIR)/pmt/versioning.h
|
||||||
if [ -d "$(TEMP_DIR)" ]; then \
|
|
||||||
rm -rf $(TEMP_DIR); \
|
|
||||||
fi; \
|
|
||||||
exit 1; \
|
|
||||||
fi;
|
|
||||||
endef
|
|
||||||
|
|
||||||
# controls the presence of header file. usage: $(call check_hfile,<SOURCE_FILE>)
|
PROGRESS_LIST := \
|
||||||
define check_hfile
|
welcome \
|
||||||
# the first argument is taken and controlled by the file with -f option
|
$(SRCS_REQ) \
|
||||||
printf " CHK include/pmt/`basename $1`\n"; \
|
$(HEADERS_REQ) \
|
||||||
if [ ! -f $1 ]; then \
|
pr_obj \
|
||||||
printf " ==> Couldn't found required header file: include/pmt/`basename $1`\n"; \
|
$(OBJS) \
|
||||||
if [ -d "$(TEMP_DIR)" ]; then \
|
make_outdirs \
|
||||||
rm -rf $(TEMP_DIR); \
|
$(STATIC_LIBS) \
|
||||||
fi; \
|
make_executable \
|
||||||
exit 1; \
|
end_progress
|
||||||
fi;
|
|
||||||
|
define check_hf
|
||||||
|
@ [ ! -f "$1" ] \
|
||||||
|
&& $(E_NS) " ==> Couldn't found required header file: include/pmt/`basename $1`" \
|
||||||
|
&& exit 1
|
||||||
endef
|
endef
|
||||||
|
|
||||||
# all target for building
|
# all target for building
|
||||||
all:
|
all: $(PROGRESS_LIST)
|
||||||
$(hide)rm -f $(BUILD)/config/oldenv.mk
|
|
||||||
$(hide)printf " ---- Partition Manager Builder ---- \n\n"
|
welcome:
|
||||||
$(hide)printf " - Version: $(VERSION)\n"
|
@ rm -f $(BUILD)/config/oldenv.mk
|
||||||
$(hide)printf " - Version code: $(VERSION_CODE)\n\n"
|
@ echo " ---- Partition Manager Builder ---- " \
|
||||||
$(hide)printf " -------------------------------- \n\n"
|
&& $(E_NS)
|
||||||
$(hide)if [ -f $(SOURCE_DIR)/debugging.o ]; then \
|
$(E) " - Version: $(VERSION)"
|
||||||
printf " - Please clean up before you build it.\n\n"; \
|
$(E) " - Version code: $(VERSION_CODE)" \
|
||||||
printf " ----------------------------------- \n"; \
|
&& $(E_NS)
|
||||||
|
$(E) " -------------------------------- " \
|
||||||
|
&& $(E_NS)
|
||||||
|
@ if [ -f $(SOURCE_DIR)/debugging.o ]; then \
|
||||||
|
$(E_NS) " - Please clean up before you build it." && echo; \
|
||||||
|
$(E_NS) " ----------------------------------- "; \
|
||||||
exit 1; \
|
exit 1; \
|
||||||
fi
|
fi
|
||||||
$(hide)printf " - Checking required source files...\n"
|
$(E) " - Checking required source files..."
|
||||||
$(hide)sleep 1
|
@ sleep 1
|
||||||
$(foreach src_cf, \
|
|
||||||
$(SRCS_REQ), \
|
pr_obj:
|
||||||
$(call check_cfile,$(src_cf)) \
|
$(E) " - Building objects..."
|
||||||
)
|
|
||||||
$(foreach src_hf, \
|
make_outdirs:
|
||||||
$(HEADERS_REQ), \
|
@ rm -rf $(IN_OUT_DIR)
|
||||||
$(call check_hfile,$(src_hf)) \
|
@ mkdir $(BINARY_DIR)
|
||||||
)
|
@ mkdir $(PACKAGE_DIR)
|
||||||
$(hide)printf " - Building objects...\n"
|
@ mkdir $(STATICLIB_DIR)
|
||||||
$(hide)sleep 2
|
|
||||||
$(foreach csrc, \
|
place-holder/%.c:
|
||||||
$(SRCS), \
|
$(E) " CHK $(SOURCE_DIRNAME)/`basename $@`"
|
||||||
$(call make_obj,$(csrc)) \
|
@ if [ ! -f "$(SOURCE_DIR)/`basename $@`" ]; then \
|
||||||
)
|
$(E_NS) " ==> Couldn't found required source file: $(SOURCE_DIRNAME)/`basename $@`"; \
|
||||||
$(foreach reqdir,$(IN_OUT_DIR),$(call mdir,$(reqdir)))
|
exit 1; \
|
||||||
$(hide)printf " - Making static libraries...\n"
|
fi
|
||||||
$(foreach s_obj, \
|
|
||||||
$(shell basename -a $(STATICLIB_OBJS)), \
|
$(PMT_INCDIR)/%.h:
|
||||||
$(eval s_obj_t = $(s_obj:.o=.a)) \
|
$(E) " CHK include/pmt/`basename $@`"
|
||||||
$(call make_staticlib,libpmt_$(s_obj_t),$(s_obj)) \
|
@ if [ ! -f "$(INCLUDE_DIR)/pmt/`basename $@`" ]; then \
|
||||||
)
|
$(E_NS) " ==> Couldn't found required header file: include/pmt/`basename $@`"; \
|
||||||
$(hide)sleep 1
|
exit 1; \
|
||||||
$(call make_executable)
|
fi
|
||||||
$(hide)sleep 1
|
|
||||||
$(hide)abort_build() { \
|
$(SOURCE_DIR)/%.o: $(SOURCE_DIR)/%.c
|
||||||
if [ -d "$(PACKAGE_DIR)" ]; then \
|
$(E) " CC $(SOURCE_DIRNAME)/`basename $@`"
|
||||||
rm -rf "$(PACKAGE_DIR)"; \
|
@ $(CC) $(CFLAGS) -c "$<" || exit 1
|
||||||
fi; \
|
$(eval GEN_OBJS_MSG = )
|
||||||
if [ -d "$(BINARY_DIR)" ]; then \
|
|
||||||
rm -rf "$(BINARY_DIR)"; \
|
lib$(TARGET)_root.a:
|
||||||
fi; \
|
$(E) " - Making static libraries..."
|
||||||
if [ -d "$(STATICLIB_DIR)" ]; then \
|
$(E) " AR $@"
|
||||||
rm -rf "$(STATICLIB_DIR)"; \
|
@ $(AR) rcs "$@" "$(SOURCE_DIR)/root.o" || exit 1
|
||||||
fi; \
|
|
||||||
|
lib$(TARGET)_debugging.a:
|
||||||
|
$(E) " AR $@"
|
||||||
|
@ $(AR) rcs "$@" "$(SOURCE_DIR)/debugging.o"
|
||||||
|
|
||||||
|
lib$(TARGET)_listpart.a:
|
||||||
|
$(E) " AR $@"
|
||||||
|
@ $(AR) rcs "$@" "$(SOURCE_DIR)/listpart.o"
|
||||||
|
|
||||||
|
lib$(TARGET)_partitiontool.a:
|
||||||
|
$(E) " AR $@"
|
||||||
|
@ $(AR) rcs "$@" "$(SOURCE_DIR)/partitiontool.o"
|
||||||
|
@ sleep 1
|
||||||
|
|
||||||
|
make_executable:
|
||||||
|
$(E) " - Making executable file..."
|
||||||
|
$(E) " LD $(TARGET)"
|
||||||
|
@ $(CC) $(CFLAGS) -L$(SOURCE_DIR) -l$(TARGET)_root -l$(TARGET)_debugging -l$(TARGET)_listpart -l$(TARGET)_partitiontool -o $(TARGET) $(OBJS_EXEC) || exit 1
|
||||||
|
@ sleep 1
|
||||||
|
|
||||||
|
end_progress:
|
||||||
|
@ abort_build() { \
|
||||||
|
[ -d "$(PACKAGE_DIR)" ] \
|
||||||
|
&& rm -rf "$(PACKAGE_DIR)"; \
|
||||||
|
[ -d "$(BINARY_DIR)" ] \
|
||||||
|
&& rm -rf "$(BINARY_DIR)"; \
|
||||||
|
[ -d "$(STATICLIB_DIR)" ] \
|
||||||
|
&& rm -rf "$(STATICLIB_DIR)"; \
|
||||||
exit 1; \
|
exit 1; \
|
||||||
}; \
|
}; \
|
||||||
mv $(TARGET) $(BINARY_DIR) || abort_build; \
|
mv $(TARGET) $(BINARY_DIR) || abort_build; \
|
||||||
mv *.a $(STATICLIB_DIR) || abort_build; \
|
mv *.a $(STATICLIB_DIR) || abort_build; \
|
||||||
printf "\n - Generating package...\n"; \
|
$(E_NS) " - Generating package..."; \
|
||||||
cp $(BINARY_DIR)/$(TARGET) $(PACKAGE_DIR) || abort_build; \
|
cp $(BINARY_DIR)/$(TARGET) $(PACKAGE_DIR) || abort_build; \
|
||||||
printf " XZ $(OUT_DIRNAME)/package/$(TARGET)-$(ARCH).xz"
|
$(E_NS) " XZ $(OUT_DIRNAME)/package/$(TARGET)-`date +%Y%m%d`.xz"
|
||||||
xz $(PACKAGE_DIR)/$(TARGET) || abort_build; \
|
xz $(PACKAGE_DIR)/$(TARGET) || abort_build; \
|
||||||
sleep 1; \
|
sleep 1; \
|
||||||
mv $(PACKAGE_DIR)/$(TARGET).xz $(PACKAGE_DIR)/$(TARGET)-$(ARCH).xz || abort_build; \
|
mv $(PACKAGE_DIR)/$(TARGET).xz $(PACKAGE_DIR)/$(TARGET)-`date +%Y%m%d`.xz || abort_build
|
||||||
printf "\n - Success"; \
|
$(E) " - Success" && $(E_NS)
|
||||||
sleep 1; \
|
@ sleep 1
|
||||||
printf "\n\n ----------------------------------- \n"
|
$(E) " ----------------------------------- "
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
export PMT_VERSION="2.5.0"
|
export PMT_VERSION="2.6.0"
|
||||||
export PMT_VERSION_CODE=250
|
export PMT_VERSION_CODE=260
|
||||||
export NDK_LINK="https://dl.google.com/android/repository/android-ndk-r27-linux.zip"
|
export NDK_LINK="https://dl.google.com/android/repository/android-ndk-r27-linux.zip"
|
||||||
export NDK_VERSION="r27"
|
export NDK_VERSION="r27"
|
||||||
export NDK_IS="android-ndk"
|
export NDK_IS="android-ndk"
|
||||||
@@ -16,8 +16,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __PMT_DOCS_H
|
#ifndef __PMT_HELP_MSGS_H
|
||||||
#define __PMT_DOCS_H
|
#define __PMT_HELP_MSGS_H
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
@@ -16,6 +16,10 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if !defined(__clang__) && !defined(__NDK_BUILD)
|
||||||
|
#error "Your compiler is NOT clang. Please build with LLVM clang."
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
@@ -28,11 +32,13 @@ __BEGIN_DECLS
|
|||||||
#ifdef INC_MAIN_LIBS
|
#ifdef INC_MAIN_LIBS
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#if !defined(HELP) || !defined(VERSIONING)
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef INC_GETOPT
|
#ifdef INC_GETOPT
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ __BEGIN_DECLS
|
|||||||
|
|
||||||
/* versioning */
|
/* versioning */
|
||||||
#define PMT_MAJOR 2
|
#define PMT_MAJOR 2
|
||||||
#define PMT_MINOR 5
|
#define PMT_MINOR 6
|
||||||
#define PMT_PATCHLEVEL 0
|
#define PMT_PATCHLEVEL 0
|
||||||
|
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
|
|||||||
226
jni/Makefile
226
jni/Makefile
@@ -26,121 +26,149 @@ ifeq ($(INC_OLDENV),true)
|
|||||||
include $(BUILD)/config/oldenv.mk
|
include $(BUILD)/config/oldenv.mk
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# make objects. Usage $(call make_obj,<SRCFILE>)
|
INCLUDE_DIR := $(realpath ../include)
|
||||||
define make_obj
|
PMT_INCDIR := $(INCLUDE_DIR)/pmt
|
||||||
$(eval OBJ := $(1:.c=.o))
|
|
||||||
$(call m_stat,CC,`basename $(SOURCE_DIR)`/`basename $(OBJ)`,n)
|
|
||||||
$(CC) $(CFLAGS) -c "$1" || exit 1;
|
|
||||||
$(hide)printf "\n"
|
|
||||||
endef
|
|
||||||
|
|
||||||
# make executable file with using static libraries and objects. Usage: $(call make_executable)
|
# the presence of all source files that are on this list will be checked
|
||||||
define make_executable
|
SRCS_REQ := \
|
||||||
printf " - Making executable file...\n"; \
|
place-holder/debugging.c \
|
||||||
printf " LD $(TARGET)"; \
|
place-holder/help.c \
|
||||||
$(CC) $(CFLAGS) -L$(SOURCE_DIR) \
|
place-holder/get_stat.c \
|
||||||
$(foreach s_obj_b, \
|
place-holder/lang_tools.c \
|
||||||
$(shell basename -a $(STATICLIB_OBJS)), \
|
place-holder/languages.c \
|
||||||
$(eval s_obj_t_b = $(s_obj_b:.o=)) \
|
place-holder/partitiontool.c \
|
||||||
$(shell echo -lpmt_$(s_obj_t_b)) \
|
place-holder/pmt.c \
|
||||||
) \
|
place-holder/root.c \
|
||||||
-o $(TARGET) $(OBJS_EXEC) || exit 1;
|
place-holder/tools.c \
|
||||||
endef
|
place-holder/versioning.c
|
||||||
|
|
||||||
# make static library. Usage $(call make_staticlib,<LIBRARY_NAME>,<OBJECT(S)>)
|
# objects to be used when executable file is created
|
||||||
define make_staticlib
|
OBJS_EXEC := \
|
||||||
echo -n " AR $1"; \
|
$(SOURCE_DIR)/$(TARGET).o \
|
||||||
$(AR) rcs "$1" "$2" || exit 1; \
|
$(SOURCE_DIR)/help.o \
|
||||||
echo;
|
$(SOURCE_DIR)/versioning.o \
|
||||||
endef
|
$(SOURCE_DIR)/get_stat.o \
|
||||||
|
$(SOURCE_DIR)/tools.o \
|
||||||
|
$(SOURCE_DIR)/lang_tools.o \
|
||||||
|
$(SOURCE_DIR)/languages.o
|
||||||
|
|
||||||
# controls the presence of source file. usage: $(call check_cfile,<SOURCE_FILE>)
|
HEADERS_REQ := \
|
||||||
define check_cfile
|
$(PMT_INCDIR)/pmt/deprecates.h \
|
||||||
# the first argument is taken and controlled by the file with -f option
|
$(PMT_INCDIR)/pmt/help_msgs.h \
|
||||||
printf " CHK $(SOURCE_DIRNAME)/`basename $1`\n"; \
|
$(PMT_INCDIR)/pmt/pmt.h \
|
||||||
if [ ! -f $1 ]; then \
|
$(PMT_INCDIR)/pmt/stringkeys.h \
|
||||||
printf " ==> Couldn't found required source file: $(SOURCE_DIRNAME)/`basename $1`\n"; \
|
$(PMT_INCDIR)/pmt/versioning.h
|
||||||
if [ -d "$(TEMP_DIR)" ]; then \
|
|
||||||
rm -rf $(TEMP_DIR); \
|
|
||||||
fi; \
|
|
||||||
exit 1; \
|
|
||||||
fi;
|
|
||||||
endef
|
|
||||||
|
|
||||||
# controls the presence of header file. usage: $(call check_hfile,<SOURCE_FILE>)
|
PROGRESS_LIST := \
|
||||||
define check_hfile
|
welcome \
|
||||||
# the first argument is taken and controlled by the file with -f option
|
$(SRCS_REQ) \
|
||||||
printf " CHK include/pmt/`basename $1`\n"; \
|
$(HEADERS_REQ) \
|
||||||
if [ ! -f $1 ]; then \
|
pr_obj \
|
||||||
printf " ==> Couldn't found required header file: include/pmt/`basename $1`\n"; \
|
$(OBJS) \
|
||||||
if [ -d "$(TEMP_DIR)" ]; then \
|
make_outdirs \
|
||||||
rm -rf $(TEMP_DIR); \
|
$(STATIC_LIBS) \
|
||||||
fi; \
|
make_executable \
|
||||||
exit 1; \
|
end_progress
|
||||||
fi;
|
|
||||||
|
define check_hf
|
||||||
|
@ [ ! -f "$1" ] \
|
||||||
|
&& $(E_NS) " ==> Couldn't found required header file: include/pmt/`basename $1`" \
|
||||||
|
&& exit 1
|
||||||
endef
|
endef
|
||||||
|
|
||||||
# all target for building
|
# all target for building
|
||||||
all:
|
all: $(PROGRESS_LIST)
|
||||||
$(hide)rm -f $(BUILD)/config/oldenv.mk
|
|
||||||
$(hide)printf " ---- Partition Manager Builder ---- \n\n"
|
welcome:
|
||||||
$(hide)printf " - Version: $(VERSION)\n"
|
@ rm -f $(BUILD)/config/oldenv.mk
|
||||||
$(hide)printf " - Version code: $(VERSION_CODE)\n\n"
|
@ echo " ---- Partition Manager Builder ---- " \
|
||||||
$(hide)printf " -------------------------------- \n\n"
|
&& $(E_NS)
|
||||||
$(hide)if [ -f $(SOURCE_DIR)/debugging.o ]; then \
|
$(E) " - Version: $(VERSION)"
|
||||||
printf " - Please clean up before you build it.\n\n"; \
|
$(E) " - Version code: $(VERSION_CODE)" \
|
||||||
printf " ----------------------------------- \n"; \
|
&& $(E_NS)
|
||||||
|
$(E) " -------------------------------- " \
|
||||||
|
&& $(E_NS)
|
||||||
|
@ if [ -f $(SOURCE_DIR)/debugging.o ]; then \
|
||||||
|
$(E_NS) " - Please clean up before you build it." && echo; \
|
||||||
|
$(E_NS) " ----------------------------------- "; \
|
||||||
exit 1; \
|
exit 1; \
|
||||||
fi
|
fi
|
||||||
$(hide)printf " - Checking required source files...\n"
|
$(E) " - Checking required source files..."
|
||||||
$(hide)sleep 1
|
@ sleep 1
|
||||||
$(foreach src_cf, \
|
|
||||||
$(SRCS_REQ), \
|
pr_obj:
|
||||||
$(call check_cfile,$(src_cf)) \
|
$(E) " - Building objects..."
|
||||||
)
|
|
||||||
$(foreach src_hf, \
|
make_outdirs:
|
||||||
$(HEADERS_REQ), \
|
@ rm -rf $(IN_OUT_DIR)
|
||||||
$(call check_hfile,$(src_hf)) \
|
@ mkdir $(BINARY_DIR)
|
||||||
)
|
@ mkdir $(PACKAGE_DIR)
|
||||||
$(hide)printf " - Building objects...\n"
|
@ mkdir $(STATICLIB_DIR)
|
||||||
$(hide)sleep 2
|
|
||||||
$(foreach csrc, \
|
place-holder/%.c:
|
||||||
$(SRCS), \
|
$(E) " CHK $(SOURCE_DIRNAME)/`basename $@`"
|
||||||
$(call make_obj,$(csrc)) \
|
@ if [ ! -f "$(SOURCE_DIR)/`basename $@`" ]; then \
|
||||||
)
|
$(E_NS) " ==> Couldn't found required source file: $(SOURCE_DIRNAME)/`basename $@`"; \
|
||||||
$(foreach reqdir,$(IN_OUT_DIR),$(call mdir,$(reqdir)))
|
exit 1; \
|
||||||
$(hide)printf " - Making static libraries...\n"
|
fi
|
||||||
$(foreach s_obj, \
|
|
||||||
$(shell basename -a $(STATICLIB_OBJS)), \
|
$(PMT_INCDIR)/%.h:
|
||||||
$(eval s_obj_t = $(s_obj:.o=.a)) \
|
$(E) " CHK include/pmt/`basename $@`"
|
||||||
$(call make_staticlib,libpmt_$(s_obj_t),$(s_obj)) \
|
@ if [ ! -f "$(INCLUDE_DIR)/pmt/`basename $@`" ]; then \
|
||||||
)
|
$(E_NS) " ==> Couldn't found required header file: include/pmt/`basename $@`"; \
|
||||||
$(hide)sleep 1
|
exit 1; \
|
||||||
$(call make_executable)
|
fi
|
||||||
$(hide)sleep 1
|
|
||||||
$(hide)abort_build() { \
|
$(SOURCE_DIR)/%.o: $(SOURCE_DIR)/%.c
|
||||||
if [ -d "$(PACKAGE_DIR)" ]; then \
|
$(E) " CC $(SOURCE_DIRNAME)/`basename $@`"
|
||||||
rm -rf "$(PACKAGE_DIR)"; \
|
@ $(CC) $(CFLAGS) -c "$<" || exit 1
|
||||||
fi; \
|
$(eval GEN_OBJS_MSG = )
|
||||||
if [ -d "$(BINARY_DIR)" ]; then \
|
|
||||||
rm -rf "$(BINARY_DIR)"; \
|
lib$(TARGET)_root.a:
|
||||||
fi; \
|
$(E) " - Making static libraries..."
|
||||||
if [ -d "$(STATICLIB_DIR)" ]; then \
|
$(E) " AR $@"
|
||||||
rm -rf "$(STATICLIB_DIR)"; \
|
@ $(AR) rcs "$@" "$(SOURCE_DIR)/root.o" || exit 1
|
||||||
fi; \
|
|
||||||
|
lib$(TARGET)_debugging.a:
|
||||||
|
$(E) " AR $@"
|
||||||
|
@ $(AR) rcs "$@" "$(SOURCE_DIR)/debugging.o"
|
||||||
|
|
||||||
|
lib$(TARGET)_listpart.a:
|
||||||
|
$(E) " AR $@"
|
||||||
|
@ $(AR) rcs "$@" "$(SOURCE_DIR)/listpart.o"
|
||||||
|
|
||||||
|
lib$(TARGET)_partitiontool.a:
|
||||||
|
$(E) " AR $@"
|
||||||
|
@ $(AR) rcs "$@" "$(SOURCE_DIR)/partitiontool.o"
|
||||||
|
@ sleep 1
|
||||||
|
|
||||||
|
make_executable:
|
||||||
|
$(E) " - Making executable file..."
|
||||||
|
$(E) " LD $(TARGET)"
|
||||||
|
@ $(CC) $(CFLAGS) -L$(SOURCE_DIR) -l$(TARGET)_root -l$(TARGET)_debugging -l$(TARGET)_listpart -l$(TARGET)_partitiontool -o $(TARGET) $(OBJS_EXEC) || exit 1
|
||||||
|
@ sleep 1
|
||||||
|
|
||||||
|
end_progress:
|
||||||
|
@ abort_build() { \
|
||||||
|
[ -d "$(PACKAGE_DIR)" ] \
|
||||||
|
&& rm -rf "$(PACKAGE_DIR)"; \
|
||||||
|
[ -d "$(BINARY_DIR)" ] \
|
||||||
|
&& rm -rf "$(BINARY_DIR)"; \
|
||||||
|
[ -d "$(STATICLIB_DIR)" ] \
|
||||||
|
&& rm -rf "$(STATICLIB_DIR)"; \
|
||||||
exit 1; \
|
exit 1; \
|
||||||
}; \
|
}; \
|
||||||
mv $(TARGET) $(BINARY_DIR) || abort_build; \
|
mv $(TARGET) $(BINARY_DIR) || abort_build; \
|
||||||
mv *.a $(STATICLIB_DIR) || abort_build; \
|
mv *.a $(STATICLIB_DIR) || abort_build; \
|
||||||
printf "\n - Generating package...\n"; \
|
$(E_NS) " - Generating package..."; \
|
||||||
cp $(BINARY_DIR)/$(TARGET) $(PACKAGE_DIR) || abort_build; \
|
cp $(BINARY_DIR)/$(TARGET) $(PACKAGE_DIR) || abort_build; \
|
||||||
printf " XZ $(OUT_DIRNAME)/package/$(TARGET)-`date +%Y%m%d`.xz"
|
$(E_NS) " XZ $(OUT_DIRNAME)/package/$(TARGET)-`date +%Y%m%d`.xz"
|
||||||
xz $(PACKAGE_DIR)/$(TARGET) || abort_build; \
|
xz $(PACKAGE_DIR)/$(TARGET) || abort_build; \
|
||||||
sleep 1; \
|
sleep 1; \
|
||||||
mv $(PACKAGE_DIR)/$(TARGET).xz $(PACKAGE_DIR)/$(TARGET)-`date +%Y%m%d`.xz || abort_build; \
|
mv $(PACKAGE_DIR)/$(TARGET).xz $(PACKAGE_DIR)/$(TARGET)-`date +%Y%m%d`.xz || abort_build
|
||||||
printf "\n - Success"; \
|
$(E) " - Success" && $(E_NS)
|
||||||
sleep 1; \
|
@ sleep 1
|
||||||
printf "\n\n ----------------------------------- \n"
|
$(E) " ----------------------------------- "
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
|
|||||||
@@ -27,8 +27,6 @@ extern "C" {
|
|||||||
|
|
||||||
void debug(LogLevel status, const char* _Nullable fmt, ...)
|
void debug(LogLevel status, const char* _Nullable fmt, ...)
|
||||||
{
|
{
|
||||||
if (fmt == NULL) exit(1);
|
|
||||||
|
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
|
|
||||||
|
|||||||
@@ -21,10 +21,11 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define INC_MAIN_LIBS
|
#define INC_MAIN_LIBS
|
||||||
|
#define HELP
|
||||||
|
|
||||||
#include <pmt/pmt.h>
|
#include <pmt/pmt.h>
|
||||||
#include <pmt/stringkeys.h>
|
#include <pmt/stringkeys.h>
|
||||||
#include <pmt/docs.h>
|
#include <pmt/help_msgs.h>
|
||||||
|
|
||||||
extern char* bin_name;
|
extern char* bin_name;
|
||||||
extern char* curr_lang;
|
extern char* curr_lang;
|
||||||
@@ -54,7 +54,7 @@ langctrl(const char* _Nonnull lang_)
|
|||||||
|
|
||||||
int loadlang(void)
|
int loadlang(void)
|
||||||
{
|
{
|
||||||
static char lang_fpr[10] = "en";
|
static char lang_fpr[3] = "en";
|
||||||
langconf = NULL;
|
langconf = NULL;
|
||||||
|
|
||||||
if (get_stat(TERMUX_PMT_MANDOC, "file") == 0)
|
if (get_stat(TERMUX_PMT_MANDOC, "file") == 0)
|
||||||
|
|||||||
@@ -86,30 +86,22 @@ list(const char* operation, const char* target_dir)
|
|||||||
/* list existing partitions */
|
/* list existing partitions */
|
||||||
int listpart(void)
|
int listpart(void)
|
||||||
{
|
{
|
||||||
|
static char acc_cxt[350];
|
||||||
|
|
||||||
if (pmt_use_cust_cxt)
|
if (pmt_use_cust_cxt)
|
||||||
|
sprintf(acc_cxt, "%s", cust_cxt);
|
||||||
|
else
|
||||||
|
sprintf(acc_cxt, "%s", CUR_DEV_CNTX);
|
||||||
|
|
||||||
|
if (list("access", acc_cxt) != 0)
|
||||||
{
|
{
|
||||||
if (list("access", cust_cxt) != 0)
|
if (!pmt_force_mode)
|
||||||
{
|
LOGE("%s: `%s': %s\n", current->not_open, acc_cxt, strerror(errno));
|
||||||
if (!pmt_force_mode)
|
|
||||||
LOGE("%s: `%s': %s\n", current->not_open, cust_cxt, strerror(errno));
|
|
||||||
else
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
list("print", cust_cxt);
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
list("print", acc_cxt);
|
||||||
if (list("access", CUR_DEV_CNTX) != 0)
|
|
||||||
{
|
|
||||||
if (!pmt_force_mode)
|
|
||||||
LOGE("%s: `%s': %s\n", current->not_open, CUR_DEV_CNTX, strerror(errno));
|
|
||||||
else
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
list("print", CUR_DEV_CNTX);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pmt_logical)
|
if (pmt_logical)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -29,7 +29,9 @@ extern "C" {
|
|||||||
#include <pmt/pmt.h>
|
#include <pmt/pmt.h>
|
||||||
#include <pmt/stringkeys.h>
|
#include <pmt/stringkeys.h>
|
||||||
#include <pmt/deprecates.h>
|
#include <pmt/deprecates.h>
|
||||||
#include <pmt/docs.h>
|
#include <pmt/help_msgs.h>
|
||||||
|
|
||||||
|
#define opt_symbol "-"
|
||||||
|
|
||||||
/* add value to variables that are added globally and are not worth */
|
/* add value to variables that are added globally and are not worth */
|
||||||
char* out = NULL;
|
char* out = NULL;
|
||||||
@@ -51,7 +53,6 @@ bool pmt_force_mode = false;
|
|||||||
bool pmt_inst_on_termux = false;
|
bool pmt_inst_on_termux = false;
|
||||||
|
|
||||||
/* variable for use in control of '-' expression */
|
/* variable for use in control of '-' expression */
|
||||||
static const char* opt_symbol = "-";
|
|
||||||
static char common_symbol_rule[350];
|
static char common_symbol_rule[350];
|
||||||
|
|
||||||
#if !defined(__clang__)
|
#if !defined(__clang__)
|
||||||
|
|||||||
92
jni/tools.c
92
jni/tools.c
@@ -29,6 +29,8 @@ extern "C" {
|
|||||||
#include <pmt/pmt.h>
|
#include <pmt/pmt.h>
|
||||||
#include <pmt/stringkeys.h>
|
#include <pmt/stringkeys.h>
|
||||||
|
|
||||||
|
#define count (1024 * 1024 * 1024)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* it is meant to calculate the size of the quickly given file.
|
* it is meant to calculate the size of the quickly given file.
|
||||||
* its purpose is for rapid processing
|
* its purpose is for rapid processing
|
||||||
@@ -79,38 +81,35 @@ int pmt(unsigned short progress_code)
|
|||||||
{
|
{
|
||||||
/* required variables */
|
/* required variables */
|
||||||
static int srcf, targetf;
|
static int srcf, targetf;
|
||||||
static char backupper_path[512];
|
static char acc_part_path[512];
|
||||||
static char ppath[100];
|
|
||||||
static char formatter_cmd[200];
|
static char formatter_cmd[200];
|
||||||
static char outf[512];
|
static char outf[512];
|
||||||
static char flasher_path[512];
|
|
||||||
static char buffer[BFSIZE];
|
static char buffer[BFSIZE];
|
||||||
static ssize_t readed_data;
|
static ssize_t readed_data;
|
||||||
static unsigned long long copied_data = 0;
|
static unsigned long long copied_data = 0;
|
||||||
static unsigned long long count = 1024 * 1024 * 1024;
|
|
||||||
|
if (pmt_use_logical)
|
||||||
|
sprintf(acc_part_path, "/dev/block/mapper/%s", target_partition);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (pmt_use_cust_cxt)
|
||||||
|
sprintf(acc_part_path, "%s/%s", cust_cxt, target_partition);
|
||||||
|
else
|
||||||
|
sprintf(acc_part_path, "/dev/block/by-name/%s", target_partition);
|
||||||
|
}
|
||||||
|
|
||||||
|
search_partition(acc_part_path);
|
||||||
|
|
||||||
if (progress_code == 1)
|
if (progress_code == 1)
|
||||||
{
|
{
|
||||||
if (!pmt_use_logical)
|
if (calc_flsz(acc_part_path) != -1)
|
||||||
{
|
LOGD("%s: %.2fM\n", current->part_disk_sz, calc_flsz(acc_part_path));
|
||||||
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
|
|
||||||
sprintf(backupper_path, "/dev/block/mapper/%s", target_partition);
|
|
||||||
|
|
||||||
search_partition(backupper_path);
|
|
||||||
|
|
||||||
if (calc_flsz(backupper_path) != -1)
|
|
||||||
LOGD("%s: %.2f\n", current->part_disk_sz, calc_flsz(backupper_path));
|
|
||||||
else
|
else
|
||||||
LOGW("%s\n", current->part_disk_sz_fail);
|
LOGW("%s\n", current->part_disk_sz_fail);
|
||||||
|
|
||||||
srcf = open(backupper_path, O_RDONLY);
|
srcf = open(acc_part_path, O_RDONLY);
|
||||||
if (srcf == -1)
|
if (srcf == -1)
|
||||||
LOGE("%s: %s: %s\n", current->not_read, backupper_path, strerror(errno));
|
LOGE("%s: %s: %s\n", current->not_read, acc_part_path, strerror(errno));
|
||||||
|
|
||||||
/* determine output */
|
/* determine output */
|
||||||
if (strcmp(out, target_partition) == 0)
|
if (strcmp(out, target_partition) == 0)
|
||||||
@@ -133,7 +132,7 @@ int pmt(unsigned short progress_code)
|
|||||||
{
|
{
|
||||||
if (get_stat(outf, "file") == 0)
|
if (get_stat(outf, "file") == 0)
|
||||||
remove(outf);
|
remove(outf);
|
||||||
LOGF("%s: %s: %s\n", current->not_write, backupper_path, strerror(errno));
|
LOGF("%s: %s: %s\n", current->not_write, acc_part_path, strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
copied_data += writed_data;
|
copied_data += writed_data;
|
||||||
@@ -147,35 +146,19 @@ int pmt(unsigned short progress_code)
|
|||||||
}
|
}
|
||||||
else if (progress_code == 2)
|
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
|
|
||||||
sprintf(flasher_path, "/dev/block/mapper/%s", target_partition);
|
|
||||||
|
|
||||||
/* check partition */
|
|
||||||
search_partition(flasher_path);
|
|
||||||
|
|
||||||
if (calc_flsz(target_flash_file) != -1)
|
if (calc_flsz(target_flash_file) != -1)
|
||||||
LOGD("%s: %.2f\n", current->flash_file_sz, calc_flsz(target_flash_file));
|
LOGD("%s: %.2fM\n", current->flash_file_sz, calc_flsz(target_flash_file));
|
||||||
else
|
else
|
||||||
LOGW("%s\n", current->flash_file_sz_fail);
|
LOGW("%s\n", current->flash_file_sz_fail);
|
||||||
|
|
||||||
if (calc_flsz(flasher_path) != -1)
|
if (calc_flsz(acc_part_path) != -1)
|
||||||
LOGD("%s: %.2f\n", current->part_disk_sz, calc_flsz(flasher_path));
|
LOGD("%s: %.2fM\n", current->part_disk_sz, calc_flsz(acc_part_path));
|
||||||
else
|
else
|
||||||
LOGW("%s\n", current->part_disk_sz_fail);
|
LOGW("%s\n", current->part_disk_sz_fail);
|
||||||
|
|
||||||
if (calc_flsz(target_flash_file) != -1 && calc_flsz(flasher_path) != -1)
|
if (calc_flsz(target_flash_file) != -1 && calc_flsz(acc_part_path) != -1)
|
||||||
{
|
{
|
||||||
if (calc_flsz(target_flash_file) > calc_flsz(flasher_path))
|
if (calc_flsz(target_flash_file) > calc_flsz(acc_part_path))
|
||||||
LOGE("%s\n", current->ffile_more_part);
|
LOGE("%s\n", current->ffile_more_part);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,16 +166,16 @@ int pmt(unsigned short progress_code)
|
|||||||
if (srcf == -1)
|
if (srcf == -1)
|
||||||
LOGF("%s: %s: %s\n", current->not_read, target_flash_file, strerror(errno));
|
LOGF("%s: %s: %s\n", current->not_read, target_flash_file, strerror(errno));
|
||||||
|
|
||||||
targetf = open(target_partition, O_WRONLY | O_CREAT | O_TRUNC, 0660);
|
targetf = open(acc_part_path, O_WRONLY | O_CREAT | O_TRUNC, 0660);
|
||||||
if (targetf == -1)
|
if (targetf == -1)
|
||||||
LOGF("%s: %s: %s\n", current->not_read, target_partition, strerror(errno));
|
LOGF("%s: %s: %s\n", current->not_read, acc_part_path, strerror(errno));
|
||||||
|
|
||||||
/* start writing */
|
/* start writing */
|
||||||
while ((readed_data = read(srcf, buffer, BFSIZE)) > 0 && copied_data < count)
|
while ((readed_data = read(srcf, buffer, BFSIZE)) > 0 && copied_data < count)
|
||||||
{
|
{
|
||||||
ssize_t writed_data = write(targetf, buffer, readed_data);
|
ssize_t writed_data = write(targetf, buffer, readed_data);
|
||||||
if (writed_data != readed_data)
|
if (writed_data != readed_data)
|
||||||
LOGF("%s: %s: %s\n", current->not_write, backupper_path, strerror(errno));
|
LOGF("%s: %s: %s\n", current->not_write, acc_part_path, strerror(errno));
|
||||||
|
|
||||||
copied_data += writed_data;
|
copied_data += writed_data;
|
||||||
}
|
}
|
||||||
@@ -204,28 +187,13 @@ int pmt(unsigned short progress_code)
|
|||||||
}
|
}
|
||||||
else if (progress_code == 3)
|
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
|
|
||||||
sprintf(ppath, "/dev/block/mapper/%s", target_partition);
|
|
||||||
|
|
||||||
/* check partition */
|
|
||||||
search_partition(ppath);
|
|
||||||
|
|
||||||
/* get target partition block size */
|
/* get target partition block size */
|
||||||
struct statvfs file_sys_inf;
|
struct statvfs file_sys_inf;
|
||||||
if (statvfs(ppath, &file_sys_inf) != 0)
|
if (statvfs(acc_part_path, &file_sys_inf) != 0)
|
||||||
LOGE("%s\n", current->cannot_get_bsz);
|
LOGE("%s\n", current->cannot_get_bsz);
|
||||||
|
|
||||||
/* generate mke2fs command */
|
/* generate mke2fs command */
|
||||||
sprintf(formatter_cmd, "mke2fs -Fq -t %s -b %lu %s", format_fs, file_sys_inf.f_bsize, ppath);
|
sprintf(formatter_cmd, "mke2fs -Fq -t %s -b %lu %s", format_fs, file_sys_inf.f_bsize, acc_part_path);
|
||||||
|
|
||||||
/* run command */
|
/* run command */
|
||||||
if (system(formatter_cmd) != 0)
|
if (system(formatter_cmd) != 0)
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define INC_MAIN_LIBS
|
#define INC_MAIN_LIBS
|
||||||
|
#define VERSIONING
|
||||||
|
|
||||||
#include <pmt/pmt.h>
|
#include <pmt/pmt.h>
|
||||||
#include <pmt/stringkeys.h>
|
#include <pmt/stringkeys.h>
|
||||||
@@ -40,7 +41,7 @@ void version(void)
|
|||||||
|
|
||||||
#if defined(__clang__) && !defined(__NDK_BUILD)
|
#if defined(__clang__) && !defined(__NDK_BUILD)
|
||||||
LOGD("%s: clang %d.%d.%d\n", current->compiler_str, __clang_major__, __clang_minor__, __clang_patchlevel__);
|
LOGD("%s: clang %d.%d.%d\n", current->compiler_str, __clang_major__, __clang_minor__, __clang_patchlevel__);
|
||||||
#elif defined(__clang__) && defined(__NDK_BUILD)
|
#elif defined(__NDK_BUILD)
|
||||||
LOGD("%s\n", __NDK_CC_VERSION__);
|
LOGD("%s\n", __NDK_CC_VERSION__);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
199
out/Makefile
199
out/Makefile
@@ -25,102 +25,127 @@ include ../Makefile.inc
|
|||||||
-include $(BUILD)/config/INS_STAT.mk
|
-include $(BUILD)/config/INS_STAT.mk
|
||||||
-include $(BUILD)/config/UNINS_STAT.mk
|
-include $(BUILD)/config/UNINS_STAT.mk
|
||||||
|
|
||||||
|
INSTALL_PROGRESS_LIST := \
|
||||||
|
really_termux \
|
||||||
|
welcome \
|
||||||
|
check_ins_stat \
|
||||||
|
deb_installer \
|
||||||
|
really_builded \
|
||||||
|
install_binary
|
||||||
|
|
||||||
|
UNINSTALL_PROGRESS_LIST := \
|
||||||
|
really_termux \
|
||||||
|
welcome \
|
||||||
|
check_unins_stat \
|
||||||
|
uninstall_$(TARGET)
|
||||||
|
|
||||||
# create an empty target
|
# create an empty target
|
||||||
all:
|
all:
|
||||||
$(hide)printf ""
|
$(P) ""
|
||||||
|
|
||||||
# installer
|
# installer
|
||||||
.PHONY: install
|
.PHONY: install
|
||||||
install:
|
install: $(INSTALL_PROGRESS_LIST)
|
||||||
# really termux?
|
|
||||||
$(hide)if [ -f $(TERMUX_BIN)/termux-open ]; then \
|
|
||||||
printf " ------------ $(TARGET) installer ------------ \n"; \
|
|
||||||
if [ -f $(TERMUX_BIN)/$(TARGET) ]; then \
|
|
||||||
printf " - $(TARGET) already installed\n"; \
|
|
||||||
exit; \
|
|
||||||
fi; \
|
|
||||||
if [ ! "$(INSTALL_SUCCESS)" = "true" ] && [ ! "$(INSTALL_SUCCESS)" = "" ]; then \
|
|
||||||
printf " - $(YELLOW)$(BOLD)Warning:$(BOLD_RESET)$(RESET) a previously-stayed failed installation process found\n"; \
|
|
||||||
fi; \
|
|
||||||
if [ -f $(DEB_DIR)/*.deb ]; then \
|
|
||||||
printf " - The created deb pack was found. It's setup...\n"; \
|
|
||||||
cd $(DEB_DIR) || exit 1; \
|
|
||||||
apt install ./*.deb || exit 1; \
|
|
||||||
if [ ! "$?" = "0" ]; then \
|
|
||||||
cd $(CUR_DIR); \
|
|
||||||
printf " - Success.\n\n"; \
|
|
||||||
echo "INSTALL_SUCCESS := true" > $(BUILD)/config/INS_STAT.mk; \
|
|
||||||
echo "UNINSTALLED_SUCCESS := " > $(BUILD)/config/UNINS_STAT.mk; \
|
|
||||||
cd ..; \
|
|
||||||
exit 0; \
|
|
||||||
else \
|
|
||||||
cd $(CUR_DIR); \
|
|
||||||
printf " - $(RED)$(BOLD)Error:$(BOLD_RESET)$(RESET) installing failed!\n"; \
|
|
||||||
echo "INSTALL_SUCCESS := false" > $(BUILD)/config/INS_STAT.mk; \
|
|
||||||
cd ..; \
|
|
||||||
exit 1; \
|
|
||||||
fi; \
|
|
||||||
fi; \
|
|
||||||
if [ ! -f $(BINARY_DIR)/$(TARGET) ]; then \
|
|
||||||
printf " - $(RED)$(BOLD)Error:$(BOLD_RESET)$(RESET) Package not builded! Please build package and try again \n"; \
|
|
||||||
echo "INSTALL_SUCCESS := false" > $(BUILD)/config/INS_STAT.mk; \
|
|
||||||
exit 1; \
|
|
||||||
fi; \
|
|
||||||
printf " - Installing binary...\n"; \
|
|
||||||
if [ "`cp $(BINARY_DIR)/$(TARGET) /data/data/com.termux/files/usr/bin/$(TARGET)`" = "" ]; then \
|
|
||||||
printf " - Setting up permissions...\n"; \
|
|
||||||
else \
|
|
||||||
echo "INSTALL_SUCCESS := false" > $(BUILD)/config/INS_STAT.mk; \
|
|
||||||
exit 1; \
|
|
||||||
fi; \
|
|
||||||
if [ "`chmod 777 $(TERMUX_BIN)/$(TARGET)`" = "" ]; then \
|
|
||||||
printf " - Saving current status...\n"; \
|
|
||||||
echo "INSTALL_SUCCESS := true" > $(BUILD)/config/INS_STAT.mk; \
|
|
||||||
else \
|
|
||||||
echo "INSTALL_SUCCESS := false" > $(BUILD)/config/INS_STAT.mk; \
|
|
||||||
exit 1; \
|
|
||||||
fi; \
|
|
||||||
printf " - Success.\n\n"; \
|
|
||||||
echo "INSTALL_SUCCESS := true" > $(BUILD)/config/INS_STAT.mk; \
|
|
||||||
echo "UNINSTALLED_SUCCESS := " > $(BUILD)/config/UNINS_STAT.mk; \
|
|
||||||
else \
|
|
||||||
printf " - $(RED)$(BOLD)Error:$(BOLD_RESET)$(RESET) This function is only available on Termux.\n"; \
|
|
||||||
exit 1; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
# uninstaller
|
# uninstaller
|
||||||
.PHONY: uninstall
|
.PHONY: uninstall
|
||||||
uninstall:
|
uninstall: $(UNINSTALL_PROGRESS_LIST)
|
||||||
# really termux?
|
|
||||||
$(hide)if [ -f $(TERMUX_BIN)/termux-open ]; then \
|
install_binary:
|
||||||
printf " ----------- $(TARGET) uninstaller ----------- \n"; \
|
$(E) " - Installing binary..."
|
||||||
if [ ! -f $(TERMUX_BIN)/$(TARGET) ]; then \
|
if cp $(BINARY_DIR)/$(TARGET) /data/data/com.termux/files/usr/bin/$(TARGET); then \
|
||||||
printf " - $(TARGET) already uninstalled\n"; \
|
$(E_NS) " - Setting up permissions..."; \
|
||||||
exit; \
|
|
||||||
fi; \
|
|
||||||
if [ ! "$(UNINSTALL_SUCCESS)" = "true" ] && [ ! "$(UNINSTALL_SUCCESS)" = "" ]; then \
|
|
||||||
printf " - $(YELLOW)$(BOLD)Warning:$(BOLD_RESET)$(RESET) a previously-stayed failed uninstallation process found\n"; \
|
|
||||||
fi; \
|
|
||||||
if [ -f $(TERMUX_USR)/share/man/man8/$(TARGET).8.gz ]; then \
|
|
||||||
printf " - It was found to be established by $(TARGET)'s deb pack. It's removed with apt...\n"; \
|
|
||||||
apt remove -y $(TARGET) || exit 1; \
|
|
||||||
printf " - Success.\n\n"; \
|
|
||||||
echo "UNINSTALLED_SUCCESS := true" > $(BUILD)/config/UNINS_STAT.mk; \
|
|
||||||
echo "INSTALL_SUCCESS := " > $(BUILD)/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)/$(TARGET)`" = "" ]; then \
|
|
||||||
printf " - Success.\n\n"; \
|
|
||||||
echo "UNINSTALLED_SUCCESS := true" > $(BUILD)/config/UNINS_STAT.mk; \
|
|
||||||
echo "INSTALL_SUCCESS := " > $(BUILD)/config/INS_STAT.mk; \
|
|
||||||
else \
|
|
||||||
echo "UNINSTALLED_SUCCESS := false" > $(BUILD)/config/UNINS_STAT.mk; \
|
|
||||||
exit 1; \
|
|
||||||
fi; \
|
|
||||||
fi; \
|
|
||||||
else \
|
else \
|
||||||
printf "$(RED)$(BOLD)Error:$(BOLD_RESET)$(RESET) This function is only available on Termux.\n"; \
|
$(E_NS) "INSTALL_SUCCESS := false" > $(BUILD)/config/INS_STAT.mk; \
|
||||||
|
exit 1; \
|
||||||
|
fi; \
|
||||||
|
if chmod 777 $(TERMUX_BIN)/$(TARGET); then \
|
||||||
|
$(E_NS) " - Saving current status..."; \
|
||||||
|
$(E_NS) "INSTALL_SUCCESS := true" > $(BUILD)/config/INS_STAT.mk; \
|
||||||
|
else \
|
||||||
|
$(E_NS) "INSTALL_SUCCESS := false" > $(BUILD)/config/INS_STAT.mk; \
|
||||||
|
exit 1; \
|
||||||
|
fi; \
|
||||||
|
$(P) " - Success.\n\n"; \
|
||||||
|
$(E_NS) "INSTALL_SUCCESS := true" > $(BUILD)/config/INS_STAT.mk; \
|
||||||
|
$(E_NS) "UNINSTALLED_SUCCESS := " > $(BUILD)/config/UNINS_STAT.mk; \
|
||||||
|
|
||||||
|
uninstall_$(TARGET):
|
||||||
|
if [ -f $(TERMUX_USR)/share/man/man8/$(TARGET).8.gz ]; then \
|
||||||
|
$(E_NS) " - It was found to be established by $(TARGET)'s deb pack. It's removed with apt..."; \
|
||||||
|
apt remove -y $(TARGET) || exit 1; \
|
||||||
|
$(P) " - Success.\n\n"; \
|
||||||
|
$(E_NS) "UNINSTALLED_SUCCESS := true" > $(BUILD)/config/UNINS_STAT.mk; \
|
||||||
|
$(E_NS) "INSTALL_SUCCESS := " > $(BUILD)/config/INS_STAT.mk; \
|
||||||
|
else \
|
||||||
|
$(E_NS) " - It was found that pmt was manually established (with this makefile or copying). Manually removed..."; \
|
||||||
|
if rm $(TERMUX_BIN)/$(TARGET); then \
|
||||||
|
$(P) " - Success.\n\n"; \
|
||||||
|
$(E_NS) "UNINSTALLED_SUCCESS := true" > $(BUILD)/config/UNINS_STAT.mk; \
|
||||||
|
$(E_NS) "INSTALL_SUCCESS := " > $(BUILD)/config/INS_STAT.mk; \
|
||||||
|
else \
|
||||||
|
$(E_NS) "UNINSTALLED_SUCCESS := false" > $(BUILD)/config/UNINS_STAT.mk; \
|
||||||
|
exit 1; \
|
||||||
|
fi; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
deb_installer:
|
||||||
|
if [ -f $(DEB_DIR)/*.deb ]; then \
|
||||||
|
$(E_NS) " - The created deb pack was found. It's setup..."; \
|
||||||
|
cd $(DEB_DIR) || exit 1; \
|
||||||
|
apt install ./*.deb || exit 1; \
|
||||||
|
if [ ! "$?" = "0" ]; then \
|
||||||
|
cd $(CUR_DIR); \
|
||||||
|
$(P) " - Success.\n\n"; \
|
||||||
|
$(E_NS) "INSTALL_SUCCESS := true" > $(BUILD)/config/INS_STAT.mk; \
|
||||||
|
$(E_NS) "UNINSTALLED_SUCCESS := " > $(BUILD)/config/UNINS_STAT.mk; \
|
||||||
|
cd ..; \
|
||||||
|
exit 0; \
|
||||||
|
else \
|
||||||
|
cd $(CUR_DIR); \
|
||||||
|
$(P) " - $(RED)$(BOLD)Error:$(BOLD_RESET)$(RESET) installing failed!\n"; \
|
||||||
|
$(E_NS) "INSTALL_SUCCESS := false" > $(BUILD)/config/INS_STAT.mk; \
|
||||||
|
cd ..; \
|
||||||
|
exit 1; \
|
||||||
|
fi; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
check_ins_stat:
|
||||||
|
@ if [ ! "$(INSTALL_SUCCESS)" = "true" ] && [ ! "$(INSTALL_SUCCESS)" = "" ]; then \
|
||||||
|
$(P) " - $(YELLOW)$(BOLD)Warning:$(BOLD_RESET)$(RESET) a previously-stayed failed installation process found\n"; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
check_unins_stat:
|
||||||
|
@ if [ ! "$(UNINSTALL_SUCCESS)" = "true" ] && [ ! "$(UNINSTALL_SUCCESS)" = "" ]; then \
|
||||||
|
$(P) " - $(YELLOW)$(BOLD)Warning:$(BOLD_RESET)$(RESET) a previously-stayed failed uninstallation process found\n"; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
welcome:
|
||||||
|
$(E) " ----------- $(TARGET) $(PROG)er ----------- "
|
||||||
|
@ if [ "$(PROG)" = "uninstall" ]; then \
|
||||||
|
if [ ! -f $(TERMUX_BIN)/$(TARGET) ]; then \
|
||||||
|
$(E_NS) " - $(TARGET) already $(PROG)ed"; \
|
||||||
|
exit 1; \
|
||||||
|
fi; \
|
||||||
|
fi
|
||||||
|
@ if [ "$(PROG)" = "install" ]; then \
|
||||||
|
if [ -f $(TERMUX_BIN)/$(TARGET) ]; then \
|
||||||
|
$(E_NS) " - $(TARGET) already $(PROG)ed"; \
|
||||||
|
exit 1; \
|
||||||
|
fi; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
really_termux:
|
||||||
|
@ if [ ! -f $(TERMUX_BIN)/termux-open ]; then \
|
||||||
|
$(P) "$(RED)$(BOLD)Error:$(BOLD_RESET)$(RESET) This function is only available on Termux.\n"; \
|
||||||
exit 1; \
|
exit 1; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# end
|
really_builded:
|
||||||
|
if [ ! -f $(BINARY_DIR)/$(TARGET) ]; then \
|
||||||
|
$(P) " - $(RED)$(BOLD)Error:$(BOLD_RESET)$(RESET) Package not builded! Please build package and try again \n"; \
|
||||||
|
$(E_NS) "INSTALL_SUCCESS := false" > $(BUILD)/config/INS_STAT.mk; \
|
||||||
|
exit 1; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
# end
|
||||||
|
|||||||
Reference in New Issue
Block a user