Make some corrections.

This commit is contained in:
2024-06-10 06:28:01 +03:00
parent d0a7b2d16f
commit 99ecb9daf3
15 changed files with 42 additions and 52 deletions

Binary file not shown.

BIN
debutils/mandoc/pmt.8.gz Executable file

Binary file not shown.

View File

@@ -46,4 +46,4 @@ endif
include $(BUILD_EXECUTABLE) include $(BUILD_EXECUTABLE)
# end # end

View File

@@ -25,7 +25,7 @@ extern "C" {
extern char* bin_name; extern char* bin_name;
void licenses() void licenses(void)
{ {
printf("Copyright 2024 Partition Manager\n"); printf("Copyright 2024 Partition Manager\n");
printf("Licensed under the Apache License, Version 2.0 (the \"License\");\n"); printf("Licensed under the Apache License, Version 2.0 (the \"License\");\n");
@@ -38,7 +38,7 @@ void licenses()
printf("See the License for the specific language governing permissions and limitations under the License.\n"); printf("See the License for the specific language governing permissions and limitations under the License.\n");
} }
void help() void help(void)
{ {
printf("Usage: \n"); printf("Usage: \n");
printf(" %s backup PARTITION [OUTPUT] [OPTIONS]...\n", bin_name); printf(" %s backup PARTITION [OUTPUT] [OPTIONS]...\n", bin_name);

View File

@@ -16,15 +16,11 @@
* limitations under the License. * limitations under the License.
*/ */
#if defined(__cplusplus) __BEGIN_DECLS
extern "C" {
#endif /* __cplusplus */
void help(); void help(void);
void licenses(); void licenses(void);
#if defined(__cplusplus) __END_DECLS
}
#endif /* __cplusplus */
/* end */ /* end */

View File

@@ -16,17 +16,13 @@
* limitations under the License. * limitations under the License.
*/ */
#if defined(__cplusplus) __BEGIN_DECLS
extern "C" {
#endif /* __cplusplus */
/* versioning */ /* versioning */
#define PMT_MAJOR 2 #define PMT_MAJOR 2
#define PMT_MINOR 1 #define PMT_MINOR 1
#define PMT_PATCHLEVEL 0 #define PMT_PATCHLEVEL 0
#if defined(__cplusplus) __END_DECLS
}
#endif /* __cplusplus */
/* end */ /* end */

View File

@@ -16,9 +16,7 @@
* limitations under the License. * limitations under the License.
*/ */
#if defined(__cplusplus) __BEGIN_DECLS
extern "C" {
#endif
#if !defined(__PMT_H_) #if !defined(__PMT_H_)
#define __PMT_H_ #define __PMT_H_
@@ -50,16 +48,14 @@ extern bool pmt_format;
extern bool pmt_force_mode; extern bool pmt_force_mode;
/* function definations */ /* function definations */
int listpart(); int listpart(void);
void check_dev_point(); void check_dev_point(void);
void check_root(); void check_root(void);
int pmt(unsigned short progress_code); int pmt(unsigned short progress_code);
void version(); void version(void);
#endif /* __PMT_H_ */ #endif /* __PMT_H_ */
#if defined(__cplusplus) __END_DECLS
}
#endif /* __cplusplus */
/* end of code */ /* end of code */

View File

@@ -40,7 +40,7 @@ extern char* cust_cxt;
extern char* bin_name; extern char* bin_name;
/* list existing partitions */ /* list existing partitions */
int listpart() { int listpart(void) {
DIR *dir; DIR *dir;
struct dirent *entry; struct dirent *entry;

View File

@@ -68,4 +68,6 @@ void check_dev_point()
#if defined(__cplusplus) #if defined(__cplusplus)
} }
#endif /* __cplusplus */ #endif /* __cplusplus */
/* end */

View File

@@ -205,7 +205,7 @@ int main(int argc, char* argv[])
break; break;
default: default:
printf("Usage: %s [backup] flash] [format] [-l | --logical] [-c | --context] [-D | --list] [-v | --version] [--help] [-L | --license]\n", argv[0]); printf("Usage: %s [backup] flash] [format] [-l | --logical] [-c | --context] [-D | --list] [-v | --version] [--help] [-L | --license]\n", argv[0]);
exit(EX_USAGE); return EX_USAGE;
} }
} }

