Compare commits
222 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ec5a2b97b9 | |||
| 95c100453f | |||
| 157e99a08e | |||
| b1f9e491b3 | |||
| 9313a8ec4a | |||
| 512d35737b | |||
| 9bcde145a5 | |||
| 5d51e44a2c | |||
| ed745369fa | |||
| 851f0aaeb2 | |||
| 00990ea242 | |||
| 356e8683a5 | |||
| 9c72226498 | |||
| 2f87fd57c0 | |||
| 5b00b0bfe3 | |||
| 36efab6eb3 | |||
| 74ca2de92e | |||
| 3640331184 | |||
| 0fc709f34f | |||
| 36c49131be | |||
| 14788d1aaf | |||
| 9c61fcfaae | |||
| b834134221 | |||
| 7eb6289726 | |||
| 3b612d1df4 | |||
| fb6b7dca06 | |||
| 41cb1801c0 | |||
| d2e4b58ab6 | |||
| b4b9f1d1df | |||
| 8c8d9edbd4 | |||
| 2dcf2c124f | |||
| 04d7121eb6 | |||
| ad8756a05c | |||
| 26cc9740b7 | |||
| 0519bc3a66 | |||
| 484fa8dcca | |||
| 91713b86be | |||
| 4f8e15935a | |||
| 19b8d74498 | |||
| da15903881 | |||
| 57403a0196 | |||
| d591c760e1 | |||
| ec6148b0d9 | |||
| f7bbe2ba15 | |||
| c9453ef968 | |||
| 7943fa312c | |||
| 3fb873199b | |||
|
|
c6163bc752 | ||
|
|
30f1a84f13 | ||
| 4607f565af | |||
| 2edc502bbf | |||
| fd15d460f6 | |||
| fe752d7505 | |||
| 464027fd1c | |||
| 99b45da4a7 | |||
| 284bb42faa | |||
| 964d9b5426 | |||
| 4dd49c2509 | |||
| 934d1b0112 | |||
| 32ac3a3dd6 | |||
| fc02df6583 | |||
| deb42c9ff5 | |||
| 60904a4b2f | |||
| ad6115f51b | |||
| 6cc59d92f8 | |||
| fe69408eb5 | |||
| cd386ac6f9 | |||
| 268aa8ac77 | |||
| c5746fe14b | |||
| d2cb68df5e | |||
| 3976e0fb39 | |||
| 0a9e164b9c | |||
| ecada5f076 | |||
| ca09bb94e1 | |||
| 52ffe99d4b | |||
| 416939634a | |||
| cbbd36899e | |||
| 9dc79ae923 | |||
| b522dcc62b | |||
| 7aeea39e41 | |||
| 974774eb3e | |||
| 70ce307e50 | |||
| 99ecb9daf3 | |||
| d0a7b2d16f | |||
| 96336bcd0b | |||
| 545376afb2 | |||
| 62b24d5705 | |||
| 0fca319b29 | |||
| 929150e034 | |||
| 93843a511d | |||
| 0981e70268 | |||
| b214da3cd6 | |||
| 464bfe6e56 | |||
| f5531fde32 | |||
| f771fb7c68 | |||
| 4bc5235952 | |||
| d4b4c91ff4 | |||
| 6fc38eb01d | |||
| 42e5d132e7 | |||
| 39d1411b11 | |||
| 04d6471c86 | |||
| f7d2f313de | |||
| 49a87b0387 | |||
| 5a104e5b22 | |||
| 055213f2f6 | |||
| 7f270e319c | |||
| 6a035f8f41 | |||
| 1b2dda655a | |||
| 07d63944c1 | |||
| 36b7bcf246 | |||
| cd3f65a145 | |||
| 9dd29f96b8 | |||
| 7254637caf | |||
| 2af00a8028 | |||
| b5790af803 | |||
| 8fe1548796 | |||
| 04d8ccdd81 | |||
| 1a790d1d89 | |||
| 1296e488f1 | |||
| 3fea6c73cc | |||
| cf4b590130 | |||
| 352ef6e68a | |||
| 754ebaade2 | |||
| 8a28a8f1ef | |||
| 086a2dd93d | |||
| 383a1efe55 | |||
| b96977a5fc | |||
| 976c10593c | |||
| d45dd67cbe | |||
| 0fa5a546aa | |||
| 0c487c62fe | |||
| 105d92e0ca | |||
| 850d104a1a | |||
| 6d24fb9eae | |||
| ae8c73c4f5 | |||
| 890d93131c | |||
| a33d4e3f16 | |||
| f344d62d4c | |||
| 40c5b155dc | |||
| 0547e18639 | |||
| f34a47889e | |||
| a9fac9e661 | |||
| e8040de436 | |||
| ff6e82c556 | |||
| 0c7da875b2 | |||
| 41565d221f | |||
| 5ba78d860e | |||
| 181125dfca | |||
| 4464c203fd | |||
| b9e58df98f | |||
| e2f8cf4ca3 | |||
| 07e2249ef1 | |||
| fd970be822 | |||
| 45c964997c | |||
| 31b7f16a29 | |||
| 5f83a4476f | |||
| 5438f5210f | |||
| cb7904cd5a | |||
| 9c570d5b02 | |||
| c9736863fe | |||
| d5ce065e8b | |||
| a4bc9e3834 | |||
| ce017e2cbc | |||
| b5daf8a44c | |||
| f125ae760c | |||
| f68f92ade1 | |||
| 3a723446cc | |||
| 1d66a3c21f | |||
| 13e31df7c6 | |||
| 4922ed5a35 | |||
| 3220aace91 | |||
| 7f85d63088 | |||
| 412b697b9c | |||
| afc958aeb4 | |||
| fbd45e0936 | |||
| 0ef8767eb5 | |||
| 9bc871573e | |||
| adad63bbbd | |||
| 0157c886ae | |||
| 076774d9f4 | |||
| 25642cc6f2 | |||
| 16c8654fa2 | |||
| 1fb592a94f | |||
| 5bb26c9eea | |||
| 540dd4fe35 | |||
| 22ef985925 | |||
| 2e81ab9541 | |||
| 112a2986b5 | |||
| 65fd480ba2 | |||
| d31bccd8f6 | |||
| 6c574e9536 | |||
| a4838b24e1 | |||
| 908060219e | |||
| ac06203a2c | |||
| 56976b2bd0 | |||
| b7ebb92fcd | |||
| 3b36e1309d | |||
| 8dbc54f9fc | |||
| 4b4b53a080 | |||
| 09d9aa1ee6 | |||
| 171de34710 | |||
| 5e39fdcdc9 | |||
| fbb4822872 | |||
| 711319cce0 | |||
| 6dbf7acf3c | |||
| 287c75aa67 | |||
| 1835ecc1e0 | |||
| 8afbb2314c | |||
| 283346f522 | |||
| c46a65607b | |||
| dd6c1c9faf | |||
| 6ab211c1b3 | |||
| 372563fceb | |||
| 0b34fdbfd9 | |||
| a2aee5c5e8 | |||
| d3d6bfd244 | |||
| 97edfbc133 | |||
| b5d4c76b2d | |||
| 39b1e67f8e | |||
| 1ffd0f90be | |||
| b8a8b7ff8f | |||
| 848412e1cd |
113
.github/workflows/build.yml
vendored
Normal file
113
.github/workflows/build.yml
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
name: Build and release
|
||||
|
||||
on: [workflow_dispatch]
|
||||
|
||||
jobs:
|
||||
build-and-rel-pmt:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
id: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Cleanup
|
||||
id: cleanup
|
||||
uses: rokibhasansagar/slimhub_actions@main
|
||||
|
||||
- name: Setup GitHub CLI
|
||||
id: setup-gh
|
||||
run: |
|
||||
type -p curl >/dev/null || (sudo apt update && sudo apt install curl -y)
|
||||
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
|
||||
&& sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
|
||||
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
|
||||
&& sudo apt update \
|
||||
&& sudo apt install gh -y
|
||||
|
||||
- name: Update and setup packages
|
||||
id: general-packages-progress
|
||||
run: |
|
||||
sudo apt update \
|
||||
&& sudo apt upgrade -y \
|
||||
&& sudo apt install make xz-utils aria2 gawk -y
|
||||
|
||||
- name: Save spefic version variables
|
||||
id: save-vars
|
||||
run: |
|
||||
. build/workflow/build.config
|
||||
echo "PMT_VERSION=${PMT_VERSION}" >> $GITHUB_ENV
|
||||
echo "PMT_VERSION_CODE=${PMT_VERSION_CODE}" >> $GITHUB_ENV
|
||||
echo "NDK_VERSION=${NDK_VERSION}" >> $GITHUB_ENV
|
||||
echo "NDK_LINK=${NDK_LINK}" >> $GITHUB_ENV
|
||||
echo "NDK_IS=${NDK_IS}" >> $GITHUB_ENV
|
||||
cd /home
|
||||
sudo git clone https://github.com/ShawkTeam/pmt -b ${PMT_VERSION}
|
||||
sudo chmod 777 pmt
|
||||
echo "PMT_SRCDIR=/home/pmt" >> $GITHUB_ENV
|
||||
echo "NDK_DIR=/home/ndk/android-ndk" >> $GITHUB_ENV
|
||||
echo "NDK_IN_DIR=/home/ndk" >> $GITHUB_ENV
|
||||
sudo mkdir -p "/home/ndk" && cd "/home/ndk" && sudo chmod 777 "/home/ndk"
|
||||
|
||||
- name: Download and extract NDK
|
||||
id: setup-ndk
|
||||
run: |
|
||||
echo "Downloading NDK ${{ env.NDK_VERSION }}..."
|
||||
aria2c "${{ env.NDK_LINK }}"
|
||||
echo "Extracting..."
|
||||
unzip -q *.zip && rm *.zip
|
||||
mv * "${{ env.NDK_IS }}"
|
||||
sudo chmod -R 777 *
|
||||
working-directory: ${{ env.NDK_IN_DIR }}
|
||||
|
||||
- name: Build pmt
|
||||
id: build-pmt
|
||||
run: |
|
||||
make gen-ndk-makefiles
|
||||
export NDK_PROJECT_PATH=${PWD}
|
||||
export NDK_ROOT_DIR=${{ env.NDK_DIR }}
|
||||
echo "NDK_ROOT_DIR=${NDK_ROOT_DIR}" >> $GITHUB_ENV
|
||||
bash build/bash/gen-header
|
||||
cd ${{ env.NDK_DIR }}
|
||||
./ndk-build
|
||||
working-directory: ${{ env.PMT_SRCDIR }}
|
||||
|
||||
- name: Last small transactions
|
||||
id: small-transactions
|
||||
run: |
|
||||
export CC_64="${PWD}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang"
|
||||
export CC_32="${PWD}/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi21-clang"
|
||||
export AR="${PWD}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar"
|
||||
export CC_VERSION=$(${CC_64} --version | head -n 1)
|
||||
echo "CC_VERSION=${CC_VERSION}" >> $GITHUB_ENV
|
||||
. ${{ env.PMT_SRCDIR }}/build/workflow/build.config
|
||||
. ${{ 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
|
||||
for arch in arm64-v8a armeabi-v7a; do
|
||||
xz libs/${arch}/pmt
|
||||
mv libs/${arch}/pmt.xz ${PWD}/pmt-${arch}-$(date +%Y%m%d).xz
|
||||
done
|
||||
for CC_COMP in ${CC_64} ${CC_32}; do
|
||||
make clean
|
||||
make CC="${CC_COMP}" AR="${AR}" PMT_EXTRA_CFLAGS="-D__NDK_BUILD"
|
||||
[[ "${CC_COMP}" == *"aarch64"* ]] && make deb FOR_THIS=64
|
||||
[[ "${CC_COMP}" == *"armv7a"* ]] && make deb FOR_THIS=32
|
||||
mv out/debpackage/*.deb .
|
||||
make clean
|
||||
done
|
||||
working-directory: ${{ env.NDK_DIR }}
|
||||
|
||||
- name: Upload to release
|
||||
id: upload-to-rels
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
files: |
|
||||
/home/pmt/pmt*.xz
|
||||
/home/pmt/pmt*.deb
|
||||
/home/pmt/pmt-objs-local.zip
|
||||
name: Partition Manager ${{ env.PMT_VERSION }} Release
|
||||
tag_name: ${{ env.PMT_VERSION }}
|
||||
body_path: /home/pmt/release_body.txt
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.PMT_WORKFLOW_GTOKEN }}
|
||||
35
.github/workflows/check_commits.yml
vendored
Normal file
35
.github/workflows/check_commits.yml
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
name: Check commit
|
||||
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
check-commit:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Detect commit type
|
||||
id: check-commit-type
|
||||
run: |
|
||||
echo "BRANCH=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_ENV
|
||||
COMM_MSG=$(git log -1 --pretty=%B)
|
||||
if [ "${GITHUB_EVENT_NAME}" == "push" ]; then
|
||||
if [[ "${COMM_MSG}" == *"initial"* ]]; then
|
||||
echo "run_builder=true" >> $GITHUB_ENV
|
||||
else
|
||||
echo "run_builder=false" >> $GITHUB_ENV
|
||||
fi
|
||||
elif [ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]; then
|
||||
echo "run_builder=true" >> $GITHUB_ENV
|
||||
fi
|
||||
|
||||
- name: Run release workflow
|
||||
id: run-rel-workflow
|
||||
if: env.run_builder == 'true'
|
||||
uses: benc-uk/workflow-dispatch@v1
|
||||
with:
|
||||
workflow: 'build.yml'
|
||||
token: ${{ secrets.PMT_WORKFLOW_GTOKEN }}
|
||||
ref: ${{ env.BRANCH }}
|
||||
146
ADD-LANGUAGES.md
Executable file
146
ADD-LANGUAGES.md
Executable file
@@ -0,0 +1,146 @@
|
||||
### Add a new language to pmt (guide)
|
||||
|
||||
On this page, I will tell you how to add languages to pmt. This is not a difficult thing :)
|
||||
|
||||
##### Send ready stuff
|
||||
- Send ready translations via pull requests. After making the necessary checks, if there is no problem, I will accept it.
|
||||
- Proper commit messages are required.
|
||||
- If there is an error, I will mention it in the pull request comments.
|
||||
- Once you accept it, I (YZBruh) will implement the rest of the necessary things.
|
||||
- It may take 5 days for me to notice :P
|
||||
|
||||
##### Little important notes
|
||||
- You don't have to be a professional to do this thing.
|
||||
- There will be only one place you need to pay attention to, I will explain it.
|
||||
- There is no need to know C.
|
||||
- You can edit existing translations.
|
||||
- You may need ready pmt to understand some things.
|
||||
- If you are on an x86 PC, you can compile and use it, but the functions will never work.
|
||||
|
||||
##### Understanding general logic
|
||||
All the texts (strings) in pmt are like variables in bash. I mean:
|
||||
|
||||
```
|
||||
Bash
|
||||
export missing_operand="missing operand."
|
||||
|
||||
APPLYING:
|
||||
~ $ echo -n "$missing_operand\n" # for more detail I used the -n argument
|
||||
missing operand
|
||||
~ $
|
||||
|
||||
C / C++
|
||||
const char* _Nonnull missing_operand = "missing operand.";
|
||||
const std::string missing_operand = "missing operand.";
|
||||
|
||||
APPLYING (C / C++):
|
||||
printf("%s\n", missing_operand); // Move to new line with '\n' character
|
||||
std::cout << missing_operand << std::endl; // Move to new line with std::endl
|
||||
```
|
||||
|
||||
For example, let's take the output directly in pmt without any arguments and process the variables and structures behind the work.
|
||||
|
||||
```
|
||||
Shell
|
||||
~ $ pmt
|
||||
pmt: missing operand
|
||||
Try `pmt --help' for more information.
|
||||
~ $
|
||||
|
||||
Code pieces (C)
|
||||
struct pmt_langdb_general en = {
|
||||
// other translations
|
||||
.missing_operand = "missing operand",
|
||||
.try_h = "Try",
|
||||
.for_more = "for more information",
|
||||
// other translations
|
||||
}
|
||||
|
||||
// pmt code functions [ logging ]
|
||||
LOGE("%s\n%s `%s --help' %s.\n, missing_operand, try_h, argv[0], for_more); // LOGE is error logger (pmt). argv[0] = execution name
|
||||
```
|
||||
|
||||
In short, there are variables for texts. And I made these dynamic by using [struct](https://chatgpt.com/share/a798b57c-7e29-4b17-8887-f230414e57bd) method in C. You just need to add translation :)
|
||||
|
||||
##### Translating main program texts (relevant part)
|
||||
|
||||
- Let's open our jni/languages.c source file.
|
||||
- Now, let's create the translation with the ready-made struct structure (see jni/include/StringKeys.h for the structure).
|
||||
```
|
||||
// Main
|
||||
struct pmt_langdb_general <LANGUAGE_PREFIX> = { // LANGUAGE_PREFIX must be the corresponding abbreviation of the language in English. For example, it's like en in English.
|
||||
// translations
|
||||
}
|
||||
|
||||
// Example
|
||||
struct pmt_langdb_general en = {
|
||||
// translation
|
||||
}
|
||||
```
|
||||
- We need to add some information about the language.
|
||||
```
|
||||
struct pmt_langdb_general <LANGUAGE_PREFIX> = {
|
||||
.lang_by_s = // Names of those who made the translation. It's up to you. Do you use & between more than one person?
|
||||
.language = // Language name. For example English
|
||||
.lang_prefix = // Language prefix. For example en
|
||||
// other translations
|
||||
}
|
||||
|
||||
// Example
|
||||
struct pmt_langdb_general 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...
|
||||
```
|
||||
- Now do the others :)
|
||||
- Now let me explain the documentation...
|
||||
|
||||
##### Document texts translation (relevant part)
|
||||
|
||||
- Let's open our jni/languages.c source file.
|
||||
- Now, let's create the translation with the ready-made struct structure (see jni/include/StringKeys.h for the structure).
|
||||
```
|
||||
struct pmt_langdb_docs <LANGUAGE_PREFIX>_docs = {
|
||||
// translations
|
||||
}
|
||||
|
||||
// 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
|
||||
|
||||
##### General things to do in translation
|
||||
|
||||
- Open jni/languages.c
|
||||
- Go down a bit...
|
||||
```
|
||||
struct pmt_langdb_langs lang[] = {
|
||||
{"en"},
|
||||
{"tr"},
|
||||
// language prefix. {"<LANGUAGE_PREFIX>"},
|
||||
{NULL} // PLEASE DO NOT ADD IT UNDER 'NULL'!
|
||||
};
|
||||
|
||||
// Example
|
||||
struct pmt_langdb_langs lang[] = {
|
||||
{"en"},
|
||||
{"tr"},
|
||||
{"az"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
// Add the language you are translating into these existing language prefixes. I will fix the errors here (if there is an error)
|
||||
```
|
||||
|
||||
##### Notes
|
||||
- Apologies for the crappy current language control structure :(
|
||||
- You can ask your questions: <t.me / ShawkTeam | Topics | pmt>
|
||||
16
CHANGELOG.md
Normal file → Executable file
16
CHANGELOG.md
Normal file → Executable file
@@ -1,10 +1,10 @@
|
||||
#### Version 1.5.0 (code 150):
|
||||
- provide the recognition feature unknown flags to the assembly system
|
||||
- bring the flash feature
|
||||
- clean the unnecessary code (variables etc.)
|
||||
- provide a more modular code
|
||||
- go to the change named project (Partition backupper (pbt) to Partition Manager (pmt)
|
||||
### Version 2.7.0 Changelog
|
||||
|
||||
| END OF VERSION 1.5.0 CHANGELOG |
|
||||
|------------------------------------|
|
||||
- Operation support with pipe (|) operator has been added.
|
||||
- Build system has been made dynamic.
|
||||
- Minor changes were made to the layout of bash scripts.
|
||||
- Header names have been changed.
|
||||
|
||||
```
|
||||
END OF 2.7.0 UPDATE CHANGELOG
|
||||
```
|
||||
|
||||
17
DISCLAIMER
Normal file → Executable file
17
DISCLAIMER
Normal file → Executable file
@@ -1,6 +1,11 @@
|
||||
WARNING:
|
||||
Disclaimer of Liability Regarding the Use of the C Library
|
||||
- This library is intended for the user to backup the C android partitions. However, we do not accept responsibility for any problems or losses that may arise during its use.
|
||||
- Users should carefully test the library functions and, if necessary, implement their own error management mechanisms.
|
||||
- The authors reserve the right to make any changes or updates related to the library.
|
||||
- This library is intended for backing up android partitions and its suitability for any specific project or application is not guaranteed. It is important for users to evaluate the suitability of their own projects.
|
||||
Disclaimer regarding problems caused by PMT
|
||||
|
||||
1. This program is provided as is, without warranty.
|
||||
2. Not for commercial purposes.
|
||||
3. The developer is NOT responsible for any damages, losses or similar problems that may occur as a result of the use of the program.
|
||||
4. THE USER IS RESPONSIBLE FOR ANY PROBLEMS THAT MAY COME FROM WRONG OR FAILURE USING THE PROGRAM.
|
||||
5. Developers do NOT have to keep the program always updated.
|
||||
6. There is NO guarantee that updates will be provided in the future.
|
||||
7. The user must use the program IN ACCORDANCE with the license.
|
||||
8. The developer has ALL rights to the development and distribution of the program.
|
||||
9. The developer will only be interested in solving users' queries etc. AND THE UPDATE MAY NOT DO THIS AFTER THE INTERRUPTION.
|
||||
|
||||
108
Makefile
Normal file → Executable file
108
Makefile
Normal file → Executable file
@@ -1,8 +1,6 @@
|
||||
include mka/config.mk
|
||||
|
||||
# By YZBruh
|
||||
|
||||
# Copyright 2024 YZBruh - Partition Manager
|
||||
# Copyright 2024 Partition Manager
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -16,101 +14,13 @@ include mka/config.mk
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# speficy
|
||||
VERSION := 1.5.0
|
||||
VERSION_CODE := 150
|
||||
SOURCE_DIR := binary
|
||||
TARGET := pmt
|
||||
LANG := en
|
||||
ARCH := $(shell uname -m)
|
||||
CUR_DIR := $(shell pwd)
|
||||
THIS_IS = main
|
||||
NDK_PROG ?= false
|
||||
FORCE_GEN ?= false
|
||||
|
||||
# code list
|
||||
SRCS := $(SOURCE_DIR)/$(TARGET).c
|
||||
SRCS += $(SOURCE_DIR)/error.c
|
||||
SRCS += $(SOURCE_DIR)/checkers.c
|
||||
SRCS += $(SOURCE_DIR)/lister.c
|
||||
SRCS += $(SOURCE_DIR)/flash.c
|
||||
SRCS += $(SOURCE_DIR)/backup.c
|
||||
# include needed variables
|
||||
include Makefile.inc
|
||||
include $(TOOLS)/gen-makefiles.mk
|
||||
include $(TOOLS)/clean-makefiles.mk
|
||||
|
||||
OBJS := $(SOURCE_DIR)/$(TARGET).o
|
||||
OBJS += $(SOURCE_DIR)/error.o
|
||||
OBJS += $(SOURCE_DIR)/checkers.o
|
||||
OBJS += $(SOURCE_DIR)/lister.o
|
||||
OBJS += $(SOURCE_DIR)/flash.o
|
||||
OBJS += $(SOURCE_DIR)/backup.o
|
||||
|
||||
OUT_DIR := $(CUR_DIR)/out
|
||||
BINARY_DIR := $(OUT_DIR)/binary
|
||||
PACKAGE_DIR := $(OUT_DIR)/package
|
||||
|
||||
# display
|
||||
all:
|
||||
@printf " --- Building Partition Manager --- \n"; \
|
||||
printf "Version: $(VERSION)\n"; \
|
||||
printf "Version code: $(VERSION_CODE)\n"; \
|
||||
printf " \n"; \
|
||||
printf " ------------------------------------- \n"; \
|
||||
printf " \n"; \
|
||||
printf "Starting build... Please waith.\n"; \
|
||||
sleep 2; \
|
||||
printf "Make running with silent mode...\n"; \
|
||||
make -s pmt;
|
||||
|
||||
# build progress
|
||||
.PHONY: $(TARGET)
|
||||
$(TARGET): $(OBJS)
|
||||
$(CC) $(CFLAGS) -o $@ $(OBJS)
|
||||
@mkdir -p $(OUT_DIR); \
|
||||
mkdir -p $(BINARY_DIR); \
|
||||
mkdir -p $(PACKAGE_DIR); \
|
||||
mv pmt $(BINARY_DIR); \
|
||||
printf "Generating gzip package...\n"; \
|
||||
cp $(BINARY_DIR)/pmt $(PACKAGE_DIR); \
|
||||
gzip -f $(PACKAGE_DIR)/pmt; \
|
||||
mv $(PACKAGE_DIR)/pmt.gz $(PACKAGE_DIR)/pmt-$(ARCH)-$(LANG).gz; \
|
||||
printf " \n"; \
|
||||
printf " ------------------------------------- \n";
|
||||
|
||||
# cleaner functions
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@printf "Cleaning (builded files [.o extended])...\n"; \
|
||||
sleep 2; \
|
||||
rm -rf $(OBJS); \
|
||||
printf "Success\n";
|
||||
|
||||
.PHONY: clean-all
|
||||
clean-all:
|
||||
@printf "Cleaning (builded files [.o extended] and binary)...\n"; \
|
||||
sleep 2; \
|
||||
rm -rf $(OBJS) $(OUT_DIR); \
|
||||
printf "Success\n";
|
||||
|
||||
# helper function
|
||||
.PHONY: help
|
||||
help:
|
||||
@printf " --------- Partition Manager help ---------\n"; \
|
||||
printf " \n"; \
|
||||
printf " Commands;\n"; \
|
||||
printf " make ==> Build Partition Manager\n"; \
|
||||
printf " make clean ==> Clear files (Builded binaries are not deleted)\n"; \
|
||||
printf " make clean-all ==> Clear files (Builded binaries are deleted)\n"; \
|
||||
printf " make install-termux ==> If you are using termux, it installs the compiled pmt into termux. So it allows you to use it like a normal command.\n"; \
|
||||
printf " make help ==> Display help message\n"; \
|
||||
printf " \n";
|
||||
|
||||
.PHONY: install-termux
|
||||
install-termux:
|
||||
@if [ -f /data/data/com.termux/files/usr/bin/termux-open ]; then \
|
||||
printf " ------------------------------------- \n"; \
|
||||
printf " pmt installer \n"; \
|
||||
printf " ------------------------------------- \n"; \
|
||||
cp $(BINARY_DIR)/pmt /data/data/com.termux/files/usr/bin/pmt || exit 1; \
|
||||
chmod 777 /data/data/com.termux/files/usr/bin/pmt || exit 1; \
|
||||
printf " \n"; \
|
||||
printf "Success.\n"; \
|
||||
printf " \n"; \
|
||||
else \
|
||||
printf "This function is only available on Termux Android devices using aarch64 (64-bit) and armv7l (32-bit)\n"; \
|
||||
fi
|
||||
include $(BUILD)/main.mk
|
||||
128
Makefile.inc
Executable file
128
Makefile.inc
Executable file
@@ -0,0 +1,128 @@
|
||||
# By YZBruh
|
||||
|
||||
# Copyright 2024 Partition Manager
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# speficy
|
||||
VERSION := 2.7.0
|
||||
VERSION_CODE := 270
|
||||
TARGET := pmt
|
||||
|
||||
# device arch info
|
||||
ARCH := $(shell uname -m)
|
||||
|
||||
# current directory
|
||||
OUT_DIRNAME ?= out
|
||||
SOURCE_DIRNAME ?= jni
|
||||
|
||||
# others needed important variables
|
||||
ifeq ($(THIS_IS),src)
|
||||
BUILD := ../build
|
||||
SOURCE_DIR := $(CURDIR)
|
||||
OUT_DIR := ../$(OUT_DIRNAME)
|
||||
DEBUTILS_DIR := $(BUILD)/deb
|
||||
else ifeq ($(THIS_IS),debutils)
|
||||
BUILD := ..
|
||||
SOURCE_DIR := ../../$(SOURCE_DIRNAME)
|
||||
OUT_DIR := ../../$(OUT_DIRNAME)
|
||||
DEBUTILS_DIR := $(BUILD)/deb
|
||||
else ifeq ($(THIS_IS),out)
|
||||
BUILD := ../build
|
||||
SOURCE_DIR := ../$(SOURCE_DIRNAME)
|
||||
OUT_DIR := $(CURDIR)
|
||||
DEBUTILS_DIR := $(BÜILD)/deb
|
||||
else ifeq ($(THIS_IS),main)
|
||||
BUILD := $(CURDIR)/build
|
||||
SOURCE_DIR := $(CURDIR)/$(SOURCE_DIRNAME)
|
||||
OUT_DIR := $(CURDIR)/$(OUT_DIRNAME)
|
||||
DEBUTILS_DIR := $(BUILD)/deb
|
||||
endif
|
||||
|
||||
BINARY_DIR := $(OUT_DIR)/binary
|
||||
PACKAGE_DIR := $(OUT_DIR)/package
|
||||
STATICLIB_DIR := $(OUT_DIR)/static_libs
|
||||
DEB_DIR := $(OUT_DIR)/debpackage
|
||||
TOOLS := $(BUILD)/tools
|
||||
UTILS := $(BUILD)/util
|
||||
BASH_DIR := $(BUILD)/bash
|
||||
OTHERS := $(BUILD)/others
|
||||
TERMUX_USR := /data/data/com.termux/files/usr
|
||||
TERMUX_BIN := $(TERMUX_USR)/bin
|
||||
LINUX_BIN := /usr/bin
|
||||
DEBTERMUX_USR := $(DEBUTILS_DIR)/template$(TERMUX_USR)
|
||||
|
||||
ifneq ($(wildcard $(LINUX_BIN)),)
|
||||
BIN := $(LINUX_BIN)
|
||||
else
|
||||
BIN := $(TERMUX_BIN)
|
||||
endif
|
||||
|
||||
include $(UTILS)/utils.mk
|
||||
|
||||
ifneq ($(shell basename $(SOURCE_DIR)),$(SOURCE_DIRNAME))
|
||||
$(error The index name specified with the current source directory name is not the same! Something's wrong)
|
||||
endif
|
||||
|
||||
ifneq ($(shell basename $(OUT_DIR)),$(OUT_DIRNAME))
|
||||
$(error The index name specified with the current output directory name is not the same! Something's wrong)
|
||||
endif
|
||||
|
||||
# sources
|
||||
SRCS := $(wildcard $(SOURCE_DIR)/*.c)
|
||||
OBJS = $(SRCS:.c=.o)
|
||||
|
||||
STATIC_LIBS := \
|
||||
$(TARGET)_root \
|
||||
$(TARGET)_debug \
|
||||
$(TARGET)_listpart \
|
||||
$(TARGET)_partitiontool
|
||||
|
||||
# other directories in the out directory
|
||||
IN_OUT_DIR := \
|
||||
$(BINARY_DIR) \
|
||||
$(PACKAGE_DIR) \
|
||||
$(STATICLIB_DIR)
|
||||
|
||||
# list of file/directory to be checked when the deb pack is created
|
||||
DEB_CHECKS := \
|
||||
$(DEBUTILS_DIR)/ \
|
||||
$(DEBUTILS_DIR)/DEBIAN \
|
||||
$(DEBUTILS_DIR)/DEBIAN/control_32 \
|
||||
$(DEBUTILS_DIR)/DEBIAN/control_64 \
|
||||
$(DEBUTILS_DIR)/mandoc \
|
||||
$(DEBUTILS_DIR)/mandoc/$(TARGET).8.gz \
|
||||
$(DEBUTILS_DIR)/data \
|
||||
$(DEBUTILS_DIR)/data/data \
|
||||
$(DEBUTILS_DIR)/data/data/com.termux \
|
||||
$(DEBUTILS_DIR)/data/data/com.termux/files \
|
||||
$(DEBUTILS_DIR)/data/data/com.termux/files/usr \
|
||||
$(DEBUTILS_DIR)/data/data/com.termux/files/usr/bin \
|
||||
$(DEBUTILS_DIR)/data/data/com.termux/files/usr/share \
|
||||
$(DEBUTILS_DIR)/data/data/com.termux/files/usr/share/man \
|
||||
$(DEBUTILS_DIR)/data/data/com.termux/files/usr/share/man/man8
|
||||
|
||||
# for running make with silent mode
|
||||
MAKE_HIDE := @ $(MAKE)
|
||||
SILENT := -s
|
||||
E := @ echo
|
||||
E_NS := echo
|
||||
P := printf
|
||||
|
||||
# color definations
|
||||
RESET := \033[0m
|
||||
RED := \033[0;31m
|
||||
GREEN := \033[0;32m
|
||||
YELLOW := \033[0;33m
|
||||
|
||||
# end
|
||||
4
NOTICE
Normal file → Executable file
4
NOTICE
Normal file → Executable file
@@ -1,4 +1,4 @@
|
||||
Copyright 2024 YZBruh - Partition Manager
|
||||
Copyright 2024 Partition Manager
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -10,4 +10,4 @@ Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
limitations under the License.
|
||||
136
README.md
Normal file → Executable file
136
README.md
Normal file → Executable file
@@ -1,72 +1,114 @@
|
||||
## Partition Manager (pmt)
|
||||
|
||||
This binary static C library is for manage partitions of android devices.
|
||||
It offers a lot of options. I will place these below. But first let me talk about the operation...
|
||||
[](https://github.com/ShawkTeam/pmt/actions/workflows/check_commits.yml)
|
||||
|
||||
```
|
||||
1. The partition name is obtained (with the -p or --partition argument)
|
||||
2. Other arguments (if used) are processed.
|
||||
3. It is backed up using DD. If the progress is not a problem, it is not given (DD)
|
||||
```
|
||||
This binary, written in C, is for writing/reading and formatting on Android partitions.
|
||||
|
||||
#### Presented arguments (options)
|
||||
|
||||
```
|
||||
Usage (arguments):
|
||||
-b, --backup backup mode
|
||||
-f, --flash flash mode
|
||||
-p, --partition name of the partition to be backed up
|
||||
-l, --logical know that the partition that will be backed up is logical
|
||||
-o, --out (only backups) the output name of the backed-up partition (default: partition name)
|
||||
-d, --outdir (only backups) directory where the backup partition will be saved (default: /storage/emulated/0)
|
||||
-c, --context it is meant to specify a custom /dev context. Only classic partitions (default: /dev/block/by-name)
|
||||
-D, --list list partitions
|
||||
-v, --version see version
|
||||
-h, --help see help message
|
||||
-L, --license see license
|
||||
Usage: pmt backup PARTITION [OUTPUT] [OPTIONS]...
|
||||
or: pmt flash PARTITION FILE [OPTIONS]...
|
||||
or: pmt format PARTITION FILE_SYSTEM[ext/2/3/4] [OPTIONS]...
|
||||
|
||||
Example 1:
|
||||
-b --partition boot_a -o boot_slot_a_image -d /sdcard/backup -c /dev/block/platform/bootdevice/by-name
|
||||
Options:
|
||||
-l, --logical It is meant to determine whether the target partition is logical.
|
||||
-c, --context It is meant to specify a custom /dev context. Only classic partitions (default: /dev/block/by-name).
|
||||
-p, --list List partitions.
|
||||
-s, --silent Information and warning messages are silenced in normal work.
|
||||
-f, --force Force mode. Some things are ignored.
|
||||
-S, --set-lang Set current language.
|
||||
-v, --version See version.
|
||||
--help See this help message.
|
||||
|
||||
Example 2:
|
||||
--flash /sdcard/twrp/boot.img -p boot_a -c /dev/block/platform/bootdevice/by-name
|
||||
Examples:
|
||||
pmt backup boot_a -c /dev/block/platform/bootdevice/by-name
|
||||
pmt flash boot_a /sdcard/twrp/boot.img -c /dev/block/platform/bootdevice/by-name
|
||||
pmt format system_a ext4 --logical
|
||||
pmt -c /dev/block/platform/bootdevice/by-name --list
|
||||
|
||||
Example 3:
|
||||
-c /dev/block/platform/bootdevice/by-name --list
|
||||
|
||||
Report bugs to <xda-@YZBruh>
|
||||
Report bugs to <t.me/ShawkTeam | Topics | pmt>
|
||||
```
|
||||
|
||||
#### Some notes
|
||||
|
||||
- pmt supports multiple languages. [See languages.](https://github.com/ShawkTeam/pmt/blob/2.7.0/LANGUAGES.md)
|
||||
- [Add language.](https://github.com/ShawkTeam/pmt/blob/2.7.0/ADD-LANGUAGES.md)
|
||||
- Feel free to ask any questions you want.
|
||||
- Packages are available in publications.
|
||||
- İt is mandatory to use the `-b` | `--backup` or `-f` | `--flash` and `-p` | `--partition` argument. After all, a partition name and progress type is required to be progress.
|
||||
- If the logical partition flag is not used, a classic partition is tried to be processing by default.
|
||||
- [Click to see special version changes](https://github.com/YZBruh/pbt/blob/1.5.0-en/CHANGELOG.md)
|
||||
- Let me know your suggestions!
|
||||
- [Click to see special version changes.](https://github.com/ShawkTeam/pmt/blob/2.7.0/CHANGELOG.md)
|
||||
- We are always open to your suggestions and support (developing)!
|
||||
|
||||
### How is it built?
|
||||
Even termux is enough to build the pmt. Or you can compile it with linux if you want. NOTE: Use a custom gcc according to the architecture you want to compile.
|
||||
Make or Android NDK is required to build.
|
||||
|
||||
If you want to change something, take a look at the configuration. You can change him.
|
||||
it is located in the `mka` folder. His name is `config.mk`. I gave the information in the file. You can ask more.
|
||||
##### Build with NDK
|
||||
- [Download Android NDK](https://developer.android.com/ndk/downloads) and extract the NDK package.
|
||||
- Clone this repository. And get access to it.
|
||||
```
|
||||
git clone https://github.com/ShawkTeam/pmt -b 2.7.0
|
||||
cd pmt
|
||||
```
|
||||
- Set the NDK working directory variable.
|
||||
```
|
||||
make gen-ndk-makefiles
|
||||
# If you fail the audit, etc., use FORCE_GEN.
|
||||
# Example:
|
||||
make gen-ndk-makefiles FORCE_GEN=true
|
||||
|
||||
# Required by Android NDK
|
||||
export NDK_PROJECT_PATH="${PWD}"
|
||||
```
|
||||
- Go to the NDK directory and start the build
|
||||
```
|
||||
# Required for creating clang version information and directory access
|
||||
export NDK_ROOT_DIR="${PWD}"
|
||||
cd "${NDK_PROJECT_PATH}" \
|
||||
&& bash build/bash/gen-header \
|
||||
&& cd "${NDK_ROOT_DIR}"
|
||||
|
||||
# Start build
|
||||
./ndk-build
|
||||
```
|
||||
- The output files will be inside the `pmt` folder. Binaries are available in two architectures within the `libs` folder. `arm64-v8a` (64-bit) and `armeabi-v7a` (32-bit).
|
||||
```
|
||||
pmt/
|
||||
|
|
||||
________________|________________
|
||||
| | | |
|
||||
jni/ build/ obj/ libs/
|
||||
|
|
||||
__________|__________
|
||||
| |
|
||||
arm64-v8a/ armeabi-v7a/
|
||||
| |
|
||||
pmt pmt
|
||||
```
|
||||
|
||||
##### Build with Makefiles
|
||||
|
||||
To build;
|
||||
```
|
||||
make
|
||||
|
||||
# To specify clang, just use CC=<clang> next to the command (and same logic in AR)
|
||||
# Example:
|
||||
make CC=${PWD}/../toolchain/bin/clang-18
|
||||
make AR=${PWD}/../toolchain/bin/ar
|
||||
make CC=${PWD}/../toolchain/bin/clang-18 AR=${PWD}/../toolchain/bin/ar
|
||||
|
||||
# Use termux :D
|
||||
```
|
||||
- For the make installable debian package:
|
||||
|
||||
```
|
||||
make deb <ARCH_NUM>
|
||||
|
||||
# Examples
|
||||
make deb FOR_THIS=64
|
||||
make deb FOR_THIS=32
|
||||
```
|
||||
|
||||
Special `make` commands (pbt offers :) ;
|
||||
```
|
||||
--------- Partition Manager help ---------
|
||||
|
||||
Commands;
|
||||
make ==> Build Partition Backupper
|
||||
make clean ==> Clear files (Builded binaries are not deleted)
|
||||
make clean-all ==> Clear files (Builded binaries are deleted)
|
||||
make install-termux ==> If you are using termux, it installs the compiled pbt into termux. So it allows you to use it like a normal command.
|
||||
make help ==> Display help message
|
||||
```
|
||||
|
||||
I compiled it with termux :D. Why should I bother... I compiled it with `GCC 17.0.6`. You can look at the version with the viewing option :)
|
||||
### Notes
|
||||
If you want to change something, take a look at the configuration. You can change him.
|
||||
it is located in the `build/config` folder. His name is `env.mk`. I gave the information in the file. You can ask more.
|
||||
|
||||
24
SETUP-DEBS.md
Executable file
24
SETUP-DEBS.md
Executable file
@@ -0,0 +1,24 @@
|
||||
### Installing pmt deb packages in Termux
|
||||
|
||||
It's pretty simple.
|
||||
|
||||
###### Package selection
|
||||
- If the device is 64 bit, you should choose `arm64-v8a` package. If not, choose `armeabi-v7a` package.
|
||||
- And of course download it.
|
||||
|
||||
###### Setup
|
||||
- Access downloads or wherever the package is located.
|
||||
```
|
||||
# Access downloads
|
||||
cd /sdcard/Download
|
||||
```
|
||||
- Now it's time to set up.
|
||||
```
|
||||
Syntax:
|
||||
apt install ./pmt-<VARIANT>.deb
|
||||
|
||||
Examples:
|
||||
apt install ./pmt-armeabi-v7a.deb
|
||||
apt install ./pmt-arm64-v8a.deb
|
||||
```
|
||||
- And enjoy!
|
||||
@@ -1,92 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "include/common.h"
|
||||
|
||||
/* By YZBruh */
|
||||
|
||||
/*
|
||||
* Copyright 2024 YZBruh - Partition Manager
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
extern char *out;
|
||||
extern char *outdir;
|
||||
extern char *cust_cxt;
|
||||
extern bool use_logical;
|
||||
extern bool use_cust_cxt;
|
||||
|
||||
/* backupper func */
|
||||
void backup(char *target_backup_partition, char *backup_partition_style)
|
||||
{
|
||||
static char backupper_path[200];
|
||||
if (strstr(backup_partition_style, "classic") != NULL) {
|
||||
if (use_cust_cxt) {
|
||||
sprintf(backupper_path, "%s/%s", cust_cxt, target_backup_partition);
|
||||
} else {
|
||||
sprintf(backupper_path, "/dev/block/by-name/%s", target_backup_partition);
|
||||
}
|
||||
} else if (strstr(backup_partition_style, "logical") != NULL) {
|
||||
sprintf(backupper_path, "/dev/block/mapper/%s", target_backup_partition);
|
||||
} else {
|
||||
error("İnvalid partition type!\n");
|
||||
}
|
||||
|
||||
if (access(backupper_path, F_OK) == -1) {
|
||||
error("Partition not found!\n");
|
||||
} else {
|
||||
printf("Target partition: %s\nBackupping...\n", target_backup_partition);
|
||||
}
|
||||
|
||||
static char backupper_cmd[256];
|
||||
if (outdir != NULL) {
|
||||
if (out != NULL) {
|
||||
sprintf(backupper_cmd, "dd if=%s of=%s/%s.img status=none", backupper_path, outdir, out);
|
||||
} else {
|
||||
sprintf(backupper_cmd, "dd if=%s of=%s/%s.img status=none", backupper_path, outdir, target_backup_partition);
|
||||
}
|
||||
} else {
|
||||
if (out != NULL) {
|
||||
sprintf(backupper_cmd, "dd if=%s of=/storage/emulated/0/%s.img status=none", backupper_path, out);
|
||||
} else {
|
||||
sprintf(backupper_cmd, "dd if=%s of=/storage/emulated/0/%s.img status=none", backupper_path, target_backup_partition);
|
||||
}
|
||||
}
|
||||
|
||||
if (system(backupper_cmd) != 0) {
|
||||
error("Failed!\n");
|
||||
} else {
|
||||
if (outdir != NULL) {
|
||||
if (out != NULL) {
|
||||
printf("%sSuccess. Output: %s/%s.img%s\n", ANSI_GREEN, outdir, out, ANSI_RESET);
|
||||
} else {
|
||||
printf("%sSuccess. Output: %s/%s.img%s\n", ANSI_GREEN, outdir, target_backup_partition, ANSI_RESET);
|
||||
}
|
||||
} else {
|
||||
if (out != NULL) {
|
||||
printf("%sSuccess. Output: /storage/emulated/0/%s.img%s\n", ANSI_GREEN, out, ANSI_RESET);
|
||||
} else {
|
||||
printf("%sSuccess. Output: /storage/emulated/0/%s.img%s\n", ANSI_GREEN, target_backup_partition, ANSI_RESET);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* end of code */
|
||||
@@ -1,70 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "include/common.h"
|
||||
|
||||
/* By YZBruh */
|
||||
|
||||
/*
|
||||
* Copyright 2024 YZBruh - Partition Manager
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
extern char *cust_cxt;
|
||||
extern bool use_cust_cxt;
|
||||
|
||||
/* flasher func */
|
||||
void flash(char *target_flash_partition, char *target_file, char *flash_partition_style)
|
||||
{
|
||||
static char flasher_path[200];
|
||||
/* determine device block */
|
||||
/* for classic */
|
||||
if (strstr(flash_partition_style, "classic") != NULL) {
|
||||
if (use_cust_cxt) {
|
||||
sprintf(flasher_path, "%s/%s", cust_cxt, target_flash_partition);
|
||||
} else {
|
||||
sprintf(flasher_path, "/dev/block/by-name/%s", target_flash_partition);
|
||||
}
|
||||
/* for logical */
|
||||
} else if (strstr(flash_partition_style, "logical") != NULL) {
|
||||
sprintf(flasher_path, "/dev/block/mapper/%s", target_flash_partition);
|
||||
} else {
|
||||
error("İnvalid partition type!\n");
|
||||
}
|
||||
|
||||
/* check partition */
|
||||
if (access(flasher_path, F_OK) == -1) {
|
||||
error("Partition not found!\n");
|
||||
} else {
|
||||
printf("Target partition: %s\nFlashing...\n", target_flash_partition);
|
||||
}
|
||||
|
||||
/* setting up */
|
||||
static char flasher_cmd[256];
|
||||
sprintf(flasher_cmd, "dd if=%s of=%s status=none", target_file, flasher_path);
|
||||
|
||||
/* start flash */
|
||||
if (system(flasher_cmd) != 0) {
|
||||
error("Failed!\n");
|
||||
} else {
|
||||
printf("%sSuccess.%s\n", ANSI_GREEN, ANSI_RESET);
|
||||
}
|
||||
}
|
||||
|
||||
/* end of code */
|
||||
@@ -1,52 +0,0 @@
|
||||
#define _COMMON_H_
|
||||
|
||||
/* By YZBruh */
|
||||
|
||||
/*
|
||||
* Copyright 2024 YZBruh - Partition Manager
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/* color definations */
|
||||
#define ANSI_RED "\033[31m"
|
||||
#define ANSI_YELLOW "\033[33m"
|
||||
#define ANSI_GREEN "\033[32m"
|
||||
#define ANSI_RESET "\033[0m"
|
||||
|
||||
/* info */
|
||||
#define PACK_VER "1.5.0"
|
||||
#define PACK_VER_CODE "150"
|
||||
#define PACK_NAME "Partition Manager"
|
||||
#define PACK_LANG "en"
|
||||
|
||||
/* variable definations */
|
||||
extern char *out;
|
||||
extern char *outdir;
|
||||
extern char *cust_cxt;
|
||||
extern char *target_partition;
|
||||
extern char *target_flash_file;
|
||||
extern bool use_logical;
|
||||
extern bool use_cust_cxt;
|
||||
extern bool pmt_ab;
|
||||
extern bool pmt_logical;
|
||||
extern bool pmt_flash;
|
||||
extern bool pmt_backup;
|
||||
|
||||
/* function definations */
|
||||
void listpart();
|
||||
void error(const char *err_msg);
|
||||
void check_psf();
|
||||
void check_root();
|
||||
void backup(char *target_backup_partition, char *backup_partition_style);
|
||||
void flash(char *target_flash_partition, char *target_file, char *flash_partition_style);
|
||||
@@ -1,57 +0,0 @@
|
||||
#define _DOCUMENTATION_H_
|
||||
|
||||
/* By YZBruh */
|
||||
|
||||
/*
|
||||
* Copyright 2024 YZBruh - Partition Manager
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
void licenses()
|
||||
{
|
||||
printf("Copyright 2024 YZBruh - Partition Manager\n");
|
||||
printf("Licensed under the Apache License, Version 2.0 (the \"License\");\n");
|
||||
printf("you may not use this file except in compliance with the License.\n");
|
||||
printf("You may obtain a copy of the License at\n\n");
|
||||
printf(" http://www.apache.org/licenses/LICENSE-2.0\n\n");
|
||||
printf("Unless required by applicable law or agreed to in writing, software\n");
|
||||
printf("distributed under the License is distributed on an \"AS IS\" BASIS,\n");
|
||||
printf("WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n");
|
||||
printf("See the License for the specific language governing permissions and limitations under the License.\n");
|
||||
}
|
||||
|
||||
void help()
|
||||
{
|
||||
printf("Usage (arguments): \n");
|
||||
printf(" -b, --backup backup mode\n");
|
||||
printf(" -f, --flash flash mode\n");
|
||||
printf(" -p, --partition name of the partition to be backed up\n");
|
||||
printf(" -l, --logical know that the partition that will be backed up is logical\n");
|
||||
printf(" -o, --out (only backups) the output name of the backed-up partition (default: partition name)\n");
|
||||
printf(" -d, --outdir (only backups) directory where the backup partition will be saved (default: /storage/emulated/0)\n");
|
||||
printf(" -c, --context it is meant to specify a custom /dev context. Only classic partitions (default: /dev/block/by-name)\n");
|
||||
printf(" -D, --list list partitions\n");
|
||||
printf(" -v, --version see version\n");
|
||||
printf(" -h, --help see help message\n");
|
||||
printf(" -L, --license see license\n\n");
|
||||
printf("Example 1:\n");
|
||||
printf(" -b --partition boot_a -o boot_slot_a_image -d /sdcard/backup -c /dev/block/platform/bootdevice/by-name\n\n");
|
||||
printf("Example 2:\n");
|
||||
printf(" --flash /sdcard/twrp/boot.img -p boot_a -c /dev/block/platform/bootdevice/by-name\n\n");
|
||||
printf("Example 3:\n");
|
||||
printf(" -c /dev/block/platform/bootdevice/by-name --list\n\n");
|
||||
printf("Report bugs to <xda-@YZBruh>\n");
|
||||
}
|
||||
|
||||
/* end of code */
|
||||
@@ -1,63 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "include/common.h"
|
||||
|
||||
/* By YZBruh */
|
||||
|
||||
/*
|
||||
* Copyright 2024 YZBruh - Partition Manager
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
extern char *cust_cxt;
|
||||
extern bool use_cust_cxt;
|
||||
extern bool pmt_ab;
|
||||
extern bool pmt_logical;
|
||||
|
||||
/* list existing partitions */
|
||||
void listpart() {
|
||||
if (use_cust_cxt) {
|
||||
printf("List of classic partitions (%s): \n", cust_cxt);
|
||||
static char cust_cxt_path[150];
|
||||
sprintf(cust_cxt_path, "ls %s", cust_cxt);
|
||||
if (system(cust_cxt_path) != 0) {
|
||||
error("An error occurred when the partition list appears!\n");
|
||||
}
|
||||
} else {
|
||||
printf("List of classic partitions (/dev/block/by-name): \n");
|
||||
if (system("ls /dev/block/by-name") != 0) {
|
||||
error("An error occurred when the classic partition list appears!\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (pmt_logical) {
|
||||
printf("List of logical partitions (/dev/block/mapper): \n");
|
||||
if (system("ls /dev/block/mapper") != 0) {
|
||||
error("An error occurred when the logical partition list appears!\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (pmt_ab) {
|
||||
printf("%sWarning: device using A/B partition style.%s\n", ANSI_YELLOW, ANSI_RESET);
|
||||
}
|
||||
|
||||
if (pmt_logical) {
|
||||
printf("%sWarning: device using logical partition type.%s\n", ANSI_YELLOW, ANSI_RESET);
|
||||
}
|
||||
}
|
||||
|
||||
/* end of code */
|
||||
239
binary/pmt.c
239
binary/pmt.c
@@ -1,239 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include <getopt.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "include/common.h"
|
||||
#include "include/documentation.h"
|
||||
|
||||
/* By YZBruh */
|
||||
|
||||
/*
|
||||
* Copyright 2024 YZBruh - Partition Manager
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
char *out = NULL;
|
||||
char *outdir = NULL;
|
||||
char *cust_cxt = NULL;
|
||||
char *target_partition = NULL;
|
||||
char *target_flash_file = NULL;
|
||||
bool use_logical = NULL;
|
||||
bool use_cust_cxt = NULL;
|
||||
bool pmt_ab = false;
|
||||
bool pmt_logical = false;
|
||||
bool pmt_flash = false;
|
||||
bool pmt_backup = false;
|
||||
|
||||
/* classic main function (C binary here xd) */
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
/* check argument total */
|
||||
if (argc < 2) {
|
||||
printf("Usage: %s [-b, --backup] [-f, --flash] [-p, --partition] [-l, --logical] [-f, --flash] [-o, --out] [-d, --outdir] [-D, --list] [-v, --version] [-h, --help] [-L, --license]\n", argv[0]);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* a structure for long arguments... */
|
||||
struct option long_options[] = {
|
||||
{"backup", no_argument, 0, 'b'},
|
||||
{"flash", required_argument, 0, 'f'},
|
||||
{"partition", required_argument, 0, 'p'},
|
||||
{"logical", no_argument, 0, 'l'},
|
||||
{"out", required_argument, 0, 'o'},
|
||||
{"outdir", required_argument, 0, 'd'},
|
||||
{"context", required_argument, 0, 'c'},
|
||||
{"list", no_argument, 0, 'D'},
|
||||
{"version", no_argument, 0, 'v'},
|
||||
{"help", no_argument, 0, 'h'},
|
||||
{"license", no_argument, 0, 'L'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
static char *opt_symbol = "-";
|
||||
static char *common_symbol_rule;
|
||||
common_symbol_rule = "When entering the attached argument of an option, an argument of another option type cannot be used. In short, the rule is: there can be no '-' at the beginning of the attached argument.\n";
|
||||
int opt;
|
||||
/* control for each argument */
|
||||
while ((opt = getopt_long(argc, argv, "bf:p:lo:d:c:DvhL", long_options, NULL)) != -1) {
|
||||
/* process arguments */
|
||||
switch (opt) {
|
||||
case 'b':
|
||||
pmt_backup = true;
|
||||
break;
|
||||
case 'f':
|
||||
target_flash_file = strdup(optarg);
|
||||
if (strncmp(target_flash_file, opt_symbol, 1) == 0) {
|
||||
error(common_symbol_rule);
|
||||
}
|
||||
pmt_flash = true;
|
||||
check_root();
|
||||
check_psf();
|
||||
struct stat flashf_info;
|
||||
if (stat(target_flash_file, &flashf_info) != 0) {
|
||||
fprintf(stderr, "%s: %s: no such file or directory.\n", argv[0], target_flash_file);
|
||||
exit(EXIT_FAILURE);
|
||||
} else {
|
||||
if (!S_ISREG(flashf_info.st_mode)) {
|
||||
fprintf(stderr, "%s: %s: is a not file.\n", argv[0], target_flash_file);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'p':
|
||||
target_partition = strdup(optarg);
|
||||
if (strncmp(target_partition, opt_symbol, 1) == 0) {
|
||||
error(common_symbol_rule);
|
||||
}
|
||||
break;
|
||||
case 'l':
|
||||
check_root();
|
||||
check_psf();
|
||||
if (pmt_logical) {
|
||||
use_logical = true;
|
||||
} else {
|
||||
error("This device does not have logical partitions!\n");
|
||||
}
|
||||
break;
|
||||
case 'o':
|
||||
out = strdup(optarg);
|
||||
if (strncmp(out, opt_symbol, 1) == 0) {
|
||||
error(common_symbol_rule);
|
||||
}
|
||||
break;
|
||||
case 'd':
|
||||
outdir = strdup(optarg);
|
||||
if (strncmp(outdir, opt_symbol, 1) == 0) {
|
||||
error(common_symbol_rule);
|
||||
}
|
||||
check_root();
|
||||
check_psf();
|
||||
struct stat out_info;
|
||||
if (stat(outdir, &out_info) != 0) {
|
||||
fprintf(stderr, "%s: %s: no such file or directory.\n", argv[0], outdir);
|
||||
exit(EXIT_FAILURE);
|
||||
} else {
|
||||
if (!S_ISDIR(out_info.st_mode)) {
|
||||
fprintf(stderr, "%s: %s: is a not directory.\n", argv[0], outdir);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'c':
|
||||
use_cust_cxt = true;
|
||||
cust_cxt = strdup(optarg);
|
||||
if (strncmp(cust_cxt, opt_symbol, 1) == 0) {
|
||||
error(common_symbol_rule);
|
||||
}
|
||||
break;
|
||||
case 'D':
|
||||
check_root();
|
||||
listpart();
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
case 'v':
|
||||
printf("Version: %s (code %s)\n", PACK_VER, PACK_VER_CODE);
|
||||
# ifdef __clang__
|
||||
printf("Compiler: clang %s", __clang_version__);
|
||||
# endif
|
||||
# ifdef __GNUC__
|
||||
printf("(GNUC %d.%d.%d)\n", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
|
||||
# else
|
||||
printf("\n");
|
||||
# endif
|
||||
printf("See licenses with -L argument.\n");
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
case 'h':
|
||||
help();
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
case 'L':
|
||||
licenses();
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
case '?':
|
||||
printf("Try `%s --help' for more information.\n", argv[0]);
|
||||
exit(EXIT_FAILURE);
|
||||
break;
|
||||
default:
|
||||
printf("Usage: %s [-b, --backup] [-f, --flash] [-p, --partition] [-l, --logical] [-f, --flash] [-o, --out] [-d, --outdir] [-D, --list] [-v, --version] [-h, --help] [-L, --license]\n", argv[0]);
|
||||
}
|
||||
}
|
||||
|
||||
/* minor checks */
|
||||
if (!pmt_backup && !pmt_flash) {
|
||||
fprintf(stderr, "%s: no target (backup or flash).\nTry `%s --help` for more information.\n", argv[0], argv[0]);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (pmt_backup && pmt_flash) {
|
||||
error("Backup and flash functions cannot be used in the same command\n");
|
||||
}
|
||||
|
||||
/* checks */
|
||||
check_root();
|
||||
check_psf();
|
||||
|
||||
/* custom context checker */
|
||||
if (use_cust_cxt) {
|
||||
struct stat cxtinfo;
|
||||
if (stat(cust_cxt, &cxtinfo) == 0) {
|
||||
if (S_ISDIR(cxtinfo.st_mode)) {
|
||||
/* empty */
|
||||
} else {
|
||||
fprintf(stderr, "%s: custom context: %s: is a not directory.\n", argv[0], cust_cxt);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
} else {
|
||||
error("The specified context was not found!\n");
|
||||
}
|
||||
if (strstr(cust_cxt, "/dev") == NULL) {
|
||||
printf("%sThis custom context is strange...%s\n", ANSI_YELLOW, ANSI_RESET);
|
||||
}
|
||||
}
|
||||
|
||||
if (target_partition == NULL) {
|
||||
fprintf(stderr, "%s: required partition name.\nTry `%s --help' for more information.\n", argv[0], argv[0]);
|
||||
exit(EXIT_FAILURE);
|
||||
} else {
|
||||
if (pmt_backup) {
|
||||
if (use_logical) {
|
||||
backup(target_partition, "logical");
|
||||
exit(EXIT_SUCCESS);
|
||||
} else {
|
||||
backup(target_partition, "classic");
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
} else if (pmt_flash) {
|
||||
if (use_logical) {
|
||||
flash(target_partition, target_flash_file, "logical");
|
||||
exit(EXIT_SUCCESS);
|
||||
} else {
|
||||
flash(target_partition, target_flash_file, "classic");
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "%s: no target (backup or flash).\nTry `%s --help` for more information.\n", argv[0], argv[0]);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* end of code */
|
||||
37
build/bash/check-makefiles
Executable file
37
build/bash/check-makefiles
Executable file
@@ -0,0 +1,37 @@
|
||||
# By YZBruh
|
||||
|
||||
# Copyright 2024 Partition Manager
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
[ ! "${THIS_IS}" = "main" ] \
|
||||
&& abort "The caller is not the main makefile. Something's wrong."
|
||||
|
||||
try_with="Try with force mode (FORCE_GEN=true)."
|
||||
|
||||
if [ "${NDK_PROG}" = "true" ]; then
|
||||
mfiles=("${SOURCE_DIR}/Android.mk" "${SOURCE_DIR}/Application.mk")
|
||||
else
|
||||
mfiles=("${OUT_DIR}/Makefile" "${SOURCE_DIR}/Makefile")
|
||||
fi
|
||||
|
||||
for mfile in ${mfiles[@]}; do
|
||||
|
||||
[ -f "${mfile}" ] && \
|
||||
if [ "${FORCE_GEN}" = "true" ]; then
|
||||
rm -f "${mfile}"
|
||||
else
|
||||
abort "$(output=$(dirname ${mfile}) && basename "${output}")/$(basename ${mfile}) exits."
|
||||
fi
|
||||
|
||||
done
|
||||
44
build/bash/clean-makefiles
Executable file
44
build/bash/clean-makefiles
Executable file
@@ -0,0 +1,44 @@
|
||||
# By YZBruh
|
||||
|
||||
# Copyright 2024 Partition Manager
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
. build/bash/vars
|
||||
. build/bash/functions
|
||||
|
||||
[ ! "${THIS_IS}" = "main" ] \
|
||||
&& abort "The caller is not the main makefile. Something's wrong."
|
||||
|
||||
if [ "${NDK_PROG}" = "true" ]; then
|
||||
|
||||
[ "${UPDATE_MAKEFILES}" = "true" ] \
|
||||
|| print " - Removing Android.mk..." \
|
||||
&& print " - Removing Application.mk..."
|
||||
|
||||
rm -f ${SOURCE_DIR}/Application.mk \
|
||||
${SOURCE_DIR}/Android.mk
|
||||
|
||||
else
|
||||
|
||||
[ "${UPDATE_MAKEFILES}" = "true" ] \
|
||||
|| print " - Info: Main makefile won't be deleted." \
|
||||
&& print " - Removing output directory makefile..." \
|
||||
&& print " - Removing source directory makefile..."
|
||||
|
||||
rm -f ${SOURCE_DIR}/Makefile \
|
||||
${OUT_DIR}/Makefile
|
||||
|
||||
fi
|
||||
|
||||
[ "${UPDATE_MAKEFILES}" = "true" ] || print " - Success."
|
||||
37
build/bash/functions
Executable file
37
build/bash/functions
Executable file
@@ -0,0 +1,37 @@
|
||||
# By YZBruh
|
||||
|
||||
# Copyright 2024 Partition Manager
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
function abort()
|
||||
{
|
||||
[ -n "${1}" ] \
|
||||
&& echo -e " - ${RED}${BOLD}Error:${BOLD_RESET}${RESET} ${1}"
|
||||
exit 1
|
||||
}
|
||||
|
||||
function read_file()
|
||||
{
|
||||
cat "${1}" >> "${2}" \
|
||||
|| abort "failed to read/write ${1}/${2}"
|
||||
}
|
||||
|
||||
function gen()
|
||||
{
|
||||
[ "${FORCE_GEN}" = "true" -a "${UPDATE_MAKEFILES}" = "true" ] \
|
||||
&& rm -f "${1}"
|
||||
touch "${1}" || abort "failed to generate: ${1}"
|
||||
}
|
||||
|
||||
function print() { echo -e "${1}"; }
|
||||
34
build/bash/gen-header
Executable file
34
build/bash/gen-header
Executable file
@@ -0,0 +1,34 @@
|
||||
# By YZBruh
|
||||
|
||||
# Copyright 2024 Partition Manager
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
[ -z ${NDK_ROOT_DIR} ] \
|
||||
&& echo "Please set NDK_ROOT_DIR variable!" \
|
||||
&& exit 1
|
||||
|
||||
[ -z ${NDK_PROJECT_PATH} ] \
|
||||
&& echo "Please set NDK_PROJECT_PATH variable!" \
|
||||
&& exit 1
|
||||
|
||||
CC_IS="${NDK_ROOT_DIR}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang"
|
||||
CC_VERS=$(${CC_IS} --version | head -n 1)
|
||||
HEADER="${NDK_PROJECT_PATH}/include/pmt/generated/clang-version.h
|
||||
|
||||
mkdir -p "${NDK_PROJECT_PATH}/include/pmt/generated"
|
||||
touch "${HEADER}"
|
||||
echo "/*" >> "${HEADER}"
|
||||
cat "${NDK_PROJECT_PATH}/NOTICE" >> "${HEADER}"
|
||||
echo -e "\n *\n*/" >> "${HEADER}"
|
||||
echo -e "\n\n#define __NDK_CC_VERSION__ \"${CC_VERS}\"" >> "${HEADER}"
|
||||
66
build/bash/gen-makefiles
Executable file
66
build/bash/gen-makefiles
Executable file
@@ -0,0 +1,66 @@
|
||||
# By YZBruh
|
||||
|
||||
# Copyright 2024 Partition Manager
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
. build/bash/vars
|
||||
. build/bash/functions
|
||||
|
||||
[ ! "${UPDATE_MAKEFILES}" = "true" ] \
|
||||
&& . build/bash/check-makefiles
|
||||
[ ! "${THIS_IS}" = "main" ] \
|
||||
&& abort "The caller is not the main makefile. Something's wrong."
|
||||
|
||||
if [ "${UPDATE_MAKEFILES}" = "true" ]; then
|
||||
GENR="Re-generating"
|
||||
else
|
||||
GENR="Generating"
|
||||
fi
|
||||
|
||||
if [ "${NDK_PROG}" = "true" ]; then
|
||||
|
||||
gen "${SOURCE_DIR}/Android.mk"
|
||||
gen "${SOURCE_DIR}/Application.mk"
|
||||
|
||||
else
|
||||
|
||||
gen "${CUR_DIR}/Makefile"
|
||||
gen "${OUT_DIR}/Makefile"
|
||||
gen "${SOURCE_DIR}/Makefile"
|
||||
|
||||
fi
|
||||
|
||||
if [ "${NDK_PROG}" = "true" ]; then
|
||||
|
||||
print " - ${GENR} Android.mk..."
|
||||
read_file "${OTHERS}/makefile.androidmk" "${SOURCE_DIR}/Android.mk"
|
||||
|
||||
print " - ${GENR} Application.mk"
|
||||
read_file "${OTHERS}/makefile.applicationmk" "${SOURCE_DIR}/Application.mk"
|
||||
|
||||
else
|
||||
|
||||
print " - Re-generating main makefile..."
|
||||
rm -f "${CUR_DIR}/Makefile"
|
||||
read_file "${OTHERS}/makefile.main" "${CUR_DIR}/Makefile"
|
||||
|
||||
print " - ${GENR} output directory makefile..."
|
||||
read_file "${OTHERS}/makefile.outdir" "${OUT_DIR}/Makefile"
|
||||
|
||||
print " - ${GENR} source directory makefile..."
|
||||
read_file "${OTHERS}/makefile.sourcedir" "${SOURCE_DIR}/Makefile"
|
||||
|
||||
fi
|
||||
|
||||
print " - Success."
|
||||
33
build/bash/vars
Executable file
33
build/bash/vars
Executable file
@@ -0,0 +1,33 @@
|
||||
# By YZBruh
|
||||
|
||||
# Copyright 2024 Partition Manager
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
. build/bash/additional-vars
|
||||
|
||||
CUR_DIR=$(pwd)
|
||||
SOURCE_DIR=${CUR_DIR}/${SOURCE_DIRNAME}
|
||||
OUT_DIR=${CUR_DIR}/${OUT_DIRNAME}
|
||||
BUILD=${CUR_DIR}/build
|
||||
BASH_DIR=$(pwd)
|
||||
OTHERS=${BUILD}/others
|
||||
TOOLS=${BUILD}/tools
|
||||
|
||||
# font types, colors etc
|
||||
BOLD="\e[1m"
|
||||
BOLD_RESET="\e[0m"
|
||||
RESET="\033[0m"
|
||||
RED="\033[0;31m"
|
||||
GREEN="\033[0;32m"
|
||||
YELLOW="\033[0;33m"
|
||||
1
build/config/INS_STAT.mk
Executable file
1
build/config/INS_STAT.mk
Executable file
@@ -0,0 +1 @@
|
||||
INSTALL_SUCCESS := true
|
||||
52
build/config/Makefile
Executable file
52
build/config/Makefile
Executable file
@@ -0,0 +1,52 @@
|
||||
# By YZBruh
|
||||
|
||||
# Copyright 2024 Partition Manager
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
include env.mk
|
||||
|
||||
#########################################
|
||||
# #
|
||||
# Apply Configuration #
|
||||
# #
|
||||
# Warning: please do not edit #
|
||||
# #
|
||||
#########################################
|
||||
|
||||
CC = clang
|
||||
CFLAGS ?= "-O3 -I../include -std=c11 -pedantic -Wall -Wextra -Werror -Wno-nullability-extension -Wno-gnu-zero-variadic-macro-arguments $(PMT_EXTRA_CFLAGS)"
|
||||
|
||||
# set compiler setting (clang-gcc and ar)
|
||||
ifneq ($(PMT_CC),)
|
||||
CC ?= $(PMT_CC)
|
||||
else
|
||||
CC ?= clang
|
||||
endif
|
||||
|
||||
ifneq ($(PMT_AR),)
|
||||
AR ?= $(PMT_AR)
|
||||
else
|
||||
AR ?= ar
|
||||
endif
|
||||
|
||||
# compiler flags settings
|
||||
ifneq ($(PMT_ENABLE_DEBUG),)
|
||||
CFLAGS += -gdwarf-5 -fsanitize=address
|
||||
endif
|
||||
|
||||
# write current env configuration to oldenv.mk
|
||||
all:
|
||||
@ echo "CC := $(CC)" > oldenv.mk
|
||||
@ echo "AR := $(AR)" >> oldenv.mk
|
||||
@ echo "CFLAGS := $(CFLAGS)" >> oldenv.mk
|
||||
1
build/config/UNINS_STAT.mk
Executable file
1
build/config/UNINS_STAT.mk
Executable file
@@ -0,0 +1 @@
|
||||
UNINSTALLED_SUCCESS :=
|
||||
38
build/config/env.mk
Executable file
38
build/config/env.mk
Executable file
@@ -0,0 +1,38 @@
|
||||
# By YZBruh
|
||||
|
||||
# Copyright 2024 Partition Manager
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
#########################################
|
||||
# #
|
||||
# Configuration Flags #
|
||||
# #
|
||||
# Warning: you can edit #
|
||||
# #
|
||||
#########################################
|
||||
|
||||
# speficy c compiler (cc)
|
||||
PMT_CC ?=
|
||||
|
||||
# speficy ar
|
||||
PMT_AR ?=
|
||||
|
||||
# addionital compiler flags
|
||||
PMT_EXTRA_CFLAGS ?=
|
||||
|
||||
# debugging mode (binary). it's enabling address sanitizer and source level debug information with dwarf version 5
|
||||
PMT_ENABLE_DEBUG ?=
|
||||
|
||||
#########################################
|
||||
#########################################
|
||||
9
build/deb/DEBIAN/control_32
Executable file
9
build/deb/DEBIAN/control_32
Executable file
@@ -0,0 +1,9 @@
|
||||
Source: pmt
|
||||
Package: pmt
|
||||
Version: 2.6.0
|
||||
Architecture: arm
|
||||
Description: pmt is for reading, writing and formatting partitions of android devices
|
||||
Section: misc
|
||||
Priority: optional
|
||||
Maintainer: YZBruh <yagizzengin73@gmail.com>
|
||||
Standards-Version: 4.5.0
|
||||
9
build/deb/DEBIAN/control_64
Executable file
9
build/deb/DEBIAN/control_64
Executable file
@@ -0,0 +1,9 @@
|
||||
Source: pmt
|
||||
Package: pmt
|
||||
Version: 2.6.0
|
||||
Architecture: aarch64
|
||||
Description: pmt is for reading, writing and formatting partitions of android devices
|
||||
Section: misc
|
||||
Priority: optional
|
||||
Maintainer: YZBruh <yagizzengin73@gmail.com>
|
||||
Standards-Version: 4.5.0
|
||||
0
build/deb/data/data/com.termux/files/usr/bin/dummy
Executable file
0
build/deb/data/data/com.termux/files/usr/bin/dummy
Executable file
0
build/deb/data/data/com.termux/files/usr/share/man/man8/dummy
Executable file
0
build/deb/data/data/com.termux/files/usr/share/man/man8/dummy
Executable file
99
build/deb/deb.mk
Executable file
99
build/deb/deb.mk
Executable file
@@ -0,0 +1,99 @@
|
||||
# By YZBruh
|
||||
|
||||
# Copyright 2024 Partition Manager
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
#####
|
||||
# sub-make for making deb package
|
||||
#####
|
||||
|
||||
THIS_IS := debutils
|
||||
|
||||
# include needed variables
|
||||
include ../../Makefile.inc
|
||||
|
||||
TEMP_DIR := $(DEBUTILS_DIR)/template
|
||||
|
||||
ifeq ($(FOR_THIS),64)
|
||||
DEB_ARCH_NAME := arm64-v8a
|
||||
else ifeq ($(FOR_THIS),32)
|
||||
DEB_ARCH_NAME := armeabi-v7a
|
||||
endif
|
||||
|
||||
ifneq ($(wildcard /dev/block/by-name),)
|
||||
SUDO := su -c
|
||||
else ifeq ($(wildcard /system/build.prop),)
|
||||
SUDO := sudo
|
||||
else
|
||||
SUDO :=
|
||||
endif
|
||||
|
||||
PROGRESS_LIST := \
|
||||
startup \
|
||||
$(DEB_CHECKS) \
|
||||
check_binary \
|
||||
prepare \
|
||||
make_debian_pack
|
||||
|
||||
# make deb package
|
||||
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 \
|
||||
$(E_NS) " - Invalid arch number: $(FOR_THIS) [maybe null]" && abort; \
|
||||
fi; \
|
||||
$(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; \
|
||||
$(E_NS) " - Starting dpkg-deb..."; \
|
||||
sleep 2; \
|
||||
$(SUDO) chmod -R 755 *; \
|
||||
dpkg-deb -b $(TEMP_DIR) $(DEB_DIR)/$(TARGET)-$(DEB_ARCH_NAME).deb || abort; \
|
||||
rm -rf $(TEMP_DIR); \
|
||||
$(E_NS) " - Done!"
|
||||
|
||||
$(DEBUTILS_DIR)/%:
|
||||
@ [ ! -e "$@" ] && $(E_NS) " - Check failed! Not found: $@" && exit 1
|
||||
|
||||
# end
|
||||
BIN
build/deb/mandoc/pmt.8.gz
Executable file
BIN
build/deb/mandoc/pmt.8.gz
Executable file
Binary file not shown.
130
build/main.mk
Executable file
130
build/main.mk
Executable file
@@ -0,0 +1,130 @@
|
||||
# By YZBruh
|
||||
|
||||
# Copyright 2024 Partition Manager
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
UPDATE_MAKEFILES = false
|
||||
CLS_ADTS := rm -f $(BUILD)/bash/additional-vars
|
||||
|
||||
all:
|
||||
$(MAKE_HIDE) $(SILENT) -C $(BUILD)/config || exit 1
|
||||
$(MAKE_HIDE) $(SILENT) -C $(SOURCE_DIRNAME) INC_OLDENV=true || exit 1
|
||||
|
||||
# cleaner functions
|
||||
.PHONY: clean
|
||||
clean:
|
||||
$(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
|
||||
@ sleep 1
|
||||
$(E) "Success."
|
||||
|
||||
# helper function
|
||||
.PHONY: help
|
||||
help:
|
||||
$(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
|
||||
$(P) ""
|
||||
|
||||
# install pmt in to termux
|
||||
.PHONY: install
|
||||
install:
|
||||
$(eval PROG := $@)
|
||||
$(MAKE_HIDE) $(SILENT) -C $(OUT_DIRNAME) install PROG=$(PROG) || exit 1
|
||||
|
||||
# uninstall pmt in to termux
|
||||
.PHONY: uninstall
|
||||
uninstall:
|
||||
$(eval PROG := $@)
|
||||
$(MAKE_HIDE) $(SILENT) -C $(OUT_DIRNAME) uninstall PROG=$(PROG) || exit 1
|
||||
|
||||
# clean ndk makefiles
|
||||
.PHONY: gen-ndk-makefiles
|
||||
gen-ndk-makefiles:
|
||||
$(eval NDK_PROG = true)
|
||||
$(call save-gen-vars)
|
||||
$(call gen-ndk-mfiles)
|
||||
@ $(CLS_ADTS)
|
||||
|
||||
.PHONY: gen-makefiles
|
||||
gen-makefiles:
|
||||
$(call save-gen-vars)
|
||||
$(call gen-mfiles)
|
||||
@ $(CLS_ADTS)
|
||||
|
||||
.PHONY: update-ndk-makefiles
|
||||
update-ndk-makefiles:
|
||||
$(E) " ------ Updating NDK makefiles ------ "
|
||||
$(eval NDK_PROG = true)
|
||||
$(eval UPDATE_MAKEFILES = true)
|
||||
$(call save-gen-vars)
|
||||
$(call clean-ndk-mfiles)
|
||||
$(call gen-ndk-mfiles)
|
||||
@ $(CLS_ADTS)
|
||||
|
||||
.PHONY: update-makefiles
|
||||
update-makefiles:
|
||||
$(E) " ------ Updating makefiles ------ "
|
||||
$(eval UPDATE_MAKEFILES = true)
|
||||
$(call save-gen-vars)
|
||||
$(call clean-ndk-mfiles)
|
||||
$(call gen-mfiles)
|
||||
@ $(CLS_ADTS)
|
||||
|
||||
.PHONY: clean-ndk-makefiles
|
||||
clean-ndk-makefiles:
|
||||
$(eval NDK_PROG = true)
|
||||
$(call save-gen-vars)
|
||||
$(call clean-ndk-mfiles)
|
||||
@ $(CLS_ADTS)
|
||||
|
||||
.PHONY: clean-makefiles
|
||||
clean-makefiles:
|
||||
$(call save-gen-vars)
|
||||
$(call clean-mfiles)
|
||||
@ $(CLS_ADTS)
|
||||
|
||||
# end
|
||||
98
build/others/makefile.androidmk
Executable file
98
build/others/makefile.androidmk
Executable file
@@ -0,0 +1,98 @@
|
||||
# By YZBruh
|
||||
|
||||
# Copyright 2024 Partition Manager
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
########
|
||||
# 2.7.0
|
||||
########
|
||||
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(LOCAL_PATH)/../build/config/env.mk
|
||||
|
||||
PMT_CFLAGS = \
|
||||
-O3 \
|
||||
-std=c11 \
|
||||
-pedantic \
|
||||
-Wall \
|
||||
-Wextra \
|
||||
-Werror \
|
||||
-Wno-nullability-extension \
|
||||
-Wno-gnu-zero-variadic-macro-arguments \
|
||||
-D__NDK_BUILD \
|
||||
$(EXTRA_COMPILER_FLAGS)
|
||||
|
||||
ifneq ($(PMT_ENABLE_DEBUG),)
|
||||
PMT_CFLAGS += -gdwarf-5 -fsanitize=address -fsanitize=undefined
|
||||
endif
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := libpmt_root
|
||||
LOCAL_SRC_FILES := root.c
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include
|
||||
LOCAL_CFLAGS := $(PMT_CFLAGS)
|
||||
|
||||
include $(BUILD_STATIC_LIBRARY)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := libpmt_debug
|
||||
LOCAL_SRC_FILES := debug.c
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include
|
||||
LOCAL_CFLAGS := $(PMT_CFLAGS)
|
||||
|
||||
include $(BUILD_STATIC_LIBRARY)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := libpmt_partitiontool
|
||||
LOCAL_SRC_FILES := partitiontool.c
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include
|
||||
LOCAL_CFLAGS := $(PMT_CFLAGS)
|
||||
|
||||
include $(BUILD_STATIC_LIBRARY)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := libpmt_list
|
||||
LOCAL_SRC_FILES := listpart.c
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include
|
||||
LOCAL_CFLAGS := $(PMT_CFLAGS)
|
||||
|
||||
include $(BUILD_STATIC_LIBRARY)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := pmt
|
||||
LOCAL_SRC_FILES := \
|
||||
pmt.c \
|
||||
version.c \
|
||||
get_stat.c \
|
||||
tools.c \
|
||||
lang_tools.c \
|
||||
languages.c \
|
||||
help.c
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include
|
||||
LOCAL_STATIC_LIBRARIES := \
|
||||
libpmt_root \
|
||||
libpmt_debug \
|
||||
libpmt_partitiontool \
|
||||
libpmt_list
|
||||
LOCAL_CFLAGS := $(PMT_CFLAGS)
|
||||
|
||||
include $(BUILD_EXECUTABLE)
|
||||
|
||||
# end
|
||||
21
mka/config.mk → build/others/makefile.applicationmk
Normal file → Executable file
21
mka/config.mk → build/others/makefile.applicationmk
Normal file → Executable file
@@ -1,6 +1,6 @@
|
||||
# By YZBruh
|
||||
|
||||
# Copyright 2024 YZBruh - Partition Manager
|
||||
# Copyright 2024 Partition Manager
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -14,16 +14,17 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# use custom gcc | true or false
|
||||
USE_CUST_GCC := false
|
||||
########
|
||||
# 2.7.0
|
||||
########
|
||||
|
||||
# custom gcc ext (if used)
|
||||
CUST_GCC :=
|
||||
# architecture
|
||||
APP_ABI := \
|
||||
arm64-v8a \
|
||||
armeabi-v7a
|
||||
|
||||
# addionital gcc flags
|
||||
EXTRA_GCC_FLAGS :=
|
||||
APP_PLATFORM := android-21
|
||||
|
||||
# apply configration
|
||||
include mka/apply-config.mk
|
||||
APP_OPTIM := release
|
||||
|
||||
# end of config
|
||||
# end
|
||||
26
build/others/makefile.main
Executable file
26
build/others/makefile.main
Executable file
@@ -0,0 +1,26 @@
|
||||
# By YZBruh
|
||||
|
||||
# Copyright 2024 Partition Manager
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
THIS_IS = main
|
||||
NDK_PROG ?= false
|
||||
FORCE_GEN ?= false
|
||||
|
||||
# include needed variables
|
||||
include Makefile.inc
|
||||
include $(TOOLS)/gen-makefiles.mk
|
||||
include $(TOOLS)/clean-makefiles.mk
|
||||
|
||||
include $(BUILD)/main.mk
|
||||
151
build/others/makefile.outdir
Executable file
151
build/others/makefile.outdir
Executable file
@@ -0,0 +1,151 @@
|
||||
# By YZBruh
|
||||
|
||||
# Copyright 2024 Partition Manager
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
#####
|
||||
# sub-make for installing-uninstalling
|
||||
#####
|
||||
|
||||
THIS_IS := out
|
||||
|
||||
# include needed variables
|
||||
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:
|
||||
$(P) ""
|
||||
|
||||
# installer
|
||||
.PHONY: install
|
||||
install: $(INSTALL_PROGRESS_LIST)
|
||||
|
||||
# uninstaller
|
||||
.PHONY: uninstall
|
||||
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 \
|
||||
$(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
|
||||
|
||||
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
|
||||
182
build/others/makefile.sourcedir
Executable file
182
build/others/makefile.sourcedir
Executable file
@@ -0,0 +1,182 @@
|
||||
# By YZBruh
|
||||
|
||||
# Copyright 2024 Partition Manager
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
#####
|
||||
# sub-make for building package
|
||||
#####
|
||||
|
||||
THIS_IS = src
|
||||
|
||||
include ../Makefile.inc
|
||||
|
||||
ifeq ($(INC_OLDENV),true)
|
||||
include $(BUILD)/config/oldenv.mk
|
||||
endif
|
||||
|
||||
INCLUDE_DIR := $(realpath ../include)
|
||||
PMT_INCDIR := $(INCLUDE_DIR)/pmt
|
||||
|
||||
# the presence of all source files that are on this list will be checked
|
||||
SRCS_REQ := \
|
||||
place-holder/debug.c \
|
||||
place-holder/help.c \
|
||||
place-holder/get_stat.c \
|
||||
place-holder/lang_tools.c \
|
||||
place-holder/languages.c \
|
||||
place-holder/partitiontool.c \
|
||||
place-holder/pmt.c \
|
||||
place-holder/root.c \
|
||||
place-holder/tools.c \
|
||||
place-holder/version.c
|
||||
|
||||
# objects to be used when executable file is created
|
||||
OBJS_EXEC := \
|
||||
$(SOURCE_DIR)/$(TARGET).o \
|
||||
$(SOURCE_DIR)/help.o \
|
||||
$(SOURCE_DIR)/version.o \
|
||||
$(SOURCE_DIR)/get_stat.o \
|
||||
$(SOURCE_DIR)/tools.o \
|
||||
$(SOURCE_DIR)/lang_tools.o \
|
||||
$(SOURCE_DIR)/languages.o
|
||||
|
||||
HEADERS_REQ := \
|
||||
$(PMT_INCDIR)/pmt/ExternC.h \
|
||||
$(PMT_INCDIR)/pmt/Deprecates.h \
|
||||
$(PMT_INCDIR)/pmt/HelpMessages.h \
|
||||
$(PMT_INCDIR)/pmt/pmt.h \
|
||||
$(PMT_INCDIR)/pmt/StringKeys.h \
|
||||
$(PMT_INCDIR)/pmt/VersionVars.h
|
||||
|
||||
PROGRESS_LIST := \
|
||||
welcome \
|
||||
wait \
|
||||
$(SRCS_REQ) \
|
||||
$(HEADERS_REQ) \
|
||||
pr_obj \
|
||||
$(OBJS) \
|
||||
make_outdirs \
|
||||
pr_sts \
|
||||
$(STATIC_LIBS) \
|
||||
make_executable \
|
||||
wait \
|
||||
end_progress
|
||||
|
||||
define check_hf
|
||||
@ [ ! -f "$1" ] \
|
||||
&& $(E_NS) " ==> Couldn't found required header file: include/pmt/`basename $1`" \
|
||||
&& exit 1
|
||||
endef
|
||||
|
||||
# all target for building
|
||||
all: $(PROGRESS_LIST)
|
||||
|
||||
welcome:
|
||||
@ rm -f $(BUILD)/config/oldenv.mk
|
||||
@ echo " ---- Partition Manager Builder ---- " \
|
||||
&& $(E_NS)
|
||||
$(E) " - Version: $(VERSION)"
|
||||
$(E) " - Version code: $(VERSION_CODE)" \
|
||||
&& $(E_NS)
|
||||
$(E) " -------------------------------- " \
|
||||
&& $(E_NS)
|
||||
@ if [ -f $(SOURCE_DIR)/debug.o ]; then \
|
||||
$(E_NS) " - Please clean up before you build it." && echo; \
|
||||
$(E_NS) " ----------------------------------- "; \
|
||||
exit 1; \
|
||||
fi
|
||||
$(E) " - Checking required source files..."
|
||||
|
||||
pr_obj:
|
||||
$(E) " - Building objects..."
|
||||
|
||||
pr_sts:
|
||||
$(E) " - Making static libraries..."
|
||||
|
||||
wait:
|
||||
@ sleep 2
|
||||
|
||||
make_outdirs:
|
||||
@ rm -rf $(IN_OUT_DIR)
|
||||
@ mkdir $(BINARY_DIR)
|
||||
@ mkdir $(PACKAGE_DIR)
|
||||
@ mkdir $(STATICLIB_DIR)
|
||||
|
||||
place-holder/%.c:
|
||||
$(E) " CHK $(SOURCE_DIRNAME)/`basename $@`"
|
||||
@ if [ ! -f "$(SOURCE_DIR)/`basename $@`" ]; then \
|
||||
$(E_NS) " ==> Couldn't found required source file: $(SOURCE_DIRNAME)/`basename $@`"; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
$(PMT_INCDIR)/%.h:
|
||||
$(E) " CHK include/pmt/`basename $@`"
|
||||
@ if [ ! -f "$(INCLUDE_DIR)/pmt/`basename $@`" ]; then \
|
||||
$(E_NS) " ==> Couldn't found required header file: include/pmt/`basename $@`"; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
$(SOURCE_DIR)/%.o: $(SOURCE_DIR)/%.c
|
||||
$(E) " CC $(SOURCE_DIRNAME)/`basename $@`"
|
||||
@ $(CC) $(CFLAGS) -c "$<" || exit 1
|
||||
|
||||
$(TARGET)_%:
|
||||
$(E) " AR lib$@.a"
|
||||
@ $(AR) rcs "lib$@.a" "$(SOURCE_DIR)/$$(echo "$@" | cut -d'_' -f2).o"
|
||||
|
||||
make_executable:
|
||||
$(E) " - Making executable file..."
|
||||
$(E) " LD $(TARGET)"
|
||||
@ $(CC) $(CFLAGS) -L$(SOURCE_DIR) $(foreach st,$(STATIC_LIBS),$(shell echo -n -l$(st) )) -o $(TARGET) $(OBJS_EXEC) || exit 1
|
||||
|
||||
end_progress:
|
||||
@ abort_build() { \
|
||||
[ -d "$(PACKAGE_DIR)" ] \
|
||||
&& rm -rf "$(PACKAGE_DIR)"; \
|
||||
[ -d "$(BINARY_DIR)" ] \
|
||||
&& rm -rf "$(BINARY_DIR)"; \
|
||||
[ -d "$(STATICLIB_DIR)" ] \
|
||||
&& rm -rf "$(STATICLIB_DIR)"; \
|
||||
exit 1; \
|
||||
}; \
|
||||
mv $(TARGET) $(BINARY_DIR) || abort_build; \
|
||||
mv *.a $(STATICLIB_DIR) || abort_build; \
|
||||
$(E_NS) " - Generating package..."; \
|
||||
cp $(BINARY_DIR)/$(TARGET) $(PACKAGE_DIR) || abort_build; \
|
||||
$(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
|
||||
$(E) " - Success" && $(E_NS)
|
||||
@ sleep 1
|
||||
$(E) " ----------------------------------- "
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
$(eval STATICLIBS = $(wildcard $(SOURCE_DIR)/*.a))
|
||||
$(eval OBJS = $(wildcard $(SOURCE_DIR)/*.o))
|
||||
$(info Cleaning files...)
|
||||
$(foreach obj, \
|
||||
$(OBJS), \
|
||||
$(call m_stat_nn,$(SOURCE_DIRNAME)/$(shell basename $(obj))) \
|
||||
$(call erase,$(obj)) \
|
||||
)
|
||||
$(foreach lib, \
|
||||
$(STATICLIBS), \
|
||||
$(call m_stat_nn,$(SOURCE_DIRNAME)/$(shell basename $(lib))) \
|
||||
$(call erase,$(lib)) \
|
||||
)
|
||||
|
||||
# end
|
||||
31
build/tools/clean-makefiles.mk
Executable file
31
build/tools/clean-makefiles.mk
Executable file
@@ -0,0 +1,31 @@
|
||||
# By YZBruh
|
||||
|
||||
# Copyright 2024 Partition Manager
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
##################
|
||||
# See "erase" funtion for build/util/utils.mk
|
||||
##################
|
||||
|
||||
include $(TOOLS)/save-gen-vars.mk
|
||||
|
||||
define clean-ndk-mfiles
|
||||
@ [ "$(UPDATE_MAKEFILES)" = "true" ] || printf " ------ Cleaning NDK Makefiles ------ \n"
|
||||
@ cat $(BASH_DIR)/clean-makefiles | $(BIN)/bash
|
||||
endef
|
||||
|
||||
define clean-mfiles
|
||||
@ [ "$(UPDATE_MAKEFILES)" = "true" ] || printf " ------ Cleaning Makefiles ------ \n"
|
||||
@ cat $(BASH_DIR)/clean-makefiles | $(BIN)/bash
|
||||
endef
|
||||
31
build/tools/gen-makefiles.mk
Executable file
31
build/tools/gen-makefiles.mk
Executable file
@@ -0,0 +1,31 @@
|
||||
# By YZBruh
|
||||
|
||||
# Copyright 2024 Partition Manager
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
##################
|
||||
# See "save-gen-vars" funtion for build/tools/save-gen-vars.mk
|
||||
##################
|
||||
|
||||
include $(TOOLS)/save-gen-vars.mk
|
||||
|
||||
define gen-ndk-mfiles
|
||||
@ [ "$(UPDATE_MAKEFILES)" = "true" ] || printf " ------ Generating NDK Makefiles ------ \n"
|
||||
@ cat $(BASH_DIR)/gen-makefiles | $(BIN)/bash
|
||||
endef
|
||||
|
||||
define gen-mfiles
|
||||
@ [ "$(UPDATE_MAKEFILES)" = "true" ] || printf " ------ Generating Makefiles ------ \n"
|
||||
@ cat $(BASH_DIR)/gen-makefiles | $(BIN)/bash
|
||||
endef
|
||||
26
build/tools/save-gen-vars.mk
Executable file
26
build/tools/save-gen-vars.mk
Executable file
@@ -0,0 +1,26 @@
|
||||
# By YZBruh
|
||||
|
||||
# Copyright 2024 Partition Manager
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
define save-gen-vars
|
||||
@ rm -f $(BASH_DIR)/additional-vars
|
||||
$(call touch,$(BASH_DIR)/additional-vars)
|
||||
@ echo "NDK_PROG=$(NDK_PROG)" >> $(BASH_DIR)/additional-vars
|
||||
@ echo "FORCE_GEN=$(FORCE_GEN)" >> $(BASH_DIR)/additional-vars
|
||||
@ echo "THIS_IS=$(THIS_IS)" >> $(BASH_DIR)/additional-vars
|
||||
@ echo "UPDATE_MAKEFILES=$(UPDATE_MAKEFILES)" >> $(BASH_DIR)/additional-vars
|
||||
@ echo "SOURCE_DIRNAME=$(SOURCE_DIRNAME)" >> $(BASH_DIR)/additional-vars
|
||||
@ echo "OUT_DIRNAME=$(OUT_DIRNAME)" >> $(BASH_DIR)/additional-vars
|
||||
endef
|
||||
19
mka/apply-config.mk → build/tools/update-makefiles.mk
Normal file → Executable file
19
mka/apply-config.mk → build/tools/update-makefiles.mk
Normal file → Executable file
@@ -1,6 +1,6 @@
|
||||
# By YZBruh
|
||||
|
||||
# Copyright 2024 YZBruh - Partition Manager
|
||||
# Copyright 2024 Partition Manager
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -14,18 +14,11 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# gcc setting
|
||||
ifeq ($(USE_CUST_GCC), true)
|
||||
CC := $(CUST_GCC)
|
||||
LD := $(CUST_GCC)
|
||||
else ifeq ($(USE_CUST_GCC), false)
|
||||
CC := gcc
|
||||
LD := gcc
|
||||
else
|
||||
$(error İnvalid custom gcc config flag: $(USE_CUST_GCC))
|
||||
ifneq ($(THIS_IS),main)
|
||||
$(error The caller is not the main makefile. Something's wrong)
|
||||
endif
|
||||
|
||||
# gcc flag settings
|
||||
CFLAGS := -O3 -g -Wno-unused-parameter -Wall -Wextra -static $(EXTRA_GCC_FLAGS)
|
||||
UPDATE_MAKEFILES = true
|
||||
|
||||
# end of code
|
||||
include $(TOOLS)/clean-makefiles.mk
|
||||
include $(TOOLS)/gen-makefiles.mk
|
||||
58
build/util/utils.mk
Executable file
58
build/util/utils.mk
Executable file
@@ -0,0 +1,58 @@
|
||||
# By YZBruh
|
||||
|
||||
# Copyright 2024 Partition Manager
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# generate any text based empty file. Usage: $(call touch,<PATH>)
|
||||
define touch
|
||||
@ [ ! "$(FORCE_GEN)" = "true" ] || rm -f "$1"
|
||||
@ touch "$1" || exit 1
|
||||
endef
|
||||
|
||||
# copy files. Usage: $(call copy,<SOURCE>,<COPY_PATH>)
|
||||
define copy
|
||||
cp "$1" "$2" || exit 1
|
||||
endef
|
||||
|
||||
# copy dirs. Usage: $(call copydir,<SOURCE>,<COPY_PATH>)
|
||||
define copydir
|
||||
cp -r "$1" "$2" || exit 1
|
||||
endef
|
||||
|
||||
# file/dir are deleted. usage: $(call erase,<file/directory>)
|
||||
define erase
|
||||
rm -rf "$1"
|
||||
endef
|
||||
|
||||
# make directories. usage: $(call mdir,<PATH>,<PRINTSTATUS=y/NULL>)
|
||||
define mdir
|
||||
[ -z $2 ] || printf " - Generating `basename $1` dir...\n"; \
|
||||
mkdir -p "$1" || exit 1;
|
||||
endef
|
||||
|
||||
# make status. usage: $(call m_stat,"<MESSAGE>",<NEW_LINE_STATE: RANDOM>)
|
||||
define m_stat
|
||||
printf " $1 $2"
|
||||
endef
|
||||
|
||||
# make status (not newline and using make functions). usage: $(call m_stat_nn,"<MESSAGE>")
|
||||
define m_stat_nn
|
||||
$(info ==> $(1))
|
||||
endef
|
||||
|
||||
# Get file content and if speficed write target, write speficed file. Usage: $(call cat,<SOURCE>,<WRITE_PATH>)
|
||||
define cat
|
||||
[ -z "$2" ] && cat "$1" || exit 1
|
||||
[ -n "$2" ] && cat "$1" >> "$2" || exit 1
|
||||
endef
|
||||
5
build/workflow/build.config
Executable file
5
build/workflow/build.config
Executable file
@@ -0,0 +1,5 @@
|
||||
export PMT_VERSION="2.7.0"
|
||||
export PMT_VERSION_CODE=270
|
||||
export NDK_LINK="https://dl.google.com/android/repository/android-ndk-r27-linux.zip"
|
||||
export NDK_VERSION="r27"
|
||||
export NDK_IS="android-ndk"
|
||||
11
build/workflow/relnotes
Executable file
11
build/workflow/relnotes
Executable file
@@ -0,0 +1,11 @@
|
||||
echo -e "\`${CC_VERSION}\`
|
||||
|
||||
Version/Version Code: \`${PMT_VERSION}\`/\`${PMT_VERSION_CODE}\`
|
||||
Supported architectures: \`arm64-v8a\` (64-bit) and \`armeabi-v7a\` (32-bit)
|
||||
|
||||
Notes:
|
||||
Builded with Android NDK ${NDK_VERSION}
|
||||
Packages are compressed with xz.
|
||||
Builded debian packages for termux. [Click](https://github.com/ShawkTeam/pmt/blob/${PMT_VERSION}/SETUP-DEBS.md) for guide.
|
||||
Report bugs and suggestions.
|
||||
[Click](https://github.com/ShawkTeam/pmt/blob/${PMT_VERSION}/CHANGELOG.md) for viewing version ${PMT_VERSION} changelog."
|
||||
101
include/pmt/Deprecates.h
Executable file
101
include/pmt/Deprecates.h
Executable file
@@ -0,0 +1,101 @@
|
||||
/* By YZBruh */
|
||||
|
||||
/**
|
||||
* Copyright 2024 Partition Manager
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __PMT_DEPRECATED_H
|
||||
#define __PMT_DEPRECATED_H
|
||||
|
||||
#include <pmt/ExternC.h>
|
||||
|
||||
PMT_EXTERN_C_BEGIN
|
||||
|
||||
#define deprecated_opt 1
|
||||
#define changed_opt 2
|
||||
#define end_depr_pointer 0
|
||||
#define not_changed 0
|
||||
#define not_changed_long NULL
|
||||
|
||||
/* versions */
|
||||
#define v150 "1.5.0"
|
||||
#define v160 "1.6.0"
|
||||
#define v170 "1.7.0"
|
||||
#define v180 "1.8.0"
|
||||
#define v190 "1.9.0"
|
||||
#define v200 "2.0.0"
|
||||
#define v210 "2.1.0"
|
||||
#define v220 "2.2.0"
|
||||
#define v230 "2.3.0"
|
||||
#define v240 "2.4.0"
|
||||
#define v250 "2.5.0"
|
||||
#define v260 "2.6.0"
|
||||
#define v270 "2.7.0"
|
||||
#define vUNK NULL
|
||||
|
||||
struct pmt_deprecates {
|
||||
int depr_type;
|
||||
int option;
|
||||
int option_new;
|
||||
const char* option_long;
|
||||
const char* option_long_new;
|
||||
const char* depr_version;
|
||||
};
|
||||
|
||||
static void
|
||||
__deprecated_opt_handle(int opt, const char* opt_long, const char* depr_msg)
|
||||
{
|
||||
static char long_e_msg[250];
|
||||
|
||||
static struct pmt_deprecates depr_table[] = {
|
||||
{deprecated_opt, 'b', not_changed, "backup", not_changed_long, v210},
|
||||
{deprecated_opt, 'F', not_changed, "flash", not_changed_long, v210},
|
||||
{deprecated_opt, 'r', not_changed, "format", not_changed_long, v210},
|
||||
{deprecated_opt, 'L', not_changed, "license", not_changed_long, v250},
|
||||
{changed_opt, 'D', 'p', "list", not_changed_long, v210},
|
||||
{end_depr_pointer, not_changed, not_changed, not_changed_long, not_changed_long, vUNK}
|
||||
};
|
||||
|
||||
if (opt_long == NULL)
|
||||
sprintf(long_e_msg, "%s", current->not_changed_opt);
|
||||
else
|
||||
sprintf(long_e_msg, "%s", opt_long);
|
||||
|
||||
for (int optctrl = 0; depr_table[optctrl].depr_type != 0; optctrl++)
|
||||
{
|
||||
|
||||
if (depr_table[optctrl].depr_type == 1)
|
||||
{
|
||||
if (opt == depr_table[optctrl].option || strcmp(opt_long, depr_table[optctrl].option_long) == 0)
|
||||
LOGD("%s [%s]: -%c (%s): %s\n", current->depr_opt_str, depr_table[optctrl].depr_version, (char)depr_table[optctrl].option, depr_table[optctrl].option_long, depr_msg);
|
||||
|
||||
}
|
||||
else if (depr_table[optctrl].depr_type == 2)
|
||||
{
|
||||
if (opt == depr_table[optctrl].option || strcmp(opt_long, depr_table[optctrl].option_long) == 0)
|
||||
LOGD("%s [%s]: -%c (%s): %s\n", current->switched_opt_str, depr_table[optctrl].depr_version, (char)depr_table[optctrl].option, long_e_msg, depr_msg);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#define DEPR_HANDLE(x, y, z) __deprecated_opt_handle(x, y, z)
|
||||
|
||||
PMT_EXTERN_C_END
|
||||
|
||||
#endif
|
||||
|
||||
/* end of code */
|
||||
30
include/pmt/ExternC.h
Executable file
30
include/pmt/ExternC.h
Executable file
@@ -0,0 +1,30 @@
|
||||
/* By YZBruh */
|
||||
|
||||
/**
|
||||
* Copyright 2024 Partition Manager
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __PMT_EXTERN_C_H_
|
||||
#define __PMT_EXTERN_C_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define PMT_EXTERN_C_BEGIN extern "C" {
|
||||
#define PMT_EXTERN_C_END }
|
||||
#else
|
||||
#define PMT_EXTERN_C_BEGIN
|
||||
#define PMT_EXTERN_C_END
|
||||
#endif
|
||||
|
||||
#endif
|
||||
29
binary/error.c → include/pmt/HelpMessages.h
Normal file → Executable file
29
binary/error.c → include/pmt/HelpMessages.h
Normal file → Executable file
@@ -1,14 +1,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "include/common.h"
|
||||
|
||||
/* By YZBruh */
|
||||
|
||||
/*
|
||||
* Copyright 2024 YZBruh - Partition Manager
|
||||
* Copyright 2024 Partition Manager
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,11 +16,17 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/* shorter error messages will be functional xd */
|
||||
void error(const char *err_msg)
|
||||
{
|
||||
fprintf(stderr, ANSI_RED "%s" ANSI_RESET, err_msg);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
#ifndef __PMT_HELP_MSGS_H
|
||||
#define __PMT_HELP_MSGS_H
|
||||
|
||||
/* end of code */
|
||||
#include <pmt/ExternC.h>
|
||||
|
||||
PMT_EXTERN_C_BEGIN
|
||||
|
||||
void help(void);
|
||||
|
||||
PMT_EXTERN_C_END
|
||||
|
||||
#endif
|
||||
|
||||
/* end */
|
||||
121
include/pmt/PartitionManager.h
Executable file
121
include/pmt/PartitionManager.h
Executable file
@@ -0,0 +1,121 @@
|
||||
/* By YZBruh */
|
||||
|
||||
/**
|
||||
* Copyright 2024 Partition Manager
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#if !defined(__clang__) && !defined(__NDK_BUILD)
|
||||
#error "Your compiler is NOT clang. Please build with LLVM clang."
|
||||
#endif
|
||||
|
||||
#include <pmt/ExternC.h>
|
||||
|
||||
PMT_EXTERN_C_BEGIN
|
||||
|
||||
#ifndef __PMT_H_
|
||||
#define __PMT_H_
|
||||
|
||||
#ifdef INC_MAIN_LIBS
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
||||
#if !defined(HELP) || !defined(VERSIONING)
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef INC_GETOPT
|
||||
#include <getopt.h>
|
||||
#endif
|
||||
|
||||
#ifdef INC_DIRENT
|
||||
#include <dirent.h>
|
||||
#endif
|
||||
|
||||
#ifdef INC_STAT
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
#ifdef INC_DEBUGERS
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
#ifdef INC_TOOLS_REQS
|
||||
#include <fcntl.h>
|
||||
#include <sys/statvfs.h>
|
||||
#endif
|
||||
|
||||
/* variable definations */
|
||||
extern char* _Nullable out;
|
||||
extern char* _Nullable cust_cxt;
|
||||
extern char* _Nullable target_partition;
|
||||
extern char* _Nullable target_flash_file;
|
||||
extern char* _Nullable format_fs;
|
||||
extern char* _Nullable partition_type;
|
||||
extern char* _Nullable bin_name;
|
||||
extern bool pmt_use_logical;
|
||||
extern bool pmt_use_cust_cxt;
|
||||
extern bool pmt_ab;
|
||||
extern bool pmt_logical;
|
||||
extern bool pmt_silent;
|
||||
extern bool pmt_flash;
|
||||
extern bool pmt_backup;
|
||||
extern bool pmt_format;
|
||||
extern bool pmt_force_mode;
|
||||
extern bool pmt_inst_on_termux;
|
||||
|
||||
/* language struces configurations */
|
||||
extern struct pmt_langdb_general* _Nullable current;
|
||||
extern struct pmt_langdb_docs* _Nullable curr_docs;
|
||||
extern struct pmt_langdb_general en;
|
||||
extern struct pmt_langdb_general tr;
|
||||
extern struct pmt_langdb_docs en_docs;
|
||||
extern struct pmt_langdb_docs tr_docs;
|
||||
|
||||
/* logging levels */
|
||||
typedef enum {
|
||||
LOG_LEVEL_FATAL,
|
||||
LOG_LEVEL_ERR,
|
||||
LOG_LEVEL_WARN,
|
||||
LOG_LEVEL_DEBUG
|
||||
} LogLevel;
|
||||
|
||||
/* function definations */
|
||||
int listpart(void);
|
||||
void check_dev_point(void);
|
||||
void check_root(void);
|
||||
int pmt(unsigned short progress_code);
|
||||
void version(void);
|
||||
void setlang(const char* _Nonnull lang, int null_conf_stat);
|
||||
int search_sls(void);
|
||||
int loadlang(void);
|
||||
int get_stat(const char* _Nonnull filepath, const char* _Nonnull stype);
|
||||
void debug(LogLevel status, const char* _Nullable fmt, ...);
|
||||
|
||||
/* logging macros */
|
||||
#define LOGF(fmt, ...) debug(LOG_LEVEL_FATAL, fmt, ##__VA_ARGS__)
|
||||
#define LOGE(fmt, ...) debug(LOG_LEVEL_ERR, fmt, ##__VA_ARGS__)
|
||||
#define LOGW(fmt, ...) debug(LOG_LEVEL_WARN, fmt, ##__VA_ARGS__)
|
||||
#define LOGD(fmt, ...) debug(LOG_LEVEL_DEBUG, fmt, ##__VA_ARGS__)
|
||||
|
||||
#endif
|
||||
|
||||
PMT_EXTERN_C_END
|
||||
|
||||
/* end of code */
|
||||
121
include/pmt/StringKeys.h
Executable file
121
include/pmt/StringKeys.h
Executable file
@@ -0,0 +1,121 @@
|
||||
/* By YZBruh */
|
||||
|
||||
/**
|
||||
* Copyright 2024 Partition Manager
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __PMT_STRINGKEYS_
|
||||
#define __PMT_STRINGKEYS_
|
||||
|
||||
#include <pmt/ExternC.h>
|
||||
|
||||
PMT_EXTERN_C_BEGIN
|
||||
|
||||
/* The struct is a very good option for setting the languages of texts etc. */
|
||||
struct pmt_langdb_general {
|
||||
const char* _Nonnull lang_by_s;
|
||||
const char* _Nonnull language;
|
||||
const char* _Nonnull lang_prefix;
|
||||
const char* _Nonnull not_logical;
|
||||
const char* _Nonnull not_file;
|
||||
const char* _Nonnull not_dir;
|
||||
const char* _Nonnull not_in_dev;
|
||||
const char* _Nonnull not_open;
|
||||
const char* _Nonnull not_block;
|
||||
const char* _Nonnull not_read;
|
||||
const char* _Nonnull not_readdir;
|
||||
const char* _Nonnull not_write;
|
||||
const char* _Nonnull not_gen;
|
||||
const char* _Nonnull no_root;
|
||||
const char* _Nonnull no_target;
|
||||
const char* _Nonnull expected_backup_arg;
|
||||
const char* _Nonnull expected_flash_arg;
|
||||
const char* _Nonnull expected_format_arg;
|
||||
const char* _Nonnull missing_operand;
|
||||
const char* _Nonnull multiple_wiewers;
|
||||
const char* _Nonnull common_symbol_rule;
|
||||
const char* _Nonnull req_part_name;
|
||||
const char* _Nonnull part_not_found;
|
||||
const char* _Nonnull unsupported_fs;
|
||||
const char* _Nonnull cannot_stat;
|
||||
const char* _Nonnull ffile_more_part;
|
||||
const char* _Nonnull cannot_get_bsz;
|
||||
const char* _Nonnull format_fail;
|
||||
const char* _Nonnull depr_backup_opt;
|
||||
const char* _Nonnull depr_flash_opt;
|
||||
const char* _Nonnull depr_format_opt;
|
||||
const char* _Nonnull depr_Vlicense_opt;
|
||||
const char* _Nonnull depr_ch_list_opt;
|
||||
const char* _Nonnull not_spec_opt;
|
||||
const char* _Nonnull logical_warn;
|
||||
const char* _Nonnull ab_warn;
|
||||
const char* _Nonnull out_not_spec;
|
||||
const char* _Nonnull please_rerun;
|
||||
const char* _Nonnull part_disk_sz;
|
||||
const char* _Nonnull flash_file_sz;
|
||||
const char* _Nonnull part_disk_sz_fail;
|
||||
const char* _Nonnull flash_file_sz_fail;
|
||||
const char* _Nonnull unknown_opr;
|
||||
const char* _Nonnull list_of_dir;
|
||||
const char* _Nonnull success_backup;
|
||||
const char* _Nonnull success_flash;
|
||||
const char* _Nonnull warn;
|
||||
const char* _Nonnull fatal;
|
||||
const char* _Nonnull switching_lang;
|
||||
const char* _Nonnull welcome;
|
||||
const char* _Nullable welcome_;
|
||||
const char* _Nonnull for_more;
|
||||
const char* _Nonnull try_h;
|
||||
const char* _Nonnull usage_head;
|
||||
const char* _Nonnull depr_opt_str;
|
||||
const char* _Nonnull switched_opt_str;
|
||||
const char* _Nonnull not_changed_opt;
|
||||
const char* _Nonnull compiler_str;
|
||||
const char* _Nonnull version_str;
|
||||
const char* _Nonnull bin_str;
|
||||
const char* _Nonnull unknw_str;
|
||||
const char* _Nonnull by_str;
|
||||
};
|
||||
|
||||
/* docs etc. */
|
||||
struct pmt_langdb_docs {
|
||||
const char* _Nonnull docs_strs_l1;
|
||||
const char* _Nonnull docs_strs_l2;
|
||||
const char* _Nonnull docs_strs_l3;
|
||||
const char* _Nonnull docs_strs_l4;
|
||||
const char* _Nonnull docs_strs_l5;
|
||||
const char* _Nonnull docs_strs_l6;
|
||||
const char* _Nonnull docs_strs_l7;
|
||||
const char* _Nonnull docs_strs_l8;
|
||||
const char* _Nonnull docs_strs_l9;
|
||||
const char* _Nonnull docs_strs_l10;
|
||||
const char* _Nonnull docs_strs_l11;
|
||||
const char* _Nonnull docs_strs_l12;
|
||||
const char* _Nonnull docs_strs_l13;
|
||||
const char* _Nonnull docs_strs_l14;
|
||||
const char* _Nonnull or_str;
|
||||
const char* _Nonnull usage_docstr;
|
||||
};
|
||||
|
||||
/* for checks etc */
|
||||
struct pmt_langdb_langs {
|
||||
const char* _Nullable lang_pr;
|
||||
};
|
||||
|
||||
PMT_EXTERN_C_END
|
||||
|
||||
#endif /* __PMT_STRINGKEYS_ */
|
||||
|
||||
/* end of code */
|
||||
40
include/pmt/VersionVars.h
Executable file
40
include/pmt/VersionVars.h
Executable file
@@ -0,0 +1,40 @@
|
||||
/* By YZBruh */
|
||||
|
||||
/*
|
||||
* Copyright 2024 Partition Manager
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __PMT_VERSIONING_H
|
||||
#define __PMT_VERSIONING_H
|
||||
|
||||
#include <pmt/ExternC.h>
|
||||
|
||||
PMT_EXTERN_C_BEGIN
|
||||
|
||||
#ifdef __NDK_BUILD
|
||||
#include <android/ndk-version.h>
|
||||
#include <pmt/generated/clang-version.h>
|
||||
#endif
|
||||
|
||||
/* versioning */
|
||||
#define PMT_MAJOR 2
|
||||
#define PMT_MINOR 7
|
||||
#define PMT_PATCHLEVEL 0
|
||||
|
||||
PMT_EXTERN_C_END
|
||||
|
||||
#endif
|
||||
|
||||
/* end */
|
||||
182
jni/Makefile
Executable file
182
jni/Makefile
Executable file
@@ -0,0 +1,182 @@
|
||||
# By YZBruh
|
||||
|
||||
# Copyright 2024 Partition Manager
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
#####
|
||||
# sub-make for building package
|
||||
#####
|
||||
|
||||
THIS_IS = src
|
||||
|
||||
include ../Makefile.inc
|
||||
|
||||
ifeq ($(INC_OLDENV),true)
|
||||
include $(BUILD)/config/oldenv.mk
|
||||
endif
|
||||
|
||||
INCLUDE_DIR := $(realpath ../include)
|
||||
PMT_INCDIR := $(INCLUDE_DIR)/pmt
|
||||
|
||||
# the presence of all source files that are on this list will be checked
|
||||
SRCS_REQ := \
|
||||
place-holder/debug.c \
|
||||
place-holder/help.c \
|
||||
place-holder/get_stat.c \
|
||||
place-holder/lang_tools.c \
|
||||
place-holder/languages.c \
|
||||
place-holder/partitiontool.c \
|
||||
place-holder/pmt.c \
|
||||
place-holder/root.c \
|
||||
place-holder/tools.c \
|
||||
place-holder/version.c
|
||||
|
||||
# objects to be used when executable file is created
|
||||
OBJS_EXEC := \
|
||||
$(SOURCE_DIR)/$(TARGET).o \
|
||||
$(SOURCE_DIR)/help.o \
|
||||
$(SOURCE_DIR)/version.o \
|
||||
$(SOURCE_DIR)/get_stat.o \
|
||||
$(SOURCE_DIR)/tools.o \
|
||||
$(SOURCE_DIR)/lang_tools.o \
|
||||
$(SOURCE_DIR)/languages.o
|
||||
|
||||
HEADERS_REQ := \
|
||||
$(PMT_INCDIR)/pmt/ExternC.h \
|
||||
$(PMT_INCDIR)/pmt/Deprecates.h \
|
||||
$(PMT_INCDIR)/pmt/HelpMessages.h \
|
||||
$(PMT_INCDIR)/pmt/PartitionManager.h \
|
||||
$(PMT_INCDIR)/pmt/StringKeys.h \
|
||||
$(PMT_INCDIR)/pmt/VersionVars.h
|
||||
|
||||
PROGRESS_LIST := \
|
||||
welcome \
|
||||
wait \
|
||||
$(SRCS_REQ) \
|
||||
$(HEADERS_REQ) \
|
||||
pr_obj \
|
||||
$(OBJS) \
|
||||
make_outdirs \
|
||||
pr_sts \
|
||||
$(STATIC_LIBS) \
|
||||
make_executable \
|
||||
wait \
|
||||
end_progress
|
||||
|
||||
define check_hf
|
||||
@ [ ! -f "$1" ] \
|
||||
&& $(E_NS) " ==> Couldn't found required header file: include/pmt/`basename $1`" \
|
||||
&& exit 1
|
||||
endef
|
||||
|
||||
# all target for building
|
||||
all: $(PROGRESS_LIST)
|
||||
|
||||
welcome:
|
||||
@ rm -f $(BUILD)/config/oldenv.mk
|
||||
@ echo " ---- Partition Manager Builder ---- " \
|
||||
&& $(E_NS)
|
||||
$(E) " - Version: $(VERSION)"
|
||||
$(E) " - Version code: $(VERSION_CODE)" \
|
||||
&& $(E_NS)
|
||||
$(E) " -------------------------------- " \
|
||||
&& $(E_NS)
|
||||
@ if [ -f $(SOURCE_DIR)/debug.o ]; then \
|
||||
$(E_NS) " - Please clean up before you build it." && echo; \
|
||||
$(E_NS) " ----------------------------------- "; \
|
||||
exit 1; \
|
||||
fi
|
||||
$(E) " - Checking required source files..."
|
||||
|
||||
pr_obj:
|
||||
$(E) " - Building objects..."
|
||||
|
||||
pr_sts:
|
||||
$(E) " - Making static libraries..."
|
||||
|
||||
wait:
|
||||
@ sleep 2
|
||||
|
||||
make_outdirs:
|
||||
@ rm -rf $(IN_OUT_DIR)
|
||||
@ mkdir $(BINARY_DIR)
|
||||
@ mkdir $(PACKAGE_DIR)
|
||||
@ mkdir $(STATICLIB_DIR)
|
||||
|
||||
place-holder/%.c:
|
||||
$(E) " CHK $(SOURCE_DIRNAME)/`basename $@`"
|
||||
@ if [ ! -f "$(SOURCE_DIR)/`basename $@`" ]; then \
|
||||
$(E_NS) " ==> Couldn't found required source file: $(SOURCE_DIRNAME)/`basename $@`"; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
$(PMT_INCDIR)/%.h:
|
||||
$(E) " CHK include/pmt/`basename $@`"
|
||||
@ if [ ! -f "$(INCLUDE_DIR)/pmt/`basename $@`" ]; then \
|
||||
$(E_NS) " ==> Couldn't found required header file: include/pmt/`basename $@`"; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
$(SOURCE_DIR)/%.o: $(SOURCE_DIR)/%.c
|
||||
$(E) " CC $(SOURCE_DIRNAME)/`basename $@`"
|
||||
@ $(CC) $(CFLAGS) -c "$<" || exit 1
|
||||
|
||||
$(TARGET)_%:
|
||||
$(E) " AR lib$@.a"
|
||||
@ $(AR) rcs "lib$@.a" "$(SOURCE_DIR)/$$(echo "$@" | cut -d'_' -f2).o"
|
||||
|
||||
make_executable:
|
||||
$(E) " - Making executable file..."
|
||||
$(E) " LD $(TARGET)"
|
||||
@ $(CC) $(CFLAGS) -L$(SOURCE_DIR) $(foreach st,$(STATIC_LIBS),$(shell echo -n -l$(st) )) -o $(TARGET) $(OBJS_EXEC) || exit 1
|
||||
|
||||
end_progress:
|
||||
@ abort_build() { \
|
||||
[ -d "$(PACKAGE_DIR)" ] \
|
||||
&& rm -rf "$(PACKAGE_DIR)"; \
|
||||
[ -d "$(BINARY_DIR)" ] \
|
||||
&& rm -rf "$(BINARY_DIR)"; \
|
||||
[ -d "$(STATICLIB_DIR)" ] \
|
||||
&& rm -rf "$(STATICLIB_DIR)"; \
|
||||
exit 1; \
|
||||
}; \
|
||||
mv $(TARGET) $(BINARY_DIR) || abort_build; \
|
||||
mv *.a $(STATICLIB_DIR) || abort_build; \
|
||||
$(E_NS) " - Generating package..."; \
|
||||
cp $(BINARY_DIR)/$(TARGET) $(PACKAGE_DIR) || abort_build; \
|
||||
$(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
|
||||
$(E) " - Success" && $(E_NS)
|
||||
@ sleep 1
|
||||
$(E) " ----------------------------------- "
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
$(eval STATICLIBS = $(wildcard $(SOURCE_DIR)/*.a))
|
||||
$(eval OBJS = $(wildcard $(SOURCE_DIR)/*.o))
|
||||
$(info Cleaning files...)
|
||||
$(foreach obj, \
|
||||
$(OBJS), \
|
||||
$(call m_stat_nn,$(SOURCE_DIRNAME)/$(shell basename $(obj))) \
|
||||
$(call erase,$(obj)) \
|
||||
)
|
||||
$(foreach lib, \
|
||||
$(STATICLIBS), \
|
||||
$(call m_stat_nn,$(SOURCE_DIRNAME)/$(shell basename $(lib))) \
|
||||
$(call erase,$(lib)) \
|
||||
)
|
||||
|
||||
# end
|
||||
71
jni/debug.c
Executable file
71
jni/debug.c
Executable file
@@ -0,0 +1,71 @@
|
||||
/* By YZBruh */
|
||||
|
||||
/**
|
||||
* Copyright 2024 Partition Manager
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define INC_MAIN_LIBS
|
||||
|
||||
#include <pmt/PartitionManager.h>
|
||||
#include <pmt/StringKeys.h>
|
||||
|
||||
void debug(LogLevel status, const char* _Nullable fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
|
||||
switch (status)
|
||||
{
|
||||
case LOG_LEVEL_ERR:
|
||||
if (!pmt_silent)
|
||||
{
|
||||
fprintf(stderr, "%s: ", bin_name);
|
||||
vfprintf(stderr, fmt, args);
|
||||
}
|
||||
exit(1);
|
||||
break;
|
||||
case LOG_LEVEL_WARN:
|
||||
if (!pmt_silent)
|
||||
{
|
||||
fprintf(stderr, "%s: ", current->warn);
|
||||
vfprintf(stderr, fmt, args);
|
||||
}
|
||||
break;
|
||||
case LOG_LEVEL_FATAL:
|
||||
if (!pmt_silent)
|
||||
{
|
||||
fprintf(stderr, "%s: ", current->fatal);
|
||||
vfprintf(stderr, fmt, args);
|
||||
}
|
||||
abort();
|
||||
break;
|
||||
case LOG_LEVEL_DEBUG:
|
||||
if (!pmt_silent)
|
||||
vfprintf(stdout, fmt, args);
|
||||
break;
|
||||
}
|
||||
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/* end of code */
|
||||
79
jni/get_stat.c
Executable file
79
jni/get_stat.c
Executable file
@@ -0,0 +1,79 @@
|
||||
/* By YZBruh */
|
||||
|
||||
/**
|
||||
* Copyright 2024 Partition Manager
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define INC_MAIN_LIBS
|
||||
#define INC_STAT
|
||||
|
||||
#include <pmt/PartitionManager.h>
|
||||
#include <pmt/StringKeys.h>
|
||||
|
||||
/**
|
||||
* The target file is controlled by the stat function.
|
||||
* Files, directories, links and blocks (disks) are for.
|
||||
* If it is never found, it returns 1 value.
|
||||
* If he finds 0 value is returned.
|
||||
* If the desired type is not in -1 value is returned.
|
||||
*/
|
||||
int get_stat(const char* _Nonnull filepath, const char* _Nonnull stype)
|
||||
{
|
||||
static struct stat get_stat;
|
||||
|
||||
if (stat(filepath, &get_stat) != 0)
|
||||
return 1;
|
||||
|
||||
if (strcmp(stype, "dir") == 0)
|
||||
{
|
||||
if (S_ISDIR(get_stat.st_mode))
|
||||
return 0;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
else if (strcmp(stype, "file") == 0)
|
||||
{
|
||||
if (S_ISREG(get_stat.st_mode))
|
||||
return 0;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
else if (strcmp(stype, "blk") == 0)
|
||||
{
|
||||
if (S_ISBLK(get_stat.st_mode))
|
||||
return 0;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
else if (strcmp(stype, "link") == 0)
|
||||
{
|
||||
if (S_ISLNK(get_stat.st_mode))
|
||||
return 0;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/* end of code */
|
||||
71
jni/help.c
Executable file
71
jni/help.c
Executable file
@@ -0,0 +1,71 @@
|
||||
/* By YZBruh */
|
||||
|
||||
/*
|
||||
* Copyright 2024 Partition Manager
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define INC_MAIN_LIBS
|
||||
#define HELP
|
||||
|
||||
#include <pmt/PartitionManager.h>
|
||||
#include <pmt/StringKeys.h>
|
||||
#include <pmt/HelpMessages.h>
|
||||
|
||||
extern char* bin_name;
|
||||
extern char* curr_lang;
|
||||
|
||||
struct pmt_langdb_docs* curr_docs = NULL;
|
||||
|
||||
static void
|
||||
prepare_langconf_docs(void)
|
||||
{
|
||||
if (strcmp(curr_lang, "en") == 0)
|
||||
curr_docs = &en_docs;
|
||||
else if (strcmp(curr_lang, "tr") == 0)
|
||||
curr_docs = &tr_docs;
|
||||
}
|
||||
|
||||
void help(void)
|
||||
{
|
||||
prepare_langconf_docs();
|
||||
printf("%s: %s %s\n", curr_docs->usage_docstr, bin_name, curr_docs->docs_strs_l1);
|
||||
printf(" %s: %s %s\n", curr_docs->or_str, bin_name, curr_docs->docs_strs_l2);
|
||||
printf(" %s: %s %s\n\n", curr_docs->or_str, bin_name, curr_docs->docs_strs_l3);
|
||||
printf("%s: \n", curr_docs->docs_strs_l4);
|
||||
printf(" -l, --logical %s\n", curr_docs->docs_strs_l5);
|
||||
printf(" -c, --context %s\n", curr_docs->docs_strs_l6);
|
||||
printf(" -p, --list %s\n", curr_docs->docs_strs_l7);
|
||||
printf(" -s, --silent %s\n", curr_docs->docs_strs_l8);
|
||||
printf(" -f, --force %s\n", curr_docs->docs_strs_l9);
|
||||
printf(" -S, --set-lang %s\n", curr_docs->docs_strs_l10);
|
||||
printf(" -v, --version %s\n", curr_docs->docs_strs_l11);
|
||||
printf(" --help %s\n\n", curr_docs->docs_strs_l12);
|
||||
printf("%s:\n", curr_docs->docs_strs_l13);
|
||||
printf(" %s backup boot_a -c /dev/block/platform/bootdevice/by-name\n", bin_name);
|
||||
printf(" %s flash boot_a /sdcard/twrp/boot.img -c /dev/block/platform/bootdevice/by-name\n", bin_name);
|
||||
printf(" %s format system_a ext4 --logical\n", bin_name);
|
||||
printf(" %s -c /dev/block/platform/bootdevice/by-name --list\n\n", bin_name);
|
||||
printf("%s <t.me/ShawkTeam | Topics | pmt>\n", curr_docs->docs_strs_l14);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* end of code */
|
||||
165
jni/lang_tools.c
Executable file
165
jni/lang_tools.c
Executable file
@@ -0,0 +1,165 @@
|
||||
/* By YZBruh */
|
||||
|
||||
/**
|
||||
* Copyright 2024 Partition Manager
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define INC_MAIN_LIBS
|
||||
#define INC_DEBUGERS
|
||||
#define INC_STAT
|
||||
|
||||
#include <pmt/PartitionManager.h>
|
||||
#include <pmt/StringKeys.h>
|
||||
|
||||
/* pmt's man doc file path on termux */
|
||||
#define TERMUX_PMT_MANDOC "/data/data/com.termux/files/usr/share/man/man8/pmt.8.gz"
|
||||
|
||||
#define PMTLANG_CONF "/sdcard/.pmtlang.conf"
|
||||
|
||||
#define PMT_SW_POINT "/sdcard/.pmtlangsw"
|
||||
|
||||
extern struct pmt_langdb_langs lang[];
|
||||
struct pmt_langdb_general* current = NULL;
|
||||
|
||||
char* curr_lang;
|
||||
static FILE *langconf;
|
||||
|
||||
static const char*
|
||||
langctrl(const char* _Nonnull lang_)
|
||||
{
|
||||
for (int langct = 0; lang[langct].lang_pr != NULL; langct++)
|
||||
{
|
||||
if (strcmp(lang_, lang[langct].lang_pr) == 0)
|
||||
return lang_;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int loadlang(void)
|
||||
{
|
||||
static char lang_fpr[3] = "en";
|
||||
langconf = NULL;
|
||||
|
||||
if (get_stat(TERMUX_PMT_MANDOC, "file") == 0)
|
||||
pmt_inst_on_termux = true;
|
||||
|
||||
|
||||
langconf = fopen(PMTLANG_CONF, "r+");
|
||||
|
||||
if (langconf == NULL)
|
||||
{
|
||||
langconf = fopen(PMTLANG_CONF, "w+");
|
||||
|
||||
if (langconf == NULL || langconf != NULL)
|
||||
{
|
||||
setlang("en", 1);
|
||||
current = &en;
|
||||
curr_lang = "en";
|
||||
|
||||
if (langconf != NULL)
|
||||
fclose(langconf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
while (fgets(lang_fpr, sizeof(lang_fpr), langconf) != NULL)
|
||||
{
|
||||
if (strcmp(lang_fpr, "en") == 0)
|
||||
{
|
||||
fclose(langconf);
|
||||
current = &en;
|
||||
curr_lang = "en";
|
||||
return 0;
|
||||
}
|
||||
else if (strcmp(lang_fpr, "tr") == 0)
|
||||
{
|
||||
fclose(langconf);
|
||||
current = &tr;
|
||||
curr_lang = "tr";
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
fclose(langconf);
|
||||
setlang("en", 0);
|
||||
loadlang();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (fgets(lang_fpr, sizeof(lang_fpr), langconf) == NULL)
|
||||
{
|
||||
setlang("en", 1);
|
||||
loadlang();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void setlang(const char* _Nonnull lang, int null_conf_stat)
|
||||
{
|
||||
if (langctrl(lang) == NULL)
|
||||
LOGE("Unknown language: %s.\n", lang);
|
||||
|
||||
if (get_stat(PMTLANG_CONF, "file") == 0)
|
||||
remove(PMTLANG_CONF);
|
||||
|
||||
langconf = NULL;
|
||||
langconf = fopen(PMTLANG_CONF, "w");
|
||||
|
||||
if (langconf == NULL)
|
||||
LOGE("Failed!!! Cannot open/write config file.\n");
|
||||
|
||||
if (fprintf(langconf, "%s", lang) < 2)
|
||||
LOGE("Failed!!! Couldn't write config!\n");
|
||||
else
|
||||
fclose(langconf);
|
||||
|
||||
static int status;
|
||||
|
||||
if (null_conf_stat != 1)
|
||||
{
|
||||
status = open(PMT_SW_POINT, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
||||
if (status == 0)
|
||||
close(status);
|
||||
}
|
||||
}
|
||||
|
||||
int search_sls(void)
|
||||
{
|
||||
if (get_stat(PMT_SW_POINT, "file") == 0)
|
||||
{
|
||||
remove(PMT_SW_POINT);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/* end of code */
|
||||
206
jni/languages.c
Executable file
206
jni/languages.c
Executable file
@@ -0,0 +1,206 @@
|
||||
/* By YZBruh */
|
||||
|
||||
/**
|
||||
* Copyright 2024 Partition Manager
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define INC_MAIN_LIBS
|
||||
|
||||
#include <pmt/PartitionManager.h>
|
||||
#include <pmt/StringKeys.h>
|
||||
|
||||
struct pmt_langdb_general en = {
|
||||
.lang_by_s = "YZBruh & r0manas",
|
||||
.language = "English",
|
||||
.lang_prefix = "en",
|
||||
.not_logical = "This device does not have logical partitions!",
|
||||
.not_file = "is not a file.",
|
||||
.not_dir = "is not a directory.",
|
||||
.not_in_dev = "Nothing found in /dev. Use force mode to avoid this error.",
|
||||
.not_open = "Couldn't open",
|
||||
.not_block = "The specified partition is not recognized as a block device.",
|
||||
.not_read = "Couldn't read",
|
||||
.not_readdir = "Couldn't read directory",
|
||||
.not_write = "Couldn't write",
|
||||
.not_gen = "Couldn't generate",
|
||||
.no_root = "Root access could not be detected! Please run this with root permissions.",
|
||||
.no_target = "No target specified (backup, flash, or format)",
|
||||
.expected_backup_arg = "Expected backup argument 2 (1 of them are not mandatory), retrieved",
|
||||
.expected_flash_arg = "Expected flash argument 2, retrieved",
|
||||
.expected_format_arg = "Expected format argument 2, retrieved",
|
||||
.missing_operand = "Missing operand",
|
||||
.multiple_wiewers = "Multiple viewers can't be used on the same line.",
|
||||
.common_symbol_rule = "When specifying arguments for an option, ensure they do not begin with '-'. Each argument must correspond correctly to its respective option.",
|
||||
.req_part_name = "Partition name required.",
|
||||
.part_not_found = "Partition not found!",
|
||||
.unsupported_fs = "Formatter: unsupported filesystem",
|
||||
.cannot_stat = "Can't retrieve file status",
|
||||
.ffile_more_part = "Flash file size exceeds partition capacity.",
|
||||
.cannot_get_bsz = "Failed to retrieve partition block size.",
|
||||
.format_fail = "Formatting failed! There is a possibility of data damage.",
|
||||
.depr_backup_opt = "These options for the backup are unavailable.",
|
||||
.depr_flash_opt = "These options for the flash are unavailable.",
|
||||
.depr_format_opt = "These options for the format are unavailable.",
|
||||
.depr_Vlicense_opt = "No memory for unnecessary options!",
|
||||
.depr_ch_list_opt = "Use -p argument for listing partitions.",
|
||||
.not_spec_opt = "Specify the necessary arguments, not option",
|
||||
.logical_warn = "This device uses logical partitions.",
|
||||
.ab_warn = "This device uses A/B partition style.",
|
||||
.out_not_spec = "Output file name not specified. Using default name",
|
||||
.please_rerun = "Please rerun the command.",
|
||||
.part_disk_sz = "Partition disk size",
|
||||
.flash_file_sz = "Flash file size",
|
||||
.part_disk_sz_fail = "Failed to retrieve partition disk size.",
|
||||
.flash_file_sz_fail = "Failed to retrieve flash file size.",
|
||||
.unknown_opr = "Unknown operand",
|
||||
.list_of_dir = "Directory listing",
|
||||
.success_backup = "Backup successful. Output",
|
||||
.success_flash = "Flash successful",
|
||||
.warn = "WARNING",
|
||||
.fatal = "FATAL ERROR",
|
||||
.switching_lang = "Switching language...",
|
||||
.welcome = "language!",
|
||||
.welcome_ = "Welcome to ",
|
||||
.for_more = "for more information",
|
||||
.try_h = "Try",
|
||||
.usage_head = "Usage",
|
||||
.depr_opt_str = "DEPRECATED OPTION",
|
||||
.switched_opt_str = "SWITCHED OPTION",
|
||||
.not_changed_opt = "not changed",
|
||||
.compiler_str = "Compiler",
|
||||
.version_str = "version",
|
||||
.bin_str = "binary",
|
||||
.unknw_str = "unknown",
|
||||
.by_str = "By"
|
||||
};
|
||||
|
||||
struct pmt_langdb_general tr = {
|
||||
.lang_by_s = "YZBruh",
|
||||
.language = "Türkçe",
|
||||
.lang_prefix = "tr",
|
||||
.not_logical = "Bu cihaz mantıksal (logical) bölümlere sahip değil!",
|
||||
.not_file = "Bu bir dosya değil",
|
||||
.not_dir = "Bu bir dizin değil",
|
||||
.not_in_dev = "Bu bir şakamı? Bunun /dev dizini ile bi r ilgisi yok (içermiyor). Bu hatayla karşılaşmak istemiyorsanız zorlama (force) modu kullanın.",
|
||||
.not_open = "Açılamıyor",
|
||||
.not_block = "Belirtilen bölüm bir blok değil. Yani aslında bu bir bölüm bile değil (disk). Bu hatayı almak için şanslı olmak gerek..!",
|
||||
.not_read = "Veri okunamıyor",
|
||||
.not_readdir = "Dizin verisi okunamıyor",
|
||||
.not_write = "Veri yazılamıyor",
|
||||
.not_gen = "Oluşturulamıyor",
|
||||
.no_root = "Root erişimi tespit edilemedi! Lütfen root erişimi ile çalıştırın.",
|
||||
.no_target = "Hedef işlem yok (yedek, flaş veya format).",
|
||||
.expected_backup_arg = "Beklenen yedekleme argümanı 2 (bir tanesi zorunlu değil), alınan",
|
||||
.expected_flash_arg = "Beklenen flaş argümanı 2, alınan",
|
||||
.expected_format_arg = "Beklenen format argümanı 2, alınan",
|
||||
.missing_operand = "İşlem belirtilmedi",
|
||||
.multiple_wiewers = "Birden fazla görüntüleme işlemi yapan fonksiyonlar bir arada kullanılamaz. Aynı anda sadece bir tanesi kullanılabilir.",
|
||||
.common_symbol_rule = "Bir seçeneğin argümanını verirken argüman önüne '-' sembolü getirilemez. Sembolü kaldırın ve tekrar deneyin.",
|
||||
.req_part_name = "Bölüm adı gereklidir.",
|
||||
.part_not_found = "Bölüm bulunamadı!",
|
||||
.unsupported_fs = "Formatlayıcı: desteklenmeyen dosya sistemi:",
|
||||
.cannot_stat = "Durumu tespit edilemedi",
|
||||
.ffile_more_part = "Flaşlanacak dosyanın boyutu mevcut bölüm boyutundan fazla.",
|
||||
.cannot_get_bsz = "Bölüm blok boyutu tespit edilemedi!",
|
||||
.format_fail = "Formatlama başarısız oldu. Bazı şeyler zarar görmüş olabilir!",
|
||||
.depr_backup_opt = "Yedek için artık bu seçeneği kullanamazsınız.",
|
||||
.depr_flash_opt = "Flaşlama için artık bu seçeneği kullanamazsınız.",
|
||||
.depr_format_opt = "Formatlama için artıi bu seçeneği kullanamazsınız.",
|
||||
.depr_Vlicense_opt = "Gereksiz seçeneklere bellek yok!",
|
||||
.depr_ch_list_opt = "Listeleme için -p seçeneğini kullanabilirsiniz.",
|
||||
.logical_warn = "Uyarı: bu cihaz mantıksal (logical) bölümlere sahip.",
|
||||
.not_spec_opt = "Seçenek değil, gerekli argümanları belirtin",
|
||||
.ab_warn = "Uyarı: bu cihazın bazı bölümleri A/B kullanıyor.",
|
||||
.out_not_spec = "Uyarı: çıktı dosya belirtilmedi. Çıktı dosya adı bölüm adına göre belirlenecek.",
|
||||
.please_rerun = "Lütfen yeniden çalıştırın",
|
||||
.part_disk_sz = "Bölümün disk boyutu",
|
||||
.flash_file_sz = "Flaşlanacak dosyanın boyutu",
|
||||
.flash_file_sz_fail = "Uyarı: flaşlanacak dosyanın boyutu tespit edilemedi.",
|
||||
.part_disk_sz_fail = "Uyarı: bölüm boyutunun boyutu tespit edilemedi.",
|
||||
.unknown_opr = "Bilinmeyen işlem",
|
||||
.list_of_dir = "Dizin içeriğinin listesi",
|
||||
.success_backup = "Başarılı. Çıktı",
|
||||
.success_flash = "Başarılı.",
|
||||
.warn = "UYARI",
|
||||
.fatal = "KRİTİK HATA",
|
||||
.switching_lang = "Dil değiştiriliyor...",
|
||||
.welcome = "diline hoş geldiniz!",
|
||||
.welcome_ = NULL,
|
||||
.for_more = "komutunu kullanabilirsiniz",
|
||||
.try_h = "Daha fazla bilgi",
|
||||
.usage_head = "Kullanımı",
|
||||
.depr_opt_str = "KALDIRILMIŞ SEÇENEK",
|
||||
.switched_opt_str = "DEĞİŞTİRİLMİŞ SEÇENEK",
|
||||
.not_changed_opt = "değiştirilmedi",
|
||||
.compiler_str = "Derleyici",
|
||||
.version_str = "versiyon",
|
||||
.bin_str = "yapı",
|
||||
.unknw_str = "bilinmeyen",
|
||||
.by_str = "Çeviriyi yapan(lar):"
|
||||
};
|
||||
|
||||
struct pmt_langdb_docs en_docs = {
|
||||
.docs_strs_l1 = "backup PARTITION [OUTPUT] [OPTIONS]...",
|
||||
.docs_strs_l2 = "flash PARTITION FILE [OPTIONS]...",
|
||||
.docs_strs_l3 = "format PARTITION FILE_SYSTEM[ext/2/3/4] [OPTIONS]...",
|
||||
.docs_strs_l4 = "Options",
|
||||
.docs_strs_l5 = "It is meant to determine whether the target partition is logical.",
|
||||
.docs_strs_l6 = "It is meant to specify a custom /dev context. Only classic partitions (default: /dev/block/by-name).",
|
||||
.docs_strs_l7 = "List partitions.",
|
||||
.docs_strs_l8 = "Information and warning messages are silenced in normal work.",
|
||||
.docs_strs_l9 = "Force mode. Some things are ignored.",
|
||||
.docs_strs_l10 = "Set current language.",
|
||||
.docs_strs_l11 = "See version.",
|
||||
.docs_strs_l12 = "See this help message.",
|
||||
.docs_strs_l13 = "Examples",
|
||||
.docs_strs_l14 = "Report bugs to",
|
||||
.or_str = "or",
|
||||
.usage_docstr = "Usage"
|
||||
};
|
||||
|
||||
struct pmt_langdb_docs tr_docs = {
|
||||
.docs_strs_l1 = "backup BÖLÜM [ÇIKTI] [SEÇENEKLER]...",
|
||||
.docs_strs_l2 = "flash BÖLÜM DOSYA [SEÇENEKLER]...",
|
||||
.docs_strs_l3 = "format BÖLÜM DOSYA_SİSTEMİ[ext/2/3/4] [SEÇENEKLER]...",
|
||||
.docs_strs_l4 = "Seçenekler",
|
||||
.docs_strs_l5 = "Mantıksal (logical) bölüm ile işlem yapın.",
|
||||
.docs_strs_l6 = "Özel /dev bağlamı belirtin. Sadece normal bölümler içindir (Varsayılan: /dev/block/by-name).",
|
||||
.docs_strs_l7 = "Bölümler listelenir.",
|
||||
.docs_strs_l8 = "Bilgi ve uyarı mesajları susturulur.",
|
||||
.docs_strs_l9 = "Zorlama modu. Bazı şeyler göz ardı edilir.",
|
||||
.docs_strs_l10 = "Mevcut dili ayarlayın.",
|
||||
.docs_strs_l11 = "Sürümü görüntüleyin.",
|
||||
.docs_strs_l12 = "Bu yardım mesajını görüntüleyin.",
|
||||
.docs_strs_l13 = "Örnekler",
|
||||
.docs_strs_l14 = "Sorunları şu adrese bildirin:",
|
||||
.or_str = "yada",
|
||||
.usage_docstr = "Kullanımı"
|
||||
};
|
||||
|
||||
struct pmt_langdb_langs lang[] = {
|
||||
{"en"},
|
||||
{"tr"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/* end of code */
|
||||
127
jni/listpart.c
Executable file
127
jni/listpart.c
Executable file
@@ -0,0 +1,127 @@
|
||||
/* By YZBruh */
|
||||
|
||||
/**
|
||||
* Copyright 2024 Partition Manager
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define INC_MAIN_LIBS
|
||||
#define INC_DEBUGERS
|
||||
#define INC_DIRENT
|
||||
|
||||
#include <pmt/PartitionManager.h>
|
||||
#include <pmt/StringKeys.h>
|
||||
|
||||
/* current /dev context */
|
||||
#define CUR_DEV_CNTX "/dev/block/by-name"
|
||||
|
||||
/* for logical partitions */
|
||||
#define LGC_DEV_CNTX "/dev/block/mapper"
|
||||
|
||||
static DIR *dir;
|
||||
|
||||
static int
|
||||
list(const char* operation, const char* target_dir)
|
||||
{
|
||||
static bool list = false;
|
||||
static int count;
|
||||
struct dirent **nlist;
|
||||
dir = NULL;
|
||||
|
||||
if (strcmp(operation, "access") == 0)
|
||||
list = false;
|
||||
else if (strcmp(operation, "print") == 0)
|
||||
list = true;
|
||||
else
|
||||
return -1;
|
||||
|
||||
dir = opendir(target_dir);
|
||||
|
||||
if (dir != NULL)
|
||||
{
|
||||
closedir(dir);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return -1;
|
||||
|
||||
if (list)
|
||||
{
|
||||
count = scandir(target_dir, &nlist, NULL, alphasort);
|
||||
|
||||
if (count < 0)
|
||||
LOGE("%s: `%s': %s\n", current->not_readdir, target_dir, strerror(errno));
|
||||
|
||||
for (int cont_count = 0; cont_count < count; cont_count++)
|
||||
{
|
||||
if (nlist[cont_count]->d_name[0] != '.')
|
||||
LOGD("%s\n", nlist[cont_count]->d_name);
|
||||
|
||||
free(nlist[cont_count]);
|
||||
}
|
||||
|
||||
free(nlist);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
/* 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 (!pmt_force_mode)
|
||||
LOGE("%s: `%s': %s\n", current->not_open, acc_cxt, strerror(errno));
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
list("print", acc_cxt);
|
||||
|
||||
if (pmt_logical)
|
||||
{
|
||||
if (list("access", LGC_DEV_CNTX) != 0)
|
||||
LOGE("%s: `%s': %s\n", current->not_open, LGC_DEV_CNTX, strerror(errno));
|
||||
else
|
||||
list("print", LGC_DEV_CNTX);
|
||||
}
|
||||
|
||||
if (pmt_ab)
|
||||
LOGD("%s: %s\n", bin_name, current->ab_warn);
|
||||
|
||||
if (pmt_logical)
|
||||
LOGD("%s: %s\n", bin_name, current->logical_warn);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* end of code */
|
||||
83
binary/checkers.c → jni/partitiontool.c
Normal file → Executable file
83
binary/checkers.c → jni/partitiontool.c
Normal file → Executable file
@@ -1,17 +1,7 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "include/common.h"
|
||||
|
||||
/* By YZBruh */
|
||||
|
||||
/*
|
||||
* Copyright 2024 YZBruh - Partition Manager
|
||||
/**
|
||||
* Copyright 2024 Partition Manager
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -26,56 +16,61 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
extern bool use_cust_cxt;
|
||||
extern bool pmt_ab;
|
||||
extern bool pmt_logical;
|
||||
extern char *cust_cxt;
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define INC_MAIN_LIBS
|
||||
|
||||
#include <pmt/PartitionManager.h>
|
||||
|
||||
static int
|
||||
accf(const char* _Nonnull target) { return access(target, F_OK); }
|
||||
|
||||
/* check parts */
|
||||
void check_psf()
|
||||
void check_dev_point(void)
|
||||
{
|
||||
/* true = ab | false = a */
|
||||
if (use_cust_cxt) {
|
||||
if (pmt_use_cust_cxt)
|
||||
{
|
||||
static char cust_cxt_ck_path[150];
|
||||
sprintf(cust_cxt_ck_path, "%s/boot_a", cust_cxt);
|
||||
if (access(cust_cxt_ck_path, F_OK) != 0) {
|
||||
|
||||
if (accf(cust_cxt_ck_path) != 0)
|
||||
pmt_ab = false;
|
||||
} else {
|
||||
else
|
||||
pmt_ab = true;
|
||||
}
|
||||
} else {
|
||||
if (access("/dev/block/by-name/boot_a", F_OK) != 0) {
|
||||
pmt_ab = false;
|
||||
} else {
|
||||
pmt_ab = true;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (accf("/dev/block/by-name/boot_a") != 0)
|
||||
pmt_ab = false;
|
||||
else
|
||||
pmt_ab = true;
|
||||
}
|
||||
|
||||
/* true = logical | false = classic */
|
||||
if (use_cust_cxt) {
|
||||
if (pmt_use_cust_cxt)
|
||||
{
|
||||
static char cust_cxt_ckl_path[150];
|
||||
sprintf(cust_cxt_ckl_path, "%s/super", cust_cxt);
|
||||
if (access(cust_cxt_ckl_path, F_OK) != 0) {
|
||||
|
||||
if (accf(cust_cxt_ckl_path) != 0)
|
||||
pmt_logical = false;
|
||||
} else {
|
||||
else
|
||||
pmt_logical = true;
|
||||
}
|
||||
} else {
|
||||
if (access("/dev/block/by-name/super", F_OK) != 0) {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (accf("/dev/block/by-name/super") != 0)
|
||||
pmt_logical = false;
|
||||
} else {
|
||||
else
|
||||
pmt_logical = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* root checker function */
|
||||
void check_root()
|
||||
{
|
||||
/* a quick, easy method to verify root :D */
|
||||
if (chdir("/dev/block") != 0) {
|
||||
error("Root privileges could not be detected! Please run this binary with root.\n");
|
||||
}
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* end of code */
|
||||
/* end */
|
||||
407
jni/pmt.c
Executable file
407
jni/pmt.c
Executable file
@@ -0,0 +1,407 @@
|
||||
/* By YZBruh */
|
||||
|
||||
/**
|
||||
* Copyright 2024 Partition Manager
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/* force use C std (if default is C++) */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define INC_MAIN_LIBS
|
||||
#define INC_DEBUGERS
|
||||
#define INC_STAT
|
||||
#define INC_GETOPT
|
||||
|
||||
#include <pmt/PartitionManager.h>
|
||||
#include <pmt/StringKeys.h>
|
||||
#include <pmt/Deprecates.h>
|
||||
#include <pmt/HelpMessages.h>
|
||||
|
||||
#define opt_symbol "-"
|
||||
|
||||
/* add value to variables that are added globally and are not worth */
|
||||
char* out = NULL;
|
||||
char* cust_cxt = NULL;
|
||||
char* target_partition = NULL;
|
||||
char* target_flash_file = NULL;
|
||||
char* partition_type = NULL;
|
||||
char* format_fs = NULL;
|
||||
char* bin_name = NULL;
|
||||
bool pmt_use_logical = false;
|
||||
bool pmt_use_cust_cxt = false;
|
||||
bool pmt_ab = false;
|
||||
bool pmt_logical = false;
|
||||
bool pmt_silent = false;
|
||||
bool pmt_flash = false;
|
||||
bool pmt_backup = false;
|
||||
bool pmt_format = false;
|
||||
bool pmt_force_mode = false;
|
||||
bool pmt_inst_on_termux = false;
|
||||
|
||||
/* variable for use in control of '-' expression */
|
||||
static char common_symbol_rule[350];
|
||||
|
||||
/**
|
||||
* He controls whether the '-' sign at
|
||||
* the beginning of the given word
|
||||
*/
|
||||
static void
|
||||
check_optsym(const char* _Nullable symbol)
|
||||
{
|
||||
if (symbol != NULL)
|
||||
{
|
||||
if (strncmp(symbol, opt_symbol, 1) == 0)
|
||||
LOGE("%s\n", common_symbol_rule);
|
||||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
ctrl_arg(const char* _Nullable argv_holder)
|
||||
{
|
||||
if (strcmp(argv_holder, "--logical") != 0 && strcmp(argv_holder, "--context") != 0 && strcmp(argv_holder, "--silent") != 0 && strcmp(argv_holder, "-l") != 0 && strcmp(argv_holder, "-c") != 0 && strcmp(argv_holder, "-s") != 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* classic main function (C binary here xd) */
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
bin_name = argv[0];
|
||||
|
||||
int argc_n = argc;
|
||||
char buf[256];
|
||||
char** args = malloc((argc + 1) * sizeof(char *));
|
||||
|
||||
/* copy original arguments */
|
||||
for (int i = 0; i < argc; i++)
|
||||
args[i] = argv[i];
|
||||
|
||||
if (!isatty(fileno(stdin)))
|
||||
{
|
||||
while (fgets(buf, sizeof(buf), stdin) != NULL)
|
||||
{
|
||||
buf[strcspn(buf, "\n")] = 0;
|
||||
|
||||
args = realloc(args, (argc_n + 1) * sizeof(char *));
|
||||
args[argc_n] = strdup(buf);
|
||||
argc_n++;
|
||||
}
|
||||
}
|
||||
|
||||
argc = argc_n;
|
||||
|
||||
/* load language */
|
||||
if (loadlang() != 0)
|
||||
{
|
||||
printf("loadlang fail\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
sprintf(common_symbol_rule, "%s", current->common_symbol_rule);
|
||||
|
||||
if (search_sls() == 0)
|
||||
{
|
||||
if (current->welcome_ != NULL)
|
||||
LOGD("%s", current->welcome_);
|
||||
|
||||
LOGD("%s %s %s %s.\n", current->language, current->welcome, current->by_str, current->lang_by_s);
|
||||
}
|
||||
|
||||
/* check argument total */
|
||||
if (argc < 2)
|
||||
LOGE("%s.\n%s `%s --help' %s.\n", current->missing_operand, current->try_h, args[0], current->for_more);
|
||||
|
||||
/* a structure for long arguments */
|
||||
struct option option_table[] = {
|
||||
{"backup", no_argument, 0, 'b'},
|
||||
{"flash", no_argument, 0, 'F'},
|
||||
{"format", no_argument, 0, 'r'},
|
||||
{"is_dummy", no_argument, 0, 'D'},
|
||||
{"logical", no_argument, 0, 'l'},
|
||||
{"context", required_argument, 0, 'c'},
|
||||
{"list", no_argument, 0, 'p'},
|
||||
{"silent", no_argument, 0, 's'},
|
||||
{"force", no_argument, 0, 'f'},
|
||||
{"set-language", required_argument, 0, 'S'},
|
||||
{"version", no_argument, 0, 'v'},
|
||||
{"help", no_argument, 0, 0},
|
||||
{"license", no_argument, 0, 'L'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
/* boolean statements (only valid in this file) to distinguish. and pointer from a shortcut for the symbol rule */
|
||||
static bool wiew_help = false;
|
||||
static bool wiew_version = false;
|
||||
static bool logical_spec = false;
|
||||
static bool list_partitions = false;
|
||||
static bool combo_wiewers = false;
|
||||
static bool pmt_setlang = false;
|
||||
static char* langpr;
|
||||
static int search_result = 3;
|
||||
static int opt;
|
||||
|
||||
if (strcmp(args[1], "backup") == 0)
|
||||
{
|
||||
if (argc <= 2)
|
||||
LOGE("%s 0.\n", current->expected_backup_arg);
|
||||
|
||||
if (ctrl_arg(args[2]))
|
||||
target_partition = args[2];
|
||||
else
|
||||
LOGE("%s.\n", current->not_spec_opt);
|
||||
|
||||
out = target_partition;
|
||||
|
||||
if (argc > 3 && ctrl_arg(args[3]))
|
||||
out = args[3];
|
||||
|
||||
check_optsym(target_partition);
|
||||
check_optsym(out);
|
||||
|
||||
pmt_backup = true;
|
||||
}
|
||||
else if (strcmp(args[1], "flash") == 0)
|
||||
{
|
||||
if (argc <= 2)
|
||||
LOGE("%s 0.\n", current->expected_flash_arg);
|
||||
|
||||
if (argc <= 3)
|
||||
LOGE("%s 1.\n", current->expected_flash_arg);
|
||||
|
||||
if (ctrl_arg(args[2]))
|
||||
target_partition = args[2];
|
||||
else
|
||||
LOGE("%s.\n", current->not_spec_opt);
|
||||
|
||||
if (ctrl_arg(args[3]))
|
||||
target_flash_file = args[3];
|
||||
else
|
||||
LOGE("%s.\n", current->not_spec_opt);
|
||||
|
||||
check_optsym(target_flash_file);
|
||||
check_optsym(target_partition);
|
||||
|
||||
pmt_flash = true;
|
||||
}
|
||||
else if (strcmp(args[1], "format") == 0)
|
||||
{
|
||||
|
||||
if (argc <= 2)
|
||||
LOGE("%s 0.\n", current->expected_format_arg);
|
||||
|
||||
if (argc <= 3)
|
||||
LOGE("%s 1.\n", current->expected_format_arg);
|
||||
|
||||
if (ctrl_arg(args[2]))
|
||||
target_partition = args[2];
|
||||
else
|
||||
LOGE("%s.\n", current->not_spec_opt);
|
||||
|
||||
if (ctrl_arg(args[3]))
|
||||
format_fs = args[3];
|
||||
else
|
||||
LOGE("%s.\n", current->not_spec_opt);
|
||||
|
||||
check_optsym(format_fs);
|
||||
check_optsym(target_partition);
|
||||
|
||||
pmt_format = true;
|
||||
}
|
||||
|
||||
/* control for each argument */
|
||||
while ((opt = getopt_long(argc, args, "bFrDlc:psfS:vL", option_table, NULL)) != -1)
|
||||
{
|
||||
/* process arguments */
|
||||
switch (opt)
|
||||
{
|
||||
/* handle deprecates */
|
||||
case 'b':
|
||||
DEPR_HANDLE('b', "backup", current->depr_backup_opt);
|
||||
exit(1);
|
||||
break;
|
||||
case 'F':
|
||||
DEPR_HANDLE('F', "flash", current->depr_flash_opt);
|
||||
exit(1);
|
||||
break;
|
||||
case 'r':
|
||||
DEPR_HANDLE('r', "format", current->depr_format_opt);
|
||||
exit(1);
|
||||
break;
|
||||
case 'D':
|
||||
DEPR_HANDLE('D', "NULLPTR", current->depr_ch_list_opt);
|
||||
exit(1);
|
||||
break;
|
||||
case 'L':
|
||||
DEPR_HANDLE('L', "license", current->depr_Vlicense_opt);
|
||||
exit(1);
|
||||
break;
|
||||
/* logical partitions option */
|
||||
case 'l':
|
||||
logical_spec = true;
|
||||
break;
|
||||
/* context selector option */
|
||||
case 'c':
|
||||
pmt_use_cust_cxt = true;
|
||||
cust_cxt = strdup(optarg);
|
||||
check_optsym(cust_cxt);
|
||||
break;
|
||||
/* partition lister function */
|
||||
case 'p':
|
||||
list_partitions = true;
|
||||
/* check combo wiewer options and progress */
|
||||
if (wiew_version || wiew_help) combo_wiewers = true;
|
||||
break;
|
||||
/* force mode option */
|
||||
case 'f':
|
||||
pmt_force_mode = true;
|
||||
break;
|
||||
/* silent mode option */
|
||||
case 's':
|
||||
pmt_silent = true;
|
||||
break;
|
||||
/* language setter option */
|
||||
case 'S':
|
||||
pmt_setlang = true;
|
||||
langpr = strdup(optarg);
|
||||
break;
|
||||
/* version info option */
|
||||
case 'v':
|
||||
wiew_version = true;
|
||||
/* check combo wiewer options and progress */
|
||||
if (list_partitions || wiew_help) combo_wiewers = true;
|
||||
break;
|
||||
/* help message opption */
|
||||
case 0:
|
||||
wiew_help = true;
|
||||
/* check combo wiewer options and progress */
|
||||
if (wiew_version || list_partitions) combo_wiewers = true;
|
||||
break;
|
||||
/* for invalid options */
|
||||
case '?':
|
||||
LOGD("%s `%s --help' %s\n", current->try_h, args[0], current->for_more);
|
||||
return 1;
|
||||
break;
|
||||
default:
|
||||
LOGD("%s: %s [backup] [flash] [format] [-l | --logical] [-c | --context] [-p | --list] [-s | --silent] [-v | --version] [--help]\n", current->usage_head, args[0]);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* stop the program if multiple viewer is used */
|
||||
if (combo_wiewers)
|
||||
LOGE("%s", current->multiple_wiewers);
|
||||
|
||||
/* controller to handle viewer */
|
||||
if (wiew_help)
|
||||
{
|
||||
help();
|
||||
return 0;
|
||||
}
|
||||
else if (wiew_version)
|
||||
{
|
||||
version();
|
||||
return 0;
|
||||
}
|
||||
else if (list_partitions)
|
||||
{
|
||||
check_root();
|
||||
return listpart();
|
||||
}
|
||||
|
||||
if (pmt_setlang)
|
||||
{
|
||||
LOGD("%s: %s\n", args[0], current->switching_lang);
|
||||
setlang(langpr, 0);
|
||||
sleep(2);
|
||||
LOGD("%s: %s.\n", args[0], current->please_rerun);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!pmt_backup && !pmt_flash && !pmt_format)
|
||||
LOGE("%s.\n%s `%s --help` %s\n", current->no_target, current->try_h, args[0], current->for_more);
|
||||
|
||||
if (pmt_format)
|
||||
{
|
||||
if (strcmp(format_fs, "ext4") != 0 && strcmp(format_fs, "ext3") != 0 && strcmp(format_fs, "ext2") != 0)
|
||||
LOGE("%s: %s\n", current->unsupported_fs, format_fs);
|
||||
}
|
||||
|
||||
/* checks */
|
||||
check_root();
|
||||
check_dev_point();
|
||||
|
||||
if (logical_spec)
|
||||
{
|
||||
if (pmt_logical)
|
||||
pmt_use_logical = true;
|
||||
else
|
||||
LOGE("%s\n", current->not_logical);
|
||||
}
|
||||
|
||||
if (pmt_flash)
|
||||
{
|
||||
search_result = get_stat(target_flash_file, "file");
|
||||
|
||||
if (search_result == 1)
|
||||
LOGE("%s `%s': %s\n", current->cannot_stat, target_flash_file, strerror(errno));
|
||||
else if (search_result == -1)
|
||||
LOGE("`%s': %s\n", target_flash_file, current->not_file);
|
||||
}
|
||||
|
||||
/* custom context checker */
|
||||
if (pmt_use_cust_cxt)
|
||||
{
|
||||
search_result = get_stat(cust_cxt, "dir");
|
||||
|
||||
if (search_result == 1)
|
||||
LOGE("%s `%s': %s\n", current->cannot_stat, cust_cxt, strerror(errno));
|
||||
else if (search_result == -1)
|
||||
LOGE("`%s': %s\n", cust_cxt, current->not_dir);
|
||||
|
||||
if (strstr(cust_cxt, "/dev") == NULL && !pmt_force_mode)
|
||||
LOGE("%s\n", current->not_in_dev);
|
||||
}
|
||||
|
||||
if (target_partition == NULL)
|
||||
{
|
||||
if (!pmt_force_mode)
|
||||
LOGE("%s\n%s `%s --help' %s\n", current->req_part_name, current->try_h, args[0], current->for_more);
|
||||
}
|
||||
else
|
||||
{
|
||||
/**
|
||||
* 1 = backup mode
|
||||
*
|
||||
* 2 = flash mode
|
||||
*
|
||||
* 3 = format
|
||||
*/
|
||||
if (pmt_backup)
|
||||
return pmt(1);
|
||||
else if (pmt_flash)
|
||||
return pmt(2);
|
||||
else if (pmt_format)
|
||||
return pmt(3);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/* end of code */
|
||||
41
jni/root.c
Executable file
41
jni/root.c
Executable file
@@ -0,0 +1,41 @@
|
||||
/* By YZBruh */
|
||||
|
||||
/**
|
||||
* Copyright 2024 Partition Manager
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define INC_MAIN_LIBS
|
||||
#define INC_DEBUGERS
|
||||
|
||||
#include <pmt/PartitionManager.h>
|
||||
#include <pmt/StringKeys.h>
|
||||
|
||||
/* root checker function */
|
||||
void check_root(void)
|
||||
{
|
||||
/* a quick, easy method for verifying root */
|
||||
if (getuid() != 0)
|
||||
LOGE("%s\n", current->no_root);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* end of code */
|
||||
210
jni/tools.c
Executable file
210
jni/tools.c
Executable file
@@ -0,0 +1,210 @@
|
||||
/* By YZBruh */
|
||||
|
||||
/**
|
||||
* Copyright 2024 Partition Manager
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define BFSIZE 1024
|
||||
#define INC_MAIN_LIBS
|
||||
#define INC_STAT
|
||||
#define INC_DEBUGERS
|
||||
#define INC_TOOLS_REQS
|
||||
|
||||
#include <pmt/PartitionManager.h>
|
||||
#include <pmt/StringKeys.h>
|
||||
|
||||
#define count (1024 * 1024 * 1024)
|
||||
|
||||
/**
|
||||
* it is meant to calculate the size of the quickly given file.
|
||||
* its purpose is for rapid processing
|
||||
*/
|
||||
static double
|
||||
calc_flsz(const char* _Nonnull filepath)
|
||||
{
|
||||
static int calc_flsz_file;
|
||||
calc_flsz_file = open(filepath, O_RDONLY);
|
||||
|
||||
if (calc_flsz_file == -1)
|
||||
return calc_flsz_file;
|
||||
|
||||
static off_t flsz;
|
||||
flsz = lseek(calc_flsz_file, 0, SEEK_END);
|
||||
close(calc_flsz_file);
|
||||
|
||||
if (flsz == (off_t)-1)
|
||||
return -1;
|
||||
|
||||
return (double)flsz / (1024 * 1024);
|
||||
}
|
||||
|
||||
/**
|
||||
* error that the partition is not found.
|
||||
* It's for quick action.
|
||||
*/
|
||||
static void
|
||||
partition_not_found(void) { LOGE("%s\n", current->part_not_found); }
|
||||
|
||||
/* to stop use of function type */
|
||||
#define partition_not_found partition_not_found()
|
||||
|
||||
/* the partitions are meant to quickly find. */
|
||||
static void
|
||||
search_partition(const char* _Nonnull partition)
|
||||
{
|
||||
static int partition_results = 0;
|
||||
partition_results = get_stat(partition, "blk");
|
||||
|
||||
if (partition_results == 1)
|
||||
partition_not_found;
|
||||
else if (partition_results == -1)
|
||||
LOGE("%s\n", current->not_block);
|
||||
}
|
||||
|
||||
int pmt(unsigned short progress_code)
|
||||
{
|
||||
/* required variables */
|
||||
static int srcf, targetf;
|
||||
static char acc_part_path[512];
|
||||
static char formatter_cmd[200];
|
||||
static char outf[512];
|
||||
static char buffer[BFSIZE];
|
||||
static ssize_t readed_data;
|
||||
static unsigned long long copied_data = 0;
|
||||
|
||||
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 (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(acc_part_path, O_RDONLY);
|
||||
if (srcf == -1)
|
||||
LOGE("%s: %s: %s\n", current->not_read, acc_part_path, strerror(errno));
|
||||
|
||||
/* determine output */
|
||||
if (strcmp(out, target_partition) == 0)
|
||||
{
|
||||
sprintf(outf, "%s.img", out);
|
||||
LOGW("%s: %s\n", current->out_not_spec, outf);
|
||||
}
|
||||
else
|
||||
sprintf(outf, "%s", out);
|
||||
|
||||
targetf = open(outf, O_WRONLY | O_CREAT | O_TRUNC, 0660);
|
||||
if (targetf == -1)
|
||||
LOGE("%s: %s: %s\n", current->not_gen, outf, 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)
|
||||
{
|
||||
if (get_stat(outf, "file") == 0)
|
||||
remove(outf);
|
||||
LOGF("%s: %s: %s\n", current->not_write, acc_part_path, strerror(errno));
|
||||
}
|
||||
|
||||
copied_data += writed_data;
|
||||
}
|
||||
|
||||
/* close files */
|
||||
close(srcf);
|
||||
close(targetf);
|
||||
|
||||
LOGD("%s: %s\n", current->success_backup, outf);
|
||||
}
|
||||
else if (progress_code == 2)
|
||||
{
|
||||
if (calc_flsz(target_flash_file) != -1)
|
||||
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(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(acc_part_path) != -1)
|
||||
{
|
||||
if (calc_flsz(target_flash_file) > calc_flsz(acc_part_path))
|
||||
LOGE("%s\n", current->ffile_more_part);
|
||||
}
|
||||
|
||||
srcf = open(target_flash_file, O_RDONLY);
|
||||
if (srcf == -1)
|
||||
LOGF("%s: %s: %s\n", current->not_read, target_flash_file, strerror(errno));
|
||||
|
||||
targetf = open(acc_part_path, O_WRONLY | O_CREAT | O_TRUNC, 0660);
|
||||
if (targetf == -1)
|
||||
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, acc_part_path, strerror(errno));
|
||||
|
||||
copied_data += writed_data;
|
||||
}
|
||||
|
||||
close(srcf);
|
||||
close(targetf);
|
||||
|
||||
LOGD("%s.\n", current->success_flash);
|
||||
}
|
||||
else if (progress_code == 3)
|
||||
{
|
||||
/* get target partition block size */
|
||||
struct statvfs file_sys_inf;
|
||||
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, acc_part_path);
|
||||
|
||||
/* run command */
|
||||
if (system(formatter_cmd) != 0)
|
||||
LOGF("%s\n", current->format_fail);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* end of code */
|
||||
53
jni/version.c
Executable file
53
jni/version.c
Executable file
@@ -0,0 +1,53 @@
|
||||
/* By YZBruh */
|
||||
|
||||
/**
|
||||
* Copyright 2024 Partition Manager
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define INC_MAIN_LIBS
|
||||
#define VERSIONING
|
||||
|
||||
#include <pmt/PartitionManager.h>
|
||||
#include <pmt/StringKeys.h>
|
||||
#include <pmt/VersionVars.h>
|
||||
|
||||
void version(void)
|
||||
{
|
||||
LOGD("%s %s %d.%d.%d (%d%d%d) ", bin_name, current->version_str, PMT_MAJOR, PMT_MINOR, PMT_PATCHLEVEL, PMT_MAJOR, PMT_MINOR, PMT_PATCHLEVEL);
|
||||
|
||||
#if __SIZEOF_POINTER__ == 4
|
||||
LOGD("32-bit %s\n", current->bin_str);
|
||||
#elif __SIZEOF_POINTER__ == 8
|
||||
LOGD("64-bit %s\n", current->bin_str);
|
||||
#else
|
||||
LOGD("<%s> %s\n", current->unknw_str, current->bin_str);
|
||||
#endif
|
||||
|
||||
#if defined(__clang__) && !defined(__NDK_BUILD)
|
||||
LOGD("%s: clang %d.%d.%d\n", current->compiler_str, __clang_major__, __clang_minor__, __clang_patchlevel__);
|
||||
#elif defined(__NDK_BUILD)
|
||||
LOGD("%s\n", __NDK_CC_VERSION__);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/* end of code */
|
||||
151
out/Makefile
Executable file
151
out/Makefile
Executable file
@@ -0,0 +1,151 @@
|
||||
# By YZBruh
|
||||
|
||||
# Copyright 2024 Partition Manager
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
#####
|
||||
# sub-make for installing-uninstalling
|
||||
#####
|
||||
|
||||
THIS_IS := out
|
||||
|
||||
# include needed variables
|
||||
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:
|
||||
$(P) ""
|
||||
|
||||
# installer
|
||||
.PHONY: install
|
||||
install: $(INSTALL_PROGRESS_LIST)
|
||||
|
||||
# uninstaller
|
||||
.PHONY: uninstall
|
||||
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 \
|
||||
$(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
|
||||
|
||||
really_builded:
|
||||
if [ ! -f $(BINARY_DIR)/$(TARGET) ]; then \
|
||||
$(P) " - $(RED)$(BOLD)Error:$(BOLD_RESET)$(RESET) Package not builded! Please build package and try again \n"; \
|
||||
$(E_NS) "INSTALL_SUCCESS := false" > $(BUILD)/config/INS_STAT.mk; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
# end
|
||||
Reference in New Issue
Block a user