283 Commits
1.4.0 ... 2.8.0

Author SHA1 Message Date
82bd2939cd nevermind 2024-09-11 19:24:40 +03:00
82fa4bffbb pmt: use static libc++_shared 2024-09-11 19:14:55 +03:00
cf7a095dac pmt: deb maker: fix typo 2024-09-11 18:39:58 +03:00
29d11d5259 pmt: script: switch wrong name 2024-09-11 18:31:10 +03:00
742b946935 pmt: script: some fixes 2024-09-11 18:30:47 +03:00
e145dea230 pmt: script, deb: some fixes 2024-09-11 18:30:03 +03:00
fcf61f3348 pmt: termux script: some minor additions 2024-09-11 18:13:48 +03:00
5701862621 pmt: releases: fix body on releases 2024-09-11 17:50:35 +03:00
7daf21df00 pmt: workflow: fix making deb package 2024-09-11 17:41:26 +03:00
affbdbcf20 pmt: workflow: fix typo 2024-09-11 17:34:20 +03:00
87ab05b4c6 pmt: update changelog 2024-09-11 17:24:03 +03:00
cf98bb9c9e pmt: try fix workflow, The script was explained 2024-09-11 17:20:41 +03:00
7bd057156f pmt: workflow try fix build issues with NDK 2024-09-11 16:52:00 +03:00
e39769460f pmt: f*** 2024-09-11 07:46:43 +03:00
3d246fe653 pmt: use LOCAL_STL for linking libc++_shared 2024-09-11 07:16:49 +03:00
c5f0498eef pmt: f*** C++ 2024-09-11 07:06:08 +03:00
0b15005dbd pmt: Link libc++_shared to binary 2024-09-11 06:59:26 +03:00
9ed45938e6 pmt: disable debugging 2024-09-11 06:52:54 +03:00
a4491447cb pmt: Android.mk: switch std to C++ 14 2024-09-11 06:52:21 +03:00
7abc4318cf pmt: fixup generator bash script 2024-09-11 06:46:01 +03:00
e1801d5789 pmt: workflow: try fix build issues 2024-09-11 06:33:59 +03:00
f6c9ac66f5 pmt: cleanup dummy files 2024-09-11 06:25:36 +03:00
542330f63b pmt: fix NDK issues [placeholder: initial] 2024-09-11 06:25:03 +03:00
001887fd8b pmt: f*** NDK 2024-09-10 06:48:45 +03:00
39ac8b2797 pmt: fixup main.mk 2024-09-10 06:39:51 +03:00
34b4c1beb2 pmt: fixup workflow [place-holder: initial] 2024-09-10 06:31:57 +03:00
595f3b00b3 pmt: initial 2.8.0 update 2024-09-10 06:17:41 +03:00
ec5a2b97b9 pmt: header: add license text per generated header for automatic clang version detection 2024-08-03 12:28:33 +03:00
95c100453f pmt: fix wrong source paths (said) 2024-08-02 18:25:06 +03:00
157e99a08e pmt: utils: run commands silently 2024-08-02 18:05:47 +03:00
b1f9e491b3 pmt: fix wrong include 2024-08-02 18:04:41 +03:00
9313a8ec4a pmt: fix problem in makefile build system 2024-08-02 17:54:52 +03:00
512d35737b pmt: transfer documents to 2.7.0 branch 2024-08-02 17:53:27 +03:00
9bcde145a5 pmt: 2.7.0 changelog update 2024-08-02 17:52:24 +03:00
5d51e44a2c pmt: initial 2.7.0 update 2024-08-02 17:44:31 +03:00
ed745369fa pmt: Fixes the deficiencies in the update in the compilation system 2024-08-02 09:02:39 +03:00
851f0aaeb2 pmt: enable NDK build type in builds for deb packages (version targeted) 2024-07-31 13:38:36 +03:00
00990ea242 pmt: update mandoc 2024-07-29 21:41:29 +03:00
356e8683a5 pmt: fixup builder workflow problem 2024-07-29 21:25:26 +03:00
9c72226498 pmt: README: fix wrong links 2024-07-29 21:17:42 +03:00
2f87fd57c0 pmt: header: add missing include (fcntl) 2024-07-29 21:16:15 +03:00
5b00b0bfe3 pmt: initial 2.6.0 update 2024-07-28 23:01:21 +03:00
36efab6eb3 forget it 2024-07-22 23:25:14 +03:00
74ca2de92e pmt: cleanup release notes 2024-07-22 22:22:51 +03:00
3640331184 pmt: add more information about compilation 2024-07-22 16:29:06 +03:00
0fc709f34f pmt: Add documentation about adding languages 2024-07-22 11:59:44 +03:00
36c49131be pmt: Update disclaimer 2024-07-22 11:51:35 +03:00
14788d1aaf pmt: ad badge 2024-07-22 11:38:09 +03:00
9c61fcfaae pmt: delete accidentally loaded build specific files 2024-07-22 11:35:04 +03:00
b834134221 pmt: Use timestamp instead of architecture in xz package name and use sudo when creating deb package 2024-07-22 08:52:42 +03:00
7eb6289726 pmt: fix wrong help message in source 2024-07-22 08:27:21 +03:00
3b612d1df4 pmt: fix wrong help message 2024-07-22 08:26:38 +03:00
fb6b7dca06 pmt: update man page [automake: initial] 2024-07-22 08:23:20 +03:00
41cb1801c0 pmt: Make builder workflow only manually executable 2024-07-21 22:30:44 +03:00
d2e4b58ab6 pmt: Create separate workflow for automatic commit review 2024-07-21 22:27:43 +03:00
b4b9f1d1df pmt: change title 2024-07-21 22:15:37 +03:00
8c8d9edbd4 pmt: fix wrong erase path 2024-07-21 22:03:59 +03:00
2dcf2c124f pmt: Add text about deb installation to Termux automatically in posts 2024-07-21 22:01:14 +03:00
04d7121eb6 pmt: Create guide for installing deb in Termux 2024-07-21 21:59:40 +03:00
ad8756a05c pmt: Use code font in clang version information in release descriptions 2024-07-21 21:47:20 +03:00
26cc9740b7 pmt: switch check-out version 4 2024-07-21 21:39:13 +03:00
0519bc3a66 pmt: workflow: change token name 2024-07-21 21:07:48 +03:00
484fa8dcca pmt: add missing explantions 2024-07-21 20:23:49 +03:00
91713b86be pmt: initial 2.5.0 update 2024-07-21 20:20:17 +03:00
4f8e15935a pmt: copy commit
pmt: fix wrong translations
2024-07-14 08:19:53 +03:00
19b8d74498 pmt: fix wrong translations 2024-07-14 08:18:19 +03:00
da15903881 pmt: solve serious working problem 2024-07-13 21:55:51 +03:00
57403a0196 pmt: generate build config for workflows (soon) 2024-07-11 17:46:18 +03:00
d591c760e1 pmt: Create comments and text appropriate for the ShawkTeam repository 2024-07-11 16:07:07 +03:00
ec6148b0d9 f*** C 2024-07-10 14:35:30 +03:00
f7bbe2ba15 pmt: languages: en: fix typos 2024-07-10 14:33:48 +03:00
c9453ef968 Merge pull request #1 from r0manas-dev/patch-1
pmt: fix bad English translations
2024-07-10 01:47:07 +03:00
7943fa312c pmt: fix broken syntax 2024-07-10 01:45:30 +03:00
3fb873199b Update ADD-LANGUAGES.md 2024-07-10 01:40:14 +03:00
chakra
c6163bc752 Update languages.c 2024-07-09 15:26:38 -07:00
chakra
30f1a84f13 Update languages.c 2024-07-09 15:22:11 -07:00
4607f565af Update README.md 2024-07-09 21:27:56 +03:00
2edc502bbf pmt: ADD-LANGUAGES 2024-07-09 21:26:40 +03:00
fd15d460f6 pmt.c: cleanup unnecessary code and fix wrong log text
pmt: cleanup

