12Next

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

Started By: wangxiaoli Started On: 2017-10-22 21:14:22
7240 12
                                                                                                                               

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.
                        Quote:
                                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 )...
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):
                        Quote:
                                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.
                        Quote:
                                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.
                        Quote:
                                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
                        Quote:
                                package_extract_dir("system", "/system/");
       
       
4/ Set the permissions for the files that I add
                        Quote:
                                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)
                        Quote:
                                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
                        Quote:
                                run_program("/sbin/busybox", "umount", "/data");
run_program("/sbin/busybox", "umount", "/system");
       
       

PART 2: ADDON.D
Here is mine:


1/ Files that I want to keep after a dirty flash
                        Quote:
                                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
                        Quote:
                                                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.

2. Confirm the creation of the archive file.

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

4. Your flashable zip has been created.

5. Select your zip file then Sign.

6. Select TESTKEY.

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.


Thansk a lot the xda auther.


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






Jalil_Irfan
Global moderators
2# 2017-10-23 02:19:50
Very detailed but i feel its little techy for my level of knowledge in rooting / flashing a mobile
Reply

wangxiaoli
Froyo
3# 2017-10-31 09:38:19
Jalil_Irfan replied at 2017-10-23 02:19
Very detailed but i feel its little techy for my level of knowledge in rooting / flashing a mobile

okay, but it's very detial,。

Next time I'm going to write some more basic posts.
Reply

Jalil_Irfan
Global moderators
4# 2017-10-31 13:39:25
Others might be understanding it ...since I'm new to these customising, flashing ROM etc its little hard for me to understand
Reply

gg_APPUT59
Global moderators
5# 2017-11-4 12:30:55
Easy to understand, I'm looking forward into making custom ROMS for everyone here!
Reply

Homotoyosi10
Honeycomb
6# 2017-11-4 21:24:31
everything looks like Chinese to me
Reply

wangxiaoli
Froyo
7# 2017-11-8 20:21:11
Homotoyosi10 replied at 2017-11-4 21:24
everything looks like Chinese to me

{:4_161:} Chinese is easy to learn.
Reply

wangxiaoli
Froyo
8# 2017-11-8 20:21:31
gg_APPUT59 replied at 2017-11-4 12:30
Easy to understand, I'm looking forward into making custom ROMS for everyone here!

come on.
Reply

wangxiaoli
Froyo
9# 2017-11-8 20:22:18
Jalil_Irfan replied at 2017-10-31 13:39
Others might be understanding it ...since I'm new to these customising, flashing ROM etc its little  ...

Come on. Everyone is hard to learn at first.
Reply

gg_APPUT59
Global moderators
10# 2017-11-8 20:27:23
wangxiaoli replied at 2017-11-8 20:22
Come on. Everyone is hard to learn at first.

Right, thanks for letting us know!
Reply
12Next
You have to log in before you can reply Login | Register now Sign in with facebook Sign in with google

Points Rules

International