15 Commits
2.5.0 ... 2.7.0

46 changed files with 883 additions and 818 deletions

View File

@@ -8,6 +8,7 @@ jobs:
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
- name: Cleanup
@@ -25,7 +26,7 @@ jobs:
&& sudo apt install gh -y
- name: Update and setup packages
id: setup-packages
id: general-packages-progress
run: |
sudo apt update \
&& sudo apt upgrade -y \
@@ -83,18 +84,18 @@ jobs:
. ${{ env.PMT_SRCDIR }}/build/workflow/relnotes > /home/pmt/release_body.txt
cd ${{ env.PMT_SRCDIR }}
zip -rq pmt-objs-local.zip obj/local/arm64-v8a obj/local/armeabi-v7a
xz libs/arm64-v8a/pmt
mv libs/arm64-v8a/pmt.xz ${PWD}/pmt-arm64-v8a.xz
xz libs/armeabi-v7a/pmt
mv libs/armeabi-v7a/pmt.xz ${PWD}/pmt-armeabi-v7a.xz
make CC="${CC_64}" AR="${AR}"
make deb FOR_THIS=64
mv out/debpackage/*.deb .
make clean
make CC="${CC_32}" AR="${AR}"
make deb FOR_THIS=32
mv out/debpackage/*.deb .
make clean
for arch in arm64-v8a armeabi-v7a; do
xz libs/${arch}/pmt
mv libs/${arch}/pmt.xz ${PWD}/pmt-${arch}-$(date +%Y%m%d).xz
done
for CC_COMP in ${CC_64} ${CC_32}; do
make clean
make CC="${CC_COMP}" AR="${AR}" PMT_EXTRA_CFLAGS="-D__NDK_BUILD"
[[ "${CC_COMP}" == *"aarch64"* ]] && make deb FOR_THIS=64
[[ "${CC_COMP}" == *"armv7a"* ]] && make deb FOR_THIS=32
mv out/debpackage/*.deb .
make clean
done
working-directory: ${{ env.NDK_DIR }}
- name: Upload to release

View File

@@ -17,17 +17,17 @@ jobs:
COMM_MSG=$(git log -1 --pretty=%B)
if [ "${GITHUB_EVENT_NAME}" == "push" ]; then
if [[ "${COMM_MSG}" == *"initial"* ]]; then
echo "build_and_release=true" >> $GITHUB_ENV
echo "run_builder=true" >> $GITHUB_ENV
else
echo "build_and_release=false" >> $GITHUB_ENV
echo "run_builder=false" >> $GITHUB_ENV
fi
elif [ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]; then
echo "build_and_release=true" >> $GITHUB_ENV
echo "run_builder=true" >> $GITHUB_ENV
fi
- name: Run release workflow
id: run-rel-workflow
if: env.build_and_release == 'true'
if: env.run_builder == 'true'
uses: benc-uk/workflow-dispatch@v1
with:
workflow: 'build.yml'

40
ADD-LANGUAGES.md Normal file → Executable file
View 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
missing operand
~ $
C / C++
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)
struct pmt_langdb_general en = {
// other translations
.missing_operand = "missing operand";
.try_h = "Try";
.for_more = "for more information";
.missing_operand = "missing operand",
.try_h = "Try",
.for_more = "for more information",
// other translations
}
@@ -66,14 +65,14 @@ In short, there are variables for texts. And I made these dynamic by using [stru
##### Translating main program texts (relevant part)
- 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/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.
// translations
}
// example
// Example
struct pmt_langdb_general en = {
// translation
}
@@ -87,15 +86,16 @@ In short, there are variables for texts. And I made these dynamic by using [stru
// other translations
}
// example
// Example
struct pmt_langdb_general en = {
.lang_by_s = "YZBruh & r0manas";
.language = "English";
.lang_prefix = "en";
.lang_by_s = "YZBruh & r0manas",
.language = "English",
.lang_prefix = "en",
// 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 let me explain the documentation...
@@ -103,16 +103,18 @@ In short, there are variables for texts. And I made these dynamic by using [stru
##### Document texts translation (relevant part)
- 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/StringKeys.h for the structure).
```
struct pmt_langdb_docs <LANGUAGE_PREFIX>_docs = {
// translations
}
// example
// Example
struct pmt_langdb_docs en_docs = {
// 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
@@ -124,8 +126,18 @@ In short, there are variables for texts. And I made these dynamic by using [stru
struct pmt_langdb_langs lang[] = {
{"en"},
{"tr"},
// language prefix. {"<LANGUAGE_PREFIX>"},
{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)
```

View File

@@ -1,19 +1,10 @@
### Version 2.5.0 Changelog
### Version 2.7.0 Changelog
- Fixed serious problems with version 2.4.0.
- Stabilization was held.
- The size calculation problem that was during flashtime was corrected.
- Change in the syntax in flash and formatting processes was made.
- Problems in file system selection are corrected in formatting process.
- Deprecation system created for deprecated/changed options.
- 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.
- Operation support with pipe (|) operator has been added.
- Build system has been made dynamic.
- Minor changes were made to the layout of bash scripts.
- Header names have been changed.
```
END OF 2.5.0 UPDATE CHANGELOG
```
END OF 2.7.0 UPDATE CHANGELOG
```

View File

@@ -15,25 +15,23 @@
# limitations under the License.
# speficy
VERSION := 2.5.0
VERSION_CODE := 250
VERSION := 2.7.0
VERSION_CODE := 270
TARGET := pmt
# device arch info
ARCH := $(shell uname -m)
# current directory
CUR_DIR = $(shell pwd)
OUT_DIRNAME ?= out
SOURCE_DIRNAME ?= jni
# others needed important variables
ifeq ($(THIS_IS),src)
BUILD := ../build
SOURCE_DIR := $(CUR_DIR)
SOURCE_DIR := $(CURDIR)
OUT_DIR := ../$(OUT_DIRNAME)
DEBUTILS_DIR := $(BUILD)/deb
INCLUDE_DIR := ../include
else ifeq ($(THIS_IS),debutils)
BUILD := ..
SOURCE_DIR := ../../$(SOURCE_DIRNAME)
@@ -42,12 +40,12 @@ else ifeq ($(THIS_IS),debutils)
else ifeq ($(THIS_IS),out)
BUILD := ../build
SOURCE_DIR := ../$(SOURCE_DIRNAME)
OUT_DIR := $(CUR_DIR)
OUT_DIR := $(CURDIR)
DEBUTILS_DIR := $(BÜILD)/deb
else ifeq ($(THIS_IS),main)
BUILD := $(CUR_DIR)/build
SOURCE_DIR := $(CUR_DIR)/$(SOURCE_DIRNAME)
OUT_DIR := $(CUR_DIR)/$(OUT_DIRNAME)
BUILD := $(CURDIR)/build
SOURCE_DIR := $(CURDIR)/$(SOURCE_DIRNAME)
OUT_DIR := $(CURDIR)/$(OUT_DIRNAME)
DEBUTILS_DIR := $(BUILD)/deb
endif
@@ -84,44 +82,11 @@ endif
SRCS := $(wildcard $(SOURCE_DIR)/*.c)
OBJS = $(SRCS:.c=.o)
# the presence of all source files that are on this list will be checked
SRCS_REQ := \
$(SOURCE_DIR)/debugging.c \
$(SOURCE_DIR)/docs.c \
$(SOURCE_DIR)/get_stat.c \
$(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
STATIC_LIBS := \
$(TARGET)_root \
$(TARGET)_debug \
$(TARGET)_listpart \
$(TARGET)_partitiontool
# other directories in the out directory
IN_OUT_DIR := \
@@ -131,7 +96,7 @@ IN_OUT_DIR := \
# list of file/directory to be checked when the deb pack is created
DEB_CHECKS := \
$(DEBUTILS_DIR) \
$(DEBUTILS_DIR)/ \
$(DEBUTILS_DIR)/DEBIAN \
$(DEBUTILS_DIR)/DEBIAN/control_32 \
$(DEBUTILS_DIR)/DEBIAN/control_64 \
@@ -148,9 +113,11 @@ DEB_CHECKS := \
$(DEBUTILS_DIR)/data/data/com.termux/files/usr/share/man/man8
# for running make with silent mode
hide := @
MAKE_HIDE := $(hide)$(MAKE)
MAKE_HIDE := @ $(MAKE)
SILENT := -s
E := @ echo
E_NS := echo
P := printf
# color definations
RESET := \033[0m

View File

@@ -32,12 +32,12 @@ Report bugs to <t.me/ShawkTeam | Topics | pmt>
#### Some notes
- pmt supports multiple languages. [See languages.](https://github.com/ShawkTeam/pmt/blob/2.5.0/LANGUAGES.md)
- [Add language.](https://github.com/ShawkTeam/pmt/blob/2.5.0/ADD-LANGUAGES.md)
- pmt supports multiple languages. [See languages.](https://github.com/ShawkTeam/pmt/blob/2.7.0/LANGUAGES.md)
- [Add language.](https://github.com/ShawkTeam/pmt/blob/2.7.0/ADD-LANGUAGES.md)
- 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/ShawkTeam/pmt/blob/2.5.0/CHANGELOG.md)
- [Click to see special version changes.](https://github.com/ShawkTeam/pmt/blob/2.7.0/CHANGELOG.md)
- We are always open to your suggestions and support (developing)!
### How is it built?
@@ -47,7 +47,7 @@ Make or Android NDK is required to build.
- [Download Android NDK](https://developer.android.com/ndk/downloads) and extract the NDK package.
- Clone this repository. And get access to it.
```
git clone https://github.com/ShawkTeam/pmt -b 2.5.0
git clone https://github.com/ShawkTeam/pmt -b 2.7.0
cd pmt
```
- Set the NDK working directory variable.

View File

@@ -1,6 +0,0 @@
NDK_PROG=false
FORCE_GEN=false
THIS_IS=main
UPDATE_MAKEFILES=false
SOURCE_DIRNAME=src
OUT_DIRNAME=out

View File

@@ -14,7 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
[ ! "${THIS_IS}" = "main" ] && abort "The caller is not the main makefile. Something's wrong."
[ ! "${THIS_IS}" = "main" ] \
&& abort "The caller is not the main makefile. Something's wrong."
try_with="Try with force mode (FORCE_GEN=true)."
@@ -24,7 +25,7 @@ else
mfiles=("${OUT_DIR}/Makefile" "${SOURCE_DIR}/Makefile")
fi
for mfile in ${mfiles[0]} ${mfiles[1]}; do
for mfile in ${mfiles[@]}; do
[ -f "${mfile}" ] && \
if [ "${FORCE_GEN}" = "true" ]; then

View File

@@ -17,25 +17,27 @@
. build/bash/vars
. build/bash/functions
[ ! "${THIS_IS}" = "main" ] && abort "The caller is not the main makefile. Something's wrong."
[ ! "${THIS_IS}" = "main" ] \
&& abort "The caller is not the main makefile. Something's wrong."
if [ "${NDK_PROG}" = "true" ]; then
[ "${UPDATE_MAKEFILES}" = "true" ] || print " - Removing Android.mk..."
rm -f ${SOURCE_DIR}/Android.mk
[ "${UPDATE_MAKEFILES}" = "true" ] \
|| print " - Removing Android.mk..." \
&& print " - Removing Application.mk..."
[ "${UPDATE_MAKEFILES}" = "true" ] || print " - Removing Application.mk..."
rm -f ${SOURCE_DIR}/Application.mk
rm -f ${SOURCE_DIR}/Application.mk \
${SOURCE_DIR}/Android.mk
else
[ "${UPDATE_MAKEFILES}" = "true" ] || print " - Info: Main makefile won't be deleted."
[ "${UPDATE_MAKEFILES}" = "true" ] \
|| print " - Info: Main makefile won't be deleted." \
&& print " - Removing output directory makefile..." \
&& print " - Removing source directory makefile..."
[ "${UPDATE_MAKEFILES}" = "true" ] || print " - Removing output directory makefile..."
rm -f ${OUT_DIR}/Makefile
[ "${UPDATE_MAKEFILES}" = "true" ] || print " - Removing source directory makefile"
rm -f ${SOURCE_DIR}/Makefile
rm -f ${SOURCE_DIR}/Makefile \
${OUT_DIR}/Makefile
fi

View File

@@ -16,22 +16,22 @@
function abort()
{
[ -n "$1" ] && echo -e " - ${RED}${BOLD}Error:${BOLD_RESET}${RESET} $1"
[ -n "${1}" ] \
&& echo -e " - ${RED}${BOLD}Error:${BOLD_RESET}${RESET} ${1}"
exit 1
}
function read_file()
{
cat "$1" >> "$2" || abort "failed to read/write $1/$2"
cat "${1}" >> "${2}" \
|| abort "failed to read/write ${1}/${2}"
}
function gen()
{
[ "${FORCE_GEN}" = "true" -a "${UPDATE_MAKEFILES}" = "true" ] && rm -f "$1"
touch "$1" || abort "failed to generate: $1"
[ "${FORCE_GEN}" = "true" -a "${UPDATE_MAKEFILES}" = "true" ] \
&& rm -f "${1}"
touch "${1}" || abort "failed to generate: ${1}"
}
function print()
{
echo -e "$1"
}
function print() { echo -e "${1}"; }

View File

@@ -14,16 +14,21 @@
# See the License for the specific language governing permissions and
# limitations under the License.
[ -z ${NDK_ROOT_DIR} ] && \
echo "Please set NDK_ROOT_DIR variable!" && \
exit 1
[ -z ${NDK_ROOT_DIR} ] \
&& echo "Please set NDK_ROOT_DIR variable!" \
&& exit 1
[ -z ${NDK_PROJECT_PATH} ] && \
echo "Please set NDK_PROJECT_PATH variable!" && \
exit 1
[ -z ${NDK_PROJECT_PATH} ] \
&& echo "Please set NDK_PROJECT_PATH variable!" \
&& exit 1
CC_IS="${NDK_ROOT_DIR}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang"
CC_VERS=$(${CC_IS} --version | head -n 1)
HEADER="${NDK_PROJECT_PATH}/include/pmt/generated/clang-version.h
mkdir -p ${NDK_PROJECT_PATH}/include/pmt/generated
echo -e "#define __NDK_CC_VERSION__ \"${CC_VERS}\"" > ${NDK_PROJECT_PATH}/include/pmt/generated/clang-version.h
mkdir -p "${NDK_PROJECT_PATH}/include/pmt/generated"
touch "${HEADER}"
echo "/*" >> "${HEADER}"
cat "${NDK_PROJECT_PATH}/NOTICE" >> "${HEADER}"
echo -e "\n *\n*/" >> "${HEADER}"
echo -e "\n\n#define __NDK_CC_VERSION__ \"${CC_VERS}\"" >> "${HEADER}"

