From d088aaf38cc40fa3fd943ea61ece910c999acaee Mon Sep 17 00:00:00 2001 From: lazycodebuilder <154446636+lazycodebuilder@users.noreply.github.com> Date: Tue, 6 Feb 2024 15:25:48 +0530 Subject: [PATCH] Initial Build Tree --- .github/workflows/OrangeFox-OFRP.yml | 178 +++++++++++++++++++++++ .github/workflows/PitchBlack-PBRP.yml | 187 ++++++++++++++++++++++++ .github/workflows/SkyHawk-SHRP.yml | 185 ++++++++++++++++++++++++ .github/workflows/TeamWin-TWRP.yml | 195 ++++++++++++++++++++++++++ README.md | 23 +++ tools/ldcheck | 97 +++++++++++++ tools/libneeds | 3 + 7 files changed, 868 insertions(+) create mode 100644 .github/workflows/OrangeFox-OFRP.yml create mode 100644 .github/workflows/PitchBlack-PBRP.yml create mode 100644 .github/workflows/SkyHawk-SHRP.yml create mode 100644 .github/workflows/TeamWin-TWRP.yml create mode 100644 README.md create mode 100644 tools/ldcheck create mode 100644 tools/libneeds diff --git a/.github/workflows/OrangeFox-OFRP.yml b/.github/workflows/OrangeFox-OFRP.yml new file mode 100644 index 0000000..ce1dcc4 --- /dev/null +++ b/.github/workflows/OrangeFox-OFRP.yml @@ -0,0 +1,178 @@ +name: OrangeFox [OFRP] + +on: + workflow_dispatch: + inputs: + MANIFEST_BRANCH: + description: 'OrangeFox Manifest Branch' + required: true + default: '12.1' + type: choice + options: + - 12.1 + - 11.0 + - 10.0 + - 9.0 + - 8.1 + - 7.1 + - 6.0 + DEVICE_TREE: + description: 'Custom Recovery Tree' + required: true + default: 'https://github.com/lazycodebuilder/recovery_rmx1851' + DEVICE_TREE_BRANCH: + description: 'Custom Recovery Tree Branch' + required: true + default: 'android-14_ofrp' + DEVICE_PATH: + description: 'Specify your device path.' + required: true + default: 'device/realme/RMX1851' + DEVICE_NAME: + description: 'Specify your Device Codename.' + required: true + default: 'RMX1851' + BUILD_TARGET: + description: 'Specify your Build Target' + required: true + default: 'recovery' + type: choice + options: + - boot + - recovery + - vendorboot + LDCHECK: + description: 'Use LDCHECK' + required: false + default: 'false' + type: boolean + LDCHECKPATH: + description: 'Path of blobs to check' # Use it know what kind of dependencies your missing for decryption blobs. + required: true + default: 'system/bin/qseecomd' + +jobs: + build: + name: Build OFRP by ${{ github.actor }} + runs-on: ubuntu-latest + if: github.event.repository.owner.id == github.event.sender.id + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + permissions: + contents: write + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Display Inputs + run: | + echo "Displaying variables/inputs." + echo "Manifest Branch: ${{ github.event.inputs.MANIFEST_BRANCH }}" + echo "Device Tree: ${{ github.event.inputs.DEVICE_TREE }}" + echo "Device Branch: ${{ github.event.inputs.DEVICE_TREE_BRANCH }}" + echo "Device Path: ${{ github.event.inputs.DEVICE_PATH }}" + echo "Device Name: ${{ github.event.inputs.DEVICE_NAME }}" + echo "Build Target: ${{ github.event.inputs.BUILD_TARGET }}image" + + - name: Clean-up + uses: rokibhasansagar/slimhub_actions@main + + - name: Swap Space + uses: pierotofy/set-swap-space@master + with: + swap-size-gb: 12 + + - name: Build Environment + run: | + sudo apt install aria2 -y + git clone https://gitlab.com/OrangeFox/misc/scripts + cd scripts + sudo bash setup/android_build_env.sh + + - name: Set-up Manifest + run: | + mkdir -p ${GITHUB_WORKSPACE}/OrangeFox + cd ${GITHUB_WORKSPACE}/OrangeFox + git config --global user.name "lazycodebuilder" + git config --global user.email "154446636+lazycodebuilder@users.noreply.github.com" + git clone https://gitlab.com/OrangeFox/sync.git + if [ ${{ github.event.inputs.MANIFEST_BRANCH }} == '11.0' ] || [ ${{ github.event.inputs.MANIFEST_BRANCH }} == '12.1' ]; then + echo "Sync fox_${{ github.event.inputs.MANIFEST_BRANCH }} branch" + cd sync + ./orangefox_sync.sh --branch ${{ github.event.inputs.MANIFEST_BRANCH }} --path ${GITHUB_WORKSPACE}/OrangeFox/fox_${{ github.event.inputs.MANIFEST_BRANCH }} + else + echo "Sync legacy fox_${{ github.event.inputs.MANIFEST_BRANCH }} branch" + cd sync/legacy + ./orangefox_sync_legacy.sh --branch ${{ github.event.inputs.MANIFEST_BRANCH }} --path ${GITHUB_WORKSPACE}/OrangeFox/fox_${{ github.event.inputs.MANIFEST_BRANCH }} + fi + + - name: Clone Device Tree + run: | + cd ${GITHUB_WORKSPACE}/OrangeFox/fox_${{ github.event.inputs.MANIFEST_BRANCH }} + git clone ${{ github.event.inputs.DEVICE_TREE }} -b ${{ github.event.inputs.DEVICE_TREE_BRANCH }} ./${{ github.event.inputs.DEVICE_PATH }} + cd ${{ github.event.inputs.DEVICE_PATH }} + echo "COMMIT_ID=$(git rev-parse HEAD)" >> $GITHUB_ENV + + - name: Check Manifest Branch + uses: haya14busa/action-cond@v1 + id: fox_branch + with: + cond: ${{ github.event.inputs.MANIFEST_BRANCH == '11.0' || github.event.inputs.MANIFEST_BRANCH == '12.1' }} + if_true: lunch twrp_${{ github.event.inputs.DEVICE_NAME }}-eng && make clean && mka adbd ${{ github.event.inputs.BUILD_TARGET }}image + if_false: lunch omni_${{ github.event.inputs.DEVICE_NAME }}-eng && make clean && mka ${{ github.event.inputs.BUILD_TARGET }}image + + - name: Building OrangeFox + run: | + cd ${GITHUB_WORKSPACE}/OrangeFox/fox_${{ github.event.inputs.MANIFEST_BRANCH }} + set +e + source build/envsetup.sh + export ALLOW_MISSING_DEPENDENCIES=true + set -e + ${{ steps.fox_branch.outputs.value }} + + - name: Set Build Date # For Build Date Info, currently using Asia/Manila + run: | + echo "BUILD_DATE=$(TZ=Asia/Manila date +%Y%m%d)" >> $GITHUB_ENV + + - name: Check if Recovery Exist + run: | + cd ${GITHUB_WORKSPACE}/OrangeFox/fox_${{ github.event.inputs.MANIFEST_BRANCH }} + if [ -f out/target/product/${{ github.event.inputs.DEVICE_NAME }}/OrangeFox*.img ]; then + echo "CHECK_IMG_IS_OK=true" >> $GITHUB_ENV + echo "MD5_IMG=$(md5sum out/target/product/${{ github.event.inputs.DEVICE_NAME }}/OrangeFox*.img | cut -d ' ' -f 1)" >> $GITHUB_ENV + else + echo "Recovery out directory is empty." + fi + if [ -f out/target/product/${{ github.event.inputs.DEVICE_NAME }}/OrangeFox*.zip ]; then + echo "CHECK_ZIP_IS_OK=true" >> $GITHUB_ENV + echo "MD5_ZIP=$(md5sum out/target/product/${{ github.event.inputs.DEVICE_NAME }}/OrangeFox*.zip | cut -d ' ' -f 1)" >> $GITHUB_ENV + else + echo "Recovery out directory is empty." + fi + + - name: Upload to Release + if: env.CHECK_IMG_IS_OK == 'true' && env.CHECK_ZIP_IS_OK == 'true' + uses: softprops/action-gh-release@v1 + with: + files: | + OrangeFox/fox_${{ github.event.inputs.MANIFEST_BRANCH }}/out/target/product/${{ github.event.inputs.DEVICE_NAME }}/OrangeFox*.img + OrangeFox/fox_${{ github.event.inputs.MANIFEST_BRANCH }}/out/target/product/${{ github.event.inputs.DEVICE_NAME }}/OrangeFox*.zip + name: Unofficial OrangeFox for ${{ github.event.inputs.DEVICE_NAME }} // ${{ env.BUILD_DATE }} + tag_name: ${{ github.run_id }} + body: | + Build: ${{ github.event.inputs.MANIFEST_BRANCH }} + Device: [Device Tree/Branch](${{ github.event.inputs.DEVICE_TREE }}/tree/${{ github.event.inputs.DEVICE_TREE_BRANCH }}) + Commit: Most recent [commit](${{ github.event.inputs.DEVICE_TREE }}/commit/${{ env.COMMIT_ID }}) during building. + MD5 (img): ${{ env.MD5_IMG }} + MD5 (zip): ${{ env.MD5_ZIP }} + + - name: Run LDCheck + if: github.event.inputs.LDCHECK == 'true' + run: | + cd tools + mv -n libneeds ${GITHUB_WORKSPACE}/OrangeFox/fox_${{ github.event.inputs.MANIFEST_BRANCH }}/out/target/product/${{ github.event.inputs.DEVICE_NAME }}/recovery/root/ + mv -n ldcheck ${GITHUB_WORKSPACE}/OrangeFox/fox_${{ github.event.inputs.MANIFEST_BRANCH }}/out/target/product/${{ github.event.inputs.DEVICE_NAME }}/recovery/root/ + cd ../OrangeFox/fox_${{ github.event.inputs.MANIFEST_BRANCH }}/out/target/product/${{ github.event.inputs.DEVICE_NAME }}/recovery/root + python3 ldcheck -p system/lib64:vendor/lib64:system/lib:vendor/lib -d ${{ github.event.inputs.LDCHECKPATH }} + echo "Done checking missing dependencies. Review, and reconfigure your tree." + continue-on-error: true diff --git a/.github/workflows/PitchBlack-PBRP.yml b/.github/workflows/PitchBlack-PBRP.yml new file mode 100644 index 0000000..107f653 --- /dev/null +++ b/.github/workflows/PitchBlack-PBRP.yml @@ -0,0 +1,187 @@ +name: PitchBlack [PBRP] + +on: + workflow_dispatch: + inputs: + MANIFEST_BRANCH: + description: 'PBRP Manifest Branch' + required: true + default: '' + type: choice + options: + - android-12.1 + - android-11.0 + - android-10.0 + - android-9.0 + - android-8.1 + - android-7.1 + - android-6.0 + DEVICE_TREE: + description: 'Custom Recovery Tree' # Your already made Device Tree for TWRP + required: true + default: 'https://github.com/lazycodebuilder/recovery_rmx1851' + DEVICE_TREE_BRANCH: + description: 'Custom Recovery Tree Branch' # Your Device Tree Branch, make sure it's right. + required: true + default: 'android-14_pbrp' + DEVICE_PATH: + description: 'Specify your Device Path' # As is, just like your DEVICE_PATH in your BoardConfig.mk + required: true + default: 'device/realme/RMX1851' + DEVICE_NAME: + description: 'Specify your Device Codename' # As is, just like your PRODUCT_DEVICE in your device tree. + required: true + default: 'RMX1851' + BUILD_TARGET: + description: 'Specify your Build Target' # Pick among boot, recovery and vendor_boot + required: true + default: '' + type: choice + options: + - pbrp + - bootimage + - recoveryimage + - vendorbootimage + LDCHECK: + description: 'Use LDCHECK' + required: false + default: 'false' + type: boolean + LDCHECKPATH: + description: 'Path of blobs to check' # Use it know what kind of dependencies your missing for decryption blobs. + required: true + default: 'system/bin/qseecomd' + +jobs: + build: + name: Build PBRP by ${{ github.actor }} + runs-on: ubuntu-20.04 + if: github.event.repository.owner.id == github.event.sender.id + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + permissions: + contents: write + steps: + - name: Check Out + uses: actions/checkout@v3 + + - name: Display Inputs + run: | + echo "Displaying variables/inputs." + echo "Manifest Branch: ${{ github.event.inputs.MANIFEST_BRANCH }}" + echo "Device Tree: ${{ github.event.inputs.DEVICE_TREE }}" + echo "Device Branch: ${{ github.event.inputs.DEVICE_TREE_BRANCH }}" + echo "Device Path: ${{ github.event.inputs.DEVICE_PATH }}" + echo "Device Name: ${{ github.event.inputs.DEVICE_NAME }}" + echo "Build Target: ${{ github.event.inputs.BUILD_TARGET }}image" + + - name: Cleanup + uses: rokibhasansagar/slimhub_actions@main + + - name: Set Swap Space + uses: pierotofy/set-swap-space@master + with: + swap-size-gb: 12 + + - name: Prepare the environment + run: | + sudo apt update + sudo apt -y upgrade + sudo apt -y install gperf gcc-multilib gcc-10-multilib g++-multilib g++-10-multilib libc6-dev lib32ncurses5-dev x11proto-core-dev libx11-dev tree lib32z-dev libgl1-mesa-dev libxml2-utils xsltproc bc ccache lib32readline-dev lib32z1-dev liblz4-tool libncurses5-dev libsdl1.2-dev libwxgtk3.0-gtk3-dev libxml2 lzop pngcrush schedtool squashfs-tools imagemagick libbz2-dev lzma ncftp qemu-user-static libstdc++-10-dev libtinfo5 libgflags-dev python2 python3 + sudo add-apt-repository universe + sudo apt -y install libncurses5 + + - name: Install OpenJDK + uses: actions/setup-java@v3 + with: + distribution: 'zulu' + java-version: '8' + + - name: Install Git-Repo + run: | + mkdir ~/bin + curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo + chmod a+x ~/bin/repo + sudo ln -sf ~/bin/repo /usr/bin/repo + + - name: Initialize Repo + run: | + mkdir android-recovery + cd android-recovery + git config --global user.name "lazycodebuilder" + git config --global user.email "154446636+lazycodebuilder@users.noreply.github.com" + repo init --depth=1 -u https://github.com/PitchBlackRecoveryProject/manifest_pb.git -b ${{ github.event.inputs.MANIFEST_BRANCH }} + + - name: Repo Sync + run: | + cd android-recovery + repo sync -j$(nproc --all) --force-sync + + - name: Clone Device Tree + run: | + cd android-recovery + git clone ${{ github.event.inputs.DEVICE_TREE }} -b ${{ github.event.inputs.DEVICE_TREE_BRANCH }} ./${{ github.event.inputs.DEVICE_PATH }} + cd ${{ github.event.inputs.DEVICE_PATH }} + echo "COMMIT_ID=$(git rev-parse HEAD)" >> $GITHUB_ENV + + - name: Check Build Makefile + run: | + cd android-recovery + if [ -f ${{ github.event.inputs.DEVICE_PATH }}/twrp_${{ github.event.inputs.DEVICE_NAME}}.mk ]; then + echo "DEVICE_MAKEFILE=twrp_${{ github.event.inputs.DEVICE_NAME }}" >> $GITHUB_ENV + elif [ -f ${{ github.event.inputs.DEVICE_PATH }}/omni_${{ github.event.inputs.DEVICE_NAME}}.mk ]; then + echo "DEVICE_MAKEFILE=omni_${{ github.event.inputs.DEVICE_NAME }}" >> $GITHUB_ENV + else + echo "No recovery makefile file found!" + fi + continue-on-error: true + + - name: Installing py-is-py2 for legacy builds + run: | + sudo apt-get install python-is-python2 + + - name: Building Image + run: | + cd android-recovery + source build/envsetup.sh + export ALLOW_MISSING_DEPENDENCIES=true + lunch ${{ env.DEVICE_MAKEFILE }}-eng && mka ${{ github.event.inputs.BUILD_TARGET }} + + - name: Check Build Makefile + run: | + cd android-recovery + if [ -f out/target/product/${{ github.event.inputs.DEVICE_NAME }}/recovery.img ]; then + echo "BUILD_TARGET_NAME=recovery" >> $GITHUB_ENV + elif [ -f out/target/product/${{ github.event.inputs.DEVICE_NAME }}/boot.img ]; then + echo "BUILD_TARGET_NAME=boot" >> $GITHUB_ENV + else + echo "BUILD_TARGET_NAME=vendor_boot" >> $GITHUB_ENV + fi + + - name: Set Build Date # Output will be use in Release + run: | + echo "BUILD_DATE=$(date +%Y%m%d)" >> $GITHUB_ENV + + - name: Upload to Release + uses: softprops/action-gh-release@v1 + with: + files: | + android-recovery/out/target/product/${{ github.event.inputs.DEVICE_NAME }}/${{ env.BUILD_TARGET_NAME }}.img + android-recovery/out/target/product/${{ github.event.inputs.DEVICE_NAME }}/PBRP*.zip + name: Unofficial PBRP for ${{ github.event.inputs.DEVICE_NAME }} // ${{ env.BUILD_DATE }} + tag_name: ${{ github.run_id }} + body: | + Build: ${{ github.event.inputs.MANIFEST_BRANCH }} + Device: [Device Tree/Branch](${{ github.event.inputs.DEVICE_TREE }}/tree/${{ github.event.inputs.DEVICE_TREE_BRANCH }}) + Commit: Most recent [commit](${{ github.event.inputs.DEVICE_TREE }}/commit/${{ env.COMMIT_ID }}) during building. + + - name: Run LDCheck + if: github.event.inputs.LDCHECK == 'true' + run: | + cd tools + mv -n libneeds ${GITHUB_WORKSPACE}/android-recovery/out/target/product/${{ github.event.inputs.DEVICE_NAME }}/recovery/root/ + mv -n ldcheck ${GITHUB_WORKSPACE}/android-recovery/out/target/product/${{ github.event.inputs.DEVICE_NAME }}/recovery/root/ + cd ../android-recovery/out/target/product/${{ github.event.inputs.DEVICE_NAME }}/recovery/root + python3 ldcheck -p system/lib64:vendor/lib64:system/lib:vendor/lib -d ${{ github.event.inputs.LDCHECKPATH }} + echo "Done checking missing dependencies. Review, and reconfigure your tree." + continue-on-error: true diff --git a/.github/workflows/SkyHawk-SHRP.yml b/.github/workflows/SkyHawk-SHRP.yml new file mode 100644 index 0000000..99feb4f --- /dev/null +++ b/.github/workflows/SkyHawk-SHRP.yml @@ -0,0 +1,185 @@ +name: SkyHawk [SHRP] + +on: + workflow_dispatch: + inputs: + MANIFEST: + description: 'SHRP Manifest' + required: true + default: 'https://github.com/lazymeao/manifest_sh.git' + MANIFEST_BRANCH: + description: 'SHRP Manifest Branch' + required: true + default: '' + type: choice + options: + - v3_11.0 + - v3_10.0 + - v3_9.0 + DEVICE_TREE: + description: 'Custom Recovery Tree' # Your already made Device Tree for TWRP + required: true + default: 'https://github.com/lazycodebuilder/recovery_rmx1851' + DEVICE_TREE_BRANCH: + description: 'Custom Recovery Tree Branch' # Your Device Tree Branch, make sure it's right. + required: true + default: 'android-14_shrp' + DEVICE_PATH: + description: 'Specify your Device Path' # As is, just like your DEVICE_PATH in your BoardConfig.mk + required: true + default: 'device/realme/RMX1851' + DEVICE_NAME: + description: 'Specify your Device Codename' # As is, just like your PRODUCT_DEVICE in your device tree. + required: true + default: 'RMX1851' + BUILD_TARGET: + description: 'Specify your Build Target' # Pick among boot, recovery and vendor_boot + required: true + default: 'recovery' + type: choice + options: + - boot + - recovery + - vendorboot + LDCHECK: + description: 'Use LDCHECK' + required: false + default: 'false' + type: boolean + LDCHECKPATH: + description: 'Path of blobs to check' # Use it know what kind of dependencies your missing for decryption blobs. + required: true + default: 'system/bin/qseecomd' + +jobs: + build: + name: Build SHRP by ${{ github.actor }} + runs-on: ubuntu-20.04 + if: github.event.repository.owner.id == github.event.sender.id + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + permissions: + contents: write + steps: + - name: Check Out + uses: actions/checkout@v3 + + - name: Display Inputs + run: | + echo "Displaying variables/inputs." + echo "Manifest Branch: ${{ github.event.inputs.MANIFEST_BRANCH }}" + echo "Device Tree: ${{ github.event.inputs.DEVICE_TREE }}" + echo "Device Branch: ${{ github.event.inputs.DEVICE_TREE_BRANCH }}" + echo "Device Path: ${{ github.event.inputs.DEVICE_PATH }}" + echo "Device Name: ${{ github.event.inputs.DEVICE_NAME }}" + echo "Build Target: ${{ github.event.inputs.BUILD_TARGET }}image" + + - name: Cleanup + uses: rokibhasansagar/slimhub_actions@main + + - name: Set Swap Space + uses: pierotofy/set-swap-space@master + with: + swap-size-gb: 12 + + - name: Prepare the environment + run: | + sudo apt update + sudo apt -y upgrade + sudo apt -y install gperf gcc-multilib gcc-10-multilib g++-multilib g++-10-multilib libc6-dev lib32ncurses5-dev x11proto-core-dev libx11-dev tree lib32z-dev libgl1-mesa-dev libxml2-utils xsltproc bc ccache lib32readline-dev lib32z1-dev liblz4-tool libncurses5-dev libsdl1.2-dev libwxgtk3.0-gtk3-dev libxml2 lzop pngcrush schedtool squashfs-tools imagemagick libbz2-dev lzma ncftp qemu-user-static libstdc++-10-dev libtinfo5 libgflags-dev libncurses5 python2 python3 + sudo add-apt-repository universe + + - name: Install OpenJDK + uses: actions/setup-java@v3 + with: + distribution: 'zulu' + java-version: '8' + + - name: Install Git-Repo + run: | + mkdir ~/bin + curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo + chmod a+x ~/bin/repo + sudo ln -sf ~/bin/repo /usr/bin/repo + + - name: Initialize Repo + run: | + mkdir android-recovery + cd android-recovery + git config --global user.name "lazycodebuilder" + git config --global user.email "154446636+lazycodebuilder@users.noreply.github.com" + repo init --depth=1 -u ${{ github.event.inputs.MANIFEST }} -b ${{ github.event.inputs.MANIFEST_BRANCH }} + + - name: Set build target for upload + run: | + if [ ${{ github.event.inputs.BUILD_TARGET }} == 'recovery' ]; then + echo "BUILD_TARGET_NAME=recovery" >> $GITHUB_ENV + elif [ ${{ github.event.inputs.BUILD_TARGET }} == 'boot' ]; then + echo "BUILD_TARGET_NAME=boot" >> $GITHUB_ENV + else + echo "BUILD_TARGET_NAME=vendor_boot" >> $GITHUB_ENV + fi + + - name: Repo Sync + run: | + cd android-recovery + repo sync -j$(nproc --all) --force-sync + + - name: Clone Device Tree + run: | + cd android-recovery + git clone ${{ github.event.inputs.DEVICE_TREE }} -b ${{ github.event.inputs.DEVICE_TREE_BRANCH }} ./${{ github.event.inputs.DEVICE_PATH }} + cd ${{ github.event.inputs.DEVICE_PATH }} + echo "COMMIT_ID=$(git rev-parse HEAD)" >> $GITHUB_ENV + + - name: Check Build Makefile + run: | + cd android-recovery + if [ -f ${{ github.event.inputs.DEVICE_PATH }}/twrp_${{ github.event.inputs.DEVICE_NAME}}.mk ]; then + echo "DEVICE_MAKEFILE=twrp_${{ github.event.inputs.DEVICE_NAME }}" >> $GITHUB_ENV + elif [ -f ${{ github.event.inputs.DEVICE_PATH }}/omni_${{ github.event.inputs.DEVICE_NAME}}.mk ]; then + echo "DEVICE_MAKEFILE=omni_${{ github.event.inputs.DEVICE_NAME }}" >> $GITHUB_ENV + else + echo "No recovery makefile file found!" + fi + continue-on-error: true + + - name: Installing py-is-py2 for legacy builds + run: | + sudo apt-get install python-is-python2 + + - name: Building Image + run: | + cd android-recovery + source build/envsetup.sh + export ALLOW_MISSING_DEPENDENCIES=true + lunch ${{ env.DEVICE_MAKEFILE }}-eng && make clean && mka ${{ github.event.inputs.BUILD_TARGET }}image -j$(nproc --all) + echo "Done building your ${{ github.event.inputs.BUILD_TARGET }}.img" + + - name: Set Build Date # Output will be use in Release + run: | + echo "BUILD_DATE=$(date +%Y%m%d)" >> $GITHUB_ENV + + - name: Upload to Release + uses: softprops/action-gh-release@v1 + with: + files: | + android-recovery/out/target/product/${{ github.event.inputs.DEVICE_NAME }}/${{ env.BUILD_TARGET_NAME }}.img + android-recovery/out/target/product/${{ github.event.inputs.DEVICE_NAME }}/SHRP*.zip + name: Unofficial SHRP For ${{ github.event.inputs.DEVICE_NAME }} // ${{ env.BUILD_DATE }} + tag_name: ${{ github.run_id }} + body: | + Build: ${{ github.event.inputs.MANIFEST_BRANCH }} + Device: [Device Tree/Branch](${{ github.event.inputs.DEVICE_TREE }}/tree/${{ github.event.inputs.DEVICE_TREE_BRANCH }}) + Commit: Most recent [commit](${{ github.event.inputs.DEVICE_TREE }}/commit/${{ env.COMMIT_ID }}) during building. + + - name: Run LDCheck + if: github.event.inputs.LDCHECK == 'true' + run: | + cd tools + mv -n libneeds ${GITHUB_WORKSPACE}/android-recovery/out/target/product/${{ github.event.inputs.DEVICE_NAME }}/recovery/root/ + mv -n ldcheck ${GITHUB_WORKSPACE}/android-recovery/out/target/product/${{ github.event.inputs.DEVICE_NAME }}/recovery/root/ + cd ../android-recovery/out/target/product/${{ github.event.inputs.DEVICE_NAME }}/recovery/root + python3 ldcheck -p system/lib64:vendor/lib64:system/lib:vendor/lib -d ${{ github.event.inputs.LDCHECKPATH }} + echo "Done checking missing dependencies. Review, and reconfigure your tree." + continue-on-error: true diff --git a/.github/workflows/TeamWin-TWRP.yml b/.github/workflows/TeamWin-TWRP.yml new file mode 100644 index 0000000..b8830b3 --- /dev/null +++ b/.github/workflows/TeamWin-TWRP.yml @@ -0,0 +1,195 @@ +name: TeamWin [TWRP] + +on: + workflow_dispatch: + inputs: + MANIFEST_BRANCH: + description: 'TWRP Manifest Branch' + required: true + default: '' + type: choice + options: + - twrp-12.1 + - twrp-11 + - twrp-10.0-deprecated + - twrp-9.0 + - twrp-8.1 + - twrp-8.1-macOS + - twrp-7.1 + - twrp-6.0 + - twrp-5.1 + - twrp-4.4-deprecated + DEVICE_TREE: + description: 'Custom Recovery Tree' # Your already made Device Tree for TWRP + required: true + default: 'https://github.com/lazycodebuilder/recovery_rmx1851' + DEVICE_TREE_BRANCH: + description: 'Custom Recovery Tree Branch' # Your Device Tree Branch, make sure it's right. + required: true + default: 'android-14' + DEVICE_PATH: + description: 'Specify your Device Path' # As is, just like your DEVICE_PATH in your BoardConfig.mk + required: true + default: 'device/realme/RMX1851' + DEVICE_NAME: + description: 'Specify your Device Codename' # As is, just like your PRODUCT_DEVICE in your device tree. + required: true + default: 'RMX1851' + BUILD_TARGET: + description: 'Specify your Build Target' # Pick among boot, recovery and vendor_boot + required: true + default: 'recovery' + type: choice + options: + - boot + - recovery + - vendorboot + LDCHECK: + description: 'Use LDCHECK' + required: false + default: 'false' + type: boolean + LDCHECKPATH: + description: 'Path of blobs to check' # Use it know what kind of dependencies your missing for decryption blobs. + required: true + default: 'system/bin/qseecomd' + +jobs: + build: + name: Build TWRP by ${{ github.actor }} + runs-on: ubuntu-20.04 + if: github.event.repository.owner.id == github.event.sender.id + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + permissions: + contents: write + steps: + - name: Check Out + uses: actions/checkout@v3 + + - name: Display Inputs + run: | + echo "Displaying variables/inputs." + echo "Manifest Branch: ${{ github.event.inputs.MANIFEST_BRANCH }}" + echo "Device Tree: ${{ github.event.inputs.DEVICE_TREE }}" + echo "Device Branch: ${{ github.event.inputs.DEVICE_TREE_BRANCH }}" + echo "Device Path: ${{ github.event.inputs.DEVICE_PATH }}" + echo "Device Name: ${{ github.event.inputs.DEVICE_NAME }}" + echo "Build Target: ${{ github.event.inputs.BUILD_TARGET }}image" + + - name: Cleanup + uses: rokibhasansagar/slimhub_actions@main + + - name: Set Swap Space + uses: pierotofy/set-swap-space@master + with: + swap-size-gb: 12 + + - name: Prepare the environment + run: | + sudo apt update + sudo apt -y upgrade + sudo apt -y install gperf gcc-multilib gcc-10-multilib g++-multilib g++-10-multilib libc6-dev lib32ncurses5-dev x11proto-core-dev libx11-dev tree lib32z-dev libgl1-mesa-dev libxml2-utils xsltproc bc ccache lib32readline-dev lib32z1-dev liblz4-tool libncurses5-dev libsdl1.2-dev libwxgtk3.0-gtk3-dev libxml2 lzop pngcrush schedtool squashfs-tools imagemagick libbz2-dev lzma ncftp qemu-user-static libstdc++-10-dev libtinfo5 libgflags-dev libncurses5 python3 + sudo add-apt-repository universe + + - name: Install OpenJDK + uses: actions/setup-java@v3 + with: + distribution: 'zulu' + java-version: '8' + + - name: Install Git-Repo + run: | + mkdir ~/bin + curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo + chmod a+x ~/bin/repo + sudo ln -sf ~/bin/repo /usr/bin/repo + + - name: Check Manifest Branch + uses: haya14busa/action-cond@v1 + id: manifest + with: + cond: ${{ github.event.inputs.MANIFEST_BRANCH == 'twrp-11' || github.event.inputs.MANIFEST_BRANCH == 'twrp-12.1' }} + if_true: https://github.com/minimal-manifest-twrp/platform_manifest_twrp_aosp.git + if_false: https://github.com/minimal-manifest-twrp/platform_manifest_twrp_omni.git + + - name: Initialize Repo + run: | + mkdir android-recovery + cd android-recovery + git config --global user.name "lazycodebuilder" + git config --global user.email "154446636+lazycodebuilder@users.noreply.github.com" + repo init --depth=1 -u ${{ steps.manifest.outputs.value }} -b ${{ github.event.inputs.MANIFEST_BRANCH }} + + - name: Set build target for upload + run: | + if [ ${{ github.event.inputs.BUILD_TARGET }} == 'recovery' ]; then + echo "BUILD_TARGET_NAME=recovery" >> $GITHUB_ENV + elif [ ${{ github.event.inputs.BUILD_TARGET }} == 'boot' ]; then + echo "BUILD_TARGET_NAME=boot" >> $GITHUB_ENV + else + echo "BUILD_TARGET_NAME=vendor_boot" >> $GITHUB_ENV + fi + + - name: Repo Sync + run: | + cd android-recovery + repo sync -j$(nproc --all) --force-sync + + - name: Clone Device Tree + run: | + cd android-recovery + git clone ${{ github.event.inputs.DEVICE_TREE }} -b ${{ github.event.inputs.DEVICE_TREE_BRANCH }} ./${{ github.event.inputs.DEVICE_PATH }} + cd ${{ github.event.inputs.DEVICE_PATH }} + echo "COMMIT_ID=$(git rev-parse HEAD)" >> $GITHUB_ENV + + - name: Check Build Makefile + run: | + cd android-recovery + if [ -f ${{ github.event.inputs.DEVICE_PATH }}/twrp_${{ github.event.inputs.DEVICE_NAME}}.mk ]; then + echo "DEVICE_MAKEFILE=twrp_${{ github.event.inputs.DEVICE_NAME }}" >> $GITHUB_ENV + elif [ -f ${{ github.event.inputs.DEVICE_PATH }}/omni_${{ github.event.inputs.DEVICE_NAME}}.mk ]; then + echo "DEVICE_MAKEFILE=omni_${{ github.event.inputs.DEVICE_NAME }}" >> $GITHUB_ENV + else + echo "No recovery makefile file found!" + fi + continue-on-error: true + + - name: Installing py-is-py2 for legacy builds + run: | + sudo apt-get install python-is-python2 + + - name: Building Image + run: | + cd android-recovery + source build/envsetup.sh + export ALLOW_MISSING_DEPENDENCIES=true + lunch ${{ env.DEVICE_MAKEFILE }}-eng && make clean && make ${{ github.event.inputs.BUILD_TARGET }}image -j$(nproc --all) + echo "Done building your ${{ github.event.inputs.BUILD_TARGET }}.img" + + - name: Set Build Date # Output will be use in Release + run: | + echo "BUILD_DATE=$(date +%Y%m%d)" >> $GITHUB_ENV + + - name: Upload to Release + uses: softprops/action-gh-release@v1 + with: + files: | + android-recovery/out/target/product/${{ github.event.inputs.DEVICE_NAME }}/${{ env.BUILD_TARGET_NAME }}.img + name: Unofficial TWRP for ${{ github.event.inputs.DEVICE_NAME }} // ${{ env.BUILD_DATE }} + tag_name: ${{ github.run_id }} + body: | + Build: ${{ github.event.inputs.MANIFEST_BRANCH }} + Device: [Device Tree/Branch](${{ github.event.inputs.DEVICE_TREE }}/tree/${{ github.event.inputs.DEVICE_TREE_BRANCH }}) + Commit: Most recent [commit](${{ github.event.inputs.DEVICE_TREE }}/commit/${{ env.COMMIT_ID }}) during building. + + - name: Run LDCheck + if: github.event.inputs.LDCHECK == 'true' + run: | + cd tools + mv -n libneeds ${GITHUB_WORKSPACE}/android-recovery/out/target/product/${{ github.event.inputs.DEVICE_NAME }}/recovery/root/ + mv -n ldcheck ${GITHUB_WORKSPACE}/android-recovery/out/target/product/${{ github.event.inputs.DEVICE_NAME }}/recovery/root/ + cd ../android-recovery/out/target/product/${{ github.event.inputs.DEVICE_NAME }}/recovery/root + python3 ldcheck -p system/lib64:vendor/lib64:system/lib:vendor/lib -d ${{ github.event.inputs.LDCHECKPATH }} + echo "Done checking missing dependencies. Review, and reconfigure your tree." + continue-on-error: true diff --git a/README.md b/README.md new file mode 100644 index 0000000..6df229c --- /dev/null +++ b/README.md @@ -0,0 +1,23 @@ +## Lazy Action Recovery Builder |TWRP / PBRP / OFRP / SHRP| +Compile your first custom recovery via Github Actions - with ldcheck setup. This workflow supports both TWRP or PBRP or OFRP or SHRP, you can use it with other custom recovery as well, but you have to modify the yaml config yourself. + +# How to Use +1. Fork this repository. + +2. Go to `Action` tab > `All workflows` > Pick which Build you need (`TWRP or PBRP or OFRP or SHRP`) > `Run workflow`, then pick required information from each drop-down list: + * Manifest Branch (*12.1, *11.0, *10.0, *9.0, *8.1, *7.1, *6.0, etc.) + * Device Tree (Your device tree repository link) + * Device Tree Branch (Your device tree repository branch) + * Device Name (Your device codename) + * Device Path (device/brand/codename) + * Build Target (boot, reecovery, vendorboot) + * LDCHECK (path to your target binary file, ie. `system/bin/qseecomd`) + - If you are building manually/locally and you want to use ldcheck for checking dependencies, visit [THIS](https://github.com/TeamWin/android_device_qcom_twrp-common/tree/android-11#using-ldcheck-to-find-dependencies) this for guide. +l +## Credits +- https://github.com/CaptainThrowback +- https://github.com/azwhikaru +- https://github.com/cd-Crypton +- https://github.com/that1 +- https://github.com/carlodandan +- And to all Contributors in every repositories and scripts I used. \ No newline at end of file diff --git a/tools/ldcheck b/tools/ldcheck new file mode 100644 index 0000000..abdbdb7 --- /dev/null +++ b/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) diff --git a/tools/libneeds b/tools/libneeds new file mode 100644 index 0000000..89f0ef9 --- /dev/null +++ b/tools/libneeds @@ -0,0 +1,3 @@ +#!/bin/sh +# list needed shared libs for Android lib +readelf -d $1 |grep '\(NEEDED\)' | sed -r 's/.*\[(.*)\]/\1/'