[GUIDE] Create your own Flashable ZIP with custom updater-script and addon.d script

Search This thread
D

Deleted member 8095861

Guest
Why does it gives error: updater ended with error 6??
Here's My updater Script:

ui_print("+--------GameTools----------+");
run_program("/sbin/busybox", "unmount", "/system");
run_program("/sbin/busybox", "mount", "/system");
ui_print("***Installing Tools***");
show_progress(8.800000, 5);
package_extract_dir("system", "/system/");
ui_print("***Fixing permissions***");
set_perm(0, 0, 0644, "/system/app/GameOptimizer.apk");
set_perm(0, 0, 0644, "/system/priv-app/GameTools_Dream.apk");
run_program("/sbin/busybox", "unmount", "/system");
ui_print("Done");
ui_print("Completed.");
 

Helena666

Member
Apr 12, 2022
21
3
Can you post your whole script? Are you using other scripts?
Hey man maybe you can help me

I need a magisk flashable batch script for changing / replacing a value in many xml files per batch i wont to help the guys from viper4android maybe you know the tool following operations : open file - jump to row / string - read value - calculate new value - write value - save file - jump to next xml and so on.

Description : The values for surround section changed from 120 - 0 130 - 1 140 - 2 150 -3 160 - 4 170 -5 and so on until 8 old values : 120- 200 new values 0- 8


Maybe you can help me with this many people would be happy to solve the wrong conversion issue of viper4 Android presets or maybevyou know somebody

How can i place an ssh script and execute in avflashable zip

Would be nicevto hearvfrom you

Thx a lot anton alias helena666
 

Helena666

Member
Apr 12, 2022
21
3
Hey man maybe you can help me

I need a magisk flashable batch script for changing / replacing a value in many xml files per batch i wont to help the guys from viper4android maybe you know the tool following operations : open file - jump to row / string - read value - calculate new value - write value - save file - jump to next xml and so on.

Description : The values for surround section changed from 120 - 0 130 - 1 140 - 2 150 -3 160 - 4 170 -5 and so on until 8 old values : 120- 200 new values 0- 8


Maybe you can help me with this many people would be happy to solve the wrong conversion issue of viper4 Android presets or maybevyou know somebody

Thx for help
 

