pmt: initial 2.6.0 update
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -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 \
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
# limitations under the License.
|
||||
|
||||
########
|
||||
# 2.5.0
|
||||
# 2.6.0
|
||||
########
|
||||
|
||||
# architecture
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -26,121 +26,149 @@ 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/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,<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)/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,<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/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,<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 \
|
||||
$(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:
|
||||
|
||||
@@ -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"
|
||||
Reference in New Issue
Block a user