View File

@@ -17,8 +17,10 @@
. build/bash/vars
. build/bash/functions
[ ! "${UPDATE_MAKEFILES}" = "true" ] && . build/bash/check-makefiles
[ ! "${THIS_IS}" = "main" ] && abort "The caller is not the main makefile. Something's wrong."
[ ! "${UPDATE_MAKEFILES}" = "true" ] \
&& . build/bash/check-makefiles
[ ! "${THIS_IS}" = "main" ] \
&& abort "The caller is not the main makefile. Something's wrong."
if [ "${UPDATE_MAKEFILES}" = "true" ]; then
GENR="Re-generating"

View File

@@ -47,6 +47,6 @@ endif
# write current env configuration to oldenv.mk
all:
@echo "CC := $(CC)" > oldenv.mk; \
echo "AR := $(AR)" >> oldenv.mk; \
echo "CFLAGS := $(CFLAGS)" >> oldenv.mk
@ echo "CC := $(CC)" > oldenv.mk
@ echo "AR := $(AR)" >> oldenv.mk
@ echo "CFLAGS := $(CFLAGS)" >> oldenv.mk

View File

@@ -1,6 +1,6 @@
Source: pmt
Package: pmt
Version: 2.5.0
Version: 2.6.0
Architecture: arm
Description: pmt is for reading, writing and formatting partitions of android devices
Section: misc

View File

@@ -1,6 +1,6 @@
Source: pmt
Package: pmt
Version: 2.5.0
Version: 2.6.0
Architecture: aarch64
Description: pmt is for reading, writing and formatting partitions of android devices
Section: misc

View File