Top Liked Posts

  • There are no posts matching your filters.
  • 38
    1536042768997173670.png

    FOR WHO? AND WHY?
    • Everyone who wants to learn something today
    • Do something yourself instead of relying on a 3rd party app/system.
    • Remove/Add system apps
    • Modify DPI
    • Backup/Restore apps to survive a dirty flash
    • Apply a custom font
    • Apply a custom bootanimation
    • Install a new ringtone
    • and so on.

    Basically removing/adding system stuff can be easily done through a file manager but it takes time and we have to do it whenever we update a custom ROM.
    A couple of examples:
    1. Customizing GApps packages: if you don't use all apps that are provided then you can simply remove them
    2. Viper4Android: V4A is an awesome audio app and it's highly recommended to remove other audio apps/tweaks like AudioFX.

    We will see how to add and remove system components. Once again, it can be done manually but your phone has to be booted into Android then it needs a reboot to apply the changes.

    The last part is for the addon.d script. Your custom system changes will survive a dirty flash. No need to flash a zip file for each update :)


    WHAT DO YOU NEED?
    1. A good file manager: MiXplorer, Solid Explorer, ES File Explorer (jk :D)...
    2. ZipSigner to sign your zip (or MiX Signer if you use MiXplorer // add-on available in the XDA thread)
    3. A nandroid backup is recommended before using those scripts
    4. Prepare your custom files: apk, gps.conf, ringtone, bootanimation,... Everything you want to add after a clean flash.
    5. Free time. No young children around you :)


    TEMPLATE AND MY CUSTOM ZIP
    I'm a nice guy so I prepared a template. You can either download my own zip and customize it to your needs or use this template as a base to create your own zip "from scratch".

    TEMPLATE: DOWNLOAD LINK (basic commands / you have to add your custom values: apps, paths of ringtones, bootanimation...)

    MY ZIP: DOWNLOAD LINK (examples are always welcome to better understand an explanation. It can help to understand how to structure your files).


    The template should be enough to start using a custom script.


    SOME INFORMATIONS TO REMEMBER
    Here are the paths of the main things we want to change in the /system partition (should work for most recent Android versions but check your system to be sure):
    addon.d => backup script to survive a dirty flash (used by GApps package for instance)
    app and priv-app => system apps to add or remove
    etc => host file
    fonts => your font
    media => your bootanimation.zip
    media > audio > alarms => sounds for alarms
    media > audio > notifications => sounds for notifications
    media > audio > ringtones => sounds for ringtones
    media > audio > ui => sounds for various things such as low battery, unlock, camera,..
    root of /system for build.prop file

    Files that have been removed will be installed again after a dirty flash.
    Files that have been manually added will be removed after a dirty flash.
    => That's why we need a script to backup our modifications!

    NO space at the end of the lines


    UNDERSTAND HOW IT WORKS

    PART 1: UPDATER-SCRIPT

    Here is mine:
    ui_print("+-------------------------------------+");
    ui_print("| CLEAN FLASH SCRIPT |");
    ui_print("| |");
    ui_print("| by Primokorn |");
    ui_print("+-------------------------------------+");
    run_program("/sbin/busybox", "umount", "/system");
    run_program("/sbin/busybox", "mount", "/system");
    ui_print(" ");
    ui_print("***Deleting bloatwares***");
    delete_recursive(
    "/system/app/adaway.apk",
    "/system/app/AdAway",
    "/system/app/BasicDreams",
    "/system/app/BookmarkProvider",
    "/system/app/Calendar",
    "/system/app/CalendarWidget",
    "/system/app/CMFileManager",
    "/system/app/CMWallpapers",
    "/system/app/DeskClock",
    "/system/app/Eleven",
    "/system/app/Email",
    "/system/app/ExactCalculator",
    "/system/app/Exchange2",
    "/system/app/Gello",
    "/system/app/HexoLibre",
    "/system/app/Jelly",
    "/system/app/LiveWallpapersPicker",
    "/system/app/LockClock",
    "/system/app/messaging",
    "/system/app/MiXplorer",
    "/system/app/NexusLauncher",
    "/system/app/Phonograph",
    "/system/app/PhotoTable",
    "/system/app/PicoTts",
    "/system/app/PicoTTS",
    "/system/app/ResurrectionStats",
    "/system/app/SoundRecorder",
    "/system/app/Terminal",
    "/system/app/TugaBrowser",
    "/system/app/Wallpaper",
    "/system/app/WallpaperPickerGoogle",
    "/system/priv-app/AudioFX",
    "/system/priv-app/Chrome",
    "/system/priv-app/Gallery2",
    "/system/priv-app/MusicFX",
    "/system/priv-app/OnePlusCamera",
    "/system/priv-app/OnePlusGallery",
    "/system/priv-app/OnePlusMusic",
    "/system/priv-app/Recorder",
    "/system/priv-app/Screencast",
    "/system/priv-app/Snap",
    "/system/priv-app/SnapdragonCamera",
    "/system/priv-app/SnapdragonGallery",
    "/system/priv-app/WeatherManagerService",
    "/system/priv-app/WeatherProvider",
    "/system/priv-app/Tag"
    );
    ui_print("Installing apps and mods, etc");
    show_progress(8.800000, 5);
    package_extract_dir("system", "/system/");
    ui_print("***Fixing permissions***");
    set_perm(0, 0, 0755, "/system/addon.d/99-dirty.sh");
    set_perm(0, 0, 0644, "/system/etc/gps.conf");
    set_perm(0, 0, 0644, "/system/fonts/Roboto-Regular.ttf");
    set_perm(0, 0, 0644, "/system/media/audio/ringtones/PlasticRing.ogg");
    set_perm(0, 0, 0644, "/system/priv-app/Phonesky.apk");
    set_perm(0, 0, 0644, "/system/priv-app/microG.apk");
    set_perm(0, 0, 0644, "/system/priv-app/Gsam.apk");
    set_perm(0, 0, 0644, "/system/priv-app/BBS.apk");
    set_perm(0, 0, 0644, "/system/priv-app/V4A-Magisk.apk");
    run_program("/sbin/busybox", "mount", "/data");
    package_extract_dir("data", "/data/");
    set_perm(0, 0, 0755, "/data/local/afscript.sh");
    show_progress(8.800000, 5);
    run_program("/sbin/busybox", "umount", "/data");
    run_program("/sbin/busybox", "umount", "/system");
    ui_print(" ");
    ui_print("Done.");
    ui_print("Ready to reboot.");
    Note: ui_print(" "); is for text message. These lines don't do anything.


    1/ It's a good practice to unmount then mount the partition before working on it.
    run_program("/sbin/busybox", "umount", "/system");
    run_program("/sbin/busybox", "mount", "/system");

    2/ Remove system components. Put a comma at the end of each line EXCEPT the last one.
    delete_recursive(
    "/system/app/adaway.apk",
    "/system/app/AdAway",
    ........................
    "/system/priv-app/WeatherProvider",
    "/system/priv-app/Tag"
    );

    3/ Extract the system files I want to install
    package_extract_dir("system", "/system/");

    4/ Set the permissions for the files that I add
    set_perm(0, 0, 0755, "/system/addon.d/99-dirty.sh");
    ..............
    set_perm(0, 0, 0644, "/system/priv-app/V4A-Magisk.apk");

    5/ Same thing but for the /data folder (mount the partition > extract the data I want to add > set the permissions)
    run_program("/sbin/busybox", "mount", "/data");
    package_extract_dir("data", "/data/");
    set_perm(0, 0, 0755, "/data/local/afscript.sh");

    6/ Unmount the modified partitions
    run_program("/sbin/busybox", "umount", "/data");
    run_program("/sbin/busybox", "umount", "/system");


    PART 2: ADDON.D
    Here is mine:
    #!/sbin/sh
    #
    # /system/addon.d/99-dirty.sh
    # /system is formatted and reinstalled, then thes files are restored.
    #

    . /tmp/backuptool.functions

    list_files() {
    cat <<EOF
    addon.d/99-dirty.sh
    fonts/Roboto-Regular.ttf
    media/audio/ringtones/PlasticRing.ogg
    priv-app/BBS.apk
    priv-app/Gsam.apk
    priv-app/microG.apk
    priv-app/PhoneSky.apk
    priv-app/V4A-Magisk.apk
    etc/gps.conf
    etc/hosts
    EOF
    }

    case "$1" in
    backup)
    list_files | while read FILE DUMMY; do
    backup_file $S/"$FILE"
    done
    ;;
    restore)
    list_files | while read FILE REPLACEMENT; do
    R=""
    [ -n "$REPLACEMENT" ] && R="$S/$REPLACEMENT"
    [ -f "$C/$S/$FILE" ] && restore_file $S/"$FILE" "$R"
    done
    rm -rf /system/app/adaway.apk
    rm -rf /system/app/AdAway
    rm -rf /system/app/BasicDreams
    rm -rf /system/app/BookmarkProvider
    rm -rf /system/app/Calendar
    rm -rf /system/app/CalendarWidget
    rm -rf /system/app/CMFileManager
    rm -rf /system/app/CMWallpapers
    rm -rf /system/app/DeskClock
    rm -rf /system/app/Eleven
    rm -rf /system/app/Email
    rm -rf /system/app/ExactCalculator
    rm -rf /system/app/Exchange2
    rm -rf /system/app/Gello
    rm -rf /system/app/HexoLibre
    rm -rf /system/app/Jelly
    rm -rf /system/app/LatinIME
    rm -rf /system/app/LiveWallpapersPicker
    rm -rf /system/app/LockClock
    rm -rf /system/app/messaging
    rm -rf /system/app/MiXplorer
    rm -rf /system/app/NexusLauncher
    rm -rf /system/app/Nova.apk
    rm -rf /system/app/Phonograph
    rm -rf /system/app/PhotoTable
    rm -rf /system/app/PicoTts
    rm -rf /system/app/PicoTTS
    rm -rf /system/app/ResurrectionStats
    rm -rf /system/app/SoundRecorder
    rm -rf /system/app/Terminal
    rm -rf /system/app/TugaBrowser
    rm -rf /system/app/Wallpaper
    rm -rf /system/app/WallpaperPickerGoogle
    rm -rf /system/priv-app/AudioFX
    rm -rf /system/priv-app/Chrome
    rm -rf /system/priv-app/Gallery2
    rm -rf /system/priv-app/LatinIME
    rm -rf /system/priv-app/MusicFX
    rm -rf /system/priv-app/OnePlusCamera
    rm -rf /system/priv-app/OnePlusGallery
    rm -rf /system/priv-app/OnePlusMusic
    rm -rf /system/priv-app/Recorder
    rm -rf /system/priv-app/Screencast
    rm -rf /system/priv-app/SnapdragonCamera
    rm -rf /system/priv-app/SnapdragonGallery
    rm -rf /system/priv-app/Snap
    rm -rf /system/priv-app/Trebuchet
    rm -rf /system/priv-app/WeatherManagerService
    rm -rf /system/priv-app/WeatherProvider
    rm -rf /system/priv-app/Tag
    ;;
    pre-backup)
    # Stub
    ;;
    post-backup)
    # Stub
    ;;
    pre-restore)
    # Stub
    ;;
    post-restore)
    # Stub
    ;;
    esac

    1/ Files that I want to keep after a dirty flash
    list_files() {
    cat <<EOF
    addon.d/99-dirty.sh
    fonts/Roboto-Regular.ttf
    media/audio/ringtones/PlasticRing.ogg
    priv-app/BBS.apk
    priv-app/Gsam.apk
    priv-app/microG.apk
    priv-app/PhoneSky.apk
    priv-app/V4A-Magisk.apk
    etc/gps.conf
    etc/hosts
    EOF
    }

    2/ Files I don't want to be installed after a dirty flash
    rm -rf /system/app/adaway.apk
    rm -rf /system/app/AdAway
    rm -rf /system/app/BasicDreams
    rm -rf /system/app/BookmarkProvider
    ................................................
    rm -rf /system/priv-app/WeatherProvider
    rm -rf /system/priv-app/Tag
    ;;


    CREATE YOUR FLASHABLE ZIP
    The steps below are done with MiXplorer file manager.

    1. Select all your folders and select Archive.
    1.Archive.PNG

    2. Confirm the creation of the archive file.
    View attachment 4182479

    3. Enter the name of your file and select Store.
    3.Store.PNG

    4. Your flashable zip has been created.
    4.Creation_zip.PNG

    5. Select your zip file then Sign.
    5.Sign.PNG

    6. Select TESTKEY.
    6.TestKey.PNG

    7. Your final flashable zip is created (xxx-signed.zip). This is the file you will flash from your custom recovery. You can safely remove the first zip file.
    7.Signed_zip.PNG


    NOTES:
    • your flashable zip has to be installed after a clean flash (or after wiping /system partition and making a dirty flash of your ROM custom). The updater-script will immediately remove/add the desired apps/folders. Leave your addon.d script alone. It will do its job without any user intervention.
    Check your /system partition after the first installations to be sure that everything is working as expected.
    • if you have something better to share or tips then let us know.
    • all credits go to the people who shared their findings with the community. I picked up various information so this is more a general guide to create a custom updater-script and addon.d script.
    • I recommend to keep an eye on the template or my zip when reading this guide.
    • Ref: [TUTORIAL] The updater-script completely explained
    11
    HOW TO EDIT YOUR BUILD.PROP

    If you want to modify your build.prop or add new lines then follow those steps.

    1. Create a new .sh file (e.g build_prop.sh)

    2. To modify specific lines:
    sed -i 's/original_value/new_value/g' /system/build.prop;
    Example for LCD Density (from 480 to 420):
    sed -i 's/ro.sf.lcd_density=480/ro.sf.lcd_density=420/g' /system/build.prop;

    3. To add new lines:
    echo "your_value" >> /system/build.prop;
    Example for Viper4Android (if you don't have those lines):
    echo "IPA.decode=false" >> /system/build.prop;
    echo "tunnel.decode=false" >> /system/build.prop;
    echo "lpa.use-stagefright=false" >> /system/build.prop;

    4. In your build_prop.sh file copy this
    Code:
    #!/sbin/sh
    Then add your sed and echo lines

    Example:
    #!/sbin/sh
    sed -i 's/ro.sf.lcd_density=480/ro.sf.lcd_density=420/g' /system/build.prop;
    echo "IPA.decode=false" >> /system/build.prop;
    echo "tunnel.decode=false" >> /system/build.prop;
    echo "lpa.use-stagefright=false" >> /system/build.prop;
    Copy your script into your flashable zip (system folder). That's it for the .sh script.

    5. Now you have to create your updater-script into your flashable zip (see OP if you don't know how to do that).
    Here is what you need to put:
    Code:
    ui_print("+--------BUILD-PROP-EDITION----------+");
    run_program("/sbin/busybox", "umount", "/system");
    run_program("/sbin/busybox", "mount", "/system");
    show_progress(8.800000, 5);
    package_extract_dir("system", "/system/");
    ui_print("***Fixing permissions***");
    set_perm(0, 0, 0777, "/system/build_prop.sh");
    run_program("/sbin/sh", "system/build_prop.sh");
    show_progress(8.800000, 5);
    delete_recursive(
    "/system/build_prop.sh"
    );
    run_program("/sbin/busybox", "umount", "/system");
    ui_print(" ");
    ui_print("Completed.");
    What does it do? This will extract your build_prop.sh file into /system partition, set the permissions and delete your script.

    6. Create your flashable zip and sign it as explained in the previous post.

    7. Reboot into TWRP and flash! :)

    I have attached a compressed file as an example.
    5
    OP updated:
    • new banner
    • more information
    • new screenshots
    • new template + my own zip
    3
    @Primokorn
    Sir I think MiXSigner test keys are not verifying succesfully in recoveries when zip signature verification is enabled.....
    @osm0sis sir made a zipsigner-dexed build that is compatible within android...
    From that build i made a step by step newbie guide here https://forum.xda-developers.com/showpost.php?p=77483475&postcount=3 ....
    It verifies signature in recovery successfully.....

    Other alternative is package signer from https://www.dropbox.com/s/7wljrp4rhhk12kj/PackageSigner_1.1.apk?dl=0 to sign below 15mb files

    Please add this guide to first post...sir...
    To help others like me who don't have pc
    Sure, added to OP.
    3
    Download links are broken
    Yes, sorry. I switched to new Nextcloud servers.
    Links updated.