View File

@@ -29,7 +29,7 @@ extern "C" {
#include <pmt.h> #include <pmt.h>
/* root checker function */ /* root checker function */
void check_root() void check_root(void)
{ {
/* a quick, easy method to verify root */ /* a quick, easy method to verify root */
if (getuid() != 0) if (getuid() != 0)

View File

@@ -84,7 +84,7 @@ calc_flsz(const char* _Nonnull filepath)
* It's for quick action. * It's for quick action.
*/ */
static int static int
partition_not_found() partition_not_found(void)
{ {
if (!pmt_silent) errx(EX_OSFILE, "partition not found!"); if (!pmt_silent) errx(EX_OSFILE, "partition not found!");
else return EX_OSFILE; else return EX_OSFILE;
@@ -95,7 +95,7 @@ partition_not_found()
* It's for quick action. * It's for quick action.
*/ */
static int static int
invalid_partition_type() invalid_partition_type(void)
{ {
if (!pmt_silent) errx(EX_USAGE, "invalid partition type!"); if (!pmt_silent) errx(EX_USAGE, "invalid partition type!");
else exit(EX_USAGE); else exit(EX_USAGE);
@@ -142,7 +142,7 @@ search_stat(const char* _Nonnull filepath, const char* _Nonnull stype)
else return -1; else return -1;
} }
return 0; return 2;
} }
/* the partitions are meant to quickly find. */ /* the partitions are meant to quickly find. */

View File

@@ -26,7 +26,7 @@ extern "C" {
extern char* bin_name; extern char* bin_name;
void version() void version(void)
{ {
printf("%s version %d.%d.%d (code %d%d%d) ", bin_name, PMT_MAJOR, PMT_MINOR, PMT_PATCHLEVEL, PMT_MAJOR, PMT_MINOR, PMT_PATCHLEVEL); printf("%s version %d.%d.%d (code %d%d%d) ", bin_name, PMT_MAJOR, PMT_MINOR, PMT_PATCHLEVEL, PMT_MAJOR, PMT_MINOR, PMT_PATCHLEVEL);

View File

@@ -19,13 +19,23 @@
RED='\e[31m' RED='\e[31m'
NC='\e[0m' NC='\e[0m'
# needed variables
VERSION="2.1.0"
CUR_DIR=$(pwd)
LIB_DIR=${CUR_DIR}/libs
ARMV8A_DIR=${LIB_DIR}/arm64-v8a
ARMV7A_DIR=${LIB_DIR}/armeabi-v7a
DEB_DIR=${CUR_DIR}/deb
DEBUTILS_DIR=${CUR_DIR}/debutils
DEBTERMUX_USR=${DEBUTILS_DIR}/data/data/com.termux/files/usr
# error messages # error messages
abort() { abort() {
if [ ! "$1" = "" ]; then if [ ! "$1" = "" ]; then
printf "${RED}${1}${NC}\n" printf "${RED}${1}${NC}\n"
fi fi
if [ -d ${DEBUTILS_DIR}/temp ]; then if [ -d ${DEBUTILS_DIR}/temp ]; then
rm -rf ${DEB_DIR}/temp rm -rf ${DEBUTILS_DIR}/temp
fi fi
exit 1 exit 1
} }
@@ -55,16 +65,6 @@ case "$2" in
SUDO="" SUDO=""
esac esac
# variables
VERSION="2.1.0"
CUR_DIR=$(pwd)
LIB_DIR=${CUR_DIR}/libs
ARMV8A_DIR=${LIB_DIR}/arm64-v8a
ARMV7A_DIR=${LIB_DIR}/armeabi-v7a
DEB_DIR=${CUR_DIR}/deb
DEBUTILS_DIR=${CUR_DIR}/debutils
DEBTERMUX_USR=${DEBUTILS_DIR}/data/data/com.termux/files/usr
# set file modes (all) to 755 # set file modes (all) to 755
${SUDO} chmod -R 755 * ${SUDO} chmod -R 755 *
@@ -92,11 +92,11 @@ fi
if [ ! -d ${DEBUTILS_DIR}/data/data/com.termux/files/usr/bin ]; then if [ ! -d ${DEBUTILS_DIR}/data/data/com.termux/files/usr/bin ]; then
abort " - Not found: ${DEBUTILS_DIR}/data/data/com.termux/files/usr/bin\n" abort " - Not found: ${DEBUTILS_DIR}/data/data/com.termux/files/usr/bin\n"
fi fi
if [ ! -d ${DEBUTILS_DIR}/data/data/com.termux/files/usr/share/man/man1 ]; then if [ ! -d ${DEBUTILS_DIR}/data/data/com.termux/files/usr/share/man/man8 ]; then
abort " - Not found: ${DEBUTILS_DIR}/data/data/com.termux/files/usr/share/man/man1\n" abort " - Not found: ${DEBUTILS_DIR}/data/data/com.termux/files/usr/share/man/man8\n"
fi fi
if [ ! -f ${DEBUTILS_DIR}/mandoc/pmt.1 ]; then if [ ! -f ${DEBUTILS_DIR}/mandoc/pmt.8.gz ]; then
abort " - Not found: ${DEBUTILS_DIR}/mandoc/pmt.1\n" abort " - Not found: ${DEBUTILS_DIR}/mandoc/pmt.8.gz\n"
fi fi
if [ ! -f ${DEBUTILS_DIR}/DEBIAN/control_32 ]; then if [ ! -f ${DEBUTILS_DIR}/DEBIAN/control_32 ]; then
abort " - Not found: ${DEBUTILS_DIR}/DEBIAN/control_32\n" abort " - Not found: ${DEBUTILS_DIR}/DEBIAN/control_32\n"
@@ -121,14 +121,14 @@ ${SUDO} mkdir -p ${DEB_DIR} || abort
# copy files # copy files
printf " - Copying files...\n" printf " - Copying files...\n"
${SUDO} cp -r ${DEBUTILS_DIR}/data ${DEBUTILS_DIR}/temp || abort ${SUDO} cp -r ${DEBUTILS_DIR}/data ${DEBUTILS_DIR}/temp || abort
${SUDO} rm -f ${DEBTERMUX_USR}/share/man/man1/dummy ${SUDO} rm -f ${DEBTERMUX_USR}/share/man/man8/dummy
${SUDO} rm -f ${DEBTERMUX_USR}/bin/dummy ${SUDO} rm -f ${DEBTERMUX_USR}/bin/dummy
${SUDO} mkdir -p ${DEBUTILS_DIR}/temp/DEBIAN || abort ${SUDO} mkdir -p ${DEBUTILS_DIR}/temp/DEBIAN || abort
# select control file # select control file
printf " - Selected arm-${PREFIX} package control file.\n" printf " - Selected arm-${PREFIX} package control file.\n"
${SUDO} cp ${DEBUTILS_DIR}/DEBIAN/control_${PREFIX} ${DEBUTILS_DIR}/temp/DEBIAN/control || exit 1 ${SUDO} cp ${DEBUTILS_DIR}/DEBIAN/control_${PREFIX} ${DEBUTILS_DIR}/temp/DEBIAN/control || exit 1
${SUDO} cp ${DEBUTILS_DIR}/mandoc/pmt.1.gz ${DEBTERMUX_USR}/share/man/man1 || abort ${SUDO} cp ${DEBUTILS_DIR}/mandoc/pmt.8.gz ${DEBTERMUX_USR}/share/man/man8 || abort
if [ "${PREFIX}" = "64" ]; then if [ "${PREFIX}" = "64" ]; then
${SUDO} cp ${ARMV8A_DIR}/pmt ${DEBTERMUX_USR}/bin || abort ${SUDO} cp ${ARMV8A_DIR}/pmt ${DEBTERMUX_USR}/bin || abort
elif [ "${PREFIX}" = "32" ]; then elif [ "${PREFIX}" = "32" ]; then