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

Search This thread

Primokorn

Senior Member
Nov 17, 2012
11,472
7,718
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
 
Last edited:

Primokorn

Senior Member
Nov 17, 2012
11,472
7,718
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.
 

Attachments

  • Example.zip
    176.3 KB · Views: 769
Last edited:

raimopeku

Senior Member
Feb 21, 2012
114
29
Thank you! Will try this later :)

---------- Post added at 04:34 PM ---------- Previous post was at 03:45 PM ----------

Im so newbie with this kind of stuff, that i have to ask for specific info.
As i told in another topic, i need to keep my /system/app/Calculator/Calculator.apk when im flashing my rom update.
If i understand correctly, it can be done with addon.d script automatically, without flashing any zips?
 

Primokorn

Senior Member
Nov 17, 2012
11,472
7,718
Thank you! Will try this later :)

---------- Post added at 04:34 PM ---------- Previous post was at 03:45 PM ----------

Im so newbie with this kind of stuff, that i have to ask for specific info.
As i told in another topic, i need to keep my /system/app/Calculator/Calculator.apk when im flashing my rom update.
If i understand correctly, it can be done with addon.d script automatically, without flashing any zips?
Exactly. You can only create a .sh file into addon.d folder.
Use the following at the beginning:
Code:
list_files() {
cat <<EOF
app/Calculator/Calculator.apk
EOF
}
 
  • Like
Reactions: raimopeku

mixtapes08

Senior Member
Sep 23, 2011
3,755
1,743
Quezon City
OnePlus 6
Google Pixel 4 XL
i remove some of the addons on your updater script.
because i only want the bloatware removal scripts. Can you check if this is correct.

ui_print("+-------------------------------------+");
ui_print("| bloatware removal script |");
ui_print("| |");
ui_print("| !!!BYE BYE!!! |");
ui_print("+-------------------------------------+");
run_program("/sbin/busybox", "umount", "/system");
run_program("/sbin/busybox", "mount", "/system");
ui_print(" ");
ui_print("***Deleting bloatwares***");
delete_recursive(
"/system/priv-app/Launcher3",
"/system/priv-app/MusicFX"
);

run_program("/sbin/busybox", "unmount", "/system");
ui_print(" ");
ui_print("Completed.");
ui_print("Enjoy!");
 

Primokorn

Senior Member
Nov 17, 2012
11,472
7,718
i remove some of the addons on your updater script.
because i only want the bloatware removal scripts. Can you check if this is correct.

ui_print("+-------------------------------------+");
ui_print("| bloatware removal script |");
ui_print("| |");
ui_print("| !!!BYE BYE!!! |");
ui_print("+-------------------------------------+");
run_program("/sbin/busybox", "umount", "/system");
run_program("/sbin/busybox", "mount", "/system");
ui_print(" ");
ui_print("***Deleting bloatwares***");
delete_recursive(
"/system/priv-app/Launcher3",
"/system/priv-app/MusicFX"
);

run_program("/sbin/busybox", "unmount", "/system");
ui_print(" ");
ui_print("Completed.");
ui_print("Enjoy!");
It should work BUT Launcher3 is stored into /system/app/. Moreover you need a launcher to reach a homescreen. In other words, if you remove Launcher3 after a clean flash then you have to install another launcher.
I forgot to explain how to sign the final zip. I'll add this in the coming hours.
 
Last edited:

Primokorn

Senior Member
Nov 17, 2012
11,472
7,718
On pure nexus its located on system/priv-app and I have a novalauncher.zip that i will install after flashing. I have a installer.zip here. Can i copy my modified updater-script there?

Sent from my Nexus 5
Of course. Do not forget to remove run_program lines if you already have them in the other file :good:
 
  • Like
Reactions: mixtapes08

raimopeku

Senior Member
Feb 21, 2012
114
29
Exactly. You can only create a .sh file into addon.d folder.
Use the following at the beginning:
Code:
list_files() {
cat <<EOF
app/Calculator/Calculator.apk
EOF
}

So, i created that file in /system/addon.d/myfile.sh

And now when i updated my rom (euphoria), my old calculator was gone, and i had to manually it back?
 

raimopeku

Senior Member
Feb 21, 2012
114
29
Can you post your whole script? Are you using other scripts?

hmm, there are 2 other scripts (made by rom i assume)

myfile.sh:
Code:
list_files() {
cat <<EOF
app/Calculator/Calculator.apk
EOF
}

50-eos.sh
Code:
#!/sbin/sh
#
# /system/addon.d/50-eos.sh
# During a upgrade, this script backs up /system/etc/hosts,
# /system is formatted and reinstalled, then the file is restored.
#

. /tmp/backuptool.functions

list_files() {
cat <<EOF
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
  ;;
  pre-backup)
    # Stub
  ;;
  post-backup)
    # Stub
  ;;
  pre-restore)
    # Stub
  ;;
  post-restore)
    # Stub
  ;;
