Skip to content

Commit 77bfc19

Browse files
committed
TWRP-Recovery-Builder-2024
0 parents  commit 77bfc19

File tree

6 files changed

+235
-0
lines changed

6 files changed

+235
-0
lines changed

README.md

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# compile Custom Recovery with Github Actions
2+
```
3+
only Supports TWRP
4+
```
5+
---
6+
7+
## Release Notes
8+
```
9+
= 2024-09-05
10+
- Include Recovery to tar for Samsung devices
11+
- Include recovery installer zip
12+
- LDCheck forchecking missing dependencies.
13+
- TWRP Allow non-Github/Gitlab remotes for device trees
14+
- Clarify options in README
15+
- Add option to include recovery installer
16+
- Increase swap size for kernel inline builds
17+
- Remove common tree input fields (not needed)
18+
- Fix build with Omni manifests
19+
- Supports Samsung devices
20+
- Update to ubuntu-20.04
21+
- Updated to work with Android 12.1 AOSP minimal TWRP manifest
22+
- Completely reconstruct the use logic to reduce the difficulty of use
23+
- Optimize the parameter transfer part, now you can run multiple Workers at the same time
24+
- TWRP compilation test passed
25+
26+
```
27+
28+
-----
29+
30+
## Parameter Description
31+
![](https://s3.bmp.ovh/imgs/2024/09/07/17b331e17bc4ccd9.png)
32+
33+
| Name | Description | Example |
34+
| ------------ | -------------------- | ------------ |
35+
| `MANIFEST_BRANCH` | Source branch | 12.1 |
36+
| `DEVICE_TREE_URL` | Device tree address | https://github.com/kinguser981/android_device_samsung_a05s.git |
37+
| `DEVICE_TREE_BRANCH` | Device branch that you want to use for build (typically corresponds to the manifest branch) | android-12.1 |
38+
| `DEVICE_PATH` | Device tree location for syncing, relative to workspace root (usually listed as "LOCAL_PATH" or "DEVICE_PATH" in BoardConfig.mk) | device/samsung/a05s |
39+
| `DEVICE_NAME` | Model name (same as twrp_`<DEVICE_NAME>`.mk from device tree) | a05s |
40+
| `DEVICE_MAKEFILE` | Name of device-specific makefile from tree (format: `<PREFIX>_<DEVICE_NAME>`) | twrp_a05s
41+
| `BUILD_TARGET` | Build Target Partition (boot/recovery/vendor_boot) | recovery |
42+
| `RECOVERY_INSTALLER` | Include recovery installer zip | Optional |
43+
| `RECOVERY_TAR` | Recovery to tar for Samsung devices | Optional |
44+
45+
-----
46+
47+
## Usage Instructions
48+
49+
#### 1. Click 'Fork' in the upper right corner of this repo
50+
![](https://s3.bmp.ovh/imgs/2024/09/07/acd37b59bde6971e.png)
51+
#### 2. After waiting for the automatic redirection, you will see your own username
52+
## Building the Recovery
53+
#### 3. Click 'TWRP Recovery Builder 2024'
54+
![](https://s3.bmp.ovh/imgs/2024/09/07/4e0db9b997ea3522.png)
55+
#### 4. Click 'Run workflow', choose the branch for the recovery that you want to build, and fill in according to the above 'Parameter Description'
56+
![](https://s3.bmp.ovh/imgs/2024/09/07/29a2d0acf63c6e4f.png)
57+
#### 5. After filling in, click 'Run workflow' to start running
58+
59+
-----
60+
61+
## Compilation results
62+
Can be downloaded at [Release](../../releases)
63+
64+
-----
65+
## Reference
66+
67+
#### TeamWin Recovery Project: https://github.com/minimal-manifest-twrp

scripts/convert.sh

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/bin/bash
2+
3+
if [ -n "$1" ] && [ -e $1 ]; then
4+
file=$1
5+
else
6+
echo " ** Input File : $1 does not exist"
7+
echo " ** Please specify the correct dependencies file"
8+
echo " ** Usage : bash <path-to-script> <path-to-dependencies-file> [<path-to-local-manifest>]"
9+
exit 1
10+
fi
11+
12+
if [ -n "$2" ]; then
13+
manifest_path="$2"
14+
elif [ -e .repo ]; then
15+
mkdir -p .repo/local_manifests
16+
manifest_path=".repo/local_manifests/roomservice.xml"
17+
else
18+
echo " ** Manifest file to create not specified."
19+
echo " ** And .repo folder does not exist in $PWD"
20+
echo " ** Either run the script from root of your source or specify a custom path+filename"
21+
echo " ** Usage : bash <path-to-script> <path-to-dependencies-file> [<path-to-local-manifest>]"
22+
exit 1
23+
fi
24+
25+
26+
if [ -e $manifest_path ]; then
27+
sed -i 's@</manifest>@@g' $manifest_path
28+
else
29+
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > $manifest_path
30+
echo "<manifest>" >> $manifest_path
31+
fi
32+
33+
vars=( "remote" "repository" "target_path" "branch" "revision")
34+
35+
for i in ${!vars[@]} ; do
36+
value=$(grep "${vars[$i]}" "$file" | cut -d '"' -f4)
37+
if [ "$value" != "" ]; then
38+
declare -a ${vars[$i]}"_val"="( $value )"
39+
fi
40+
done
41+
42+
for i in {0..5}; do
43+
if [ "${repository_val[$i]}" != "" ] && [ "${target_path_val[$i]}" != "" ]; then
44+
target_path="path=\"${target_path_val[$i]}\""
45+
repository=" name=\"${repository_val[$i]}\""
46+
if [ "${remote_val[$i]}" != "" ]; then
47+
remote_for_repo=" remote=\"${remote_val[$i]}\""
48+
fi
49+
if [ "${branch_val[$i]}" != "" ]; then
50+
revision=" revision=\"${branch_val[$i]}\""
51+
elif [ "${revision_val[$i]}" != "" ]; then
52+
revision=" revision=\"${revision_val[$i]}\""
53+
fi
54+
echo " <project $target_path$repository$remote_for_repo$revision />" >> $manifest_path
55+
fi
56+
done
57+
58+
echo "</manifest>" >> $manifest_path

templates/installer.xml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<manifest>
3+
<project name="osm0sis/twrp_abtemplate" path="bootable/recovery/installer" remote="github" revision="master" />
4+
</manifest>

templates/roomservice.xml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<manifest>
3+
<!--remote name="{REMOTE_NAME}"
4+
fetch="https://{REMOTE_FETCH}"/-->
5+
<!--project name="{DEVICE_TREE_URL_REPO}" path="{DEVICE_PATH}" remote="{DEVICE_REMOTE_NAME}" revision="{DEVICE_TREE_BRANCH}"/-->
6+
</manifest>

tools/ldcheck

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#!/usr/bin/env python3
2+
3+
# Dynamic linking consistency checker
4+
# hacked together by _that@xda, 2014-12 to 2022-03
5+
6+
import os
7+
import string
8+
import argparse
9+
10+
11+
def ldcheck(files, libpath, printalldefined, printresolved, demangle):
12+
nmopts = "-C" if demangle else ""
13+
libs = files
14+
libswithpath = []
15+
16+
# find all dependencies
17+
for filename in libs:
18+
if not os.path.isfile(filename) and libpath:
19+
filename = findlibraryinpath(filename, libpath)
20+
libswithpath.append(filename)
21+
with os.popen("readelf -d {0} | grep '\(NEEDED\)' | sed -r 's/.*\[(.*)\]/\\1/'".format(filename)) as f:
22+
for line in f:
23+
dependency = line.rstrip()
24+
if dependency not in libs:
25+
libs.append(dependency)
26+
27+
print("libs:", libswithpath)
28+
libsused = set((libswithpath[0],))
29+
30+
# read all defined symbols
31+
syms = {}
32+
for filename in libswithpath:
33+
for sym in readsymbols(filename, nmopts):
34+
if sym["type"] != "U":
35+
# TODO: support symbols defined by multiple libs properly, and weak symbols
36+
# TODO: more proper handling of symbol versions, see https://maskray.me/blog/2020-11-26-all-about-symbol-versioning
37+
if "@@" in sym["name"]:
38+
syms[sym["name"].replace("@@", "@")] = {"type": sym["type"], "file": filename}
39+
syms[sym["name"].split("@@")[0]] = {"type": sym["type"], "file": filename}
40+
else:
41+
syms[sym["name"]] = {"type": sym["type"], "file": filename}
42+
43+
# resolve unresolved
44+
for filename in libswithpath:
45+
for sym in readsymbols(filename, nmopts):
46+
if sym["type"] == "U":
47+
resolved = syms.get(sym["name"])
48+
if resolved:
49+
if filename in libsused:
50+
libsused.add(resolved["file"])
51+
if printresolved:
52+
print("{0:25} {1:25} {2} {3}".format(filename, resolved["file"], resolved["type"], sym["name"]))
53+
else:
54+
print("{0:25} {1:25} U {2}".format(filename, "UNRESOLVED #####", sym["name"]))
55+
else:
56+
if printalldefined:
57+
print("{0:25} {1}".format(filename, sym["line"]))
58+
59+
unused = set(libswithpath) - libsused
60+
if unused:
61+
print("unused:", unused)
62+
63+
64+
def findlibraryinpath(filename, searchpath):
65+
for d in searchpath.split(os.pathsep):
66+
filepath = os.path.join(d, filename)
67+
if os.path.isfile(filepath):
68+
return filepath
69+
return filename
70+
71+
72+
"""
73+
output format of nm:
74+
00003004 A __bss_start
75+
U __cxa_atexit
76+
"""
77+
def readsymbol(line):
78+
s = line if line[0] == " " else line.lstrip(string.hexdigits)
79+
s = s.lstrip()
80+
return {"type": s[0], "name": s[2:], "line": line}
81+
82+
83+
def readsymbols(filename, nmopts=""):
84+
with os.popen("nm -D {0} {1}".format(nmopts, filename)) as f:
85+
for line in f:
86+
yield readsymbol(line.rstrip())
87+
88+
if __name__ == "__main__":
89+
parser = argparse.ArgumentParser(description='Check dynamic linkage consistency by matching defined vs unresolved symbols.')
90+
parser.add_argument('files', metavar='FILE', nargs='+', help="a dynamically linked executable or library.")
91+
parser.add_argument('-p', '--path', help="Search path for libraries (use like LD_LIBRARY_PATH)")
92+
parser.add_argument('-r', '--resolved', action='store_true', help="Print resolved symbols. By default only unresolved symbols are printed.")
93+
parser.add_argument('-a', '--alldefined', action='store_true', help="Print all defined symbols")
94+
parser.add_argument('-d', '--demangle', action='store_true', help="Demangle C++ names")
95+
96+
args = parser.parse_args()
97+
ldcheck(args.files, args.path, args.alldefined, args.resolved, args.demangle)

tools/libneeds

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
# list needed shared libs for Android lib
3+
readelf -d $1 |grep '\(NEEDED\)' | sed -r 's/.*\[(.*)\]/\1/'

0 commit comments

Comments
 (0)