pmt: cleanup
2024-07-09 20:38:17 +03:00
fe752d7505 pmt: First statement about supported languages 2024-07-09 19:38:45 +03:00
464027fd1c Create CHANGELOG.md 2024-07-09 19:33:29 +03:00
99b45da4a7 pmt: README: add new comments as needed 2024-07-09 19:30:52 +03:00
284bb42faa pmt: README: fix wrong text 2024-07-09 19:28:41 +03:00
964d9b5426 pmt: initial 2.4.0 update 2024-07-09 19:26:18 +03:00
4dd49c2509 pmt: fix some 2.3.0 missing: makefile 2024-07-04 14:58:08 +03:00
934d1b0112 pmt: fix some 2.3.0 missings 2024-07-04 14:57:06 +03:00
32ac3a3dd6 pmt: initial 2.3.0 update
Delete jni/Makefile
2024-06-28 00:44:34 +03:00
fc02df6583 pmt: Fix FORTIFY problems 2024-06-17 11:41:55 +03:00
deb42c9ff5 Update README.md 2024-06-17 10:57:12 +03:00
60904a4b2f Update install-termux.sh 2024-06-17 00:37:35 +03:00
ad6115f51b Update install-termux.sh 2024-06-17 00:30:59 +03:00
6cc59d92f8 Update install-termux.sh 2024-06-17 00:28:42 +03:00
fe69408eb5 Update install-termux.sh 2024-06-17 00:26:37 +03:00
cd386ac6f9 Update install-termux.sh 2024-06-17 00:22:37 +03:00
268aa8ac77 Update install-termux.sh 2024-06-17 00:21:57 +03:00
c5746fe14b Update install-termux.sh 2024-06-17 00:17:11 +03:00
d2cb68df5e Update install-termux.sh 2024-06-17 00:13:30 +03:00
3976e0fb39 Update install-termux.sh 2024-06-17 00:08:01 +03:00
0a9e164b9c Update install-termux.sh 2024-06-17 00:07:00 +03:00
ecada5f076 Update install-termux.sh 2024-06-17 00:06:28 +03:00
ca09bb94e1 Update install-termux.sh 2024-06-17 00:03:18 +03:00
52ffe99d4b Update install-termux.sh 2024-06-17 00:00:54 +03:00
416939634a pmt: fix syntax 2024-06-17 00:00:24 +03:00
cbbd36899e Update README.md 2024-06-16 23:58:10 +03:00
9dc79ae923 Update install-termux.sh 2024-06-16 23:57:15 +03:00
b522dcc62b Update install-termux.sh 2024-06-16 23:56:35 +03:00
7aeea39e41 Update README.md 2024-06-16 23:56:01 +03:00
974774eb3e pmt: add quick installer 2024-06-16 23:51:02 +03:00
70ce307e50 readme: create a general file alignment table 2024-06-16 08:44:01 +03:00
99ecb9daf3 Make some corrections. 2024-06-10 06:28:01 +03:00
d0a7b2d16f Update CHANGELOG.md 2024-06-04 18:07:35 +03:00
96336bcd0b Update README.md 2024-06-04 17:59:20 +03:00
545376afb2 Initial 2.1.0 update 2024-06-04 17:55:15 +03:00
62b24d5705 Update docs.c 2024-05-26 17:08:18 +03:00
0fca319b29 Update README.md 2024-05-26 17:07:56 +03:00
929150e034 pmt: delete unnecessary files 2024-05-26 11:31:46 +03:00
93843a511d fix typo 2024-05-26 11:30:57 +03:00
0981e70268 pmt: edit changelog 2024-05-26 11:30:03 +03:00
b214da3cd6 pmt: fix missing explanation 2024-05-26 11:24:41 +03:00
464bfe6e56 pmt: Update build guide 2024-05-26 11:23:54 +03:00
f5531fde32 pmt: initial 2.0.0 update 2024-05-26 10:49:33 +03:00
f771fb7c68 Update env.mk 2024-05-14 00:07:19 +03:00
4bc5235952 Update vars.mk 2024-05-14 00:04:29 +03:00
d4b4c91ff4 pmt; use target arch macro 2024-05-14 00:00:15 +03:00
6fc38eb01d Update vars.mk 2024-05-13 23:58:04 +03:00
42e5d132e7 Update vars.mk 2024-05-13 23:52:55 +03:00
39d1411b11 pmt; include stdint lib 2024-05-13 23:47:16 +03:00
04d6471c86 Update tools.c 2024-05-13 23:46:54 +03:00
f7d2f313de Update pmt.c 2024-05-13 23:46:37 +03:00
49a87b0387 pmt; include stdint lib 2024-05-13 23:46:15 +03:00
5a104e5b22 pmt; include stdint lib 2024-05-13 23:45:56 +03:00
055213f2f6 pmt; include stdint lib 2024-05-13 23:45:37 +03:00
7f270e319c pmt; include stdint lib 2024-05-13 23:45:17 +03:00
6a035f8f41 Update pmt.h 2024-05-13 23:43:35 +03:00
1b2dda655a Update vars.mk 2024-05-13 23:43:11 +03:00
07d63944c1 Update pmt.h 2024-05-13 23:36:54 +03:00
36b7bcf246 Update pmt.h 2024-05-13 23:35:30 +03:00
cd3f65a145 Update pmt.h 2024-05-13 23:34:56 +03:00
9dd29f96b8 Update pmt.h 2024-05-13 23:31:41 +03:00
7254637caf Update pmt.h 2024-05-13 23:30:54 +03:00
2af00a8028 Update pmt.h 2024-05-13 23:26:39 +03:00
b5790af803 pmt: change macro name 2024-05-13 23:23:02 +03:00
8fe1548796 Update vars.mk 2024-05-13 23:20:12 +03:00
04d8ccdd81 Update vars.mk 2024-05-13 23:14:59 +03:00
1a790d1d89 Update vars.mk 2024-05-13 23:13:43 +03:00
1296e488f1 Update vars.mk 2024-05-13 23:09:35 +03:00
3fea6c73cc Update vars.mk 2024-05-13 23:06:56 +03:00
cf4b590130 Update vars.mk 2024-05-13 23:05:28 +03:00
352ef6e68a Update vars.mk 2024-05-13 23:04:36 +03:00
754ebaade2 Update vars.mk 2024-05-13 23:03:37 +03:00
8a28a8f1ef Update ndk.sh 2024-05-13 23:01:43 +03:00
086a2dd93d Update vars.mk 2024-05-13 23:00:17 +03:00
383a1efe55 Create ndk.sh 2024-05-13 22:59:21 +03:00
b96977a5fc Update vars.mk 2024-05-13 22:58:17 +03:00
976c10593c Update vars.mk 2024-05-13 22:53:23 +03:00
d45dd67cbe Update vars.mk 2024-05-13 22:46:55 +03:00
0fa5a546aa Update vars.mk 2024-05-13 22:44:59 +03:00
0c487c62fe pmt: fix syntax 2024-05-13 22:43:15 +03:00
105d92e0ca Update vars.mk 2024-05-13 22:40:15 +03:00
850d104a1a Update README.md 2024-05-13 22:28:51 +03:00
6d24fb9eae pmt: adapt NDK 2024-05-13 22:28:10 +03:00
ae8c73c4f5 pmt: adapt NDK 2024-05-13 22:26:46 +03:00
890d93131c pmt: include env first 2024-05-13 22:24:57 +03:00
a33d4e3f16 Update README.md 2024-05-13 22:12:29 +03:00
f344d62d4c Update README.md 2024-05-13 22:10:44 +03:00
40c5b155dc Update README.md 2024-05-13 22:08:51 +03:00
0547e18639 Update README.md 2024-05-13 22:05:57 +03:00
f34a47889e Update README.md 2024-05-13 22:00:47 +03:00
a9fac9e661 pmt: just report compiling with android NDK 2024-05-13 21:57:15 +03:00
e8040de436 pmt: header: make compatible with android NDK 2024-05-13 21:53:54 +03:00
ff6e82c556 pmt: versioner: add 32-bit or 64-bit build information to version information 2024-05-13 21:51:20 +03:00
0c7da875b2 pmt: listpart: include string library 2024-05-13 21:43:21 +03:00
41565d221f pmt: update version 2024-05-08 06:58:40 +03:00
5ba78d860e pmt: update version 2024-05-07 20:58:37 +03:00
181125dfca pmt: initial 1.9.0 update 2024-05-05 21:06:14 +03:00
4464c203fd pmt: initial 1.9.0 update 2024-05-05 21:05:21 +03:00
b9e58df98f pmt: initial 1.9.0 update 2024-05-05 21:04:48 +03:00
e2f8cf4ca3 pmt: initial 1.9.0 update 2024-05-05 21:03:51 +03:00
07e2249ef1 pmt: initial 1.9.0 update 2024-05-05 21:03:01 +03:00
fd970be822 pmt: initial 1.9.0 update 2024-05-05 21:02:26 +03:00
45c964997c Delete src/format.c 2024-05-05 21:02:15 +03:00
31b7f16a29 pmt: initial 1.9.0 update 2024-05-05 21:02:04 +03:00
5f83a4476f pmt: initial 1.9.0 update 2024-05-05 21:01:43 +03:00
5438f5210f pmt: initial 1.9.0 update 2024-05-05 21:00:53 +03:00
cb7904cd5a pmt: initial 1.9.0 update 2024-05-05 20:57:20 +03:00
9c570d5b02 pmt: initial 1.9.0 update 2024-05-05 20:56:34 +03:00
c9736863fe pmt: initial 1.9.0 update 2024-05-05 20:55:59 +03:00
d5ce065e8b pmt: initial 1.9.0 update 2024-05-05 20:55:19 +03:00
a4bc9e3834 pmt: initial 1.9.0 update 2024-05-05 20:54:15 +03:00
ce017e2cbc pmt: move source in to src 2024-04-25 22:35:32 +03:00
b5daf8a44c pmt: move source in to src 2024-04-25 22:35:01 +03:00
f125ae760c pmt: move source in to src 2024-04-25 22:34:31 +03:00
f68f92ade1 pmt: move source in to src 2024-04-25 22:34:04 +03:00
3a723446cc pmt: move source in to src 2024-04-25 22:33:40 +03:00
1d66a3c21f pmt: move source in to src 2024-04-25 22:32:34 +03:00
13e31df7c6 pmt: move source in to src 2024-04-25 22:31:52 +03:00
4922ed5a35 pmt: move source in to src 2024-04-25 22:31:12 +03:00
3220aace91 pmt: move source in to src 2024-04-25 22:30:40 +03:00
7f85d63088 pmt: initial 1.8.0 update 2024-04-25 22:09:03 +03:00
412b697b9c pmt: initial 1.8.0 update 2024-04-25 22:08:30 +03:00
afc958aeb4 pmt: initial 1.8.0 update 2024-04-25 22:07:45 +03:00
fbd45e0936 pmt: initial 1.8.0 update 2024-04-25 22:07:05 +03:00
0ef8767eb5 pmt: initial 1.8.0 update 2024-04-25 22:06:31 +03:00
9bc871573e pmt: initial 1.8.0 update 2024-04-25 22:05:58 +03:00
adad63bbbd pmt: initial 1.8.0 update 2024-04-25 22:05:12 +03:00
0157c886ae pmt: initial 1.8.0 update 2024-04-25 22:04:33 +03:00
076774d9f4 pmt: initial 1.8.0 update 2024-04-25 22:04:00 +03:00
25642cc6f2 pmt: initial 1.8.0 update 2024-04-25 22:02:58 +03:00
16c8654fa2 pmt: initial 1.8.0 update 2024-04-25 22:02:04 +03:00
1fb592a94f pmt: initial 1.8.0 update 2024-04-25 22:01:14 +03:00
5bb26c9eea pmt: initial 1.8.0 update 2024-04-25 21:59:54 +03:00
540dd4fe35 pmt: initial 1.8.0 update 2024-04-25 21:59:06 +03:00
22ef985925 pmt: initial 1.8.0 update 2024-04-25 21:58:42 +03:00
2e81ab9541 pmt: initial 1.8.0 update 2024-04-25 21:57:50 +03:00
112a2986b5 pmt: initial 1.8.0 update 2024-04-25 21:56:59 +03:00
65fd480ba2 pmt: initial 1.8.0 update 2024-04-25 21:56:37 +03:00
d31bccd8f6 pmt: initial 1.8.0 update 2024-04-25 21:56:05 +03:00
6c574e9536 pmt: initial 1.8.0 update 2024-04-25 21:55:09 +03:00
a4838b24e1 pmt: initial 1.8.0 update 2024-04-25 21:54:10 +03:00
908060219e pmt: initial 1.8.0 update 2024-04-25 21:50:04 +03:00
ac06203a2c pmt: initial 1.8.0 update 2024-04-25 21:49:07 +03:00
56976b2bd0 pmt: initial 1.8.0 update 2024-04-25 21:48:43 +03:00
b7ebb92fcd Update CHANGELOG.md 2024-04-25 21:44:08 +03:00
3b36e1309d pmt: Specify that bugs should be reported by email 2024-04-17 17:59:31 +03:00
8dbc54f9fc pmt: build system: update help message 2024-04-13 22:30:29 +03:00
4b4b53a080 pmt: update explanation 2024-04-13 22:29:36 +03:00
09d9aa1ee6 pmt: exclude unnecessary library 2024-04-13 22:26:21 +03:00
171de34710 pmt: exclude unnecessary library 2024-04-13 22:25:54 +03:00
5e39fdcdc9 pmt: add arm defination controller 2024-04-10 01:02:06 +03:00
fbb4822872 Update pmt.h 2024-04-10 00:53:45 +03:00
711319cce0 Update pmt.h 2024-04-10 00:51:39 +03:00
6dbf7acf3c Update pmt.h 2024-04-10 00:48:11 +03:00
287c75aa67 Rename env.mk to env.mk 2024-04-10 00:41:29 +03:00
1835ecc1e0 pmt: apply version 1.7.0 changes 2024-04-09 23:55:55 +03:00
8afbb2314c pmt: apply version 1.7.0 changes 2024-04-09 23:54:53 +03:00
283346f522 Delete binary/include/documentation.h 2024-04-09 23:54:15 +03:00
c46a65607b pmt: apply version 1.7.0 changes 2024-04-09 23:54:01 +03:00
dd6c1c9faf pmt: apply version 1.7.0 changes 2024-04-09 23:53:27 +03:00
6ab211c1b3 pmt: apply version 1.7.0 changes 2024-04-09 23:47:19 +03:00
372563fceb pmt: apply version 1.7.0 changes 2024-04-09 23:46:45 +03:00
0b34fdbfd9 pmt: apply version 1.7.0 changes 2024-04-09 23:46:15 +03:00
a2aee5c5e8 pmt: apply version 1.7.0 changes 2024-04-09 23:45:38 +03:00
d3d6bfd244 pmt: apply version 1.7.0 changes 2024-04-09 23:32:06 +03:00
97edfbc133 pmt: apply version 1.7.0 changes 2024-04-09 23:31:14 +03:00
b5d4c76b2d pmt: apply version 1.7.0 changes 2024-04-09 23:30:35 +03:00
39b1e67f8e Delete mka/apply-config.mk 2024-04-09 23:29:28 +03:00
1ffd0f90be pmt: apply version 1.7.0 changes 2024-04-09 23:28:21 +03:00
b8a8b7ff8f pmt: apply version 1.7.0 changes 2024-04-09 23:26:20 +03:00
848412e1cd pmt: apply version 1.7.0 changes 2024-04-09 23:24:53 +03:00
8034ed897c Fix changelog link 2024-03-12 20:03:43 +03:00
c8c0687519 pmt: improve build system 2024-03-11 22:34:21 +03:00
c82a127e43 pmt: update err message 2024-03-06 22:50:42 +03:00
6378f8300b Update README.md 2024-03-06 20:47:07 +03:00
80b22ee9c7 pmt: initial 1.5.0 update 2024-03-06 20:39:48 +03:00
e770a80d2a pmt: initial 1.5.0 update 2024-03-06 20:39:18 +03:00
9cd749708d pmt: initial 1.5.0 update 2024-03-06 20:31:17 +03:00
39a5098f71 pmt: initial 1.5.0 update 2024-03-06 20:30:50 +03:00
d7c4ec5236 pmt: initial 1.5.0 update 2024-03-06 20:29:49 +03:00
651c49c3d9 pmt: initial 1.5.0 update 2024-03-06 20:29:15 +03:00
c88c529d2c pmt: initial 1.5.0 update 2024-03-06 20:28:11 +03:00
2d23f45387 pmt: initial 1.5.0 update 2024-03-06 20:26:56 +03:00
67d4c86dfd pmt: initial 1.5.0 update 2024-03-06 20:26:25 +03:00
682e7657fd pmt: initial 1.5.0 update 2024-03-06 20:26:05 +03:00
c91cb25c65 pmt: initial 1.5.0 update 2024-03-06 20:25:30 +03:00
d91f9279cc pmt: initial 1.5.0 update 2024-03-06 20:23:44 +03:00
099e9d2ba6 pmt: initial 1.5.0 update 2024-03-06 20:23:09 +03:00
56638ab00e pmt: initial 1.5.0 update 2024-03-06 20:22:35 +03:00
7fd5e1768e pmt: initial 1.5.0 update 2024-03-06 20:21:50 +03:00
b045bf9b87 Add headers 2024-03-04 23:57:56 +03:00
a5ded6a26e pbt: upgrade to 1.5.0 2024-03-04 23:54:36 +03:00
48bc47c1e2 Clean 2024-03-04 23:36:27 +03:00
bbf4ff76cb pbt: add some funcs 2024-03-04 23:32:02 +03:00
9260b35ae6 Update common.h 2024-03-04 23:28:25 +03:00
6064ba2ee1 pbt: update binary 2024-03-04 23:23:27 +03:00
21e7daac0f pbt: add global variables, macros 2024-03-04 23:17:13 +03:00
ddbbffff6b pbt: Let's make a change... 2024-03-04 23:01:50 +03:00
aaf0bc6660 pbt: add banner 2024-03-04 22:51:31 +03:00
d536844f1c pbt: add banner 2024-03-04 22:51:13 +03:00
7dd8694da1 pbt: add banner 2024-03-04 22:49:40 +03:00
ac6d22e58d tb8765ap1_bsp: add banner 2024-03-04 22:49:06 +03:00
189f3078ae tb8765ap1_bsp: change syntax and add banner 2024-03-04 22:48:26 +03:00
9acb17bd10 pbt: update the version and add a new feature 2024-03-04 22:43:54 +03:00
a7da00190f pbt: upgrade version info 2024-03-04 22:41:54 +03:00
62 changed files with 4767 additions and 561 deletions

108
.github/workflows/build.yml vendored Normal file
View File

