Auto Firmware Dumper #80
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Auto Firmware Dumper | |
on: | |
workflow_dispatch: | |
inputs: | |
USER_NAME: | |
description: 'Name in GitHub Account' | |
required: true | |
default: '' | |
USER_EMAIL: | |
description: 'E-mail in GitHub Account' | |
required: true | |
default: '' | |
FIRMWARE_URL: | |
description: 'Stock ROM Link' | |
required: true | |
default: '' | |
GENERATE_VENDOR: | |
description: 'Create Vendor Tree' | |
required: true | |
default: 'false' | |
type: boolean | |
UPLOAD_LINEAGE_DT: | |
description: 'Upload LineageOS tree' | |
required: true | |
default: 'false' | |
type: boolean | |
UPLOAD_TWRP_DT: | |
description: 'Upload TWRP tree' | |
required: true | |
default: 'false' | |
type: boolean | |
jobs: | |
build: | |
name: Auto Firmware Dumper | |
if: github.event.repository.owner.id == github.event.sender.id | |
runs-on: ubuntu-latest | |
env: | |
GITHUB_TOKEN: ${{ secrets.GTOKEN }} | |
TWT: ${{ github.event.inputs.UPLOAD_TWRP_DT }} | |
LOT: ${{ github.event.inputs.UPLOAD_LINEAGE_DT }} | |
GVT: ${{ github.event.inputs.GENERATE_VENDOR }} | |
FUR: ${{ github.event.inputs.FIRMWARE_URL }} | |
UN: ${{ github.event.inputs.USER_NAME }} | |
UEM: ${{ github.event.inputs.USER_EMAIL }} | |
permissions: | |
contents: write | |
steps: | |
- name: Check Out | |
uses: actions/checkout@v3 | |
- name: Cleanup | |
uses: rokibhasansagar/slimhub_actions@main | |
- name: Set Swap Space | |
uses: pierotofy/set-swap-space@master | |
with: | |
swap-size-gb: 12 | |
- name: Update Packages | |
run: | | |
sudo apt update | |
sudo apt -y upgrade | |
sudo apt -y install cpio aria2 git python3 neofetch tar gzip | |
- name: Setup GithubCLI | |
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: Clone and Setup DumprX | |
run: | | |
cd /home | |
sudo mkdir mode=777 Auto-Dumper | |
cd Auto-Dumper | |
git clone https://github.com/DumprX/DumprX | |
cd DumprX | |
sudo chmod 777 *.sh | |
bash setup.sh | |
pip3 install aospdtgen | |
pip3 install twrpdtgen | |
- name: Creating Dump | |
run: | | |
cd /home/Auto-Dumper/DumprX | |
sudo bash dumper.sh "${{ env.FUR }}" | |
sudo chmod -R 777 out | |
- name: Setting up Git | |
run: | | |
git config --global user.name "${{ env.UN }}" | |
git config --global user.email "${{ env.UEM }}" | |
- name: Uploading ROM Dump | |
run: | | |
cd /home/Auto-Dumper/DumprX/out | |
sudo chmod -R 777 * | |
if [ -d system ]; then | |
echo " " | |
else | |
echo "Failed!"; | |
cd /home/Auto-Dumper | |
sudo rm -rf DumprX | |
exit 1; | |
fi; | |
los_dir="lineage-device-tree" | |
if [ -d "$los_dir" ]; then | |
cp -r $los_dir /home/Auto-Dumper | |
else | |
echo "Lineage device tree not found!"; | |
fi; | |
tw_dir="twrp-device-tree" | |
if [ -d "$tw_dir" ]; then | |
cp -r $tw_dir /home/Auto-Dumper | |
else | |
echo "TWRP device tree not found!"; | |
unset tw_dir | |
fi; | |
if [ -d vendor ]; then | |
cd vendor | |
else | |
cd system | |
if [ -d system ]; then | |
cd system | |
fi | |
fi | |
codename=$(grep "ro.product.vendor.device=" build.prop | cut -d'=' -f2) | |
brand=$(grep "ro.product.vendor.brand=" build.prop | cut -d'=' -f2) | |
if [ "$codename" == "" ]; then | |
unset codename | |
codename=$(grep "ro.vendor.product.device=" build.prop | cut -d'=' -f2) | |
if [ "$codename" == "" ]; then | |
unset codename | |
codename=$(grep "ro.product.device=" build.prop | cut -d'=' -f2) | |
fi | |
fi | |
if [ "$brand" == "" ]; then | |
unset brand | |
brand=$(grep "ro.vendor.product.brand=" build.prop | cut -d'=' -f2) | |
if [ "$brand" == "" ]; then | |
unset brand | |
brand=$(grep "ro.product.brand=" build.prop | cut -d'=' -f2) | |
fi | |
fi | |
new_brand=$(echo "$brand" | tr 'A-Z' 'a-z') | |
unset brand | |
brand=$new_brand | |
new_codename=$(echo "$codename") | |
codename=$(echo "$new_codename" | tr -d '[:space:]') | |
cd /home/Auto-Dumper | |
echo "$codename" >> codename.txt | |
echo "$brand" >> brand.txt | |
cd /home/Auto-Dumper/DumprX/out | |
cd system | |
if [ -d system ]; then | |
cd system | |
version=$(grep "ro.build.version.release_or_codename=" build.prop | cut -d'=' -f2) | |
fingerprint=$(grep "ro.system.build.fingerprint=" build.prop | cut -d'=' -f2) | |
cd /home/Auto-Dumper | |
echo "$version" >> version.txt | |
echo "$fingerprint" >> fingerprint.txt | |
cd /home/Auto-Dumper/DumprX/out | |
else | |
version=$(grep "ro.build.version.release_or_codename=" build.prop | cut -d'=' -f2) | |
fingerprint=$(grep "ro.system.build.fingerprint=" build.prop | cut -d'=' -f2) | |
cd /home/Auto-Dumper | |
echo "$version" >> version.txt | |
echo "$fingerprint" >> fingerprint.txt | |
cd /home/Auto-Dumper/DumprX/out | |
fi | |
sudo rm -rf .git | |
echo "Compressing images..." | |
max_size="48000000" | |
if [ -f recovery.img ]; then | |
if [[ $(stat -c %s recovery.img) -gt $max_size ]]; then | |
cp recovery.img /home/Auto-Dumper | |
gzip -f recovery.img | |
fi | |
fi | |
if [ -f boot.img ]; then | |
if [[ $(stat -c %s boot.img) -gt $max_size ]]; then | |
cp boot.img /home/Auto-Dumper | |
gzip -f boot.img | |
fi | |
fi | |
if [ -f vendor_boot.img ]; then | |
if [[ $(stat -c %s vendor_boot.img) -gt $max_size ]]; then | |
cp vendor_boot.img /home/Auto-Dumper | |
gzip -f vendor_boot.img | |
fi | |
fi | |
if [ -f init_boot.img ]; then | |
if [[ $(stat -c %s init_boot.img) -gt $max_size ]]; then | |
cp init_boot.img /home/Auto-Dumper | |
gzip -f init_boot.img | |
fi | |
fi | |
if [ -f dtbo.img ]; then | |
cp dtbo.img /home/Auto-Dumper | |
fi | |
if [ -f dtb.img ]; then | |
cp dtb.img /home/Auto-Dumper | |
fi | |
find /home/Auto-Dumper/DumprX/out -type f -size +50M -delete -exec echo "Deleted: "{} \; | |
dat=$(date +%Y%m%d) | |
git init | |
git branch -M dump-"$codename"-"$dat" | |
git add . | |
git commit -s -m "Dump for $brand $codename" | |
gh repo create dump_"$brand"_"$codename" --public --description="Dump for $brand $codename " --source=. --remote=origin --push | |
cd /home/Auto-Dumper | |
mkdir vnd_project | |
mkdir vnd_project/dump | |
mkdir vnd_project/android | |
mkdir vnd_project/android/device | |
mkdir vnd_project/android/device/"$brand" | |
mkdir vnd_project/android/device/"$brand"/"$codename" | |
cd /home/Auto-Dumper/DumprX/out | |
if [ -d "$los_dir" ]; then | |
mv /home/Auto-Dumper/DumprX/out/lineage-device-tree/* /home/Auto-Dumper/vnd_project/android/device/"$brand"/"$codename" | |
rm -rf $los_dir | |
else | |
echo "LINEAGEOS DEVİCE TREE NOT FOUND!" | |
echo "IF REQUESTED, VENDOR TREE WILL NOT BE CREATED" | |
fi | |
mv /home/Auto-Dumper/DumprX/out/* /home/Auto-Dumper/vnd_project/dump | |
- name: Create vendor tree | |
if: | | |
env.GVT == 'true' | |
run: | | |
cd /home/Auto-Dumper | |
codename=$(cat codename.txt) | |
brand=$(cat brand.txt) | |
cd vnd_project | |
echo "Controlling LineageOS device tree..." | |
if [ -d android/device/"$brand"/"$codename" ]; then | |
echo "Device tree found" | |
else | |
echo "LINEAGEOS DEVİCE TREE NOT FOUND!" | |
exit 1 | |
fi | |
echo "Clonning LineageOS tools..." | |
git clone --depth=1 https://github.com/LineageOS/android_tools_extract-utils -b lineage-20.0 ./android/tools/extract-utils | |
echo "Done cloning extract-utils." | |
git clone --depth=1 https://github.com/LineageOS/android_prebuilts_extract-tools -b lineage-20.0 ./android/prebuilts/extract-tools | |
echo "Done cloning extract-tools." | |
sudo chmod 777 android/device/"$brand"/"$codename"/setup-makefiles.sh | |
cd android/device/"$brand"/"$codename" | |
sudo chmod 777 extract-files.sh | |
bash extract-files.sh /home/Auto-Dumper/vnd_project/dump/ | |
echo "Done extracting and making files." | |
echo "Pushing as repository now." | |
- name: Uploading Vendor Tree | |
if: | | |
env.GVT == 'true' | |
run: | | |
cd /home/Auto-Dumper | |
codename=$(cat codename.txt) | |
brand=$(cat brand.txt) | |
cd vnd_project/android/vendor/"$brand"/"$codename" | |
sudo chmod -R 777 * | |
dat=$(date +%Y%m%d) | |
git init | |
git branch -M vendor-"$codename"-"$dat" | |
git add . | |
git commit -s -m "$codename : initial vendor tree" | |
gh repo create android_vendor_"$brand"_"$codename" --public --description="Vendor tree for $codename" --source=. --remote=origin --push | |
echo "Succesfull" | |
cd /home/Auto-Dumper | |
sudo rm -rf DumprX | |
sudo rm -rf vnd_project | |
- name: Uploading LineageOS Device Tree | |
if: | | |
env.LOT == 'true' | |
run: | | |
cd /home/Auto-Dumper | |
codename=$(cat codename.txt) | |
brand=$(cat brand.txt) | |
cd lineage-device-tree | |
dat=$(date +%Y%m%d) | |
git init | |
git branch -M lineage-"$codename"-"$dat" | |
git add . | |
git commit -s -m "$codename : LineageOS compatible device tree" | |
gh repo create lineage_device_"$brand"_"$codename" --public --description="LineageOS compatible tree for $codename " --source=. --remote=origin --push | |
continue-on-error: true | |
- name: Uploading TWRP Device Tree | |
if: | | |
env.TWT == 'true' | |
run: | | |
cd /home/Auto-Dumper | |
codename=$(cat codename.txt) | |
brand=$(cat brand.txt) | |
version=$(cat version.txt) | |
cd twrp-device-tree/$brand/$codename | |
dat=$(date +%Y%m%d) | |
if [ -f BoardConfig.mk ]; then | |
git init | |
git branch -M twrp-"$version"-"$dat" | |
git add . | |
git commit -s -m "$codename : TWRP compatible device tree" | |
gh repo create twrp_device_"$brand"_"$codename" --public --description="TWRP compatible tree for $codename " --source=. --remote=origin --push | |
else | |
cd $brand | |
cd $codename | |
git init | |
git branch -M twrp-"$version"-"$dat" | |
git add . | |
git commit -s -m "$codename : TWRP compatible device tree" | |
gh repo create twrp_device_"$brand"_"$codename" --public --description="TWRP compatible tree for $codename " --source=. --remote=origin --push | |
fi | |
continue-on-error: true | |
- name: Uploading preview of images | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Prewiew images | |
path: | | |
/home/Auto-Dumper/boot.img | |
/home/Auto-Dumper/recovery.img | |
/home/Auto-Dumper/vendor_boot.img | |
/home/Auto-Dumper/init_boot.img | |
/home/Auto-Dumper/dtbo.img | |
/home/Auto-Dumper/dtb.img | |
if-no-files-found: ignore | |
continue-on-error: true |