@@ -32,76 +32,68 @@ else ifeq ($(FOR_THIS),32)
endif
ifneq ($(wildcard /dev/block/by-name),)
SUDO := su
SUDO := su -c
else ifeq ($(wildcard /system/build.prop),)
SUDO := sudo
else
SUDO :=
endif
# controls the presence of file/directory. usage: $(call check_local,<FILE_OR_DIRECTORY_PATH>,<PACKAGE_STAT: 1, NULL>)
define check_local
# the first argument is taken and controlled by the file/directory with -e option
if [ ! -e $1 ]; then \
if [ $2 = 1 ]; then \
printf " - Package not builded! Please build package and try again.\n"; \
else \
printf " ==> Not found: $1\n"; \
fi; \
if [ -d "$(TEMP_DIR)" ]; then \
rm -rf $(TEMP_DIR); \
fi; \
exit 1; \
fi;
endef
PROGRESS_LIST := \
startup \
$(DEB_CHECKS) \
check_binary \
prepare \
make_debian_pack
# make deb package
all:
$(hide)printf " --------- Making deb package ---------\n"
# remove template directory
$(call erase,$(TEMP_DIR))
$(hide)printf " - Checking files and directories (only neededs)...\n"
# check some files and directories with parsing DEB_CHECKS variable
$(foreach deb_chfile, \
$(DEB_CHECKS), \
$(call check_local,$(deb_chfile)) \
)
# check build status
$(call check_local, \
$(BINARY_DIR)/pmt, \
1 \
)
# make template and output directories
$(call mdir,$(TEMP_DIR),"y")
$(call mdir,$(DEB_DIR),"y")
$(hide)printf " - Copying files...\n"
# prepare
$(hide)cp -r $(DEBUTILS_DIR)/data $(TEMP_DIR) || exit 1
$(hide)rm -f $(DEBTERMUX_USR)/share/man/man8/dummy
$(hide)rm -f $(DEBTERMUX_USR)/bin/dummy
$(call mdir,$(TEMP_DIR)/DEBIAN)
$(hide)abort() { \
if [ -d $(TEMP_DIR) ]; then \
rm -rf $(TEMP_DIR); \
fi; \
if [ -d $(DEB_DIR) ]; then \
rm -rf $(DEB_DIR); \
fi; \
all: $(PROGRESS_LIST)
startup:
$(E) " --------- Making deb package --------- "
@ rm -rf $(TEMP_DIR)
$(E) " - Checking files and directories (only neededs)..."
prepare:
$(E) " - Copying files..."
@ cp -r $(DEBUTILS_DIR)/data $(TEMP_DIR) || exit 1
@ rm -f $(DEBTERMUX_USR)/share/man/man8/dummy
@ rm -f $(DEBTERMUX_USR)/bin/dummy
@ mkdir $(TEMP_DIR)/DEBIAN
check_binary:
@ if [ ! -f "$(BINARY_DIR)/pmt" ]; then \
$(E_NS) " - pmt not builded! Please build and retry."; \
exit 1; \
fi
$(E) " - Generating template directory..."
@ mkdir $(TEMP_DIR)
$(E) " - Generating debian package directory..."
@ mkdir $(DEB_DIR)
make_debian_pack:
@ abort() { \
[ -d $(TEMP_DIR) ] \
&& rm -rf $(TEMP_DIR); \
[ -d $(DEB_DIR) ] \
&& rm -rf $(DEB_DIR); \
exit 1; \
}; \
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; \
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)/mandoc/$(TARGET).8.gz $(DEBTERMUX_USR)/share/man/man8 || abort; \
cp $(BINARY_DIR)/$(TARGET) $(DEBTERMUX_USR)/bin || abort; \
printf " - Starting dpkg-deb...\n"; \
$(E_NS) " - Starting dpkg-deb..."; \
sleep 2; \
$(SUDO) chmod -R 755 *; \
dpkg-deb -b $(TEMP_DIR) $(DEB_DIR)/$(TARGET)-$(DEB_ARCH_NAME).deb || abort; \
# cleanup template directory
rm -rf $(TEMP_DIR); \
printf " - Done!\n"
$(E_NS) " - Done!"
$(DEBUTILS_DIR)/%:
@ [ ! -e "$@" ] && $(E_NS) " - Check failed! Not found: $@" && exit 1
# end

Binary file not shown.

View File

