diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e95a450..1940193 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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}" + [[ "${CC_COMP}" == *"arm64-v8a"* ]] && make deb FOR_THIS=64 + [[ "${CC_COMP}" == *"armeabi-v7a"* ]] && make deb FOR_THIS=32 + mv out/debpackage/*.deb . + make clean + done working-directory: ${{ env.NDK_DIR }} - name: Upload to release diff --git a/.github/workflows/check_commits.yml b/.github/workflows/check_commits.yml index f812ab1..ed96e92 100644 --- a/.github/workflows/check_commits.yml +++ b/.github/workflows/check_commits.yml @@ -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' diff --git a/ADD-LANGUAGES.md b/ADD-LANGUAGES.md old mode 100644 new mode 100755 index 4923e20..791ecdd --- a/ADD-LANGUAGES.md +++ b/ADD-LANGUAGES.md @@ -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 } @@ -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. - 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 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... @@ -109,10 +109,12 @@ In short, there are variables for texts. And I made these dynamic by using [stru // 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. {""}, {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) ``` diff --git a/CHANGELOG.md b/CHANGELOG.md index da371b8..976354b 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,19 +1,12 @@ -### Version 2.5.0 Changelog +### Version 2.6.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. + - 'tools.c' cleaned. + - Compilation system (make) was subject to a serious update. + - Undefined sanitizer added to debug flags. + - Dynamic makefiles with separate targets. + - Unit was given when the size information was given (M). + - use of other compilers from clang was blocked. ``` -END OF 2.5.0 UPDATE CHANGELOG -``` \ No newline at end of file +END OF 2.6.0 UPDATE CHANGELOG +``` diff --git a/Makefile.inc b/Makefile.inc index 3ff9c58..0040bdd 100755 --- a/Makefile.inc +++ b/Makefile.inc @@ -15,25 +15,23 @@ # limitations under the License. # speficy -VERSION := 2.5.0 -VERSION_CODE := 250 +VERSION := 2.6.0 +VERSION_CODE := 260 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 := \ + lib$(TARGET)_root.a \ + lib$(TARGET)_debugging.a \ + lib$(TARGET)_listpart.a \ + lib$(TARGET)_partitiontool.a # 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 diff --git a/build/config/Makefile b/build/config/Makefile index 2ab5cf4..9d3aedd 100755 --- a/build/config/Makefile +++ b/build/config/Makefile @@ -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 diff --git a/build/deb/DEBIAN/control_32 b/build/deb/DEBIAN/control_32 index 5f80b95..dea191b 100755 --- a/build/deb/DEBIAN/control_32 +++ b/build/deb/DEBIAN/control_32 @@ -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 diff --git a/build/deb/DEBIAN/control_64 b/build/deb/DEBIAN/control_64 index e17c516..f94f662 100755 --- a/build/deb/DEBIAN/control_64 +++ b/build/deb/DEBIAN/control_64 @@ -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 diff --git a/build/deb/deb.mk b/build/deb/deb.mk index c7e1b5f..de1add2 100755 --- a/build/deb/deb.mk +++ b/build/deb/deb.mk @@ -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,,) -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 diff --git a/build/main.mk b/build/main.mk index 4ca8200..000414e 100755 --- a/build/main.mk +++ b/build/main.mk @@ -17,74 +17,67 @@ UPDATE_MAKEFILES = false 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 +85,42 @@ gen-ndk-makefiles: $(eval NDK_PROG = true) $(call save-gen-vars) $(call gen-ndk-mfiles) - $(hide)printf "" + $(P) "" .PHONY: gen-makefiles gen-makefiles: $(call save-gen-vars) $(call gen-mfiles) - $(hide)printf "" + $(P) "" .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 "" .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 "" .PHONY: clean-ndk-makefiles clean-ndk-makefiles: $(eval NDK_PROG = true) $(call save-gen-vars) $(call clean-ndk-mfiles) - $(hide)printf "" + $(P) "" .PHONY: clean-makefiles clean-makefiles: $(call save-gen-vars) $(call clean-mfiles) - $(hide)printf "" + $(P) "" # end \ No newline at end of file diff --git a/build/others/makefile.androidmk b/build/others/makefile.androidmk index 28fba58..e5c4094 100755 --- a/build/others/makefile.androidmk +++ b/build/others/makefile.androidmk @@ -15,7 +15,7 @@ # limitations under the License. ######## -# 2.5.0 +# 2.6.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) @@ -79,12 +79,12 @@ include $(CLEAR_VARS) LOCAL_MODULE := pmt LOCAL_SRC_FILES := \ pmt.c \ - versioner.c \ + versioning.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 \ diff --git a/build/others/makefile.applicationmk b/build/others/makefile.applicationmk index 2d8ffa7..4dd48d0 100755 --- a/build/others/makefile.applicationmk +++ b/build/others/makefile.applicationmk @@ -15,7 +15,7 @@ # limitations under the License. ######## -# 2.5.0 +# 2.6.0 ######## # architecture diff --git a/build/others/makefile.outdir b/build/others/makefile.outdir index 204bc08..3a0706b 100755 --- a/build/others/makefile.outdir +++ b/build/others/makefile.outdir @@ -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 \ No newline at end of file +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 diff --git a/build/others/makefile.sourcedir b/build/others/makefile.sourcedir index 5ff51f3..9b3f8bc 100755 --- a/build/others/makefile.sourcedir +++ b/build/others/makefile.sourcedir @@ -26,121 +26,149 @@ ifeq ($(INC_OLDENV),true) include $(BUILD)/config/oldenv.mk endif -# make objects. Usage $(call make_obj,) -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/debugging.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/versioning.c -# make static library. Usage $(call make_staticlib,,) -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)/versioning.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,) -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/deprecates.h \ + $(PMT_INCDIR)/pmt/help_msgs.h \ + $(PMT_INCDIR)/pmt/pmt.h \ + $(PMT_INCDIR)/pmt/stringkeys.h \ + $(PMT_INCDIR)/pmt/versioning.h -# controls the presence of header file. usage: $(call check_hfile,) -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 \ + $(SRCS_REQ) \ + $(HEADERS_REQ) \ + pr_obj \ + $(OBJS) \ + make_outdirs \ + $(STATIC_LIBS) \ + make_executable \ + 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)/debugging.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..." + @ sleep 1 + +pr_obj: + $(E) " - Building objects..." + +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 + $(eval GEN_OBJS_MSG = ) + +lib$(TARGET)_root.a: + $(E) " - Making static libraries..." + $(E) " AR $@" + @ $(AR) rcs "$@" "$(SOURCE_DIR)/root.o" || exit 1 + +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; \ }; \ 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: diff --git a/build/workflow/build.config b/build/workflow/build.config index 0b405b8..3461a90 100755 --- a/build/workflow/build.config +++ b/build/workflow/build.config @@ -1,5 +1,5 @@ -export PMT_VERSION="2.5.0" -export PMT_VERSION_CODE=250 +export PMT_VERSION="2.6.0" +export PMT_VERSION_CODE=260 export NDK_LINK="https://dl.google.com/android/repository/android-ndk-r27-linux.zip" export NDK_VERSION="r27" export NDK_IS="android-ndk" \ No newline at end of file diff --git a/include/pmt/docs.h b/include/pmt/help_msgs.h similarity index 92% rename from include/pmt/docs.h rename to include/pmt/help_msgs.h index d085433..0052f2a 100755 --- a/include/pmt/docs.h +++ b/include/pmt/help_msgs.h @@ -16,8 +16,8 @@ * limitations under the License. */ -#ifndef __PMT_DOCS_H -#define __PMT_DOCS_H +#ifndef __PMT_HELP_MSGS_H +#define __PMT_HELP_MSGS_H __BEGIN_DECLS diff --git a/include/pmt/pmt.h b/include/pmt/pmt.h index ba038f9..ca35180 100755 --- a/include/pmt/pmt.h +++ b/include/pmt/pmt.h @@ -16,6 +16,10 @@ * limitations under the License. */ +#if !defined(__clang__) && !defined(__NDK_BUILD) + #error "Your compiler is NOT clang. Please build with LLVM clang." +#endif + #include __BEGIN_DECLS @@ -28,11 +32,13 @@ __BEGIN_DECLS #ifdef INC_MAIN_LIBS #include #include - #include - #include - #include #include #include + + #if !defined(HELP) || !defined(VERSIONING) + #include + #include + #endif #endif #ifdef INC_GETOPT diff --git a/include/pmt/versioning.h b/include/pmt/versioning.h index eb67692..8039d7c 100755 --- a/include/pmt/versioning.h +++ b/include/pmt/versioning.h @@ -28,7 +28,7 @@ __BEGIN_DECLS /* versioning */ #define PMT_MAJOR 2 -#define PMT_MINOR 5 +#define PMT_MINOR 6 #define PMT_PATCHLEVEL 0 __END_DECLS diff --git a/jni/Makefile b/jni/Makefile index 08860c0..9b3f8bc 100755 --- a/jni/Makefile +++ b/jni/Makefile @@ -26,121 +26,149 @@ ifeq ($(INC_OLDENV),true) include $(BUILD)/config/oldenv.mk endif -# make objects. Usage $(call make_obj,) -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/debugging.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/versioning.c -# make static library. Usage $(call make_staticlib,,) -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)/versioning.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,) -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/deprecates.h \ + $(PMT_INCDIR)/pmt/help_msgs.h \ + $(PMT_INCDIR)/pmt/pmt.h \ + $(PMT_INCDIR)/pmt/stringkeys.h \ + $(PMT_INCDIR)/pmt/versioning.h -# controls the presence of header file. usage: $(call check_hfile,) -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 \ + $(SRCS_REQ) \ + $(HEADERS_REQ) \ + pr_obj \ + $(OBJS) \ + make_outdirs \ + $(STATIC_LIBS) \ + make_executable \ + 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)/debugging.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..." + @ sleep 1 + +pr_obj: + $(E) " - Building objects..." + +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 + $(eval GEN_OBJS_MSG = ) + +lib$(TARGET)_root.a: + $(E) " - Making static libraries..." + $(E) " AR $@" + @ $(AR) rcs "$@" "$(SOURCE_DIR)/root.o" || exit 1 + +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; \ }; \ 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: diff --git a/jni/debugging.c b/jni/debugging.c index a04e434..fab4269 100755 --- a/jni/debugging.c +++ b/jni/debugging.c @@ -27,8 +27,6 @@ extern "C" { void debug(LogLevel status, const char* _Nullable fmt, ...) { - if (fmt == NULL) exit(1); - va_list args; va_start(args, fmt); diff --git a/jni/docs.c b/jni/help.c similarity index 98% rename from jni/docs.c rename to jni/help.c index eb8b206..0d99997 100755 --- a/jni/docs.c +++ b/jni/help.c @@ -21,10 +21,11 @@ extern "C" { #endif #define INC_MAIN_LIBS +#define HELP #include #include -#include +#include extern char* bin_name; extern char* curr_lang; diff --git a/jni/lang_tools.c b/jni/lang_tools.c index b58acc6..a8c3a0c 100755 --- a/jni/lang_tools.c +++ b/jni/lang_tools.c @@ -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) diff --git a/jni/listpart.c b/jni/listpart.c index 8dac0e5..4c38ff8 100755 --- a/jni/listpart.c +++ b/jni/listpart.c @@ -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) { diff --git a/jni/pmt.c b/jni/pmt.c index 9737c70..943b896 100755 --- a/jni/pmt.c +++ b/jni/pmt.c @@ -29,7 +29,9 @@ extern "C" { #include #include #include -#include +#include + +#define opt_symbol "-" /* add value to variables that are added globally and are not worth */ char* out = NULL; @@ -51,7 +53,6 @@ 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__) diff --git a/jni/tools.c b/jni/tools.c index 8e9b105..893b286 100755 --- a/jni/tools.c +++ b/jni/tools.c @@ -29,6 +29,8 @@ extern "C" { #include #include +#define count (1024 * 1024 * 1024) + /** * it is meant to calculate the size of the quickly given file. * its purpose is for rapid processing @@ -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) diff --git a/jni/versioner.c b/jni/versioning.c similarity index 96% rename from jni/versioner.c rename to jni/versioning.c index 03433c5..7d58eb9 100755 --- a/jni/versioner.c +++ b/jni/versioning.c @@ -21,6 +21,7 @@ extern "C" { #endif #define INC_MAIN_LIBS +#define VERSIONING #include #include @@ -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 } diff --git a/out/Makefile b/out/Makefile index 204bc08..3a0706b 100755 --- a/out/Makefile +++ b/out/Makefile @@ -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 \ No newline at end of file +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