esac

70-gapps.sh
Code:
#!/sbin/sh
# 
# /system/addon.d/70-gapps.sh
#
. /tmp/backuptool.functions

list_files() {
cat <<EOF
app/FaceLock/lib/arm/libfacelock_jni.so
app/FaceLock/lib/arm64/libfacelock_jni.so
app/FaceLock/FaceLock.apk
app/GoogleContactsSyncAdapter/GoogleContactsSyncAdapter.apk
etc/permissions/com.google.android.camera2.xml
etc/permissions/com.google.android.maps.xml
etc/permissions/com.google.android.media.effects.xml
etc/permissions/com.google.widevine.software.drm.xml
etc/preferred-apps/google.xml
framework/com.google.android.camera2.jar
framework/com.google.android.maps.jar
framework/com.google.android.media.effects.jar
framework/com.google.widevine.software.drm.jar
lib/libfilterpack_facedetect.so
lib64/libfilterpack_facedetect.so
lib/libjni_latinime.so
lib64/libjni_latinime.so
lib/libjni_latinimegoogle.so
lib64/libjni_latinimegoogle.so
priv-app/GoogleBackupTransport/GoogleBackupTransport.apk
priv-app/GoogleFeedback/GoogleFeedback.apk
priv-app/GoogleLoginService/GoogleLoginService.apk
priv-app/GoogleOneTimeInitializer/GoogleOneTimeInitializer.apk
priv-app/GooglePartnerSetup/GooglePartnerSetup.apk
priv-app/GoogleServicesFramework/GoogleServicesFramework.apk
priv-app/HotwordEnrollment/HotwordEnrollment.apk
priv-app/Phonesky/Phonesky.apk
priv-app/PrebuiltGmsCore/lib/arm/libAppDataSearch.so
priv-app/PrebuiltGmsCore/lib/arm/libconscrypt_gmscore_jni.so
priv-app/PrebuiltGmsCore/lib/arm/libdirect-audio.so
priv-app/PrebuiltGmsCore/lib/arm/libgcastv2_base.so
priv-app/PrebuiltGmsCore/lib/arm/libgcastv2_support.so
priv-app/PrebuiltGmsCore/lib/arm/libgmscore.so
priv-app/PrebuiltGmsCore/lib/arm/libgms-ocrclient.so
priv-app/PrebuiltGmsCore/lib/arm/libjgcastservice.so
priv-app/PrebuiltGmsCore/lib/arm/libNearbyApp.so
priv-app/PrebuiltGmsCore/lib/arm/libsslwrapper_jni.so
priv-app/PrebuiltGmsCore/lib/arm/libwearable-selector.so
priv-app/PrebuiltGmsCore/lib/arm/libWhisper.so
priv-app/PrebuiltGmsCore/lib/arm64/libAppDataSearch.so
priv-app/PrebuiltGmsCore/lib/arm64/libconscrypt_gmscore_jni.so
priv-app/PrebuiltGmsCore/lib/arm64/libdirect-audio.so
priv-app/PrebuiltGmsCore/lib/arm64/libgcastv2_base.so
priv-app/PrebuiltGmsCore/lib/arm64/libgcastv2_support.so
priv-app/PrebuiltGmsCore/lib/arm64/libgmscore.so
priv-app/PrebuiltGmsCore/lib/arm64/libgms-ocrclient.so
priv-app/PrebuiltGmsCore/lib/arm64/libjgcastservice.so
priv-app/PrebuiltGmsCore/lib/arm64/libNearbyApp.so
priv-app/PrebuiltGmsCore/lib/arm64/libsslwrapper_jni.so
priv-app/PrebuiltGmsCore/lib/arm64/libwearable-selector.so
priv-app/PrebuiltGmsCore/lib/arm64/libWhisper.so
priv-app/PrebuiltGmsCore/PrebuiltGmsCore.apk
priv-app/SetupWizard.apk
priv-app/Velvet/lib/arm/libcronet.so
priv-app/Velvet/lib/arm/libgoogle_speech_jni.so
priv-app/Velvet/lib/arm/libgoogle_speech_micro_jni.so
priv-app/Velvet/lib/arm64/libcronet.so
priv-app/Velvet/lib/arm64/libgoogle_speech_jni.so
priv-app/Velvet/lib/arm64/libgoogle_speech_micro_jni.so
priv-app/Velvet/Velvet.apk
usr/srec/en-US/c_fst
usr/srec/en-US/clg
usr/srec/en-US/commands.abnf
usr/srec/en-US/compile_grammar.config
usr/srec/en-US/contacts.abnf
usr/srec/en-US/dict
usr/srec/en-US/dictation.config
usr/srec/en-US/dnn
usr/srec/en-US/endpointer_dictation.config
usr/srec/en-US/endpointer_voicesearch.config
usr/srec/en-US/ep_acoustic_model
usr/srec/en-US/g2p_fst
usr/srec/en-US/grammar.config
usr/srec/en-US/hclg_shotword
usr/srec/en-US/hmm_symbols
usr/srec/en-US/hmmlist
usr/srec/en-US/hotword.config
usr/srec/en-US/hotword_classifier
usr/srec/en-US/hotword_normalizer
usr/srec/en-US/hotword_prompt.txt
usr/srec/en-US/hotword_word_symbols
usr/srec/en-US/metadata
usr/srec/en-US/norm_fst
usr/srec/en-US/normalizer
usr/srec/en-US/offensive_word_normalizer
usr/srec/en-US/phone_state_map
usr/srec/en-US/phonelist
usr/srec/en-US/rescoring_lm
usr/srec/en-US/wordlist
vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.8/landmark_group_meta_data.bin
vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.8/left_eye-y0-yi45-p0-pi45-r0-ri20.lg_32-tree7-wmd.bin
vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.8/nose_base-y0-yi45-p0-pi45-r0-ri20.lg_32-tree7-wmd.bin
vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.8/right_eye-y0-yi45-p0-pi45-r0-ri20.lg_32-3-tree7-wmd.bin
vendor/pittpatt/models/detection/yaw_roll_face_detectors.7.1/head-y0-yi45-p0-pi45-r0-ri30.4a-v24-tree7-2-wmd.bin
vendor/pittpatt/models/detection/yaw_roll_face_detectors.7.1/head-y0-yi45-p0-pi45-rn30-ri30.5-v24-tree7-2-wmd.bin
vendor/pittpatt/models/detection/yaw_roll_face_detectors.7.1/head-y0-yi45-p0-pi45-rp30-ri30.5-v24-tree7-2-wmd.bin
vendor/pittpatt/models/detection/yaw_roll_face_detectors.7.1/pose-r.8.1.bin
vendor/pittpatt/models/detection/yaw_roll_face_detectors.7.1/pose-y-r.8.1.bin
vendor/pittpatt/models/recognition/face.face.y0-y0-71-N-tree_7-wmd.bin
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
  ;;
  pre-backup)
    # Stub
  ;;
  post-backup)
    # Stub
  ;;
  pre-restore)
    # Stub
  ;;
  post-restore)
   rm -rf /system/app/BrowserProviderProxy
   rm -f /system/app/BrowserProviderProxy.apk
   rm -rf /system/app/PartnerBookmarksProvider
   rm -f /system/app/PartnerBookmarksProvider.apk
   rm -rf /system/app/Provision
   rm -f /system/app/Provision.apk
   rm -rf /system/app/QuickSearchBox
   rm -f /system/app/QuickSearchBox.apk
   rm -rf /system/app/Vending
   rm -f /system/app/Vending.apk
   rm -rf /system/priv-app/BrowserProviderProxy
   rm -f /system/priv-app/BrowserProviderProxy.apk
   rm -rf /system/priv-app/PartnerBookmarksProvider
   rm -f /system/priv-app/PartnerBookmarksProvider.apk
   rm -rf /system/priv-app/Provision
   rm -f /system/priv-app/Provision.apk
   rm -rf /system/priv-app/QuickSearchBox
   rm -f /system/priv-app/QuickSearchBox.apk
   rm -rf /system/priv-app/Vending
   rm -f /system/priv-app/Vending.apk
  ;;
