[Nexus 5 Q&A, Help & Troubleshooting] Primokorn:
Hi, I created an addon.d script called 'deleteapks.sh' into /system/addon.d:

Here is the code:

#!/sbin/sh

#

# /system/addon.d/deleteapks.sh

#

. /tmp/backuptool.functions

list_files() {

cat <priv-app/ViPER4Android_FX_A4.x/V4A.x.apk

etc/gps.conf

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/Apollo

rm -f /system/app/Apollo/Apollo.apk

rm -rf /system/app/Browser

rm -f /system/app/Browser/Browser.apk

rm -rf /system/app/Calendar

rm -f /system/app/Calendar/Calendar.apk

rm -rf /system/app/Camera2

rm -f /system/app/Camera2/Camera2.apk

rm -rf /system/app/CMFileManager

rm -f /system/app/CMFileManager/CMFileManager.apk

rm -rf /system/app/CMHome

rm -f /system/app/CMHome/CMHome.apk

rm -rf /system/app/CMWallpapers

rm -f /system/app/CMWallpapers/CMWallpapers.apk

rm -rf /system/app/DashClock

rm -f /system/app/DashClock/DashClock.apk

rm -rf /system/app/DeskClock

rm -f /system/app/DeskClock/DeskClock.apk

rm -rf /system/app/DSPManager

rm -f /system/app/DSPManager/DSPManager.apk

rm -rf /system/app/Eleven

rm -f /system/app/Eleven/Eleven.apk

rm -rf /system/app/Email

rm -f /system/app/Email/Email.apk

rm -rf /system/app/Exchange2

rm -f /system/app/Exchange2/Exchange2.apk

rm -rf /system/app/ExchangeServices

rm -f /system/app/ExchangeServices/ExchangeServices.apk

rm -rf /system/app/FaceLock

rm -f /system/app/FaceLock/FaceLock.apk

rm -rf /system/app/Galaxy4

rm -f /system/app/Galaxy4/Galaxy4.apk

rm -rf /system/app/Gallery2

rm -f /system/app/Gallery2/Gallery2.apk

rm -rf /system/app/LatinIME

rm -f /system/app/LatinIME/LatinIME.apk

rm -rf /system/app/LatinImeDictionaryPack

rm -f /system/app/LatinImeDictionaryPack/LatinImeDictionaryPack.apk

rm -rf /system/app/LiveWallpapers

rm -f /system/app/LiveWallpapers/LiveWallpapers.apk

rm -rf /system/app/LiveWallpapersPicker

rm -f /system/app/LiveWallpapersPicker/LiveWallpapersPicker.apk

rm -rf /system/app/LockClock

rm -f /system/app/LockClock/LockClock.apk

rm -rf /system/app/Music

rm -f /system/app/Music/Music.apk

rm -rf /system/app/SoundRecorder

rm -f /system/app/SoundRecorder/SoundRecorder.apk

rm -rf /system/app/VoicePlus

rm -f /system/app/VoicePlus/VoicePlus.apk

rm -rf /system/app/WhisperPush

rm -f /system/app/WhisperPush/WhisperPush.apk

rm -rf /system/priv-app/AudioFX

rm -f /system/priv-app/AudioFX/AudioFX.apk

rm -rf /system/priv-app/KernelAdiutor

rm -f /system/priv-app/KernelAdiutor/KernelAdiutor.apk

rm -rf /system/priv-app/OmniSwitch

rm -f /system/priv-app/OmniSwitch/OmniSwitch.apk

rm -rf /system/priv-app/MusicFX

rm -f /system/priv-app/MusicFX/MusicFX.apk

;;

esac

What I'd like to do:

1. Backup/Restore Viper4Android.apk and gps.conf to survive a dirty flash.

2. Delete all listed system apps after a dirty flash

I kept the same structure as a bloatware removal script and this script.

deleteapks.sh is stored into /system/addon.d with 755 permissions. I didn't wipe the /system partition before flashing the rom update and the script has not been removed.

However Viper4Android and gps.cong files didn't survive and the listed system apps weren't removed.

What's wrong with my script?

Note: I could do these modifications through a flashable zip (see below) but the aim to reduce the number of zips I have to flash.

This is the updater-script I use after a clean flash:

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/app/AudioFX",

"/system/app/Browser",

"/system/app/Calendar",

"/system/app/DeskClock",

"/system/app/DSPManager",

"/system/app/CMFileManager",

"/system/app/Eleven",

"/system/app/Email",

"/system/app/Exchange2",

"/system/app/ExchangeServices",

"/system/app/FaceLock",

"/system/app/Galaxy4",

"/system/app/Gallery2",

"/system/app/LiveWallpapers",

"/system/app/LiveWallpapersPicker",

"/system/app/LockClock",

"/system/app/MusicFX",

"/system/app/SoundRecorder",

"/system/app/WhisperPush",

"/system/etc/gps.conf",

"/system/priv-app/AudioFX",

"/system/priv-app/MusicFX",

"/system/priv-app/DSPManager",

"/system/priv-app/KernelAdiutor",

"/system/priv-app/OmniSwitch"

);

ui_print("Installing Cerberus, BBS, GSam...");

show_progress(8.800000, 5);

run_program("/sbin/busybox", "mount", "/system");

package_extract_dir("system", "/system/");

ui_print("***Fixing permissions***");

set_perm(0, 0, 0755, "/system/priv-app/Viper4Android");

set_perm(0, 0, 0755, "/system/addon.d/deleteapks.sh");

set_perm(0, 0, 0644, "/system/priv-app/Viper4Android/V4A.apk");

set_perm(0, 0, 0644, "/system/etc/gps.conf");

set_perm(0, 0, 0644, "/system/priv-app/com.asksven.betterbatterystats_signed.apk");

set_perm(0, 0, 0644, "/system/priv-app/Gsam.apk");

set_perm(0, 0, 0644, "/system/priv-app/Cerberus.apk");

show_progress(8.800000, 5);

run_program("/sbin/busybox", "unmount", "/system");

ui_print(" ");

ui_print("Completed.");

ui_print("Enjoy!");