@@ -15,76 +15,71 @@
# limitations under the License.
UPDATE_MAKEFILES = false
CLS_ADTS := rm -f $(BUILD)/bash/additional-vars
all:
$(hide)# To save configuration, the makefile in the config directory
$(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
# cleaner functions
.PHONY: clean
clean:
$(hide)printf "Cleaning directories...\n"; \
# cleanup out/binary
$(hide)if [ -d $(BINARY_DIR) ]; then \
printf "==> $(OUT_DIRNAME)/`basename $(BINARY_DIR)`\n"; \
rm -rf "$(BINARY_DIR)"; \
fi; \
# cleanup out/package
$(hide)if [ -d $(PACKAGE_DIR) ]; then \
printf "==> $(OUT_DIRNAME)/`basename $(PACKAGE_DIR)`\n"; \
rm -rf "$(PACKAGE_DIR)"; \
fi; \
# cleanup out/static_libs
$(hide)if [ -d $(STATICLIB_DIR) ]; then \
printf "==> $(OUT_DIRNAME)/`basename $(STATICLIB_DIR)`\n"; \
rm -rf "$(STATICLIB_DIR)"; \
fi; \
# 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
$(E) "Cleaning directories..."
@ if [ -d $(BINARY_DIR) ]; then \
$(E_NS) "==> $(OUT_DIRNAME)/`basename $(BINARY_DIR)`"; \
fi
@ if [ -d $(PACKAGE_DIR) ]; then \
$(E_NS) "==> $(OUT_DIRNAME)/`basename $(PACKAGE_DIR)`"; \
fi
@ if [ -d $(STATICLIB_DIR) ]; then \
$(E_NS) "==> $(OUT_DIRNAME)/`basename $(STATICLIB_DIR)`"; \
fi
@ if [ -d $(DEB_DIR) ]; then \
$(E_NS) "==> $(OUT_DIRNAME)/`basename $(DEB_DIR)`"; \
fi
@ rm -rf $(IN_OUT_DIR)
@ rm -rf $(DEB_DIR)
@ sleep 2
$(MAKE_HIDE) $(SILENT) -C $(SOURCE_DIRNAME) clean INC_OLDENV=false || exit 1
$(hide)sleep 1
$(hide)printf "Success.\n"
@ sleep 1
$(E) "Success."
# helper function
.PHONY: help
help:
$(hide)printf " ------- Partition Manager help -------\n\n"
$(hide)printf " Commands:\n"
$(hide)printf " $(MAKE) ==> Build Partition Manager.\n"
$(hide)printf " $(MAKE) deb ==> Generate debian package for termux.\n"
$(hide)printf " $(MAKE) clean ==> Clear builded binary.\n"
$(hide)printf " $(MAKE) install ==> It installs $(TARGET) into termux.\n"
$(hide)printf " $(MAKE) uninstall ==> It uninstalls $(TARGET) into termux.\n"
$(hide)printf " $(MAKE) gen-makefiles ==> Generate makefiles for build.\n"
$(hide)printf " $(MAKE) gen-ndk-makefiles ==> Generate NDK makefiles for build.\n"
$(hide)printf " $(MAKE) clean-makefiles ==> Cleanup makefiles.\n"
$(hide)printf " $(MAKE) clean-ndk-makefiles ==> Cleanup NDK makefiles.\n"
$(hide)printf " $(MAKE) update-makefiles ==> Re-generate makefiles.\n"
$(hide)printf " $(MAKE) update-ndk-makefiles ==> Re-generate NDK makefiles.\n"
$(hide)printf " $(MAKE) help ==> Display this help message.\n\n"
$(E) " ------- Partition Manager help ------- " \
&& $(E_NS)
$(E) " Commands:"
$(E) " $(MAKE) ==> Build Partition Manager."
$(E) " $(MAKE) deb ==> Generate debian package for termux."
$(E) " $(MAKE) clean ==> Clear builded binary."
$(E) " $(MAKE) install ==> It installs $(TARGET) into termux."
$(E) " $(MAKE) uninstall ==> It uninstalls $(TARGET) into termux."
$(E) " $(MAKE) gen-makefiles ==> Generate makefiles for build."
$(E) " $(MAKE) gen-ndk-makefiles ==> Generate NDK makefiles for build."
$(E) " $(MAKE) clean-makefiles ==> Cleanup makefiles."
$(E) " $(MAKE) clean-ndk-makefiles ==> Cleanup NDK makefiles."
$(E) " $(MAKE) update-makefiles ==> Re-generate makefiles."
$(E) " $(MAKE) update-ndk-makefiles ==> Re-generate NDK makefiles."
$(E) " $(MAKE) help ==> Display this help message." && $(E_NS)
# deb maker
.PHONY: deb
deb:
$(MAKE_HIDE) $(SILENT) -C $(DEBUTILS_DIR) -f deb.mk FOR_THIS=$(FOR_THIS) || exit 1
$(hide)printf ""
$(P) ""
# install pmt in to termux
.PHONY: 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
.PHONY: 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
.PHONY: gen-ndk-makefiles
@@ -92,44 +87,44 @@ gen-ndk-makefiles:
$(eval NDK_PROG = true)
$(call save-gen-vars)
$(call gen-ndk-mfiles)
$(hide)printf ""
@ $(CLS_ADTS)
.PHONY: gen-makefiles
gen-makefiles:
$(call save-gen-vars)
$(call gen-mfiles)
$(hide)printf ""
@ $(CLS_ADTS)
.PHONY: update-ndk-makefiles
update-ndk-makefiles:
$(hide)printf " ------ Updating NDK makefiles ------ \n"
$(E) " ------ Updating NDK makefiles ------ "
$(eval NDK_PROG = true)
$(eval UPDATE_MAKEFILES = true)
$(call save-gen-vars)
$(call clean-ndk-mfiles)
$(call gen-ndk-mfiles)
$(hide)printf ""
@ $(CLS_ADTS)
.PHONY: update-makefiles
update-makefiles:
$(hide)printf " ------ Updating makefiles ------ \n"
$(E) " ------ Updating makefiles ------ "
$(eval UPDATE_MAKEFILES = true)
$(call save-gen-vars)
$(call clean-ndk-mfiles)
$(call gen-mfiles)
$(hide)printf ""
@ $(CLS_ADTS)
.PHONY: clean-ndk-makefiles
clean-ndk-makefiles:
$(eval NDK_PROG = true)
$(call save-gen-vars)
$(call clean-ndk-mfiles)
$(hide)printf ""
@ $(CLS_ADTS)
.PHONY: clean-makefiles
clean-makefiles:
$(call save-gen-vars)
$(call clean-mfiles)
$(hide)printf ""
@ $(CLS_ADTS)
# end
# end

View File

@@ -15,7 +15,7 @@
# limitations under the License.
########
# 2.5.0
# 2.7.0
########
LOCAL_PATH := $(call my-dir)
@@ -35,7 +35,7 @@ PMT_CFLAGS = \
$(EXTRA_COMPILER_FLAGS)
ifneq ($(PMT_ENABLE_DEBUG),)
PMT_CFLAGS += -gdwarf-5 -fsanitize=address
PMT_CFLAGS += -gdwarf-5 -fsanitize=address -fsanitize=undefined
endif
include $(CLEAR_VARS)
@@ -49,8 +49,8 @@ include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libpmt_debugging
LOCAL_SRC_FILES := debugging.c
LOCAL_MODULE := libpmt_debug
LOCAL_SRC_FILES := debug.c
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include
LOCAL_CFLAGS := $(PMT_CFLAGS)
@@ -79,16 +79,16 @@ include $(CLEAR_VARS)
LOCAL_MODULE := pmt
LOCAL_SRC_FILES := \
pmt.c \
versioner.c \
version.c \
get_stat.c \
tools.c \
lang_tools.c \
languages.c \
docs.c
help.c
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include
LOCAL_STATIC_LIBRARIES := \
libpmt_root \
libpmt_debugging \
libpmt_debug \
libpmt_partitiontool \
libpmt_list
LOCAL_CFLAGS := $(PMT_CFLAGS)

View File

@@ -15,7 +15,7 @@
# limitations under the License.
########
# 2.5.0
# 2.7.0
########
# architecture

View File

@@ -25,102 +25,127 @@ include ../Makefile.inc
-include $(BUILD)/config/INS_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
all:
$(hide)printf ""
$(P) ""
# installer
.PHONY: install
install:
# 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
install: $(INSTALL_PROGRESS_LIST)
# uninstaller
.PHONY: uninstall
uninstall:
# really termux?
$(hide)if [ -f $(TERMUX_BIN)/termux-open ]; then \
printf " ----------- $(TARGET) uninstaller ----------- \n"; \
if [ ! -f $(TERMUX_BIN)/$(TARGET) ]; then \
printf " - $(TARGET) already uninstalled\n"; \
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; \
uninstall: $(UNINSTALL_PROGRESS_LIST)
install_binary:
$(E) " - Installing binary..."
if cp $(BINARY_DIR)/$(TARGET) /data/data/com.termux/files/usr/bin/$(TARGET); then \
$(E_NS) " - Setting up permissions..."; \
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; \
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

View File

@@ -26,121 +26,142 @@ ifeq ($(INC_OLDENV),true)
include $(BUILD)/config/oldenv.mk
endif
# make objects. Usage $(call make_obj,<SRCFILE>)
define make_obj
$(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
INCLUDE_DIR := $(realpath ../include)
PMT_INCDIR := $(INCLUDE_DIR)/pmt
# make executable file with using static libraries and objects. Usage: $(call make_executable)
define make_executable
printf " - Making executable file...\n"; \
printf " LD $(TARGET)"; \
$(CC) $(CFLAGS) -L$(SOURCE_DIR) \
$(foreach s_obj_b, \
$(shell basename -a $(STATICLIB_OBJS)), \
$(eval s_obj_t_b = $(s_obj_b:.o=)) \
$(shell echo -lpmt_$(s_obj_t_b)) \
) \
-o $(TARGET) $(OBJS_EXEC) || exit 1;
endef
# the presence of all source files that are on this list will be checked
SRCS_REQ := \
place-holder/debug.c \
place-holder/help.c \
place-holder/get_stat.c \
place-holder/lang_tools.c \
place-holder/languages.c \
place-holder/partitiontool.c \
place-holder/pmt.c \
place-holder/root.c \
place-holder/tools.c \
place-holder/version.c
# make static library. Usage $(call make_staticlib,<LIBRARY_NAME>,<OBJECT(S)>)
define make_staticlib
echo -n " AR $1"; \
$(AR) rcs "$1" "$2" || exit 1; \
echo;
endef
# objects to be used when executable file is created
OBJS_EXEC := \
$(SOURCE_DIR)/$(TARGET).o \
$(SOURCE_DIR)/help.o \
$(SOURCE_DIR)/version.o \
$(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>)
define check_cfile
# the first argument is taken and controlled by the file with -f option
printf " CHK src/`basename $1`\n"; \
if [ ! -f $1 ]; then \
printf " ==> Couldn't found required source file: src/`basename $1`\n"; \
if [ -d "$(TEMP_DIR)" ]; then \
rm -rf $(TEMP_DIR); \
fi; \
exit 1; \
fi;
endef
HEADERS_REQ := \
$(PMT_INCDIR)/pmt/ExternC.h \
$(PMT_INCDIR)/pmt/Deprecates.h \
$(PMT_INCDIR)/pmt/HelpMessages.h \
$(PMT_INCDIR)/pmt/pmt.h \
$(PMT_INCDIR)/pmt/StringKeys.h \
$(PMT_INCDIR)/pmt/VersionVars.h
# controls the presence of header file. usage: $(call check_hfile,<SOURCE_FILE>)
define check_hfile
# the first argument is taken and controlled by the file with -f option
printf " CHK include/pmt/`basename $1`\n"; \
if [ ! -f $1 ]; then \
printf " ==> Couldn't found required header file: include/pmt/`basename $1`\n"; \
if [ -d "$(TEMP_DIR)" ]; then \
rm -rf $(TEMP_DIR); \
fi; \
exit 1; \
fi;
PROGRESS_LIST := \
welcome \
wait \
$(SRCS_REQ) \
$(HEADERS_REQ) \
pr_obj \
$(OBJS) \
make_outdirs \
pr_sts \
$(STATIC_LIBS) \
make_executable \
wait \
end_progress
define check_hf
@ [ ! -f "$1" ] \
&& $(E_NS) " ==> Couldn't found required header file: include/pmt/`basename $1`" \
&& exit 1
endef
# all target for building
all:
$(hide)rm -f $(BUILD)/config/oldenv.mk
$(hide)printf " ---- Partition Manager Builder ---- \n\n"
$(hide)printf " - Version: $(VERSION)\n"
$(hide)printf " - Version code: $(VERSION_CODE)\n\n"
$(hide)printf " -------------------------------- \n\n"
$(hide)if [ -f $(SOURCE_DIR)/debugging.o ]; then \
printf " - Please clean up before you build it.\n\n"; \
printf " ----------------------------------- \n"; \
all: $(PROGRESS_LIST)
welcome:
@ rm -f $(BUILD)/config/oldenv.mk
@ echo " ---- Partition Manager Builder ---- " \
&& $(E_NS)
$(E) " - Version: $(VERSION)"
$(E) " - Version code: $(VERSION_CODE)" \
&& $(E_NS)
$(E) " -------------------------------- " \
&& $(E_NS)
@ if [ -f $(SOURCE_DIR)/debug.o ]; then \
$(E_NS) " - Please clean up before you build it." && echo; \
$(E_NS) " ----------------------------------- "; \
exit 1; \
fi
$(hide)printf " - Checking required source files...\n"
$(hide)sleep 1
$(foreach src_cf, \
$(SRCS_REQ), \
$(call check_cfile,$(src_cf)) \
)
$(foreach src_hf, \
$(HEADERS_REQ), \
$(call check_hfile,$(src_hf)) \
)
$(hide)printf " - Building objects...\n"
$(hide)sleep 2
$(foreach csrc, \
$(SRCS), \
$(call make_obj,$(csrc)) \
)
$(foreach reqdir,$(IN_OUT_DIR),$(call mdir,$(reqdir)))
$(hide)printf " - Making static libraries...\n"
$(foreach s_obj, \
$(shell basename -a $(STATICLIB_OBJS)), \
$(eval s_obj_t = $(s_obj:.o=.a)) \
$(call make_staticlib,libpmt_$(s_obj_t),$(s_obj)) \
)
$(hide)sleep 1
$(call make_executable)
$(hide)sleep 1
$(hide)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; \
$(E) " - Checking required source files..."
pr_obj:
$(E) " - Building objects..."
pr_sts:
$(E) " - Making static libraries..."
wait:
@ sleep 2
make_outdirs:
@ rm -rf $(IN_OUT_DIR)
@ mkdir $(BINARY_DIR)
@ mkdir $(PACKAGE_DIR)
@ mkdir $(STATICLIB_DIR)
place-holder/%.c:
$(E) " CHK $(SOURCE_DIRNAME)/`basename $@`"
@ if [ ! -f "$(SOURCE_DIR)/`basename $@`" ]; then \
$(E_NS) " ==> Couldn't found required source file: $(SOURCE_DIRNAME)/`basename $@`"; \
exit 1; \
fi
$(PMT_INCDIR)/%.h:
$(E) " CHK include/pmt/`basename $@`"
@ if [ ! -f "$(INCLUDE_DIR)/pmt/`basename $@`" ]; then \
$(E_NS) " ==> Couldn't found required header file: include/pmt/`basename $@`"; \
exit 1; \
fi
$(SOURCE_DIR)/%.o: $(SOURCE_DIR)/%.c
$(E) " CC $(SOURCE_DIRNAME)/`basename $@`"
@ $(CC) $(CFLAGS) -c "$<" || exit 1
$(TARGET)_%:
$(E) " AR lib$@.a"
@ $(AR) rcs "lib$@.a" "$(SOURCE_DIR)/$$(echo "$@" | cut -d'_' -f2).o"
make_executable:
$(E) " - Making executable file..."
$(E) " LD $(TARGET)"
@ $(CC) $(CFLAGS) -L$(SOURCE_DIR) $(foreach st,$(STATIC_LIBS),$(shell echo -n -l$(st) )) -o $(TARGET) $(OBJS_EXEC) || exit 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; \
}; \
mv $(TARGET) $(BINARY_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; \
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; \
sleep 1; \
mv $(PACKAGE_DIR)/$(TARGET).xz $(PACKAGE_DIR)/$(TARGET)-$(ARCH).xz || abort_build; \
printf "\n - Success"; \
sleep 1; \
printf "\n\n ----------------------------------- \n"
mv $(PACKAGE_DIR)/$(TARGET).xz $(PACKAGE_DIR)/$(TARGET)-`date +%Y%m%d`.xz || abort_build
$(E) " - Success" && $(E_NS)
@ sleep 1
$(E) " ----------------------------------- "
.PHONY: clean
clean:

View File

@@ -21,11 +21,11 @@
include $(TOOLS)/save-gen-vars.mk
define clean-ndk-mfiles
$(hide)[ "$(UPDATE_MAKEFILES)" = "true" ] || printf " ------ Cleaning NDK Makefiles ------ \n"
$(hide)cat $(BASH_DIR)/clean-makefiles | $(BIN)/bash
@ [ "$(UPDATE_MAKEFILES)" = "true" ] || printf " ------ Cleaning NDK Makefiles ------ \n"
@ cat $(BASH_DIR)/clean-makefiles | $(BIN)/bash
endef
define clean-mfiles
$(hide)[ "$(UPDATE_MAKEFILES)" = "true" ] || printf " ------ Cleaning Makefiles ------ \n"
$(hide)cat $(BASH_DIR)/clean-makefiles | $(BIN)/bash
endef
@ [ "$(UPDATE_MAKEFILES)" = "true" ] || printf " ------ Cleaning Makefiles ------ \n"
@ cat $(BASH_DIR)/clean-makefiles | $(BIN)/bash
endef

View File

@@ -21,11 +21,11 @@
include $(TOOLS)/save-gen-vars.mk
define gen-ndk-mfiles
$(hide)[ "$(UPDATE_MAKEFILES)" = "true" ] || printf " ------ Generating NDK Makefiles ------ \n"
$(hide)cat $(BASH_DIR)/gen-makefiles | $(BIN)/bash
@ [ "$(UPDATE_MAKEFILES)" = "true" ] || printf " ------ Generating NDK Makefiles ------ \n"
@ cat $(BASH_DIR)/gen-makefiles | $(BIN)/bash
endef
define gen-mfiles
$(hide)[ "$(UPDATE_MAKEFILES)" = "true" ] || printf " ------ Generating Makefiles ------ \n"
$(hide)cat $(BASH_DIR)/gen-makefiles | $(BIN)/bash
@ [ "$(UPDATE_MAKEFILES)" = "true" ] || printf " ------ Generating Makefiles ------ \n"
@ cat $(BASH_DIR)/gen-makefiles | $(BIN)/bash
endef

View File

@@ -15,12 +15,12 @@
# limitations under the License.
define save-gen-vars
$(hide)rm -f $(BASH_DIR)/additional-vars
@ rm -f $(BASH_DIR)/additional-vars
$(call touch,$(BASH_DIR)/additional-vars)
$(hide)echo "NDK_PROG=$(NDK_PROG)" >> $(BASH_DIR)/additional-vars
$(hide)echo "FORCE_GEN=$(FORCE_GEN)" >> $(BASH_DIR)/additional-vars
$(hide)echo "THIS_IS=$(THIS_IS)" >> $(BASH_DIR)/additional-vars
$(hide)echo "UPDATE_MAKEFILES=$(UPDATE_MAKEFILES)" >> $(BASH_DIR)/additional-vars
$(hide)echo "SOURCE_DIRNAME=$(SOURCE_DIRNAME)" >> $(BASH_DIR)/additional-vars
$(hide)echo "OUT_DIRNAME=$(OUT_DIRNAME)" >> $(BASH_DIR)/additional-vars
@ echo "NDK_PROG=$(NDK_PROG)" >> $(BASH_DIR)/additional-vars
@ echo "FORCE_GEN=$(FORCE_GEN)" >> $(BASH_DIR)/additional-vars
@ echo "THIS_IS=$(THIS_IS)" >> $(BASH_DIR)/additional-vars
@ echo "UPDATE_MAKEFILES=$(UPDATE_MAKEFILES)" >> $(BASH_DIR)/additional-vars
@ echo "SOURCE_DIRNAME=$(SOURCE_DIRNAME)" >> $(BASH_DIR)/additional-vars
@ echo "OUT_DIRNAME=$(OUT_DIRNAME)" >> $(BASH_DIR)/additional-vars
endef

View File

@@ -16,8 +16,8 @@
# generate any text based empty file. Usage: $(call touch,<PATH>)
define touch
$(hide)[ ! "$(FORCE_GEN)" = "true" ] || rm -f "$1"
$(hide)touch "$1" || exit 1
@ [ ! "$(FORCE_GEN)" = "true" ] || rm -f "$1"
@ touch "$1" || exit 1
endef
# copy files. Usage: $(call copy,<SOURCE>,<COPY_PATH>)

View File

@@ -1,5 +1,5 @@
export PMT_VERSION="2.5.0"
export PMT_VERSION_CODE=250
export PMT_VERSION="2.7.0"
export PMT_VERSION_CODE=270
export NDK_LINK="https://dl.google.com/android/repository/android-ndk-r27-linux.zip"
export NDK_VERSION="r27"
export NDK_IS="android-ndk"

View File

@@ -19,9 +19,9 @@
#ifndef __PMT_DEPRECATED_H
#define __PMT_DEPRECATED_H
#include <sys/cdefs.h>
#include <pmt/ExternC.h>
__BEGIN_DECLS
PMT_EXTERN_C_BEGIN
#define deprecated_opt 1
#define changed_opt 2
@@ -41,6 +41,8 @@ __BEGIN_DECLS
#define v230 "2.3.0"
#define v240 "2.4.0"
#define v250 "2.5.0"
#define v260 "2.6.0"
#define v270 "2.7.0"
#define vUNK NULL
struct pmt_deprecates {
@@ -92,7 +94,7 @@ __deprecated_opt_handle(int opt, const char* opt_long, const char* depr_msg)
#define DEPR_HANDLE(x, y, z) __deprecated_opt_handle(x, y, z)
__END_DECLS
PMT_EXTERN_C_END
#endif

30
include/pmt/ExternC.h Executable file
View File

@@ -0,0 +1,30 @@
/* 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.
*/
#ifndef __PMT_EXTERN_C_H_
#define __PMT_EXTERN_C_H_
#ifdef __cplusplus
#define PMT_EXTERN_C_BEGIN extern "C" {
#define PMT_EXTERN_C_END }
#else
#define PMT_EXTERN_C_BEGIN
#define PMT_EXTERN_C_END
#endif
#endif

View File

@@ -16,14 +16,16 @@
* limitations under the License.
*/
#ifndef __PMT_DOCS_H
#define __PMT_DOCS_H
#ifndef __PMT_HELP_MSGS_H
#define __PMT_HELP_MSGS_H
__BEGIN_DECLS
#include <pmt/ExternC.h>
PMT_EXTERN_C_BEGIN
void help(void);
__END_DECLS
PMT_EXTERN_C_END
#endif

View File

@@ -16,23 +16,28 @@
* limitations under the License.
*/
#include <sys/cdefs.h>
#if !defined(__clang__) && !defined(__NDK_BUILD)
#error "Your compiler is NOT clang. Please build with LLVM clang."
#endif
__BEGIN_DECLS
#include <pmt/ExternC.h>
PMT_EXTERN_C_BEGIN
#ifndef __PMT_H_
#define __PMT_H_
#define PMT_PACKAGE_NAME "Partition Manager"
#ifdef INC_MAIN_LIBS
#include <stdio.h>
#include <stdbool.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#if !defined(HELP) || !defined(VERSIONING)
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#endif
#endif
#ifdef INC_GETOPT
@@ -111,6 +116,6 @@ void debug(LogLevel status, const char* _Nullable fmt, ...);
#endif
__END_DECLS
PMT_EXTERN_C_END
/* end of code */

View File

@@ -19,7 +19,9 @@
#ifndef __PMT_STRINGKEYS_
#define __PMT_STRINGKEYS_
__BEGIN_DECLS
#include <pmt/ExternC.h>
PMT_EXTERN_C_BEGIN
/* The struct is a very good option for setting the languages of texts etc. */
struct pmt_langdb_general {
@@ -112,7 +114,7 @@ struct pmt_langdb_langs {
const char* _Nullable lang_pr;
};
__END_DECLS
PMT_EXTERN_C_END
#endif /* __PMT_STRINGKEYS_ */

View File

@@ -19,7 +19,9 @@
#ifndef __PMT_VERSIONING_H
#define __PMT_VERSIONING_H
__BEGIN_DECLS
#include <pmt/ExternC.h>
PMT_EXTERN_C_BEGIN
#ifdef __NDK_BUILD
#include <android/ndk-version.h>
@@ -28,10 +30,10 @@ __BEGIN_DECLS
/* versioning */
#define PMT_MAJOR 2
#define PMT_MINOR 5
#define PMT_MINOR 7
#define PMT_PATCHLEVEL 0
__END_DECLS
PMT_EXTERN_C_END
#endif

View File

@@ -26,121 +26,142 @@ ifeq ($(INC_OLDENV),true)
include $(BUILD)/config/oldenv.mk
endif
# make objects. Usage $(call make_obj,<SRCFILE>)
define make_obj
$(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
INCLUDE_DIR := $(realpath ../include)
PMT_INCDIR := $(INCLUDE_DIR)/pmt
# make executable file with using static libraries and objects. Usage: $(call make_executable)
define make_executable
printf " - Making executable file...\n"; \
printf " LD $(TARGET)"; \
$(CC) $(CFLAGS) -L$(SOURCE_DIR) \
$(foreach s_obj_b, \
$(shell basename -a $(STATICLIB_OBJS)), \
$(eval s_obj_t_b = $(s_obj_b:.o=)) \
$(shell echo -lpmt_$(s_obj_t_b)) \
) \
-o $(TARGET) $(OBJS_EXEC) || exit 1;
endef
# the presence of all source files that are on this list will be checked
SRCS_REQ := \
place-holder/debug.c \
place-holder/help.c \
place-holder/get_stat.c \
place-holder/lang_tools.c \
place-holder/languages.c \
place-holder/partitiontool.c \
place-holder/pmt.c \
place-holder/root.c \
place-holder/tools.c \
place-holder/version.c
# make static library. Usage $(call make_staticlib,<LIBRARY_NAME>,<OBJECT(S)>)
define make_staticlib
echo -n " AR $1"; \
$(AR) rcs "$1" "$2" || exit 1; \
echo;
endef
# objects to be used when executable file is created
OBJS_EXEC := \
$(SOURCE_DIR)/$(TARGET).o \
$(SOURCE_DIR)/help.o \
$(SOURCE_DIR)/version.o \
$(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>)
define check_cfile
# the first argument is taken and controlled by the file with -f option
printf " CHK $(SOURCE_DIRNAME)/`basename $1`\n"; \
if [ ! -f $1 ]; then \
printf " ==> Couldn't found required source file: $(SOURCE_DIRNAME)/`basename $1`\n"; \
if [ -d "$(TEMP_DIR)" ]; then \
rm -rf $(TEMP_DIR); \
fi; \
exit 1; \
fi;
endef
HEADERS_REQ := \
$(PMT_INCDIR)/pmt/ExternC.h \
$(PMT_INCDIR)/pmt/Deprecates.h \
$(PMT_INCDIR)/pmt/HelpMessages.h \
$(PMT_INCDIR)/pmt/PartitionManager.h \
$(PMT_INCDIR)/pmt/StringKeys.h \
$(PMT_INCDIR)/pmt/VersionVars.h
# controls the presence of header file. usage: $(call check_hfile,<SOURCE_FILE>)
define check_hfile
# the first argument is taken and controlled by the file with -f option
printf " CHK include/pmt/`basename $1`\n"; \
if [ ! -f $1 ]; then \
printf " ==> Couldn't found required header file: include/pmt/`basename $1`\n"; \
if [ -d "$(TEMP_DIR)" ]; then \
rm -rf $(TEMP_DIR); \
fi; \
exit 1; \
fi;
PROGRESS_LIST := \
welcome \
wait \
$(SRCS_REQ) \
$(HEADERS_REQ) \
pr_obj \
$(OBJS) \
make_outdirs \
pr_sts \
$(STATIC_LIBS) \
make_executable \
wait \
end_progress
define check_hf
@ [ ! -f "$1" ] \
&& $(E_NS) " ==> Couldn't found required header file: include/pmt/`basename $1`" \
&& exit 1
endef
# all target for building
all:
$(hide)rm -f $(BUILD)/config/oldenv.mk
$(hide)printf " ---- Partition Manager Builder ---- \n\n"
$(hide)printf " - Version: $(VERSION)\n"
$(hide)printf " - Version code: $(VERSION_CODE)\n\n"
$(hide)printf " -------------------------------- \n\n"
$(hide)if [ -f $(SOURCE_DIR)/debugging.o ]; then \
printf " - Please clean up before you build it.\n\n"; \
printf " ----------------------------------- \n"; \
all: $(PROGRESS_LIST)
welcome:
@ rm -f $(BUILD)/config/oldenv.mk
@ echo " ---- Partition Manager Builder ---- " \
&& $(E_NS)
$(E) " - Version: $(VERSION)"
$(E) " - Version code: $(VERSION_CODE)" \
&& $(E_NS)
$(E) " -------------------------------- " \
&& $(E_NS)
@ if [ -f $(SOURCE_DIR)/debug.o ]; then \
$(E_NS) " - Please clean up before you build it." && echo; \
$(E_NS) " ----------------------------------- "; \
exit 1; \
fi
$(hide)printf " - Checking required source files...\n"
$(hide)sleep 1
$(foreach src_cf, \
$(SRCS_REQ), \
$(call check_cfile,$(src_cf)) \
)
$(foreach src_hf, \
$(HEADERS_REQ), \
$(call check_hfile,$(src_hf)) \
)
$(hide)printf " - Building objects...\n"
$(hide)sleep 2
$(foreach csrc, \
$(SRCS), \
$(call make_obj,$(csrc)) \
)
$(foreach reqdir,$(IN_OUT_DIR),$(call mdir,$(reqdir)))
$(hide)printf " - Making static libraries...\n"
$(foreach s_obj, \
$(shell basename -a $(STATICLIB_OBJS)), \
$(eval s_obj_t = $(s_obj:.o=.a)) \
$(call make_staticlib,libpmt_$(s_obj_t),$(s_obj)) \
)
$(hide)sleep 1
$(call make_executable)
$(hide)sleep 1
$(hide)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; \
$(E) " - Checking required source files..."
pr_obj:
$(E) " - Building objects..."
pr_sts:
$(E) " - Making static libraries..."
wait:
@ sleep 2
make_outdirs:
@ rm -rf $(IN_OUT_DIR)
@ mkdir $(BINARY_DIR)
@ mkdir $(PACKAGE_DIR)
@ mkdir $(STATICLIB_DIR)
place-holder/%.c:
$(E) " CHK $(SOURCE_DIRNAME)/`basename $@`"
@ if [ ! -f "$(SOURCE_DIR)/`basename $@`" ]; then \
$(E_NS) " ==> Couldn't found required source file: $(SOURCE_DIRNAME)/`basename $@`"; \
exit 1; \
fi
$(PMT_INCDIR)/%.h:
$(E) " CHK include/pmt/`basename $@`"
@ if [ ! -f "$(INCLUDE_DIR)/pmt/`basename $@`" ]; then \
$(E_NS) " ==> Couldn't found required header file: include/pmt/`basename $@`"; \
exit 1; \
fi
$(SOURCE_DIR)/%.o: $(SOURCE_DIR)/%.c
$(E) " CC $(SOURCE_DIRNAME)/`basename $@`"
@ $(CC) $(CFLAGS) -c "$<" || exit 1
$(TARGET)_%:
$(E) " AR lib$@.a"
@ $(AR) rcs "lib$@.a" "$(SOURCE_DIR)/$$(echo "$@" | cut -d'_' -f2).o"
make_executable:
$(E) " - Making executable file..."
$(E) " LD $(TARGET)"
@ $(CC) $(CFLAGS) -L$(SOURCE_DIR) $(foreach st,$(STATIC_LIBS),$(shell echo -n -l$(st) )) -o $(TARGET) $(OBJS_EXEC) || exit 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; \
}; \
mv $(TARGET) $(BINARY_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; \
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; \
sleep 1; \
mv $(PACKAGE_DIR)/$(TARGET).xz $(PACKAGE_DIR)/$(TARGET)-`date +%Y%m%d`.xz || abort_build; \
printf "\n - Success"; \
sleep 1; \
printf "\n\n ----------------------------------- \n"
mv $(PACKAGE_DIR)/$(TARGET).xz $(PACKAGE_DIR)/$(TARGET)-`date +%Y%m%d`.xz || abort_build
$(E) " - Success" && $(E_NS)
@ sleep 1
$(E) " ----------------------------------- "
.PHONY: clean
clean:

View File

@@ -22,13 +22,11 @@ extern "C" {
#define INC_MAIN_LIBS
#include <pmt/pmt.h>
#include <pmt/stringkeys.h>
#include <pmt/PartitionManager.h>
#include <pmt/StringKeys.h>
void debug(LogLevel status, const char* _Nullable fmt, ...)
{
if (fmt == NULL) exit(1);
va_list args;
va_start(args, fmt);

View File

@@ -23,8 +23,8 @@ extern "C" {
#define INC_MAIN_LIBS
#define INC_STAT
#include <pmt/pmt.h>
#include <pmt/stringkeys.h>
#include <pmt/PartitionManager.h>
#include <pmt/StringKeys.h>
/**
* The target file is controlled by the stat function.

View File

@@ -21,10 +21,11 @@ extern "C" {
#endif
#define INC_MAIN_LIBS
#define HELP
#include <pmt/pmt.h>
#include <pmt/stringkeys.h>
#include <pmt/docs.h>
#include <pmt/PartitionManager.h>
#include <pmt/StringKeys.h>
#include <pmt/HelpMessages.h>
extern char* bin_name;
extern char* curr_lang;

View File

@@ -24,8 +24,8 @@ extern "C" {
#define INC_DEBUGERS
#define INC_STAT
#include <pmt/pmt.h>
#include <pmt/stringkeys.h>
#include <pmt/PartitionManager.h>
#include <pmt/StringKeys.h>
/* pmt's man doc file path on termux */
#define TERMUX_PMT_MANDOC "/data/data/com.termux/files/usr/share/man/man8/pmt.8.gz"
@@ -54,7 +54,7 @@ langctrl(const char* _Nonnull lang_)
int loadlang(void)
{
static char lang_fpr[10] = "en";
static char lang_fpr[3] = "en";
langconf = NULL;
if (get_stat(TERMUX_PMT_MANDOC, "file") == 0)

View File

@@ -22,8 +22,8 @@ extern "C" {
#define INC_MAIN_LIBS
#include <pmt/pmt.h>
#include <pmt/stringkeys.h>
#include <pmt/PartitionManager.h>
#include <pmt/StringKeys.h>
struct pmt_langdb_general en = {
.lang_by_s = "YZBruh & r0manas",

View File

@@ -24,8 +24,8 @@ extern "C" {
#define INC_DEBUGERS
#define INC_DIRENT
#include <pmt/pmt.h>
#include <pmt/stringkeys.h>
#include <pmt/PartitionManager.h>
#include <pmt/StringKeys.h>
/* current /dev context */
#define CUR_DEV_CNTX "/dev/block/by-name"
@@ -86,30 +86,22 @@ list(const char* operation, const char* target_dir)
/* list existing partitions */
int listpart(void)
{
static char acc_cxt[350];
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, cust_cxt, strerror(errno));
else
return 1;
}
if (!pmt_force_mode)
LOGE("%s: `%s': %s\n", current->not_open, acc_cxt, strerror(errno));
else
list("print", cust_cxt);
return 1;
}
else
{
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);
}
list("print", acc_cxt);
if (pmt_logical)
{

View File

@@ -22,7 +22,7 @@ extern "C" {
#define INC_MAIN_LIBS
#include <pmt/pmt.h>
#include <pmt/PartitionManager.h>
static int
accf(const char* _Nonnull target) { return access(target, F_OK); }

View File

@@ -26,10 +26,12 @@ extern "C" {
#define INC_STAT
#define INC_GETOPT
#include <pmt/pmt.h>
#include <pmt/stringkeys.h>
#include <pmt/deprecates.h>
#include <pmt/docs.h>
#include <pmt/PartitionManager.h>
#include <pmt/StringKeys.h>
#include <pmt/Deprecates.h>
#include <pmt/HelpMessages.h>
#define opt_symbol "-"
/* add value to variables that are added globally and are not worth */
char* out = NULL;
@@ -51,24 +53,8 @@ bool pmt_force_mode = false;
bool pmt_inst_on_termux = false;
/* variable for use in control of '-' expression */
static const char* opt_symbol = "-";
static char common_symbol_rule[350];
#if !defined(__clang__)
static char*
strdup(const char* s)
{
size_t len = strlen(s) + 1;
char* copy = malloc(len);
if (copy) {
memcpy(copy, s, len);
}
return copy;
}
#endif
/**
* He controls whether the '-' sign at
* the beginning of the given word
@@ -93,10 +79,32 @@ ctrl_arg(const char* _Nullable argv_holder)
}
/* classic main function (C binary here xd) */
int main(int argc, char* argv[])
int main(int argc, char** argv)
{
bin_name = argv[0];
int argc_n = argc;
char buf[256];
char** args = malloc((argc + 1) * sizeof(char *));
/* copy original arguments */
for (int i = 0; i < argc; i++)
args[i] = argv[i];
if (!isatty(fileno(stdin)))
{
while (fgets(buf, sizeof(buf), stdin) != NULL)
{
buf[strcspn(buf, "\n")] = 0;
args = realloc(args, (argc_n + 1) * sizeof(char *));
args[argc_n] = strdup(buf);
argc_n++;
}
}
argc = argc_n;
/* load language */
if (loadlang() != 0)
{
@@ -116,7 +124,7 @@ int main(int argc, char* argv[])
/* check argument total */
if (argc < 2)
LOGE("%s.\n%s `%s --help' %s.\n", current->missing_operand, current->try_h, argv[0], current->for_more);
LOGE("%s.\n%s `%s --help' %s.\n", current->missing_operand, current->try_h, args[0], current->for_more);
/* a structure for long arguments */
struct option option_table[] = {
@@ -147,27 +155,27 @@ int main(int argc, char* argv[])
static int search_result = 3;
static int opt;
if (strcmp(argv[1], "backup") == 0)
if (strcmp(args[1], "backup") == 0)
{
if (argc <= 2)
LOGE("%s 0.\n", current->expected_backup_arg);
if (ctrl_arg(argv[2]))
target_partition = argv[2];
if (ctrl_arg(args[2]))
target_partition = args[2];
else
LOGE("%s.\n", current->not_spec_opt);
out = target_partition;
if (argc > 3 && ctrl_arg(argv[3]))
out = argv[3];
if (argc > 3 && ctrl_arg(args[3]))
out = args[3];
check_optsym(target_partition);
check_optsym(out);
pmt_backup = true;
}
else if (strcmp(argv[1], "flash") == 0)
else if (strcmp(args[1], "flash") == 0)
{
if (argc <= 2)
LOGE("%s 0.\n", current->expected_flash_arg);
@@ -175,13 +183,13 @@ int main(int argc, char* argv[])
if (argc <= 3)
LOGE("%s 1.\n", current->expected_flash_arg);
if (ctrl_arg(argv[2]))
target_partition = argv[2];
if (ctrl_arg(args[2]))
target_partition = args[2];
else
LOGE("%s.\n", current->not_spec_opt);
if (ctrl_arg(argv[3]))
target_flash_file = argv[3];
if (ctrl_arg(args[3]))
target_flash_file = args[3];
else
LOGE("%s.\n", current->not_spec_opt);
@@ -190,7 +198,7 @@ int main(int argc, char* argv[])
pmt_flash = true;
}
else if (strcmp(argv[1], "format") == 0)
else if (strcmp(args[1], "format") == 0)
{
if (argc <= 2)
@@ -199,13 +207,13 @@ int main(int argc, char* argv[])
if (argc <= 3)
LOGE("%s 1.\n", current->expected_format_arg);
if (ctrl_arg(argv[2]))
target_partition = argv[2];
if (ctrl_arg(args[2]))
target_partition = args[2];
else
LOGE("%s.\n", current->not_spec_opt);
if (ctrl_arg(argv[3]))
format_fs = argv[3];
if (ctrl_arg(args[3]))
format_fs = args[3];
else
LOGE("%s.\n", current->not_spec_opt);
@@ -216,7 +224,7 @@ int main(int argc, char* argv[])
}
/* control for each argument */
while ((opt = getopt_long(argc, argv, "bFrDlc:psfS:vL", option_table, NULL)) != -1)
while ((opt = getopt_long(argc, args, "bFrDlc:psfS:vL", option_table, NULL)) != -1)
{
/* process arguments */
switch (opt)
@@ -285,11 +293,11 @@ int main(int argc, char* argv[])
break;
/* for invalid options */
case '?':
LOGD("%s `%s --help' %s\n", current->try_h, argv[0], current->for_more);
LOGD("%s `%s --help' %s\n", current->try_h, args[0], current->for_more);
return 1;
break;
default:
LOGD("%s: %s [backup] [flash] [format] [-l | --logical] [-c | --context] [-p | --list] [-s | --silent] [-v | --version] [--help]\n", current->usage_head, argv[0]);
LOGD("%s: %s [backup] [flash] [format] [-l | --logical] [-c | --context] [-p | --list] [-s | --silent] [-v | --version] [--help]\n", current->usage_head, args[0]);
return 1;
}
}
@@ -317,15 +325,15 @@ int main(int argc, char* argv[])
if (pmt_setlang)
{
LOGD("%s: %s\n", argv[0], current->switching_lang);
LOGD("%s: %s\n", args[0], current->switching_lang);
setlang(langpr, 0);
sleep(2);
LOGD("%s: %s.\n", argv[0], current->please_rerun);
LOGD("%s: %s.\n", args[0], current->please_rerun);
return 0;
}
if (!pmt_backup && !pmt_flash && !pmt_format)
LOGE("%s.\n%s `%s --help` %s\n", current->no_target, current->try_h, argv[0], current->for_more);
LOGE("%s.\n%s `%s --help` %s\n", current->no_target, current->try_h, args[0], current->for_more);
if (pmt_format)
{
@@ -372,7 +380,7 @@ int main(int argc, char* argv[])
if (target_partition == NULL)
{
if (!pmt_force_mode)
LOGE("%s\n%s `%s --help' %s\n", current->req_part_name, current->try_h, argv[0], current->for_more);
LOGE("%s\n%s `%s --help' %s\n", current->req_part_name, current->try_h, args[0], current->for_more);
}
else
{

View File

@@ -23,8 +23,8 @@ extern "C" {
#define INC_MAIN_LIBS
#define INC_DEBUGERS
#include <pmt/pmt.h>
#include <pmt/stringkeys.h>
#include <pmt/PartitionManager.h>
#include <pmt/StringKeys.h>
/* root checker function */
void check_root(void)

View File

@@ -26,8 +26,10 @@ extern "C" {
#define INC_DEBUGERS
#define INC_TOOLS_REQS
#include <pmt/pmt.h>
#include <pmt/stringkeys.h>
#include <pmt/PartitionManager.h>
#include <pmt/StringKeys.h>
#define count (1024 * 1024 * 1024)
/**
* it is meant to calculate the size of the quickly given file.
@@ -79,38 +81,35 @@ int pmt(unsigned short progress_code)
{
/* required variables */
static int srcf, targetf;
static char backupper_path[512];
static char ppath[100];
static char acc_part_path[512];
static char formatter_cmd[200];
static char outf[512];
static char flasher_path[512];
static char buffer[BFSIZE];
static ssize_t readed_data;
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 (!pmt_use_logical)
{
if (pmt_use_cust_cxt)
sprintf(backupper_path, "%s/%s", cust_cxt, target_partition);
else
sprintf(backupper_path, "/dev/block/by-name/%s", target_partition);
}
else
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));
if (calc_flsz(acc_part_path) != -1)
LOGD("%s: %.2fM\n", current->part_disk_sz, calc_flsz(acc_part_path));
else
LOGW("%s\n", current->part_disk_sz_fail);
srcf = open(backupper_path, O_RDONLY);
srcf = open(acc_part_path, O_RDONLY);
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 */
if (strcmp(out, target_partition) == 0)
@@ -133,7 +132,7 @@ int pmt(unsigned short progress_code)
{
if (get_stat(outf, "file") == 0)
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;
@@ -147,35 +146,19 @@ int pmt(unsigned short progress_code)
}
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)
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
LOGW("%s\n", current->flash_file_sz_fail);
if (calc_flsz(flasher_path) != -1)
LOGD("%s: %.2f\n", current->part_disk_sz, calc_flsz(flasher_path));
if (calc_flsz(acc_part_path) != -1)
LOGD("%s: %.2fM\n", current->part_disk_sz, calc_flsz(acc_part_path));
else
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);
}
@@ -183,16 +166,16 @@ int pmt(unsigned short progress_code)
if (srcf == -1)
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)
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 */
while ((readed_data = read(srcf, buffer, BFSIZE)) > 0 && copied_data < count)
{
ssize_t writed_data = write(targetf, buffer, 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;
}
@@ -204,28 +187,13 @@ int pmt(unsigned short progress_code)
}
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 */
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);
/* 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 */
if (system(formatter_cmd) != 0)

View File

@@ -21,10 +21,11 @@ extern "C" {
#endif
#define INC_MAIN_LIBS
#define VERSIONING
#include <pmt/pmt.h>
#include <pmt/stringkeys.h>
#include <pmt/versioning.h>
#include <pmt/PartitionManager.h>
#include <pmt/StringKeys.h>
#include <pmt/VersionVars.h>
void version(void)
{
@@ -40,7 +41,7 @@ void version(void)
#if defined(__clang__) && !defined(__NDK_BUILD)
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__);
#endif
}

View File

@@ -25,102 +25,127 @@ include ../Makefile.inc
-include $(BUILD)/config/INS_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
all:
$(hide)printf ""
$(P) ""
# installer
.PHONY: install
install:
# 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
install: $(INSTALL_PROGRESS_LIST)
# uninstaller
.PHONY: uninstall
uninstall:
# really termux?
$(hide)if [ -f $(TERMUX_BIN)/termux-open ]; then \
printf " ----------- $(TARGET) uninstaller ----------- \n"; \
if [ ! -f $(TERMUX_BIN)/$(TARGET) ]; then \
printf " - $(TARGET) already uninstalled\n"; \
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; \
uninstall: $(UNINSTALL_PROGRESS_LIST)
install_binary:
$(E) " - Installing binary..."
if cp $(BINARY_DIR)/$(TARGET) /data/data/com.termux/files/usr/bin/$(TARGET); then \
$(E_NS) " - Setting up permissions..."; \
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; \
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