esac
 

Primokorn

Senior Member
Nov 17, 2012
11,472
7,718
Your myfile.sh file is not complete. You have to use the whole code (just remove my custom lines: apps that I remove and audio_policy at the end).

Try this:
Code:
#!/sbin/sh
# 
#

. /tmp/backuptool.functions

list_files() {
cat <<EOF
app/Calculator/Calculator.apk
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
;;
pre-backup)
# Stub
;;
post-backup)
# Stub
;;
pre-restore)
# Stub
;;
post-restore)
# Stub
;;
esac
 
  • Like
Reactions: raimopeku

raimopeku

Senior Member
Feb 21, 2012
114
29
Your myfile.sh file is not complete. You have to use the whole code (just remove my custom lines: apps that I remove and audio_policy at the end).

Try this:
Code:
#!/sbin/sh
# 
#

. /tmp/backuptool.functions

list_files() {
cat <<EOF
app/Calculator/Calculator.apk
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
;;
pre-backup)
# Stub
;;
post-backup)
# Stub
;;
pre-restore)
# Stub
;;
post-restore)
# Stub
;;
esac

Ok, thanks m8! I updated my script, after next rom update ill report if it works :)
 

blowtorch

Senior Member
Jul 14, 2011
583
167
The "Template" (MEGA) download link in the OP is dead. Please re-upload, thanks.
 

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.