@@ -0,0 +1,108 @@
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 -R 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: Setup Android 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: |
curdate="$(date +%Y%m%d)"
export CC_64="${{ env.NDK_DIR }}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang"
export CC_VERSION=$(${CC_64} --version | head -n 1)
. build/workflow/build.config
. build/workflow/relnotes > /home/pmt/release_body.txt
zip -rq pmt-objs-local.zip obj/local/arm64-v8a obj/local/armeabi-v7a
for arch in arm64-v8a armeabi-v7a; do
mkdir -p out/binary
mv libs/${arch}/pmt out/binary
[[ "${arch}" == "arm64-v8a" ]] && make deb FOR_THIS=64
[[ "${arch}" == "armeabi-v7a" ]] && make deb FOR_THIS=32
mv out/debpackage/*.deb ${PWD}
rm -rf out/debpackage
xz out/binary/pmt
mv out/binary/pmt.xz ${PWD}/pmt-${arch}-${curdate}.xz
done
working-directory: ${{ env.PMT_SRCDIR }}
- 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
View 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
readonly 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 }}

147
ADD-LANGUAGES.md Executable file
View File

@@ -0,0 +1,147 @@
### 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/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, args[0], for_more); // LOGE is error logger (pmt). args[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 (but C++ is being used. And, it didn't change much about that). You just need to add translation :)
##### Translating main program texts (relevant part)
- Let's open our jni/Languages.cpp source file.
- Now, let's create the translation with the ready-made struct structure (see include/pmt/StringKeys.h for the structure).
```
// Main
struct langdb_general Lang<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 langdb_general LangEn = {
// translation
}
```
- We need to add some information about the language.
```
VERY IMPORTANT NOTE: You should do your translations from within the function called WCHAR_T!
struct langdb_general Lang<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 langdb_general LangEn = {
.lang_by_s = WCHAR_T("YZBruh & r0manas"),
.language = WCHAR_T("English"),
.lang_prefix = WCHAR_T("en"),
// other translations
.by_str = WCHAR_T("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.cpp source file.
- Now, let's create the translation with the ready-made struct structure (see include/pmt/StringKeys.h for the structure).
```
struct langdb_docs LangDoc<LANGUAGE_PREFIX> = {
// translations
}
// Example
struct pmt_langdb_docs LangDocEn = {
// 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/LanguageTools.cpp
```
string supp_langs[] = {
"en",
"tr",
// language prefix. "<LANGUAGE_PREFIX>",
"" // PLEASE DO NOT ADD IT UNDER `""`!
};
// Example
string supp_langs[] = {
"en",
"tr",
"az",
""
};
// 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 Executable file
View File

@@ -0,0 +1,16 @@
### Version 2.8.0 Changelog
- Base switched to C++
- Static libraries deprecated
- A certain size-change replacement failure problem has been fixed
- Flash problem corrected in sizes under 1KB
- Unrelated ones were filtered while logical sections list
- Some memory leaks were fixed
- More properly code
- Some small fixes
- Some tiny additions
- Writed script for managing binary
```
END OF 2.8.0 UPDATE CHANGELOG
```

17
DISCLAIMER Normal file → Executable file
View 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.

0
LICENSE Normal file → Executable file
View File

105
Makefile Normal file → Executable file
View File

@@ -1,8 +1,6 @@
include mka/config.mk
# By YZBruh
# Copyright 2024 YZBruh - Partition Backupper
# 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,98 +14,13 @@ include mka/config.mk
# See the License for the specific language governing permissions and
# limitations under the License.
# speficy
VERSION := 1.4.0
VERSION_CODE := 140
SOURCE_DIR := binary
TARGET := pbt
ARCH := $(shell uname -m)
THIS_IS = main
NDK_PROG ?= false
FORCE_GEN ?= false
# code list
OBJS= $(SOURCE_DIR)/pbt.o
SRCS := $(SOURCE_DIR)/pbt.c
# include needed variables
include Makefile.inc
include $(TOOLS)/gen-makefiles.mk
include $(TOOLS)/clean-makefiles.mk
# gcc flags
LDFLAGS :=
LDLIBS := -lm
# display
all:
@printf " --- Building Partition Backupper --- \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 pbt;
# build progress
.PHONY: $(TARGET)
$(TARGET): $(OBJS)
$(LD) -o $@ $(LDFLAGS) $(OBJS) $(LIBS)
@mkdir -p out; \
mkdir -p out/binary; \
mkdir -p out/package; \
mv pbt out/binary; \
printf "Generating gzip package...\n"; \
cp out/binary/pbt out/package; \
gzip -f out/package/pbt; \
mv out/package/pbt.gz out/package/pbt_$(ARCH).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; \
printf "Success\n";
# helper function
.PHONY: help
help:
@printf " --------- Partition Backupper help ---------\n"; \
printf " \n"; \
printf " Commands;\n"; \
printf " make ==> Build Partition Backupper\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 pbt 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:
@arch=$$(uname -m); \
if [ "$$arch" = "aarch64" ]; then \
printf " ------------------------------------- \n"; \
printf " pbt installer \n"; \
printf " ------------------------------------- \n"; \
cp out/binary/pbt /data/data/com.termux/files/usr/bin/pbt; \
chmod 777 /data/data/com.termux/files/usr/bin/pbt; \
printf " \n"; \
printf "Success.\n"; \
printf " \n"; \
elif [ "$$arch" = "armv7l" ]; then \
printf " ------------------------------------- \n"; \
printf " ptb installer \n"; \
printf " ------------------------------------- \n"; \
cp out/pbt /data/data/com.termux/files/usr/bin/pbt; \
chmod 777 /data/data/com.termux/files/usr/bin/pbt; \
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

121
Makefile.inc Executable file
View 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.
# speficy
VERSION := 2.8.0
VERSION_CODE := 280
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
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)/*.cpp)
OBJS = $(SRCS:.cpp=.o)
# 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

2
NOTICE Normal file → Executable file
View File

@@ -1,4 +1,4 @@
Copyright 2024 YZBruh - Partition Backupper
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.

183
README.md Normal file → Executable file
View File

@@ -1,68 +1,165 @@
## Partition Backupper (pbt)
## Partition Manager (pmt)
This binary static C library is for backing up partitions of android devices.
It offers a lot of options. I will place these below. But first let me talk about the operation...
[![Commit reviewed](https://github.com/ShawkTeam/pmt/actions/workflows/check_commits.yml/badge.svg)](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 with C++, is for writing/reading and formatting on Android partitions.
#### Presented arguments (options)
```
Usage (arguments):
-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 the output name of the backed-up partition (default: partition name)
-d, --outdir 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 [OPTIONS] backup PARTITION [OUTPUT] [OPTIONS]...
or: pmt [OPTIONS] flash PARTITION FILE [OPTIONS]...
or: pmt [OPTIONS] format PARTITION FILE_SYSTEM[ext/2/3/4] [OPTIONS]...
Example 1:
-p 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.
-V, --verbose Verbose mode. Print detailed informations etc.
-S, --set-lang Set current language.
-v, --version See version.
--help See this help message.
Example 2:
-c /dev/block/platform/bootdevice/by-name --list
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
Report bugs to <xda-@YZBruh>
Report bugs and suggestions to <t.me/ShawkTeam | Topics | pmt>
```
For example, if we want to back up the `boot_a` partition: `pbt -p boot_a` (edit the command if it has a different name).
#### Some notes
- pmt supports multiple languages. [See languages.](https://github.com/ShawkTeam/pmt/blob/2.8.0/LANGUAGES.md)
- [Add language.](https://github.com/ShawkTeam/pmt/blob/2.8.0/ADD-LANGUAGES.md)
- Feel free to ask any questions you want.
- Packages are available in publications.
- it is mandatory to use the `-p` | `--partition` argument. After all, a partition name is required to be backed up.
- If the logical partition flag is not used, a classic partition is tried to be backed up by default.
- Let me know your suggestions!
- If the logical partition flag is not used, a classic partition is tried to be processing by default.
- [Click to see special version changes.](https://github.com/ShawkTeam/pmt/blob/2.8.0/CHANGELOG.md)
- We are always open to your suggestions and support (developing)!
### How is it built?
Even termux is enough to build the pbt. 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.
To build;
##### 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.8.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
```
# Setup environment
pkg update \
&& pkg upgrade -y \
&& pkg install make clang binutils xz-utils -y
# Start build
make
# To specify clang, just use PMT_CXX=<clang++> next to the command (and same logic in AR)
# Example:
make PMT_CXX=${PWD}/../toolchain/bin/clang-18
make PMT_AR=${PWD}/../toolchain/bin/ar
make PMT_CXX=${PWD}/../toolchain/bin/clang-18 PMT_AR=${PWD}/../toolchain/bin/ar
# Speficying extra compiler flags on cmd. Example:
make PMT_EXTRA_CXXFLAGS="-O2"
# Use termux :D
# Cleaning working directory
make clean
# Rebuild
make rebuild
# Install
make install
# Uninstall
make uninstall
# Re-install (install & uninstall)
make reinstall
# Manage pmt with termux script
## Download script
curl -LSs https://github.com/ShawkTeam/pmt/raw/2.8.0/pmt-termux.sh > pmt-termux.sh
## View script help
bash pmt-termux.sh # --help (optional)
## The commands will be told to you anyway. Ask your questions from the telegram group.
```
- 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 :) ;
### How to use
```
--------- Partition Backupper 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
# Run
/system/bin/su
```
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 :)
- If you have installed the deb package of pmt, installed it with a makefile, or installed it to `$PATH` using any path, just the name of the pmt is enough (or the file name if you did it manually)
```
pmt <...>
```
- If you have not done this type of institution, pmt is in the directory where you are present you can run with `./`.
```
./pmt <...> # or whatever the file name is
```
### 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
View 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!

View File

@@ -1,54 +0,0 @@
#ifndef _DOCUMENTATION_H_
#define _DOCUMENTATION_H_
/* By YZBruh */
/*
* Copyright 2024 YZBruh - Partition Backupper
*
* 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 Backupper\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(" -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 the output name of the backed-up partition (default: partition name)\n");
printf(" -d, --outdir 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(" -p boot_a -o boot_slot_a_image -d /sdcard/backup -c /dev/block/platform/bootdevice/by-name\n\n");
printf("Example 2:\n");
printf(" -c /dev/block/platform/bootdevice/by-name --list\n\n");
printf("Report bugs to <xda-@YZBruh>\n");
}
/* end of code */
#endif

View File

@@ -1,166 +0,0 @@
#ifndef _PBT_H_
#define _PBT_H_
/* By YZBruh */
/*
* Copyright 2024 YZBruh - Partition Packupper
*
* 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.
*/
/* add pre-function important */
char *out;
char *outdir;
char *my_out;
char *cust_cxt;
bool use_cust_cxt = false;
bool pbt_ab = false;
bool pbt_logical = false;
/* 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);
}
/* check if the device is ab partitioned */
void check_psf() {
/* true = ab | false = a */
if (use_cust_cxt) {
char cust_cxt_ckpath[150];
sprintf(cust_cxt_ckpath, "%s/boot_a", cust_cxt);
if (access(cust_cxt_ckpath, F_OK) != 0) {
pbt_ab = false;
} else {
pbt_ab = true;
}
} else {
if (access("/dev/block/by-name/boot_a", F_OK) != 0) {
pbt_ab = false;
} else {
pbt_ab = true;
}
}
/* true = logical | false = classic */
if (use_cust_cxt) {
char cust_cxt_cklpath[150];
sprintf(cust_cxt_cklpath, "%s/super", cust_cxt);
if (access(cust_cxt_cklpath, F_OK) != 0) {
pbt_logical = false;
} else {
pbt_logical = true;
}
} else {
if (access("/dev/block/by-name/super", F_OK) != 0) {
pbt_logical = false;
} else {
pbt_logical = true;
}
}
}
/* list existing partitions */
void listpart() {
if (use_cust_cxt) {
printf("List of classic partitions (%s): \n", cust_cxt);
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 (pbt_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 (pbt_ab) {
printf("%sWarning: device using A/B partition style.%s\n", ANSI_YELLOW, ANSI_RESET);
}
if (pbt_logical) {
printf("%sWarning: device using logical partition type.%s\n", ANSI_YELLOW, ANSI_RESET);
}
}
/* additional function to perform backup */
void backup(char *target_pt, char *pst) {
char path[200];
if (strstr(pst, "classic") != NULL) {
if (use_cust_cxt) {
sprintf(path, "%s/%s", cust_cxt, target_pt);
} else {
sprintf(path, "/dev/block/by-name/%s", target_pt);
}
} else if (strstr(pst, "logical") != NULL) {
sprintf(path, "/dev/block/mapper/%s", target_pt);
} else {
error("İnvalid partition type!\n");
}
if (access(path, F_OK) == -1) {
error("Partition not found!\n");
} else {
printf("Target partition: %s\nBackupping...\n", target_pt);
}
char cmd[256];
if (my_out != NULL) {
if (out != NULL) {
sprintf(cmd, "dd if=%s of=%s/%s.img status=none", path, my_out, out);
} else {
sprintf(cmd, "dd if=%s of=%s/%s.img status=none", path, my_out, target_pt);
}
} else {
if (out != NULL) {
sprintf(cmd, "dd if=%s of=/storage/emulated/0/%s.img status=none", path, out);
} else {
sprintf(cmd, "dd if=%s of=/storage/emulated/0/%s.img status=none", path, target_pt);
}
}
if (system(cmd) != 0) {
error("Failed!\n");
} else {
if (my_out != NULL) {
if (out != NULL) {
printf("%sSuccess. Output: %s/%s.img%s\n", ANSI_GREEN, my_out, out, ANSI_RESET);
} else {
printf("%sSuccess. Output: %s/%s.img%s\n", ANSI_GREEN, my_out, target_pt, 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_pt, ANSI_RESET);
}
}
}
}
/* root checker function */
void verify_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");
}
}
/* end of code */
#endif

View File

@@ -1,173 +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>
#define ANSI_RED "\033[31m"
#define ANSI_YELLOW "\033[33m"
#define ANSI_GREEN "\033[32m"
#define ANSI_RESET "\033[0m"
#define PACK_VER "1.4.0"
#define PACK_VER_CODE "140"
#define PACK_NAME "Partition Backupper"
#define PACK_LANG "en"
#include "include/pbt.h"
#include "include/documentation.h"
/* By YZBruh */
/*
* Copyright 2024 YZBruh - Partition Backupper
*
* 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.
*/
/* classic main function (C binary here xd) */
int main(int argc, char *argv[]) {
# ifdef __aarch64__
/* empty */
# elif __armv8l__
/* empty */
# elif __aarch32__
/* empty */
# elif __armv7l__
/* empty */
# else
error("Incompatible architecture was detected. This binary works with only arm (32-bit or 64-bit).\n");
# endif
/* a structure for long arguments... */
struct option long_options[] = {
{"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}
};
char *argx_target_p;
bool use_argx_p = false;
bool use_logical = false;
int opt;
/* control for each argument */
while ((opt = getopt_long(argc, argv, "p:lo:d:c:DvhL", long_options, NULL)) != -1) {
/* process arguments */
switch (opt) {
case 'p':
argx_target_p = strdup(optarg);
use_argx_p = true;
break;
case 'l':
verify_root();
check_psf();
if (pbt_logical) {
use_logical = true;
} else {
error("This device does not have logical partitions!\n");
}
break;
case 'o':
out = strdup(optarg);
break;
case 'd':
verify_root();
check_psf();
outdir = strdup(optarg);
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)) {
my_out = outdir;
} else {
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);
break;
case 'D':
listpart();
exit(EXIT_SUCCESS);
break;
case 'v':
printf("Version: %s (code %s)\n", PACK_VER, PACK_VER_CODE);
# ifdef __clang__
printf("Compiled by clang version %s\n", __clang_version__);
# 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 -p, --partition PARTITION [-l, --logical] [-o, --out] [-d, --outdir] [-D, --list] [-v, --version] [-h, --help] [-L, --license]\n", argv[0]);
}
}
verify_root();
check_psf();
/* custom context checker */
if (use_cust_cxt) {
struct stat cxtinfo;
printf("Checking custom context path...\n");
if (stat(cust_cxt, &cxtinfo) == 0) {
if (S_ISDIR(cxtinfo.st_mode)) {
/* empty */
} else {
fprintf(stderr, "%s: %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") != 0) {
printf("%sThis custom context is strange...%s", ANSI_YELLOW, ANSI_RESET);
}
}
if (use_argx_p) {
if (use_logical) {
backup(argx_target_p, "logical");
} else {
backup(argx_target_p, "classic");
}
} else {
fprintf(stderr, "%s: required partition name.\nTry `%s --help' for more information.\n", argv[0], argv[0]);
exit(EXIT_FAILURE);
}
}
/* end of code */

37
build/bash/check-makefiles Executable file
View 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
View 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
View 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 "${@}" ] \
&& echo -e " - ${RED}${BOLD}Error:${BOLD_RESET}${RESET} ${@}"
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 "${@}"; }

29
build/bash/gen-header Executable file
View File

@@ -0,0 +1,29 @@
# 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
CXX_IS="${NDK_ROOT_DIR}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang++"
CXX_VERS=$(${CXX_IS} --version | head -n 1)
mkdir -p ${NDK_PROJECT_PATH}/include/PartitionManager/generated
echo -e "#define __NDK_CXX_VERSION__ \"${CXX_VERS}\"" > ${NDK_PROJECT_PATH}/include/PartitionManager/generated/clang-version.h

66
build/bash/gen-makefiles Executable file
View 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
View 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
View File

@@ -0,0 +1 @@
INSTALL_SUCCESS := true

66
build/config/Makefile Executable file
View 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.
include env.mk
#########################################
# #
# Apply Configuration #
# #
# Warning: please do not edit #
# #
#########################################
CXX = clang++
AR = ar
CXXFLAGS ?= \
-O3 \
-I../include \
-std=c++20 \
-Wall \
-Wextra \
-Werror \
-Wno-vla-cxx-extension \
-Wno-nullability-completeness \
-Wno-writable-strings \
-Wno-unused-parameter \
-Wno-unused-command-line-argument \
-Wno-nullability-extension \
-Wno-reorder-init-list \
-Wno-gnu-zero-variadic-macro-arguments \
$(PMT_EXTRA_CXXFLAGS)
# set compiler setting (clang and ar)
ifneq ($(PMT_CXX),)
CXX ?= $(PMT_CXX)
endif
ifneq ($(PMT_AR),)
AR ?= $(PMT_AR)
endif
# compiler flags settings
ifeq ($(PMT_ENABLE_DEBUG),true)
CXXFLAGS += \
-gdwarf-5 \
-fsanitize=address
endif
# write current env configuration to oldenv.mk
all:
@ echo "CXX := $(CXX)" > oldenv.mk
@ echo "AR := $(AR)" >> oldenv.mk
@ echo "CXXFLAGS := $(CXXFLAGS)" >> oldenv.mk

1
build/config/UNINS_STAT.mk Executable file
View File

@@ -0,0 +1 @@
UNINSTALLED_SUCCESS :=

38
build/config/env.mk Executable file
View 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 (cxx)
PMT_CXX ?=
# speficy ar
PMT_AR ?=
# addionital compiler flags
PMT_EXTRA_CXXFLAGS ?=
# 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
View File

@@ -0,0 +1,9 @@
Source: pmt
Package: pmt
Version: 2.8.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
View File

@@ -0,0 +1,9 @@
Source: pmt
Package: pmt
Version: 2.8.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

99
build/deb/deb.mk Executable file
View 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)/$(TARGET)" ]; then \
$(E_NS) " - $(TARGET) 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 -Z xz -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

Binary file not shown.

147
build/main.mk Executable file
View File

