Samuel kendall 1 سال پیش
کامیت
56ce62816a
6فایلهای تغییر یافته به همراه243 افزوده شده و 0 حذف شده
  1. 75 0
      README.md
  2. 58 0
      scripts/convert.sh
  3. 4 0
      templates/installer.xml
  4. 6 0
      templates/roomservice.xml
  5. 97 0
      tools/ldcheck
  6. 3 0
      tools/libneeds

+ 75 - 0
README.md

@@ -0,0 +1,75 @@
+# compile Custom Recovery with Github Actions
+```
+only Supports TWRP  14 / 12.1 / 11 / 9.0
+```
+---
+
+## Release Notes
+```
+= 2024-09-22
+- Now Supports TWRP 14
+
+
+= 2024-09-05
+- Include Recovery to tar for Samsung devices
+- Include recovery installer zip
+- LDCheck for checking missing dependencies.
+- TWRP Allow non-Github/Gitlab remotes for device trees
+- Clarify options in README
+- Increase swap size for kernel inline builds
+- Remove common tree input fields (not needed)
+- Fix build with Omni manifests
+- Update to ubuntu-20.04
+- Updated to work with Android 12.1 AOSP minimal TWRP manifest
+- Completely reconstruct the use logic to reduce the difficulty of use
+- Optimize the parameter transfer part, now you can run multiple Workers at the same time
+- TWRP compilation test passed
+
+```
+
+-----
+
+## Output will be like this
+![](https://s3.bmp.ovh/imgs/2024/09/07/17b331e17bc4ccd9.png)
+
+## Parameter Description
+| Name | Description | Example |
+| ------------ | -------------------- | ------------ |
+| `MANIFEST_BRANCH` | Source branch | twrp-14 |
+| `DEVICE_TREE_URL` | Device tree address | https://github.com/kinguser981/android_device_samsung_a05s.git |
+| `DEVICE_TREE_BRANCH` | Device branch that you want to use for build (typically corresponds to the manifest branch) | android-14.0 |
+| `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 |
+| `DEVICE_NAME` | Model name (same as twrp_`<DEVICE_NAME>`.mk from device tree) | a05s |
+| `DEVICE_MAKEFILE` | Name of device-specific makefile from tree (format: `<PREFIX>_<DEVICE_NAME>`) | twrp_a05s
+| `BUILD_TARGET` | Build Target Partition (boot/recovery/vendor_boot) | recovery |
+| `RECOVERY_INSTALLER` | Include recovery installer zip | Optional |
+| `RECOVERY_TAR` | Recovery to tar for Samsung devices | Optional |
+
+-----
+
+## Usage Instructions
+
+#### 1. Click 'Fork' in the upper right corner of this repo
+![](https://s3.bmp.ovh/imgs/2024/09/07/acd37b59bde6971e.png)
+#### 2. After waiting for the automatic redirection, you will see your own username
+## Building the Recovery
+#### 3. Click on 'Actions' then Click no 'TWRP Recovery Builder 2024'
+![](https://s3.bmp.ovh/imgs/2024/09/07/4e0db9b997ea3522.png)
+#### 4. Click 'Run workflow', choose the branch for the recovery that you want to build, and fill in according to the above 'Parameter Description'
+![](https://s3.bmp.ovh/imgs/2024/09/07/29a2d0acf63c6e4f.png)
+#### 5. After filling in, click 'Run workflow' to start running
+
+-----
+
+## Compilation results
+Can be downloaded at [Release](../../releases)
+
+-----
+## Reference and Credits
+- https://github.com/that1
+- https://github.com/TeamWin
+- https://github.com/CaptainThrowback
+- https://github.com/cd-Crypton
+- https://github.com/azwhikaru
+- And to all Contributors in every repositories and scripts I used.
+

+ 58 - 0
scripts/convert.sh

@@ -0,0 +1,58 @@
+#!/bin/bash
+
+if [ -n "$1" ] && [ -e $1 ]; then
+	file=$1
+else
+	echo " ** Input File : $1 does not exist"
+	echo " ** Please specify the correct dependencies file"
+	echo " ** Usage : bash <path-to-script> <path-to-dependencies-file> [<path-to-local-manifest>]"
+	exit 1
+fi
+
+if [ -n "$2" ]; then
+	manifest_path="$2"
+elif [ -e .repo ]; then
+	mkdir -p .repo/local_manifests
+	manifest_path=".repo/local_manifests/roomservice.xml"
+else
+	echo " ** Manifest file to create not specified."
+	echo " ** And .repo folder does not exist in $PWD"
+	echo " ** Either run the script from root of your source or specify a custom path+filename"
+	echo " ** Usage : bash <path-to-script> <path-to-dependencies-file> [<path-to-local-manifest>]"
+	exit 1
+fi
+
+
+if [ -e $manifest_path ]; then
+	sed -i 's@</manifest>@@g' $manifest_path
+else
+	echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > $manifest_path
+	echo "<manifest>" >> $manifest_path
+fi
+
+vars=( "remote" "repository" "target_path" "branch" "revision")
+
+for i in ${!vars[@]} ; do
+	value=$(grep "${vars[$i]}" "$file" | cut -d '"' -f4)
+	if [ "$value" != "" ]; then
+		declare -a ${vars[$i]}"_val"="( $value )"
+	fi
+done
+
+for i in {0..5}; do
+	if [ "${repository_val[$i]}" != "" ] && [ "${target_path_val[$i]}" != "" ]; then
+		target_path="path=\"${target_path_val[$i]}\""
+		repository=" name=\"${repository_val[$i]}\""
+		if [ "${remote_val[$i]}" != "" ]; then
+			remote_for_repo=" remote=\"${remote_val[$i]}\""
+		fi
+		if [ "${branch_val[$i]}" != "" ]; then
+			revision=" revision=\"${branch_val[$i]}\""
+		elif [ "${revision_val[$i]}" != "" ]; then
+			revision=" revision=\"${revision_val[$i]}\""
+		fi
+		echo "  <project $target_path$repository$remote_for_repo$revision />" >> $manifest_path
+	fi
+done
+
+echo "</manifest>" >> $manifest_path

+ 4 - 0
templates/installer.xml

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

+ 6 - 0
templates/roomservice.xml

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

+ 97 - 0
tools/ldcheck

@@ -0,0 +1,97 @@
+#!/usr/bin/env python3
+
+# Dynamic linking consistency checker
+# hacked together by _that@xda, 2014-12 to 2022-03
+
+import os
+import string
+import argparse
+
+
+def ldcheck(files, libpath, printalldefined, printresolved, demangle):
+    nmopts = "-C" if demangle else ""
+    libs = files
+    libswithpath = []
+
+    # find all dependencies
+    for filename in libs:
+        if not os.path.isfile(filename) and libpath:
+            filename = findlibraryinpath(filename, libpath)
+        libswithpath.append(filename)
+        with os.popen("readelf -d {0} | grep '\(NEEDED\)' | sed -r 's/.*\[(.*)\]/\\1/'".format(filename)) as f:
+            for line in f:
+                dependency = line.rstrip()
+                if dependency not in libs:
+                    libs.append(dependency)
+
+    print("libs:", libswithpath)
+    libsused = set((libswithpath[0],))
+
+    # read all defined symbols
+    syms = {}
+    for filename in libswithpath:
+        for sym in readsymbols(filename, nmopts):
+            if sym["type"] != "U":
+                # TODO: support symbols defined by multiple libs properly, and weak symbols
+                # TODO: more proper handling of symbol versions, see https://maskray.me/blog/2020-11-26-all-about-symbol-versioning
+                if "@@" in sym["name"]:
+                    syms[sym["name"].replace("@@", "@")] = {"type": sym["type"], "file": filename}
+                    syms[sym["name"].split("@@")[0]] = {"type": sym["type"], "file": filename}
+                else:
+                    syms[sym["name"]] = {"type": sym["type"], "file": filename}
+
+    # resolve unresolved
+    for filename in libswithpath:
+        for sym in readsymbols(filename, nmopts):
+            if sym["type"] == "U":
+                resolved = syms.get(sym["name"])
+                if resolved:
+                    if filename in libsused:
+                        libsused.add(resolved["file"])
+                    if printresolved:
+                        print("{0:25} {1:25} {2} {3}".format(filename, resolved["file"], resolved["type"], sym["name"]))
+                else:
+                    print("{0:25} {1:25} U {2}".format(filename, "UNRESOLVED #####", sym["name"]))
+            else:
+                if printalldefined:
+                    print("{0:25}                  {1}".format(filename, sym["line"]))
+
+    unused = set(libswithpath) - libsused
+    if unused:
+        print("unused:", unused)
+
+
+def findlibraryinpath(filename, searchpath):
+    for d in searchpath.split(os.pathsep):
+        filepath = os.path.join(d, filename)
+        if os.path.isfile(filepath):
+            return filepath
+    return filename
+
+
+"""
+output format of nm:
+00003004 A __bss_start
+         U __cxa_atexit
+"""
+def readsymbol(line):
+    s = line if line[0] == " " else line.lstrip(string.hexdigits)
+    s = s.lstrip()
+    return {"type": s[0], "name": s[2:], "line": line}
+
+
+def readsymbols(filename, nmopts=""):
+    with os.popen("nm -D {0} {1}".format(nmopts, filename)) as f:
+        for line in f:
+            yield readsymbol(line.rstrip())
+
+if __name__ == "__main__":
+    parser = argparse.ArgumentParser(description='Check dynamic linkage consistency by matching defined vs unresolved symbols.')
+    parser.add_argument('files', metavar='FILE', nargs='+', help="a dynamically linked executable or library.")
+    parser.add_argument('-p', '--path', help="Search path for libraries (use like LD_LIBRARY_PATH)")
+    parser.add_argument('-r', '--resolved', action='store_true', help="Print resolved symbols. By default only unresolved symbols are printed.")
+    parser.add_argument('-a', '--alldefined', action='store_true', help="Print all defined symbols")
+    parser.add_argument('-d', '--demangle', action='store_true', help="Demangle C++ names")
+
+    args = parser.parse_args()
+    ldcheck(args.files, args.path, args.alldefined, args.resolved, args.demangle)

+ 3 - 0
tools/libneeds

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