@@ -0,0 +1,147 @@
# 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: getvars
$(MAKE_HIDE) $(SILENT) -C $(BUILD)/config $$(cat $(BUILD)/goals.txt) || exit 1
@ rm -f $(BUILD)/goals.txt
$(MAKE_HIDE) $(SILENT) -C $(SOURCE_DIRNAME) INC_OLDENV=true || exit 1
getvars:
@ touch $(BUILD)/goals.txt
@ $(foreach var,$(sort $(.VARIABLES)),\
$(if $(filter command line,$(origin $(var))), \
echo "$(var)=$($(var))" >> goals.txt;))
.PHONY: rebuild
rebuild:
$(MAKE_HIDE) $(SILENT) clean
$(E)
$(MAKE_HIDE) $(SILENT)
# 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 $(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) rebuild ==> Re-build Partition Manager (clean and make)."
$(E) " $(MAKE) install ==> It installs $(TARGET) into termux."
$(E) " $(MAKE) uninstall ==> It uninstalls $(TARGET) into termux."
$(E) " $(MAKE) reinstall ==> It uninstall and reinstalls $(TARGET)."
$(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
.PHONY: reinstall
reinstall:
$(MAKE_HIDE) $(SILENT) uninstall
$(MAKE_HIDE) $(SILENT) install
# 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

64
build/others/makefile.androidmk Executable file
View File

@@ -0,0 +1,64 @@
# 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.8.0
########
LOCAL_PATH := $(call my-dir)
include $(LOCAL_PATH)/../build/config/env.mk
PMT_CXXFLAGS = \
-O3 \
-std=c++14 \
-Wall \
-Wextra \
-Werror \
-Wno-vla-cxx-extension \
-Wno-nullability-completeness \
-Wno-writable-strings \
-Wno-unused-parameter \
-Wno-unused-command-line-argument \
-Wno-nullability-extension \
-Wno-reorder-init-list \
-Wno-gnu-zero-variadic-macro-arguments \
-D__NDK_BUILD \
$(PMT_EXTRA_CXXFLAGS)
ifneq ($(PMT_ENABLE_DEBUG),)
PMT_CXXFLAGS += -gdwarf-5 -fsanitize=address
endif
include $(CLEAR_VARS)
LOCAL_MODULE := pmt
LOCAL_SRC_FILES := \
Debug.cpp \
Root.cpp \
PartitionManager.cpp \
PartitionTool.cpp \
ListPartitions.cpp \
Version.cpp \
GetState.cpp \
Tools.cpp \
LanguageTools.cpp \
Languages.cpp \
Help.cpp
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include
LOCAL_CFLAGS := $(PMT_CXXFLAGS)
include $(BUILD_EXECUTABLE)

23
mka/config.mk → build/others/makefile.applicationmk Normal file → Executable file
View File

@@ -1,6 +1,6 @@
# By YZBruh
# Copyright 2024 YZBruh - Partition Backupper
# 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.8.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
APP_OPTIM := release
APP_STL := c++_static
# apply configration
include mka/apply-config.mk
# end of config
# end

26
build/others/makefile.main Executable file
View 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

152
build/others/makefile.outdir Executable file
View File

@@ -0,0 +1,152 @@
# 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
@ exit 0
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
View 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.cpp \
place-holder/Help.cpp \
place-holder/GetState.cpp \
place-holder/LanguageTools.cpp \
place-holder/Languages.cpp \
place-holder/PartitionTool.cpp \
place-holder/PartitionManager.cpp \
place-holder/Root.cpp \
place-holder/Tools.cpp \
place-holder/Version.cpp
# objects to be used when executable file is created
OBJS_EXEC := \
$(SOURCE_DIR)/PartitionManager.o \
$(SOURCE_DIR)/Help.o \
$(SOURCE_DIR)/Version.o \
$(SOURCE_DIR)/GetState.o \
$(SOURCE_DIR)/Tools.o \
$(SOURCE_DIR)/Languages.o \
$(SOURCE_DIR)/LanguageTools.o
HEADERS_REQ := \
$(PMT_INCDIR)/PartitionManager/Deprecates.h \
$(PMT_INCDIR)/PartitionManager/HelpFn.h \
$(PMT_INCDIR)/PartitionManager/PartitionManager.h \
$(PMT_INCDIR)/PartitionManager/StringKeys.h \
$(PMT_INCDIR)/PartitionManager/VersionFnVars.h
PROGRESS_LIST := \
welcome \
wait \
$(SRCS_REQ) \
$(HEADERS_REQ) \
pr_obj \
$(OBJS) \
make_outdirs \
pr_sts \
$(STATIC_LIBS) \
make_executable \
wait \
end_progress
# 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)
$(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 -p $(BINARY_DIR)
@ mkdir -p $(PACKAGE_DIR)
@ mkdir -p $(STATICLIB_DIR)
place-holder/%.cpp:
$(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/PartitionManager/`basename $@`"
@ if [ ! -f "$(INCLUDE_DIR)/PartitionManager/`basename $@`" ]; then \
$(E_NS) " ==> Couldn't found required header file: include/PartitionManager/`basename $@`"; \
exit 1; \
fi
$(SOURCE_DIR)/%.o: $(SOURCE_DIR)/%.cpp
$(E) " CXX $(SOURCE_DIRNAME)/`basename $@`"
@ $(CXX) -x c++ $(CXXFLAGS) -c "$<" || exit 1
pmt_root:
$(E) " AR lib$@.a"
@ $(AR) rcs "lib$@.a" "$(SOURCE_DIR)/Root.o"
pmt_debug:
$(E) " AR lib$@.a"
@ $(AR) rcs "lib$@.a" "$(SOURCE_DIR)/Debug.o"
pmt_listpartitions:
$(E) " AR lib$@.a"
@ $(AR) rcs "lib$@.a" "$(SOURCE_DIR)/ListPartitions.o"
pmt_partitiontool:
$(E) " AR lib$@.a"
@ $(AR) rcs "lib$@.a" "$(SOURCE_DIR)/PartitionTool.o"
make_executable:
$(E) " - Making executable file..."
$(E) " LD $(TARGET)"
@ $(CXX) $(CXXFLAGS) -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
View 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
View 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
View 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

17
mka/apply-config.mk → build/tools/update-makefiles.mk Normal file → Executable file
View File

@@ -1,6 +1,6 @@
# By YZBruh
# Copyright 2024 YZBruh - Partition Backupper
# 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,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
CC := gcc
LD := 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
View 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
View File

@@ -0,0 +1,5 @@
export PMT_VERSION="2.8.0"
export PMT_VERSION_CODE=280
export NDK_VERSION="r27"
export NDK_IS="android-ndk"
export NDK_LINK="https://dl.google.com/android/repository/android-ndk-${NDK_VERSION}-linux.zip"

11
build/workflow/relnotes Executable file
View 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."

View File

@@ -0,0 +1,102 @@
/* 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_DEPRECATES_H
#define __PMT_DEPRECATES_H
#define deprecated_opt 1
#define changed_opt 2
#define end_depr_pointer 0
#define not_changed 0
#define not_changed_long nullptr
/* 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 v280 "2.8.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 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}
};
static void
__deprecated_opt_handle(int opt, const string opt_long, const char* depr_msg)
{
static string long_e_msg;
if (opt_long == "")
long_e_msg = PartitionManager::Display::UsingDispString->not_changed_opt;
else
long_e_msg = 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.c_str(), depr_table[optctrl].option_long) == 0)
{
LOGD("%s [%s]: -%c (%s): %s\n", PartitionManager::Display::UsingDispString->depr_opt_str, depr_table[optctrl].depr_version, (char)depr_table[optctrl].option, depr_table[optctrl].option_long, depr_msg);
exit(1);
}
}
else if (depr_table[optctrl].depr_type == 2)
{
if (opt == depr_table[optctrl].option || strcmp(opt_long.c_str(), depr_table[optctrl].option_long) == 0)
{
LOGD("%s [%s]: -%c (%s): %s\n", PartitionManager::Display::UsingDispString->switched_opt_str, depr_table[optctrl].depr_version, (char)depr_table[optctrl].option, long_e_msg.c_str(), depr_msg);
exit(1);
}
}
}
}
#define DEPR_HANDLE(x, y, z) __deprecated_opt_handle(x, y, z)
#endif /* __PMT_DEPRECATES_H */
/* end of code */

View File

@@ -0,0 +1,30 @@
/* By YZBruh */
/*
* Copyright 2024 Partition Manager
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __PMT_HELP_MSGS_H
#define __PMT_HELP_MSGS_H
namespace PartitionManager {
namespace Functions {
void DisplayHelp(void);
}
}
#endif
/* end */

View File

@@ -0,0 +1,149 @@
/* 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
#ifndef __PMT_H_
#define __PMT_H_
#ifdef INC_MAIN_LIBS
#include <iostream>
#include <stdbool.h>
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdarg>
#include <clocale>
#if !defined(HELP) || !defined(VERSIONING)
#include <cstdlib>
#include <unistd.h>
#include <fcntl.h>
#include <fstream>
#endif
#endif
#ifdef INC_STRINGKEYS
#include <PartitionManager/StringKeys.h>
#endif
#ifdef INC_DIRENT
#include <dirent.h>
#endif
#ifdef INC_STAT
#include <sys/stat.h>
#endif
#ifdef INC_DEBUGERS
#include <cerrno>
#endif
#ifdef INC_TOOLS_REQS
#include <sys/statvfs.h>
#endif
#ifdef INC_LIBGEN
#include <libgen.h>
#endif
using namespace std;
/* logging levels */
typedef enum {
LOG_LEVEL_FATAL,
LOG_LEVEL_ERROR,
LOG_LEVEL_WARN,
LOG_LEVEL_DEBUG
} LogLevel;
/* fast error processing without errno entry
* but errno can be given in the entrance
*/
char* strqerror(int errno_macro = errno);
/* create a special namespace */
namespace PartitionManager {
namespace Strings {
extern string OutputName;
extern string CustomContext;
extern string TargetPartition;
extern string TargetFlashFile;
extern string TargetFormatFS;
extern string PartitionType;
extern string ExecutingName;
extern string CurrentLanguage;
} /* namespace Strings */
namespace Booleans {
extern bool UseLogical;
extern bool UseCustomContext;
extern bool UsesSlots;
extern bool UsesLogical;
extern bool SilentEnabled;
extern bool FlashMode;
extern bool BackupMode;
extern bool FormatMode;
extern bool ForceMode;
extern bool VerboseMode;
extern bool InstalledOnTermux;
extern bool ActivateRoot;
} /* namespace Booleans */
namespace Display {
extern struct langdb_general* UsingDispString;
extern struct langdb_docs* UsingDocDispString;
extern struct langdb_general LangEn;
extern struct langdb_general LangTr;
extern struct langdb_docs LangDocEn;
extern struct langdb_docs LangDocTr;
} /* namespace Display */
namespace Functions {
int ListPartitions(void);
int GetState(const string& filepath, const string& stype = "file");
int Start(unsigned short progress_code);
void SetLanguage(const string& lang, unsigned short null_conf_stat);
void DisplayLog(LogLevel status, const char* fmt, ...);
void DisplayVerboseLog(LogLevel status, const char* fmt, ...);
void CheckDevPoint(void);
void CheckRoot(void);
bool CleanSWPoint(void);
bool LoadLanguage(void);
} /* namespace Functions */
} /* namespace PartitionManager */
/* logging macros */
#define LOGF(fmt, ...) \
PartitionManager::Functions::DisplayLog(LOG_LEVEL_FATAL, fmt, ##__VA_ARGS__)
#define LOGE(fmt, ...) \
PartitionManager::Functions::DisplayLog(LOG_LEVEL_ERROR, fmt, ##__VA_ARGS__)
#define LOGW(fmt, ...) \
PartitionManager::Functions::DisplayLog(LOG_LEVEL_WARN, fmt, ##__VA_ARGS__)
#define LOGD(fmt, ...) \
PartitionManager::Functions::DisplayLog(LOG_LEVEL_DEBUG, fmt, ##__VA_ARGS__)
#define VLOGF(fmt, ...) \
PartitionManager::Functions::DisplayVerboseLog(LOG_LEVEL_FATAL, fmt, ##__VA_ARGS__)
#define VLOGE(fmt, ...) \
PartitionManager::Functions::DisplayVerboseLog(LOG_LEVEL_ERROR, fmt, ##__VA_ARGS__)
#define VLOGW(fmt, ...) \
PartitionManager::Functions::DisplayVerboseLog(LOG_LEVEL_WARN, fmt, ##__VA_ARGS__)
#define VLOGD(fmt, ...) \
PartitionManager::Functions::DisplayVerboseLog(LOG_LEVEL_DEBUG, fmt, ##__VA_ARGS__)
#endif
/* end of code */

View File

@@ -0,0 +1,119 @@
/* 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_
/* The struct is a very good option for setting the languages of texts etc. */
struct 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 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 some_spec;
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 req_an_arg;
const char* _Nonnull list_of_general;
const char* _Nonnull list_of_logc;
const char* _Nonnull success_backup;
const char* _Nonnull success_flash;
const char* _Nonnull success_format;
const char* _Nonnull formatting;
const char* _Nonnull warn;
const char* _Nonnull fatal;
const char* _Nonnull is_requires_arg;
const char* _Nonnull unknw_arg;
const char* _Nonnull switching_lang;
const char* _Nonnull welcome;
const char* _Nullable welcome_;
const char* _Nonnull for_more;
const char* _Nonnull s_and_v;
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 fs_str;
const char* _Nonnull unknw_str;
const char* _Nonnull by_str;
};
/* docs etc. */
struct 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 docs_strs_l15;
const char* _Nonnull or_str;
const char* _Nonnull usage_docstr;
};
#endif /* __PMT_STRINGKEYS_ */
/* end of code */

View 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
#ifdef __NDK_BUILD
#include <android/ndk-version.h>
#include <PartitionManager/generated/clang-version.h>
#endif
/* versioning */
#define PMT_MAJOR 2
#define PMT_MINOR 8
#define PMT_PATCHLEVEL 0
namespace PartitionManager {
namespace Functions {
void DisplayVersion(void);
}
}
#endif
/* end */

114
jni/Debug.cpp Executable file
View File

@@ -0,0 +1,114 @@
/* 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 INC_MAIN_LIBS
#define INC_STRINGKEYS
#include <PartitionManager/PartitionManager.h>
using namespace PartitionManager;
/* it's prints standart logs */
void Functions::DisplayLog(LogLevel status, const char* _Nullable fmt, ...)
{
va_list args;
va_start(args, fmt);
switch (status)
{
case LOG_LEVEL_ERROR:
if (!Booleans::SilentEnabled)
{
fprintf(stderr, "%s: ", Strings::ExecutingName.c_str());
vfprintf(stderr, fmt, args);
}
exit(1);
break;
case LOG_LEVEL_WARN:
if (!Booleans::SilentEnabled)
{
fprintf(stdout, "%s: ", Display::UsingDispString->warn);
vfprintf(stdout, fmt, args);
}
break;
case LOG_LEVEL_FATAL:
if (!Booleans::SilentEnabled)
{
fprintf(stderr, "%s: ", Display::UsingDispString->fatal);
vfprintf(stderr, fmt, args);
}
abort();
break;
case LOG_LEVEL_DEBUG:
if (!Booleans::SilentEnabled)
vfprintf(stdout, fmt, args);
break;
}
va_end(args);
}
/* it's prints verbose logs */
void Functions::DisplayVerboseLog(LogLevel status, const char* fmt, ...)
{
va_list args;
va_start(args, fmt);
switch (status)
{
case LOG_LEVEL_ERROR:
if (Booleans::VerboseMode)
{
fprintf(stderr, "E:[stderr]: ");
vfprintf(stderr, fmt, args);
}
break;
case LOG_LEVEL_WARN:
if (Booleans::VerboseMode)
{
fprintf(stdout, "W:[stdout]: ");
vfprintf(stdout, fmt, args);
}
break;
case LOG_LEVEL_FATAL:
if (Booleans::VerboseMode)
{
fprintf(stderr, "F:[stderr]: ");
vfprintf(stderr, fmt, args);
abort();
}
break;
case LOG_LEVEL_DEBUG:
if (Booleans::VerboseMode)
{
fprintf(stdout, "D:[stdout]: ");
vfprintf(stdout, fmt, args);
}
break;
}
va_end(args);
}
/**
* Last error is taken from strerror by taking
* the contents of errno or taking a special entry
*/
char* strqerror(int errno_macro) { return strerror(errno_macro); }
/* end of code */

54
jni/GetState.cpp Executable file
View File

@@ -0,0 +1,54 @@
/* 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 INC_MAIN_LIBS
#define INC_STAT
#include <PartitionManager/PartitionManager.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.
* If the search type is unknown, 3 value is returned
*/
int PartitionManager::Functions::GetState(const string& filepath, const string& stype)
{
static struct stat GetStat;
VLOGD("GetStat: checking `%s' with 'stat <sys/stat.h>'...\n", filepath.c_str());
if (stat(filepath.c_str(), &GetStat) != 0)
return 1;
if (stype == "dir")
return (S_ISDIR(GetStat.st_mode)) ? 0 : -1;
else if (stype == "file")
return (S_ISREG(GetStat.st_mode)) ? 0 : -1;
else if (stype == "blk")
return (S_ISBLK(GetStat.st_mode)) ? 0 : -1;
else if (stype == "link")
return (S_ISLNK(GetStat.st_mode)) ? 0 : -1;
else
return 3;
return 2;
}
/* end of code */

65
jni/Help.cpp Executable file
View File

@@ -0,0 +1,65 @@
/* 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 INC_MAIN_LIBS
#define INC_STRINGKEYS
#define HELP
#include <PartitionManager/PartitionManager.h>
#include <PartitionManager/HelpFn.h>
using namespace PartitionManager;
struct langdb_docs* Display::UsingDocDispString = nullptr;
static void
prepare_langconf_docs(void)
{
if (Strings::CurrentLanguage == "en")
Display::UsingDocDispString = &Display::LangDocEn;
else if (Strings::CurrentLanguage == "tr")
Display::UsingDocDispString = &Display::LangDocTr;
}
void Functions::DisplayHelp(void)
{
VLOGD("DisplayHelp: Loading language for help messages... Calling prepare_langconf_docs() <local function>...\n");
prepare_langconf_docs();
VLOGD("DisplayHelp: Printing...\n");
LOGD("%s: %s %s\n", Display::UsingDocDispString->usage_docstr, Strings::ExecutingName.c_str(), Display::UsingDocDispString->docs_strs_l1);
LOGD(" %s: %s %s\n", Display::UsingDocDispString->or_str, Strings::ExecutingName.c_str(), Display::UsingDocDispString->docs_strs_l2);
LOGD(" %s: %s %s\n\n", Display::UsingDocDispString->or_str, Strings::ExecutingName.c_str(), Display::UsingDocDispString->docs_strs_l3);
LOGD("%s: \n", Display::UsingDocDispString->docs_strs_l4);
LOGD(" -l, --logical %s\n", Display::UsingDocDispString->docs_strs_l5);
LOGD(" -c, --context %s\n", Display::UsingDocDispString->docs_strs_l6);
LOGD(" -p, --list %s\n", Display::UsingDocDispString->docs_strs_l7);
LOGD(" -s, --silent %s\n", Display::UsingDocDispString->docs_strs_l8);
LOGD(" -f, --force %s\n", Display::UsingDocDispString->docs_strs_l9);
LOGD(" -V, --verbose %s\n", Display::UsingDocDispString->docs_strs_l10);
LOGD(" -S, --set-lang %s\n", Display::UsingDocDispString->docs_strs_l11);
LOGD(" -v, --version %s\n", Display::UsingDocDispString->docs_strs_l12);
LOGD(" --help %s\n\n", Display::UsingDocDispString->docs_strs_l13);
LOGD("%s:\n", Display::UsingDocDispString->docs_strs_l14);
LOGD(" %s backup boot_a -c /dev/block/platform/bootdevice/by-name\n", Strings::ExecutingName.c_str());
LOGD(" %s flash boot_a /sdcard/twrp/boot.img -c /dev/block/platform/bootdevice/by-name\n", Strings::ExecutingName.c_str());
LOGD(" %s format system_a ext4 --logical\n", Strings::ExecutingName.c_str());
LOGD(" %s -c /dev/block/platform/bootdevice/by-name --list\n\n", Strings::ExecutingName.c_str());
LOGD("%s <t.me/ShawkTeam | Topics | pmt>\n", Display::UsingDocDispString->docs_strs_l15);
}
/* end of code */

170
jni/LanguageTools.cpp Executable file
View File

@@ -0,0 +1,170 @@
/* 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 INC_MAIN_LIBS
#define INC_DEBUGERS
#define INC_STAT
#define INC_STRINGKEYS
#include <PartitionManager/PartitionManager.h>
using namespace PartitionManager;
/* 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"
struct langdb_general* Display::UsingDispString = nullptr;
static fstream langconf;
string supp_langs[] = {
"en",
"tr",
""
};
static bool
LangControl(const string lang)
{
for (int i = 0; !supp_langs[i].empty(); i++)
{
if (lang == supp_langs[i])
return true;
}
return false;
}
bool Functions::LoadLanguage(void)
{
string lang_fpr = "en";
langconf.close();
VLOGD("LoadLanguage: checking install type...\n");
if (Functions::GetState(TERMUX_PMT_MANDOC) == 0)
Booleans::InstalledOnTermux = true;
VLOGD("LoadLanguage: trying to open `%s' with 'open <fstream>'\n", PMTLANG_CONF);
langconf.open(PMTLANG_CONF, ios::in | ios::out);
VLOGD("LoadLanguage: checking status: `%s'...\n", PMTLANG_CONF);
if (!langconf.is_open())
{
langconf.open(PMTLANG_CONF, ios::out | ios::trunc);
VLOGD("LoadLanguage: calling SetLanguage()...\n");
Functions::SetLanguage("en", 1);
Display::UsingDispString = &Display::LangEn;
Strings::CurrentLanguage = "en";
if (langconf.is_open())
langconf.close();
return true;
}
else
{
VLOGD("LoadLanguage: reading `%s'\n", PMTLANG_CONF);
while (getline(langconf, lang_fpr))
{
if (lang_fpr == "en")
goto SetEn;
else if (lang_fpr == "tr")
goto SetTr;
else
{
VLOGD("LoadLanguage: calling SetLanguage()\n");
Functions::SetLanguage("en", 1);
VLOGD("LoadLanguage: re-calling LoadLanguage()\n");
Functions::LoadLanguage();
return true;
}
}
if (!getline(langconf, lang_fpr))
{
VLOGD("LoadLanguage: calling SetLanguage()\n");
Functions::SetLanguage("en", 1);
VLOGD("LoadLanguage: re-calling LoadLanguage()\n");
Functions::LoadLanguage();
return true;
}
}
SetEn:
langconf.close();
Display::UsingDispString = &Display::LangEn;
Strings::CurrentLanguage = "en";
VLOGD("LoadLanguage: loaded \"en\"\n");
return true;
SetTr:
langconf.close();
Display::UsingDispString = &Display::LangTr;
Strings::CurrentLanguage = "tr";
VLOGD("LoadLanguage: loaded \"tr\"\n");
return true;
return false;
}
void Functions::SetLanguage(const string& lang, unsigned short null_conf_stat)
{
VLOGD("SetLanguage: checking speficed language (from input).\n");
if (!LangControl(lang.c_str()))
LOGE("Unknown language: %s.\n", lang.c_str());
langconf.close();
VLOGD("SetLanguage: trying to open `%s' with 'open <fstream>'\n", PMTLANG_CONF);
langconf.open(PMTLANG_CONF, ios::out | ios::trunc);
if (!langconf.is_open())
LOGE("Failed!!! Cannot open/write config file.\n");
VLOGD("SetLanguage: write \"%s\" to `%s' with 'std <iostream>'\n", lang.c_str(), PMTLANG_CONF);
langconf << lang;
if (!langconf)
LOGE("Failed!!! Couldn't write config!\n");
else
langconf.close();
if (null_conf_stat != 1)
{
VLOGD("SetLanguage: generating dummy file `%s' with 'ofstream <fstream>'\n", PMT_SW_POINT);
ofstream sw_point(PMT_SW_POINT, ios::trunc);
if (sw_point.is_open())
sw_point.close();
}
}
bool Functions::CleanSWPoint(void)
{
if (Functions::GetState(PMT_SW_POINT) == 0)
{
VLOGD("CleanSWPoint: removing (force) `%s' with 'remove <unistd.h>'\n", PMT_SW_POINT);
remove(PMT_SW_POINT);
return true;
}
else
return false;
}
/* end of code */

216
jni/Languages.cpp Executable file
View File

@@ -0,0 +1,216 @@
/* 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 INC_MAIN_LIBS
#define INC_STRINGKEYS
#include <PartitionManager/PartitionManager.h>
namespace PartitionManager {
namespace Display {
struct langdb_general LangEn = {
.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. Use force mode to avoid this error.",
.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.",
.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! Maybe a logical partition?",
.unsupported_fs = "Formatter: unsupported filesystem",
.cannot_stat = "Can't retrieve file status",
.ffile_more_part = "Flash file size exceeds partition capacity. Use force mode to avoid this error (not recommended, riscy!).",
.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",
.some_spec = "You may have indicated options, but they don't work much unless you speficy a main transaction",
.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 created name",
.please_rerun = "Please rerun the command.",
.part_disk_sz = "Partition (backup) 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",
.req_an_arg = "option requires an argument",
.list_of_general = "List of general partitions",
.list_of_logc = "List of logical partitions",
.success_backup = "Backup successful. Output",
.success_flash = "Flash successful",
.success_format = "Format successful",
.formatting = "Formatting",
.warn = "WARNING",
.fatal = "FATAL ERROR",
.is_requires_arg = "requires an argument",
.unknw_arg = "unknown option",
.switching_lang = "Switching language...",
.welcome = "language!",
.welcome_ = "Welcome to ",
.for_more = "for more information",
.s_and_v = "Silent and verbose mode cannot be used together!",
.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",
.fs_str = "Filesystem",
.unknw_str = "unknown",
.by_str = "By"
};
struct langdb_general LangTr = {
.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 bir ilgisi yok (içermiyor). Bu hatayla karşılaşmak istemiyorsanız zorlama (force) modu kullanın.",
.not_open = "ı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..! Bu hatayla karşılaşmak istemiyorsanız zorlama (force) modu kullanın.",
.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.",
.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ı! Belki mantıksal (logical) bir bölümdür?",
.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. Bu hatayla karşılaşmak istemiyorsanız zorlama (force) modu kullanın (bunu yapmanız asla önerilmez).",
.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 = "Bu cihaz mantıksal (logical) bölümlere sahip.",
.not_spec_opt = "Seçenek değil, gerekli argümanları verin",
.some_spec = "Seçenek belirtmiş olabilirsiniz fakat, ana işlem belirtmedikçe pek işe yaramazlar",
.ab_warn = "Bu cihazın bazı bölümleri A/B kullanıyor.",
.out_not_spec = "Çıktı dosya adı belirtilmedi. Oluşturulan çıktı adı",
.please_rerun = "Lütfen yeniden çalıştırın",
.part_disk_sz = "Bölümün (yedek) 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",
.req_an_arg = "bu seçenek argüman gerektirir",
.list_of_general = "Genel bölümlerin listesi",
.list_of_logc = "Mantıksal (logical) bölümlerin listesi",
.success_backup = "Başarılı. Çıktı",
.success_flash = "Başarılı.",
.success_format = "Formatlama başarılı",
.formatting = "Formatlanıyor",
.warn = "UYARI",
.fatal = "KRİTİK HATA",
.is_requires_arg = "bir argüman gereklidir",
.unknw_arg = "bilinmeyen seçenek",
.switching_lang = "Dil değiştiriliyor...",
.welcome = "diline hoş geldiniz!",
.welcome_ = NULL,
.for_more = "komutunu kullanabilirsiniz",
.s_and_v = "Sessiz ve ayrıntılı günlüklenme aynı anda kullanılamaz!",
.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ı",
.fs_str = "Dosya sistemi",
.unknw_str = "bilinmeyen",
.by_str = "Çeviriyi yapan(lar):"
};
struct langdb_docs LangDocEn = {
.docs_strs_l1 = "[OPTIONS] backup PARTITION [OUTPUT] [OPTIONS]...",
.docs_strs_l2 = "[OPTIONS] flash PARTITION FILE [OPTIONS]...",
.docs_strs_l3 = "[OPTIONS] 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 normal 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 = "Verbose mode. Print detailed informations etc.",
.docs_strs_l11 = "Set current language.",
.docs_strs_l12 = "See version.",
.docs_strs_l13 = "See this help message.",
.docs_strs_l14 = "Examples",
.docs_strs_l15 = "Report bugs and suggestions to",
.or_str = "or",
.usage_docstr = "Usage"
};
struct langdb_docs LangDocTr = {
.docs_strs_l1 = "[SEÇENEKLER] backup BÖLÜM [ÇIKTI] [SEÇENEKLER]...",
.docs_strs_l2 = "[SEÇENEKLER] flash BÖLÜM DOSYA [SEÇENEKLER]...",
.docs_strs_l3 = "[SEÇENEKLER] 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 = "Ayrıntılı bilgi modu. Daha fazla bilgi mesajı verilir.",
.docs_strs_l11 = "Mevcut dili ayarlayın.",
.docs_strs_l12 = "Sürümü görüntüleyin.",
.docs_strs_l13 = "Bu yardım mesajını görüntüleyin.",
.docs_strs_l14 = "Örnekler",
.docs_strs_l15 = "Sorunları ve önerileri şuraya bildirin:",
.or_str = "yada",
.usage_docstr = "Kullanımı"
};
} /* namespace Display */
} /* namespace PartitionManager */
/* end of code */

131
jni/ListPartitions.cpp Executable file
View File

@@ -0,0 +1,131 @@
/* 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 INC_MAIN_LIBS
#define INC_DEBUGERS
#define INC_DIRENT
#define INC_STRINGKEYS
#include <PartitionManager/PartitionManager.h>
using namespace PartitionManager;
#define CUR_DEV_CNTX "/dev/block/by-name"
#define LGC_DEV_CNTX "/dev/block/mapper"
static DIR *dir;
static int
list(const string& operation, const char* target_dir)
{
static int count;
struct dirent **list;
bool list_parts = (operation == "print") ? true : false;
dir = nullptr;
dir = opendir(target_dir);
if (list_parts)
{
count = scandir(target_dir, &list, nullptr, alphasort);
if (count < 0)
LOGE("%s: `%s': %s\n", Display::UsingDispString->not_readdir, target_dir, strqerror());
for (int i = 0; i < count; i++)
{
if (list[i]->d_name[0] != '.' \
&& strncmp(list[i]->d_name, "com.", 4) != 0 \
&& strcmp(list[i]->d_name, "by-uuid") != 0 \
&& strcmp(list[i]->d_name, "userdata") != 0)
LOGD(" - [ %-16s ]\n", list[i]->d_name);
free(list[i]);
}
free(list);
list = nullptr;
goto directory;
}
directory:
if (dir != nullptr)
{
closedir(dir);
return 0;
}
else
return -1;
return 2;
}
/* list existing partitions */
int Functions::ListPartitions(void)
{
VLOGD("ListPartitions: selecting context...\n");
string acc_cxt = (Booleans::UseCustomContext) ? Strings::CustomContext : CUR_DEV_CNTX;
VLOGD("ListPartitions: trying to access `%s'...\n", acc_cxt.c_str());
if (list("access", acc_cxt.c_str()) != 0)
{
if (!Booleans::ForceMode)
LOGE("%s: `%s': %s\n", Display::UsingDispString->not_open, acc_cxt.c_str(), strqerror());
else
return 1;
}
else
{
LOGD("%s:\n", Display::UsingDispString->list_of_general);
list("print", acc_cxt.c_str());
}
if (Booleans::UsesLogical)
{
VLOGD("ListPartitions: checking for listing `%s'...\n", LGC_DEV_CNTX);
if (list("access", LGC_DEV_CNTX) != 0)
LOGE("%s: `%s': %s\n", Display::UsingDispString->not_open, LGC_DEV_CNTX, strqerror());
else
{
LOGD("\n%s:\n", Display::UsingDispString->list_of_logc);
list("print", LGC_DEV_CNTX);
}
}
VLOGD("ListPartitions: (if have) warnings are printed...\n");
if (Booleans::UsesLogical)
{
LOGD("\n");
LOGW("%s\n", Display::UsingDispString->logical_warn);
}
if (Booleans::UsesSlots)
{
if (!Booleans::UsesSlots)
LOGD("\n");
LOGW("%s\n", Display::UsingDispString->ab_warn);
}
return 0;
}
/* end of code */

157
jni/Makefile Executable file
View File

@@ -0,0 +1,157 @@
# 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.cpp \
place-holder/Help.cpp \
place-holder/GetState.cpp \
place-holder/LanguageTools.cpp \
place-holder/Languages.cpp \
place-holder/PartitionTool.cpp \
place-holder/PartitionManager.cpp \
place-holder/Root.cpp \
place-holder/Tools.cpp \
place-holder/Version.cpp
# objects to be used when executable file is created
OBJS_EXEC := \
$(SOURCE_DIR)/Debug.o \
$(SOURCE_DIR)/Root.o \
$(SOURCE_DIR)/PartitionManager.o \
$(SOURCE_DIR)/PartitionTool.o \
$(SOURCE_DIR)/ListPartitions.o \
$(SOURCE_DIR)/Help.o \
$(SOURCE_DIR)/Version.o \
$(SOURCE_DIR)/GetState.o \
$(SOURCE_DIR)/Tools.o \
$(SOURCE_DIR)/Languages.o \
$(SOURCE_DIR)/LanguageTools.o
HEADERS_REQ := \
$(PMT_INCDIR)/PartitionManager/Deprecates.h \
$(PMT_INCDIR)/PartitionManager/HelpFn.h \
$(PMT_INCDIR)/PartitionManager/PartitionManager.h \
$(PMT_INCDIR)/PartitionManager/StringKeys.h \
$(PMT_INCDIR)/PartitionManager/VersionFnVars.h
PROGRESS_LIST := \
welcome \
wait \
$(SRCS_REQ) \
$(HEADERS_REQ) \
pr_obj \
$(OBJS) \
make_outdirs \
make_executable \
wait \
end_progress
# 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)
$(E) " - Checking required source files..."
pr_obj:
$(E) " - Building objects..."
wait:
@ sleep 2
make_outdirs:
@ rm -rf $(IN_OUT_DIR)
@ mkdir -p $(BINARY_DIR)
@ mkdir -p $(PACKAGE_DIR)
place-holder/%.cpp:
$(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/PartitionManager/`basename $@`"
@ if [ ! -f "$(INCLUDE_DIR)/PartitionManager/`basename $@`" ]; then \
$(E_NS) " ==> Couldn't found required header file: include/PartitionManager/`basename $@`"; \
exit 1; \
fi
$(SOURCE_DIR)/%.o: $(SOURCE_DIR)/%.cpp
$(E) " CXX $(SOURCE_DIRNAME)/`basename $@`"
@ $(CXX) -x c++ $(CXXFLAGS) -c "$<" || exit 1
make_executable:
$(E) " - Making executable file..."
$(E) " LD $(TARGET)"
@ $(CXX) $(CXXFLAGS) -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; \
$(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 OBJS = $(wildcard $(SOURCE_DIR)/*.o))
$(info Cleaning files...)
$(foreach obj, \
$(OBJS), \
$(call m_stat_nn,$(SOURCE_DIRNAME)/$(shell basename $(obj))) \
$(call erase,$(obj)) \
)
# end

703
jni/PartitionManager.cpp Executable file
View File

@@ -0,0 +1,703 @@
/* 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 INC_MAIN_LIBS
#define INC_DEBUGERS
#define INC_STAT
#define INC_LIBGEN
#define INC_STRINGKEYS
#include <PartitionManager/PartitionManager.h>
#include <PartitionManager/Deprecates.h>
#include <PartitionManager/HelpFn.h>
#include <PartitionManager/VersionFnVars.h>
/* add value to variables that are added globally and are not worth */
namespace PartitionManager {
namespace Strings {
string OutputName = "";
string CustomContext = "";
string TargetPartition = "";
string TargetFlashFile = "";
string TargetFormatFS = "";
string PartitionType = "";
string ExecutingName = "";
string CurrentLanguage = "";
} /* namespace Strings */
namespace Booleans {
bool UseLogical = false;
bool UseCustomContext = false;
bool UsesSlots = false;
bool UsesLogical = false;
bool SilentEnabled = false;
bool FlashMode = false;
bool BackupMode = false;
bool FormatMode = false;
bool ForceMode = false;
bool VerboseMode = false;
bool InstalledOnTermux = false;
bool ActivateRoot = false;
} /* namespace Booleans */
} /* namespace PartitionManager */
/* variable for use in control of '-' expression */
static string common_symbol_rule;
namespace PartitionManager {
namespace Functions {
/**
* He controls whether the '-' sign at
* the beginning of the given word
*/
static void
CheckOptSymbol(const string symbol)
{
if (!symbol.empty())
{
if (strncmp(symbol.c_str(), "-", 1) == 0)
LOGE("%s\n", common_symbol_rule.c_str());
}
}
static bool
ControlArg(const char* argv_holder)
{
if (argv_holder[0] != '-')
return true;
return false;
}
} /* namespace Functions */
} /* namespace PartitionManager */
static void
deprecated(const char opt, const char* deprecation_message, const char* opt_long = "ISNULL")
{
VLOGE("Deprecated Option: -%c (--%s). Printing error...\n", opt, opt_long);
DEPR_HANDLE(opt, opt_long, deprecation_message);
exit(1);
}
static void
PrContextInput(const string& context)
{
PartitionManager::Booleans::UseCustomContext = true;
PartitionManager::Strings::CustomContext = context;
PartitionManager::Functions::CheckOptSymbol(PartitionManager::Strings::CustomContext);
}
using namespace PartitionManager;
class PartitionManagerBase {
protected:
char* BaseFunctionName = nullptr;
int StartCode = -1;
bool IsRequiredOnlyOneArg = false;
public:
void CallTargetBaseFunction(void)
{
VLOGD("CallTargetBaseFunction [class]: Start(%d)\n", StartCode);
Functions::Start(StartCode);
}
void GenericNumericalController(int searchOn, int total, const char* MissingArgMessage)
{
if (total <= searchOn)
{
VLOGE("ArgumentProcessor [class]: Missing argument total (for %s function).\n", BaseFunctionName);
LOGE("%s 0.\n", MissingArgMessage);
}
if (!IsRequiredOnlyOneArg)
{
if (total <= (searchOn + 1))
{
VLOGE("ArgumentProcessor [class]: Missing argument total (for %s function).\n", BaseFunctionName);
LOGE("%s 1.\n", MissingArgMessage);
}
}
}
virtual void ArgumentProcessor(int searchOn, int total, char** arguments) { /* dummy, it's place holder */ }
};
class PartitionManagerBackup : public PartitionManagerBase {
public:
void ArgumentProcessor(int searchOn, int total, char** arguments) override
{
BaseFunctionName = "backup";
StartCode = 1;
IsRequiredOnlyOneArg = true;
GenericNumericalController(searchOn, total, Display::UsingDispString->expected_backup_arg);
if (Functions::ControlArg(arguments[searchOn]))
Strings::TargetPartition = arguments[searchOn];
else
LOGE("%s.\n", Display::UsingDispString->not_spec_opt);
Strings::OutputName = Strings::TargetPartition;
if (total > (searchOn + 1) && Functions::ControlArg(arguments[(searchOn + 1)]))
{
VLOGD("ArgumentProcessor [class]: Non-mandatory argument was detected and retrieved (for %s function).\n", BaseFunctionName);
Strings::OutputName = arguments[(searchOn + 1)];
}
Functions::CheckOptSymbol(Strings::TargetPartition);
Functions::CheckOptSymbol(Strings::OutputName);
}
};
class PartitionManagerFlash : public PartitionManagerBase {
public:
void ArgumentProcessor(int searchOn, int total, char** arguments) override
{
BaseFunctionName = "flash";
StartCode = 2;
IsRequiredOnlyOneArg = false;
GenericNumericalController(searchOn, total, Display::UsingDispString->expected_flash_arg);
if (Functions::ControlArg(arguments[searchOn]))
Strings::TargetPartition = arguments[searchOn ];
else
LOGE("%s.\n", Display::UsingDispString->not_spec_opt);
if (Functions::ControlArg(arguments[(searchOn + 1)]))
Strings::TargetFlashFile = arguments[(searchOn + 1)];
else
LOGE("%s.\n", Display::UsingDispString->not_spec_opt);
Functions::CheckOptSymbol(Strings::TargetFlashFile);
Functions::CheckOptSymbol(Strings::TargetPartition);
}
};
class PartitionManagerFormat : public PartitionManagerBase {
public:
void ArgumentProcessor(int searchOn, int total, char** arguments) override
{
BaseFunctionName = "format";
StartCode = 3;
IsRequiredOnlyOneArg = false;
GenericNumericalController(searchOn, total, Display::UsingDispString->expected_format_arg);
if (Functions::ControlArg(arguments[searchOn]))
Strings::TargetPartition = arguments[searchOn];
else
LOGE("%s.\n", Display::UsingDispString->not_spec_opt);
if (Functions::ControlArg(arguments[(searchOn + 1)]))
Strings::TargetFormatFS = arguments[(searchOn + 1)];
else
LOGE("%s.\n", Display::UsingDispString->not_spec_opt);
Functions::CheckOptSymbol(Strings::TargetFormatFS);
Functions::CheckOptSymbol(Strings::TargetPartition);
}
};
int main(int argc, char** argv)
{
Strings::ExecutingName = basename(argv[0]);
for (int i = 0; i <= (argc - 1); i++)
{
if (strncmp(argv[i], "-V", 2) == 0 || strcmp(argv[i], "--verbose") == 0)
Booleans::VerboseMode = true;
else
continue;
}
/* Generate classes */
VLOGD("Generating classes...\n");
PartitionManagerBase* Base;
PartitionManagerBase BaseTemplate;
PartitionManagerBackup BackupArgProcessorBase;
PartitionManagerFlash FlashArgProcessorBase;
PartitionManagerFormat FormatArgProcessorBase;
VLOGD("Main function started. Setting up locale. Calling 'setlocale <clocale>'\n");
setlocale(LC_ALL, "");
int argc_n = argc;
char buf[256];
char** args = argv;
VLOGD("Checking stdin status...\n");
if (!isatty(fileno(stdin)))
{
VLOGD("stdin is not empty.\n");
VLOGD("Parsing stdin arguments...\n");
while (fgets(buf, sizeof(buf), stdin) != nullptr)
{
buf[strcspn(buf, "\n")] = 0;
args[argc_n] = strdup(buf);
argc_n++;
}
VLOGD("Parsing completed.\n");
}
else
VLOGD("stdin empty.\n");
/* load language */
VLOGD("Loading language... Calling LoadLanguage()...\n");
if (!Functions::LoadLanguage())
{
cout << "LoadLanguage() process failed..!" << endl;
abort();
}
common_symbol_rule = Display::UsingDispString->common_symbol_rule;
argc = argc_n;
int argc_parse = (argc - 1);
char** args_ctrl = args;
args_ctrl++;
static bool ViewHelp = false;
static bool ViewVersion = false;
static bool LogicalSpeficy = false;
static bool ListRequired = false;
static bool MultipleViewers = false;
static bool SetLanguageReq = false;
static bool SomeSpec = false;
static char* SpeficedLanguagePr;
static string Option;
static string Target;
static int SearchResult = 3;
static int SearchOnMainInt = -1;
VLOGD("Parsing standart arguments...\n");
while (argc_parse && args_ctrl[0] != nullptr)
{
if (args_ctrl[0][0] != '-')
{
argc_parse--;
args_ctrl++;
continue;
}
for (int x = 1; true; x++)
{
Option = args_ctrl[0];
SomeSpec = true;
switch (args_ctrl[0][x])
{
case '-':
if (Option == "--backup")
deprecated('b', Display::UsingDispString->depr_backup_opt, "backup");
else if (Option == "--flash")
deprecated('F', Display::UsingDispString->depr_flash_opt, "flash");
else if (Option == "--format")
deprecated('r', Display::UsingDispString->depr_format_opt, "format");
else if (Option == "--license")
deprecated('L', Display::UsingDispString->depr_Vlicense_opt, "license");
else if (Option == "--logical")
{
VLOGD("Logical partition type specified.\n");
LogicalSpeficy = true;
break;
}
else if (Option == "--context")
{
VLOGD("Custom context specified.\n");
if (argc_parse > 1)
PrContextInput(args_ctrl[1]);
else
LOGE("--context: %s.\n%s `%s --help' %s.\n", \
Display::UsingDispString->is_requires_arg, \
Display::UsingDispString->try_h, \
Strings::ExecutingName.c_str(), \
Display::UsingDispString->for_more);
break;
}
else if (Option == "--list")
{
VLOGD("It was requested to list the partitions.\n");
ListRequired = true;
if (ViewVersion || ViewHelp)
MultipleViewers = true;
break;
}
else if (Option == "--force")
{
VLOGD("Force mode speficed.\n");
Booleans::ForceMode = true;
break;
}
else if (Option == "--verbose")
{
VLOGD("Verbose mode speficed.\n");
Booleans::VerboseMode = true;
break;
}
else if (Option == "--silent")
{
VLOGD("Silent mode speficed.\n");
Booleans::SilentEnabled = true;
break;
}
else if (Option == "--set-language")
{
VLOGD("It was requested to adjust the language.\n");
if (argc_parse > 1)
{
VLOGE("Language inputs: getting inputs...\n");
SetLanguageReq = true;
SpeficedLanguagePr = args_ctrl[1];
}
else
LOGE("--set-language: %s.\n%s `%s --help' %s.\n", \
Display::UsingDispString->is_requires_arg, \
Display::UsingDispString->try_h, \
Strings::ExecutingName.c_str(), \
Display::UsingDispString->for_more);
break;
}
else if (Option == "--version")
{
VLOGD("The version info was requested to be displayed.\n");
ViewVersion = true;
if (ListRequired || ViewHelp)
MultipleViewers = true;
break;
}
else if (Option == "--help")
{
VLOGD("The help message was requested to be displayed.\n");
ViewHelp = true;
if (ViewVersion || ListRequired)
MultipleViewers = true;
break;
}
else
{
VLOGE("Unknown Option: %s\n", args_ctrl[0]);
LOGE("%s: %s.\n%s `%s --help' %s.\n", args_ctrl[0], \
Display::UsingDispString->unknw_arg, \
Display::UsingDispString->try_h, \
Strings::ExecutingName.c_str(), \
Display::UsingDispString->for_more);
}
break;
case 'b':
deprecated('b', Display::UsingDispString->depr_backup_opt, "backup");
break;
case 'F':
deprecated('F', Display::UsingDispString->depr_flash_opt, "flash");
break;
case 'r':
deprecated('r', Display::UsingDispString->depr_format_opt, "format");
break;
case 'L':
deprecated('L', Display::UsingDispString->depr_Vlicense_opt, "license");
break;
case 'D':
deprecated('D', Display::UsingDispString->depr_ch_list_opt);
break;
case 'l':
VLOGD("Logical partition type specified.\n");
LogicalSpeficy = true;
continue;
case 'c':
VLOGD("Custom context speficed.\n");
if (argc_parse > 1)
{
VLOGE("Context inputs: getting inputs...\n");
PrContextInput(args_ctrl[1]);
continue;
}
else
LOGE("-c: %s.\n%s `%s --help' %s.\n", \
Display::UsingDispString->is_requires_arg, \
Display::UsingDispString->try_h, \
Strings::ExecutingName.c_str(), \
Display::UsingDispString->for_more);
break;
case 'p':
VLOGD("It was requested to list the partitions.\n");
ListRequired = true;
if (ViewVersion || ViewHelp)
MultipleViewers = true;
continue;
case 'f':
VLOGD("Force mode speficed.\n");
Booleans::ForceMode = true;
continue;
case 'V':
VLOGD("Verbose mode speficed.\n");
Booleans::VerboseMode = true;
continue;
case 's':
VLOGD("Silent mode speficed.\n");
Booleans::SilentEnabled = true;
continue;
case 'S':
VLOGD("It was requested to adjust the language.\n");
if (argc_parse > 1)
{
VLOGE("Language inputs: getting inputs...\n");
SetLanguageReq = true;
SpeficedLanguagePr = args_ctrl[1];
continue;
}
else
LOGE("-S: %s.\n%s `%s --help' %s.\n", \
Display::UsingDispString->is_requires_arg, \
Display::UsingDispString->try_h, \
Strings::ExecutingName.c_str(), \
Display::UsingDispString->for_more);
case 'v':
VLOGD("The version info was requested to be displayed.\n");
ViewVersion = true;
if (ListRequired || ViewHelp)
MultipleViewers = true;
continue;
case '\0':
break;
default:
VLOGE("Unknown Option: -%c\n", args_ctrl[0][x]);
LOGE("-%c: %s.\n%s `%s --help' %s.\n", args_ctrl[0][x], \
Display::UsingDispString->unknw_arg, \
Display::UsingDispString->try_h, \
Strings::ExecutingName.c_str(), \
Display::UsingDispString->for_more);
}
break;
}
argc_parse--;
args_ctrl++;
}
Base = &BaseTemplate;
argc_parse = argc;
VLOGD("Starting cycle for trapping main options...\n");
while (1)
{
if ((argc_parse - 1) == 0)
{
VLOGD("MainFnController: argc - 1 = 0. Breaking...\n");
break;
}
if (args[(argc_parse - 1)][0] == '-')
{
VLOGD("MainFnController: args[%d] starts with '-'. Continue.\n", (argc_parse - 1));
argc_parse--;
continue;
}
else
{
Target = args[(argc_parse - 1)];
SearchOnMainInt = argc_parse;
VLOGD("MainFnController: args[%d] = %s\n", (argc_parse - 1), args[(argc_parse - 1)]);
VLOGD("MainFnController: variable of \"Target\" (string): %s\n", Target.c_str());
if (Target == "backup")
{
Base = &BackupArgProcessorBase;
Booleans::BackupMode = true;
break;
}
else if (Target == "flash")
{
Base = &FlashArgProcessorBase;
Booleans::FlashMode = true;
break;
}
else if (Target == "format")
{
Base = &FormatArgProcessorBase;
Booleans::FormatMode = true;
break;
}
else
{
Target = "";
SearchOnMainInt = -1;
argc_parse--;
continue;
}
}
break;
}
if (Booleans::SilentEnabled && Booleans::VerboseMode)
{
VLOGE("Silent and verbose mode is one-way.\n");
cout << Strings::ExecutingName << ": " << Display::UsingDispString->s_and_v << endl;
exit(1);
}
VLOGD("Checking last language switch status...\n");
if (Functions::CleanSWPoint())
{
VLOGD("Last transactions found that language was changed between.\n");
if (Display::UsingDispString->welcome_ != nullptr)
LOGD("%s", Display::UsingDispString->welcome_);
LOGD("%s %s %s %s.\n", Display::UsingDispString->language, Display::UsingDispString->welcome, Display::UsingDispString->by_str, Display::UsingDispString->lang_by_s);
}
/* check argument total */
VLOGD("argc (arguments) total: %d.\n", argc);
if (argc < 2)
LOGE("%s.\n%s '%s --help' %s.\n", Display::UsingDispString->missing_operand, Display::UsingDispString->try_h, Strings::ExecutingName.c_str(), Display::UsingDispString->for_more);
/* stop the program if multiple viewer is used */
if (MultipleViewers)
{
VLOGE("Multiple viewer option selected!\n");
LOGE("%s\n", Display::UsingDispString->multiple_wiewers);
}
/* controller to handle viewer */
if (ViewHelp)
{
VLOGD("The help message was asked to display. It's displayed... Calling DisplayHelp()\n");
Functions::DisplayHelp();
return 0;
}
else if (ViewVersion)
{
VLOGD("The version info message was asked to display. It's displayed... Calling DisplayVersion()\n");
Functions::DisplayVersion();
return 0;
}
else if (ListRequired)
{
VLOGD("Partitions were asked to be listed. It's listed... Calling CheckRoot() (root check is required), CheckDevPoint() (for generating warnings etc.) and ListPartitions()\n");
Functions::CheckRoot();
VLOGD("CheckRoot() completed.\n");
Functions::CheckDevPoint();
VLOGD("CheckDevPoint() completed.\n");
return Functions::ListPartitions();
}
if (SetLanguageReq)
{
VLOGD("The language was asked to adjust. Calling SetLanguage()...\n");
LOGD("%s: %s\n", Strings::ExecutingName.c_str(), Display::UsingDispString->switching_lang);
Functions::SetLanguage(SpeficedLanguagePr, 0);
sleep(2);
VLOGD("SetLanguage() completed.\n");
LOGD("%s: %s.\n", Strings::ExecutingName.c_str(), Display::UsingDispString->please_rerun);
return 0;
}
if (Target.empty())
{
VLOGE("There's no job to do.\n");
LOGD("%s: %s.\n", Strings::ExecutingName.c_str(), Display::UsingDispString->missing_operand);
if (SomeSpec)
LOGD("%s.\n", Display::UsingDispString->some_spec);
LOGD("%s '%s --help' %s.\n",Display::UsingDispString->try_h, Strings::ExecutingName.c_str(), Display::UsingDispString->for_more);
exit(1);
}
Base->ArgumentProcessor(SearchOnMainInt, argc, args);
if (Booleans::FormatMode)
{
VLOGD("File system name specified for formatting is being contaminated...\n");
if (Strings::TargetFormatFS != "ext4" \
&& Strings::TargetFormatFS != "ext3" \
&& Strings::TargetFormatFS != "ext2")
{
VLOGE("Unsupported file system: %s.\n", Strings::TargetFormatFS.c_str());
LOGE("%s: %s\n", Display::UsingDispString->unsupported_fs, Strings::TargetFormatFS.c_str());
}
}
/* checks */
VLOGD("Checking root status... Calling CheckRoot()...\n");
Functions::CheckRoot();
VLOGD("Checking A/B and logical device status... Calling CheckDevPoint()...\n");
Functions::CheckDevPoint();
if (LogicalSpeficy)
{
VLOGD("Logical partition type speficed. Checking partition statust's...\n");
if (Booleans::UsesLogical)
Booleans::UseLogical = true;
else
LOGE("%s\n", Display::UsingDispString->not_logical);
}
if (Booleans::FlashMode)
{
VLOGD("The status of the specified file for flashing is being checked...\n");
SearchResult = Functions::GetState(Strings::TargetFlashFile);
if (SearchResult == 1)
LOGE("%s: `%s': %s\n", Display::UsingDispString->cannot_stat, Strings::TargetFlashFile.c_str(), strqerror());
else if (SearchResult == -1)
LOGE("`%s': %s\n", Strings::TargetFlashFile.c_str(), Display::UsingDispString->not_file);
}
/* custom context checker */
if (Booleans::UseCustomContext)
{
VLOGD("The status of the \"dev\" is controlled in the specified custom /dev context...\n");
if (strncmp(Strings::CustomContext.c_str(), "/dev", 4) != 0)
{
if (!Booleans::ForceMode)
LOGE("%s\n", Display::UsingDispString->not_in_dev);
}
VLOGD("The specified custom /dev context is being put in countless...\n");
SearchResult = Functions::GetState(Strings::CustomContext, "dir");
if (SearchResult == 1)
LOGE("%s: `%s': %s\n", Display::UsingDispString->cannot_stat, Strings::CustomContext.c_str(), strqerror());
else if (SearchResult == -1)
LOGE("`%s': %s\n", Strings::CustomContext.c_str(), Display::UsingDispString->not_dir);
}
VLOGD("The partition specification status is controlled...\n");
if (Strings::TargetPartition.empty())
{
if (!Booleans::ForceMode)
LOGE("%s\n%s `%s --help' %s\n", Display::UsingDispString->req_part_name, Display::UsingDispString->try_h, Strings::ExecutingName.c_str(), Display::UsingDispString->for_more);
}
else
{
VLOGD("The call of main operations is being checked in case of the call...\n");
if (!Target.empty())
Base->CallTargetBaseFunction();
}
}
/* end of code */

52
jni/PartitionTool.cpp Executable file
View 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.
*/
#define INC_MAIN_LIBS
#include <PartitionManager/PartitionManager.h>
using namespace PartitionManager;
static bool
accf(const string fp)
{
VLOGD("accf <local function>: trying to access `%s' with 'access <unistd.h>'\n", fp.c_str());
return (access(fp.c_str(), F_OK) == 0) ? true : false;
}
/* check parts */
void Functions::CheckDevPoint(void)
{
VLOGD("CheckDevPoint: selecting context...\n");
string dpoint = (Booleans::UseCustomContext) ? Strings::CustomContext : "/dev/block/by-name";
/* true = ab | false = a only */
Booleans::UsesSlots = (accf(dpoint + "/boot_a")) ? true : false;
if (Booleans::UsesSlots)
VLOGW("CheckDevPoint: 1 warning generated: A/B status.\n");
/* true = logical | false = normal */
Booleans::UsesLogical = (accf(dpoint + "/super")) ? true : false;
if (Booleans::UsesLogical)
VLOGW("CheckDevPoint: 1 warning generated: logical partitions status.\n");
}
/* end of code */

37
jni/Root.cpp Executable file
View 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.
*/
#define INC_MAIN_LIBS
#define INC_DEBUGERS
#define INC_STRINGKEYS
#include <PartitionManager/PartitionManager.h>
/* root checker function */
void PartitionManager::Functions::CheckRoot(void)
{
VLOGD("CheckRoot: trying to get UID with 'getuid <unistd.h>'\n");
if (getuid() != 0)
{
VLOGE("CheckRoot: cannot get UID. Not executed with root!\n");
LOGE("%s\n", PartitionManager::Display::UsingDispString->no_root);
}
}
/* end of code */

243
jni/Tools.cpp Executable file
View File

@@ -0,0 +1,243 @@
/* 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 INC_MAIN_LIBS
#define INC_STAT
#define INC_DEBUGERS
#define INC_TOOLS_REQS
#define INC_STRINGKEYS
#include <PartitionManager/PartitionManager.h>
namespace PartitionManager {
namespace Functions {
/**
* it is meant to calculate the size of the quickly given file.
* its purpose is for rapid processing
*/
static double
CalculateSizeDouble(const string& fp)
{
VLOGD("CalculateSizeDouble: calculating file size: `%s'\n", fp.c_str());
VLOGD("CalculateSizeDouble: reading `%s' with 'ifstream <fstream>'\n", fp.c_str());
ifstream target(fp, ios::binary | ios::ate);
return (!target) ? -1 : static_cast<double>(target.tellg()) / (1024 * 1024);
}
static long long
CalculateSizeLongLong(const string& fp)
{
VLOGD("CalculateSizeLongLong: calculating file size: `%s'\n", fp.c_str());
VLOGD("CalculateSizeLongLong: reading `%s' with 'ifstream <fstream>'\n", fp.c_str());
ifstream target(fp, ios::binary | ios::ate);
return (!target) ? -1 : static_cast<long long>(target.tellg());
}
/**
* error that the partition is not found.
* It's for quick action.
*/
static void
PartitionNotFound(const char* p) { LOGE("`%s': %s\n", p, Display::UsingDispString->part_not_found); }
/* the partitions are meant to quickly find. */
static void
SearchPartition(const string& fp)
{
VLOGD("SearchPartition: calling GetState()...\n");
static int op = GetState(fp, "blk");
if (op == 1)
PartitionNotFound(fp.c_str());
else if (op == -1 && !Booleans::ForceMode)
LOGE("%s\n", Display::UsingDispString->not_block);
}
} /* namespace Functions */
} /* namespace PartitionNotFound */
using namespace PartitionManager;
/* to stop use of function type */
#define PartitionNotFound Functions::PartitionNotFound()
int Functions::Start(unsigned short progress_code)
{
/* required variables */
static fstream sourceF;
static fstream targetF;
static string accessPrefix;
static string opName;
static int BFSIZE = 1;
static char formatterCmd[200];
static long long copiedData = 0;
if (Booleans::UseLogical)
accessPrefix = "/dev/block/mapper/" + Strings::TargetPartition;
else
accessPrefix = (Booleans::UseCustomContext) ? (Strings::CustomContext) + ("/") + (Strings::TargetPartition) : ("/dev/block/by-name/") + (Strings::TargetPartition);
VLOGD("PartitionManager: calling SearchPartition() for searching partition (path); `%s'\n", accessPrefix.c_str());
Functions::SearchPartition(accessPrefix);
static long long count = (long long)(CalculateSizeLongLong(accessPrefix) + ((1024 * 1024) * 10));
BFSIZE = (int)(CalculateSizeLongLong(accessPrefix) / (10240 * 10240));
if (BFSIZE < 1)
BFSIZE = 1;
const int bfsize = BFSIZE;
char buffer[bfsize];
VLOGD("PartitionManager: calculating sizes...\n");
double partition_size = Functions::CalculateSizeDouble(accessPrefix);
double flashfile_size;
if (!Strings::TargetFlashFile.empty())
flashfile_size = Functions::CalculateSizeDouble(Strings::TargetFlashFile);
if (progress_code < 3)
{
if (partition_size != -1)
LOGD("%s: %.2fM\n", Display::UsingDispString->part_disk_sz, partition_size);
else
LOGW("%s\n", Display::UsingDispString->part_disk_sz_fail);
}
if (progress_code == 1)
{
VLOGD("PartitionManager: trying to open `%s' with 'open <fstream>'.\n", accessPrefix.c_str());
sourceF.open(accessPrefix, ios::binary | ios::in);
if (!sourceF.is_open())
LOGE("%s: %s: %s\n", Display::UsingDispString->not_read, accessPrefix.c_str(), strqerror());
/* determine output */
if (Strings::OutputName == Strings::TargetPartition)
{
opName = Strings::OutputName + ".img";
VLOGW("PartitionManager: output not speficed. Selecting automaticly.\n");
LOGW("%s: %s\n", Display::UsingDispString->out_not_spec, opName.c_str());
}
else
opName = Strings::OutputName;
VLOGD("Checking output status...\n");
if (GetState(opName) == 0)
LOGE("`%s': File exits.\n", opName.c_str());
VLOGD("PartitionManager: trying to open `%s' with 'open <fstream>'.\n", opName.c_str());
targetF.open(opName, ios::binary | ios::out);
if (!targetF.is_open())
LOGE("%s: %s: %s\n", Display::UsingDispString->not_gen, opName.c_str(), strqerror());
VLOGD("PartitionManager: read (partition) and write (output) 'read, write <fstream>'\n");
/* start writing */
while (sourceF.read(buffer, bfsize) && copiedData < count)
{
streamsize readed_data = sourceF.gcount();
targetF.write(buffer, readed_data);
if (targetF.fail())
{
if (Functions::GetState(opName) == 0)
remove(opName.c_str());
LOGF("%s: %s: %s\n", Display::UsingDispString->not_write, opName.c_str(), strqerror());
}
copiedData += readed_data;
}
/* close files */
sourceF.close();
targetF.close();
LOGD("%s: %s\n", Display::UsingDispString->success_backup, opName.c_str());
}
else if (progress_code == 2)
{
if (flashfile_size != -1)
LOGD("%s: %.2fM\n", Display::UsingDispString->flash_file_sz, flashfile_size);
else
LOGW("%s\n", Display::UsingDispString->flash_file_sz_fail);
if (partition_size != -1 && flashfile_size != -1)
{
if (flashfile_size > partition_size && !Booleans::ForceMode)
LOGE("%s\n", Display::UsingDispString->ffile_more_part);
}
VLOGD("PartitionManager: trying to open `%s' with 'open <fstream>'.\n", Strings::TargetFlashFile.c_str());
sourceF.open(Strings::TargetFlashFile, ios::binary | ios::in);
if (!sourceF.is_open())
LOGF("%s: %s: %s\n", Display::UsingDispString->not_read, Strings::TargetFlashFile.c_str(), strqerror());
VLOGD("PartitionManager: trying to open `%s' with 'open <fstream>'.\n", accessPrefix.c_str());
targetF.open(accessPrefix, ios::binary | ios::in | ios::out | ios::trunc);
if (!targetF.is_open())
LOGF("%s: %s: %s\n", Display::UsingDispString->not_read, accessPrefix.c_str(), strqerror());
VLOGD("PartitionManager: read (flash file) and write (partition) 'read, write <fstream>'\n");
/* start writing */
while (sourceF.read(buffer, bfsize) && copiedData < count)
{
streamsize readed_data = sourceF.gcount();
targetF.write(buffer, readed_data);
if (targetF.fail())
LOGF("%s: %s: %s\n", Display::UsingDispString->not_write, accessPrefix.c_str(), strqerror());
copiedData += readed_data;
}
sourceF.close();
targetF.close();
LOGD("%s.\n", Display::UsingDispString->success_flash);
}
else if (progress_code == 3)
{
/* get target partition block size */
VLOGD("PartitionManager: getting block size `%s' with 'statvfs <sys/statvfs.h>'\n", accessPrefix.c_str());
struct statvfs file_sys_inf;
if (statvfs(accessPrefix.c_str(), &file_sys_inf) != 0)
LOGE("%s\n", Display::UsingDispString->cannot_get_bsz);
/* generate mke2fs command */
VLOGD("PartitionManager: generating command...\n");
sprintf(formatterCmd, "/system/bin/mke2fs -Fq -t %s -b %lu %s &>/data/local/tmp/mke2fs", Strings::TargetFormatFS.c_str(), file_sys_inf.f_bsize, accessPrefix.c_str());
LOGD("%s: `%s'. %s: %s\n", Display::UsingDispString->formatting, accessPrefix.c_str(), Display::UsingDispString->fs_str, Strings::TargetFormatFS.c_str());
/* run command */
VLOGD("PartitionManager: executing command: \"%s\"\n", formatterCmd);
if (system(formatterCmd) != 0)
LOGF("%s\n", Display::UsingDispString->format_fail);
LOGD("%s.\n", Display::UsingDispString->success_format);
}
return 0;
}
/* end of code */

54
jni/Version.cpp Executable file
View File

@@ -0,0 +1,54 @@
/* 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 INC_MAIN_LIBS
#define INC_STRINGKEYS
#define VERSIONING
#include <PartitionManager/PartitionManager.h>
#include <PartitionManager/VersionFnVars.h>
using namespace PartitionManager;
void Functions::DisplayVersion(void)
{
VLOGD("DisplayVersion: printing main info...\n");
LOGD("%s %s %d.%d.%d (C++) (%d%d%d) ", Strings::ExecutingName.c_str(), Display::UsingDispString->version_str, PMT_MAJOR, PMT_MINOR, PMT_PATCHLEVEL, PMT_MAJOR, PMT_MINOR, PMT_PATCHLEVEL);
#if __SIZEOF_POINTER__ == 4
LOGD("32-bit %s\n", Display::UsingDispString->bin_str);
#elif __SIZEOF_POINTER__ == 8
LOGD("64-bit %s\n", Display::UsingDispString->bin_str);
#else
LOGD("<%s> %s\n", Display::UsingDispString->unknw_str, Display::UsingDispString->bin_str);
#endif
VLOGD("DisplayVersion: build type: ");
#if defined(__clang__) && !defined(__NDK_BUILD)
if (Booleans::VerboseMode)
printf("clang (manual).\n");
LOGD("%s: clang %d.%d.%d\n", Display::UsingDispString->compiler_str, __clang_major__, __clang_minor__, __clang_patchlevel__);
#elif defined(__NDK_BUILD)
if (Booleans::VerboseMode)
printf("NDK.\n");
LOGD("\n%s\n", __NDK_CXX_VERSION__);
#endif
}
/* end of code */

152
out/Makefile Executable file
View File

@@ -0,0 +1,152 @@
# 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
@ exit 0
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

347
pmt-termux.sh Executable file
View File

@@ -0,0 +1,347 @@
#!/data/data/com.termux/files/usr/bin/env bash
# By YZBruh | ShawkTeam
# Variables
LOCAL_VERSION="2.8.0"
LOCAL_OWNER="ShawkTeam"
LOCAL_REPO="pmt"
LOCAL_RELEASE_TAG="${LOCAL_VERSION}"
LOCAL_PREFIX="${PREFIX}"
[ -d "${LOCAL_PREFIX}" ] \
|| LOCAL_PREFIX="/data/data/com.termux/files/usr"
LOCAL_TMPDIR="${LOCAL_PREFIX}/tmp/pmt-termux-helper"
# Colors
RESET="\033[0m"
RED="\033[0;31m"
GREEN="\033[0;32m"
YELLOW="\033[0;33m"
# Printer functions
function printc() { echo -e "$*" >&2; }
function print()
{
if echo "$*" | grep "Success" &>/dev/null; then
echo -e " - ${GREEN}${1:0:7}${RESET}." >&2
else
echo -e " - $*" >&2
fi
}
# Print error and exit
function abort()
{
print "${RED}Error:${RESET} ${@}"
cleanup
exit 1
}
# Print warnings
function warning() { print "${YELLOW}Warning:${RESET} ${@}"; }
# Print head
function script_head() { printc " --- Partition Manager Termux Helper Script --- \n"; }
# For display help message
function view_help()
{
echo -n "Usage: "
if echo "${0}" | grep "./" >&/dev/null; then
printc "${0} [OPTIONS]..."
else
printc "(bash) ${0} [OPTIONS]"
fi
printc "Install, uninstall, install status checker for Partition Manager binary.\n"
printc "Options:"
printc " install, -i [OPTS] Download and install Partition Manager."
printc " uninstall, -u Uninstall Partition Manager."
printc " status, -s Display install/uninstall status."
printc " --setup, -S Setup required packages."
printc " --package <FILE> If you already have a debug package, make\n setup by specifying this way."
printc " --binary <FILE> Setup binary instead of the deb pack."
printc " --compress-algorithm [ALGO] Speficy custom algorithm for extracting package (if only custom package specified)."
printc "Supported algorithms: xz, gzip, zip, 7z, tar, tar.xz, tar.gz\n"
printc "Report bugs to <t.me/ShawkTeam | Topics | pmt>"
exit 0
}
# Script really operated termux proclamation?
function really_termux()
{
ls "${LOCAL_PREFIX}/bin" | grep "termux" &>/dev/null \
|| abort "Are you sure you're in termux?"
}
# Get architecture info
function get_architecture()
{
local arch=$(uname -m)
local archs_64=("aarch64" "armv8" "arm64-v8a" "armv8-a")
local archs_32=("aarch32" "armv7" "armeabi-v7a" "armv7l")
print "Device architecture: '${arch}'."
for a in ${archs_64[@]}; do
[ "${arch}" = "${a}" ] \
&& LOCAL_ARCH="arm64-v8a" \
&& return
done
for a in ${archs_32[@]}; do
[ "${arch}" = "${a}" ] \
&& LOCAL_ARCH="armeabi-v7a" \
&& return
done
LOCAL_ARCH="arm64-v8a"
}
# Generate template dir
function gen_tempdir() { mkdir -p "${LOCAL_TMPDIR}"; }
# Clean template dir
function cleanup() { rm -rf "${LOCAL_TMPDIR}"; }
# Check install/uninstall status
function check_status()
{
local installed="${RED}false${RESET}"
[ -f "${LOCAL_PREFIX}/bin/pmt" ] \
&& installed="${GREEN}true${RESET}"
print "Installed: ${installed}"
exit 0
}
# Check internet connection
function net_control()
{
curl "https://github.com" &>/dev/null \
|| abort "You need internet connection to this process."
}
# Download Partition Manager
function download()
{
local URL
if [ "${BINARY}" = 1 -a "${PACKAGE}" != 1 ]; then
URL="https://github.com/${LOCAL_OWNER}/${LOCAL_REPO}/releases/tag/${LOCAL_RELEASE_TAG}/download/pmt-${LOCAL_ARCH}.xz"
else
URL="https://github.com/${LOCAL_OWNER}/${LOCAL_REPO}/releases/tag/${LOCAL_RELEASE_TAG}/download/pmt-${LOCAL_ARCH}.deb"
fi
print "Downloading: \`${URL}'"
curl -L "${URL}" -o "${LOCAL_TMPDIR}/pmt-${LOCAL_ARCH}.deb" &>/dev/null \
|| abort "Download failed!"
chmod -R 777 "${LOCAL_TMPDIR}" \
|| warning "Cannot set mode '777' on installed sources."
}
# For installing required packages
function setup_packages()
{
net_control
print "Updating mirrors..."
if ! pkg update &>/dev/null || [ "$?" != 0 ]; then
abort "Updating failed!"
fi
print "Installing: 'xz-utils, p7zip'"
if ! pkg install -y xz-utils p7zip || [ "$?" != 0 ]; then
abort "Installing failed!"
fi
print "Success."
exit 0
}
# Install deb package
function install_fn()
{
local mydir="$(pwd)"
[ "${LOCAL_PACKAGE}" = "" ] || local bname=$(basename ${LOCAL_PACKAGE})
[ "${PACKAGE}" = 1 ] && \
if [ ! -f "${LOCAL_PACKAGE}" ]; then
[ -d "${LOCAL_PACKAGE}" ] \
&& abort "\`${LOCAL_PACKAGE}': is directory."
abort "\`${LOCAL_PACKAGE}': no such file."
else
cp "${LOCAL_PACKAGE}" "${LOCAL_TMPDIR}"
fi
cd "${LOCAL_TMPDIR}"
[ "${BINARY}" = 1 -a "${NONE_ALGO}" != 1 ] \
&& print "Extracting '${bname}'..." && \
if eval "${ALGO_DEC} ${ALGO_FLAGS} ${LOCAL_TMPDIR}/${bname}" &>/dev/null; then
rm -f "${bname}"
else
abort "Failed! Try speficing algorithm."
fi
[ "$(basename *)" = "*" ] \
&& abort "Deb pack or binary file was not found!"
bname=$(basename *)
if [ "${BINARY}" = 1 ]; then
mv "${bname}" pmt &>/dev/null
print "Copying..."
cp pmt "${LOCAL_PREFIX}/bin/pmt" &>/dev/null \
|| abort "Copying failed"
print "Setting up permissions..."
chmod 777 "${LOCAL_PREFIX}/bin/pmt" &>/dev/null \
|| abort "Cannot set permissions!"
print "Success."
return
fi
print "Installing Partition Manager with APT..."
if ! apt -y install ./pmt-${LOCAL_ARCH}.deb; then
warning "Installing failed with APT. Trying installing with dpkg..."
dpkg install pmt-${LOCAL_ARCH}.deb &>/dev/null \
|| abort "Cannot install Partition Manager!"
fi
print "Success."
cd "${mydir}"
}
# Uninstall deb package
function uninstall_fn()
{
[ "${BINARY}" = 1 ] \
&& print "Removing binary..." && \
if rm "${LOCAL_PREFIX}/bin/pmt" &>/dev/null; then
print "Success."
return
else
abort "Failed!"
fi
print "Uninstalling Partition Manager with APT..."
if ! apt -y remove pmt &>/dev/null; then
warning "Uninstalling failed with APT. Trying uninstalling with dpkg..."
dpkg remove pmt &>/dev/null \
|| abort "Cannot uninstall Partition Manager!"
fi
print "Success."
}
trap "abort Interrput; cleanup" SIGINT
# set -x
# Process arguments
while (($# >= 1)); do
SOME_SPEC=1
case "${1}" in
install|-i)
PROCESS=1
;;
uninstall|-u)
PROCESS=2
;;
status|-s)
script_head
check_status y
;;
--setup|-S)
script_head
print "Starting package setupper..."
setup_packages
;;
--package)
PACKAGE=1
LOCAL_PACKAGE="${2}"
;;
--binary)
BINARY=1
;;
--not-compressed)
NOT_COMP=1
;;
--compress-algorithm)
ALGO_SPEC=1
[ -z "${2}" ] \
&& abort "'--compress-algorithm' requires an argument."
case "${2}" in
xz|gzip|zip|7z|tar|tar.xz|tar.gz)
if echo "${2}" | grep "tar." &>/dev/null; then
ALGO_DEC="tar"
ALGO_FLAGS="-xf"
elif [ "${2}" = "zip" ]; then
ALGO_DEC="unzip"
ALGO_FLAGS=
elif [ "${2}" = "7z" ]; then
ALGO_DEC="7z"
ALGO_FLAGS="x"
else
ALGO_DEC="${2}"
ALGO_FLAGS="-d"
fi
;;
none)
NONE_ALGO=1
;;
*)
abort "Unknown compress algorithm: ${2}"
;;
esac
;;
--help)
view_help
;;
esac
shift 1
done
### Main ###
[ -z "${1}" -a "${SOME_SPEC}" != 1 ] && view_help
script_head
[ -z "${LOCAL_PACKAGE}" -a "${PACKAGE}" = 1 ] \
&& abort "'--package' requires an argument (file)."
really_termux
gen_tempdir
[ -z "${ALGO_DEC}" ] && ALGO_DEC="xz" && ALGO_FLAGS="-d"
[ "${ALGO_SPEC}" = 1 -a "${PACKAGE}" != 1 ] \
&& abort "Compression algorithm cannot be specified without package specification option."
if [ "${PROCESS}" = 1 ]; then
[ -f "${LOCAL_PREFIX}/bin/pmt" ] \
&& abort "Partition Manager already installed."
[ "${PACKAGE}" = 1 ] || net_control
get_architecture
print "Starting install process..."
[ "${PACKAGE}" = 1 ] || download
install_fn
elif [ "${PROCESS}" = 2 ]; then
[ ! -f "${LOCAL_PREFIX}/bin/pmt" ] \
&& abort "Partition Manager already uninstalled."
print "Starting uninstall process..."
uninstall_fn
fi
cleanup
exit 0