Maintaining build.prop changes in ROM Updates - ONE Q&A, Help & Troubleshooting

Hey guys,
So, I am using CM currently, and use CyanDelta to update every couple of days (it works so well!). It works great because I can have it flash Franco Kernel and SuperSU after updating, so those are maintained at least. Annoying part is, every time I update, my build.prop is being overwritten. I scale my DPI down to 405 in order for everything to be ungigantic, and when it gets changed back, it essentially erases my home screens. So, every update, I have to re-apply my settings, and re-do my homescreens. I'm just wondering if you guys have come up with a way to maintain build.prop changes between ROM updates? I feel like there may be a script or something out there, but with some cursory searching around, I can't find jack.
Thanks!

Just copy your current build.prop to your sd when u flash a new build copy and paste over the new one change permissions reboot
Sent from my SM-N910C using XDA Free mobile app

duvalbmarley said:
Just copy your current build.prop to your sd when u flash a new build copy and paste over the new one change permissions reboot
Sent from my SM-N910C using XDA Free mobile app
Click to expand...
Click to collapse
What happens if there are important build.prop changes in an update though?
Transmitted via Bacon

timmaaa said:
What happens if there are important build.prop changes in an update though?
Transmitted via Bacon
Click to expand...
Click to collapse
Most changes are not build.prop related and if it is it would be easier to just copy and paste those changes to the build.prop u copied on your sd card.. and if it's the same rom then it should be no problem or even if it's 2 different roms with the same Base just make sure to copy your original before replacing incase anything goes wrong.... I'm just throwing out a solution what do you suggest the op do??? Don't bash the helper give a helping hand or don't comment
Sent from my SM-N910C using XDA Free mobile app

duvalbmarley said:
Most changes are not build.prop related and if it is it would be easier to just copy and paste those changes to the build.prop u copied on your sd card.. and if it's the same rom then it should be no problem or even if it's 2 different roms with the same Base just make sure to copy your original before replacing incase anything goes wrong.... I'm just throwing out a solution what do you suggest the op do??? Don't bash the helper give a helping hand or don't comment
Sent from my SM-N910C using XDA Free mobile app
Click to expand...
Click to collapse
Whoa, calm down. I'm not bashing you, just asking a question, in order to work with you to come up with the best solution. I agree, most changes aren't contained in the build.prop, but every now and again there could be one or two and it'd take more time checking the two build.props against other than it would just changing the DPI and setting up screens after a flash. I just don't think this solution, while it may work, is a very elegant or practical one, considering that you'd need to waste time to check the build.prop anyway.
@kmakiki, what launcher do you use? I use the app Texdroider to adjust my DPI to 370 after each nightly flash too, but my home screens are never affected. I use Nova Launcher.
Transmitted via Bacon

timmaaa said:
Whoa, calm down. I'm not bashing you, just asking a question, in order to work with you to come up with the best solution. I agree, most changes aren't contained in the build.prop, but every now and again there could be one or two and it'd take more time checking the two build.props against other than it would just changing the DPI and setting up screens after a flash. I just don't think this solution, while it may work, is a very elegant or practical one, considering that you'd need to waste time to check the build.prop anyway.
@kmakiki, what launcher do you use? I use the app Texdroider to adjust my DPI to 370 after each nightly flash too, but my home screens are never affected. I use Nova Launcher.
Transmitted via Bacon
Click to expand...
Click to collapse
Well in my situation I have speed tweaks Internet tweaks dpi changes and a bunch of other tweaks I add to build.prop and i would rather just copy one or two lines then to add every tweak and change after every update
Sent from my SM-N910C using XDA Free mobile app

duvalbmarley said:
Well in my situation I have speed tweaks Internet tweaks dpi changes and a bunch of other tweaks I add to build.prop and i would rather just copy one or two lines then to add every tweak and change after every update
Sent from my SM-N910C using XDA Free mobile app
Click to expand...
Click to collapse
Yeah, but what I'm saying is that it would be time consuming to actually go through each build.prop line by line to discover if there are any that are different or added/removed. It isn't the adding of lines that's the problem, it's having to find out if you need to.
Transmitted via Bacon

timmaaa said:
Yeah, but what I'm saying is that it would be time consuming to actually go through each build.prop line by line to discover if there are any that are different or added/removed. It isn't the adding of lines that's the problem, it's having to find out if you need to.
Transmitted via Bacon
Click to expand...
Click to collapse
Most developer's have change logs to show what was updated and if it's build.prop changes which most likely it won't be u could just ask or it should be posted in change log let's not argue about the changes let's find another solution besides copy and paste since no one has came up with another option
Sent from my SM-N910C using XDA Free mobile app

duvalbmarley said:
Most developer's have change logs to show what was updated and if it's build.prop changes which most likely it won't be u could just ask or it should be posted in change log let's not argue about the changes let's find another solution besides copy and paste since no one has came up with another option
Sent from my SM-N910C using XDA Free mobile app
Click to expand...
Click to collapse
I think the best solution for him is to just change the launcher he's using, that's where the problem lies.
Transmitted via Bacon

flash this zip (attachement)
it will add a file called 99-DPI.sh to
/system/addons.d/ and, by that, it will be executed after every rom flash that uses the backupscripts (cm,... )
the script will replace the default ro.sf.lcd_density to a value you specify (the new default value is 360, this is what i use)
you can add a file called .dpi to your sdcard (/sdcard/.dpi) which contains a number (e.g. 405), then this value will be used after each rom flash.
if you have some questions then feel free to ask :>
[edit]
i just read the whole thread (i was missing some posts)
the 99-DPI.sh can be used to edit any build.prop change, you just have to add some lines, it should be self explaining.

@aHcVolle can u explain more on how to dd new lines to be added into build. Prop
Thnx in advance
@kmakiki i just think of it what if u edit the build. Prop in the cyandelta zip file b4 flashing it?

Ma7mu7 said:
@aHcVolle can u explain more on how to dd new lines to be added into build. Prop
Thnx in advance
Click to expand...
Click to collapse
Can you give more info in what you are trying to do?

aHcVolle said:
Can you give more info in what you are trying to do?
Click to expand...
Click to collapse
Thanks for the fast reply i want to add some lines to build.prop other than changing the dpi i.e disabling bootanimation 3g tweaks etc..

Ma7mu7 said:
Thanks for the fast reply i want to add some lines to build.prop other than changing the dpi i.e disabling bootanimation 3g tweaks etc..
Click to expand...
Click to collapse
OK, edit the file script/99-DPI.sh
remove everything between restore) and ;;
and add your stuff between those 2.
example:
Code:
restore)
echo "dummy_var=1" >> /system/build.prop
ui_print "added line to build.prop"
;;
that should be everything you need.

aHcVolle said:
OK, edit the file script/99-DPI.sh
remove everything between restore) and ;;
and add your stuff between those 2.
example:
Code:
restore)
echo "dummy_var=1" >> /system/build.prop
ui_print "added line to build.prop"
;;
that should be everything you need.
Click to expand...
Click to collapse
Sooo it should be
Code:
restore)
echo "dummy_var=1" >> /system/build.prop
ui_print "added line to build.prop"
debug.sf.nobootanimation=1
ro.config.hw_quickpoweron=true
persist.sys.shutdown.mode=hibernate
dev.bootcomplete=0 ;;
Instead of
Code:
restore)
# We only have work when restoring....
if [ -f $FILE ]; then
# The DPI file is existing, lets check its content
FILEDPI=$(cat $FILE)
# Convert to int (maybe not needed)
(( FILEDPI=$FILEDPI+0 ))
Right?

No
Code:
restore)
echo "debug.sf.nobootanimation=1" >> /system/build.prop
echo "ro.config.hw_quickpoweron=true" >> /system/build.prop
echo "persist.sys.shutdown.mode=hibernate" >> /system/build.prop
echo "dev.bootcomplete=0" >> /system/build.prop
ui_print "added 4 lines to build.prop"
;;

aHcVolle said:
No
Code:
restore)
echo "debug.sf.nobootanimation=1" >> /system/build.prop
echo "ro.config.hw_quickpoweron=true" >> /system/build.prop
echo "persist.sys.shutdown.mode=hibernate" >> /system/build.prop
echo "dev.bootcomplete=0" >> /system/build.prop
ui_print "added 4 lines to build.prop"
;;
Click to expand...
Click to collapse
Thank you very very much just last question
What abt the rest
Code:
# We only have work when restoring....
if [ -f $FILE ]; then
# The DPI file is existing, lets check its content
FILEDPI=$(cat $FILE)
# Convert to int (maybe not needed)
(( FILEDPI=$FILEDPI+0 ))
Shall i just delete them or keep the,m?

Ma7mu7 said:
Thank you very very much just last question
What abt the rest
Code:
# We only have work when restoring....
if [ -f $FILE ]; then
# The DPI file is existing, lets check its content
FILEDPI=$(cat $FILE)
# Convert to int (maybe not needed)
(( FILEDPI=$FILEDPI+0 ))
Shall i just delete them or keep the,m?
Click to expand...
Click to collapse
you can delete them.
make the file look like this:
Code:
#!/sbin/sh
# persistant dpi by volle
# credits: nuclearmistake for ui_print cmd
# Print function
export OUTFD=$(ps | grep -v "grep" | grep -o -E "update_binary(.*)" | cut -d " " -f 3); #BIG props to Chainfire
[ ! $OUTFD ] && export OUTFD=$(ps | grep -v "grep" | grep -o -E "/tmp/updater(.*)" | cut -d " " -f 3); #BIG props nuclearmistake for TWRP-izing
ui_print() { if [ $OUTFD ]; then echo "ui_print $*" 1>&$OUTFD; fi; return 0; }
case "$1" in
pre-backup)
;;
backup)
;;
post-backup)
;;
pre-restore)
;;
restore)
echo "debug.sf.nobootanimation=1" >> /system/build.prop
echo "ro.config.hw_quickpoweron=true" >> /system/build.prop
echo "persist.sys.shutdown.mode=hibernate" >> /system/build.prop
echo "dev.bootcomplete=0" >> /system/build.prop
ui_print "added 4 lines to build.prop"
;;
post-restore)
;;
*)
ui_print " Unkown command $1"
;;
esac

@aHcVolle thanx for the script.
i was also searching how to add lines to build.prop in recovery and it works perfect :good:

aHcVolle said:
you can delete them.
make the file look like this:
[/code]
Click to expand...
Click to collapse
I have a question about combining scripts.
I managed to combine 2 scripts.
First one i created with Android Flashable Zip Creator to install to flash apps in recovery.
Second one is the Fermion Blackhole script to remove bloatware and unwanted apps, also in recovery.
I just copied part of the blackhole into the 1st scipt. I tested it and it works.
Code:
ui_print("@Starting the install process");
ui_print("Setting up required tools...");
ui_print("Mounting Partitions...");
ui_print(" ");
run_program("/sbin/busybox","mount", "/system");
run_program("/sbin/busybox","mount", "/data");
set_progress(0.1);
ui_print("@Installing System Apps");
package_extract_dir("customize/APKs-System/APKs-System_appz", "/system/app");
set_progress(0.2);
set_progress(0.25);
set_progress(0.3);
set_progress(0.4);
set_progress(0.5);
set_progress(0.6);
set_progress(0.7);
set_progress(0.8);
set_progress(0.9);
ui_print("-Sending bloatware to a blackhole.");
delete_recursive(
"/system/app/BasicDreams",
"/system/app/Browser",
"/system/app/Camera2",
"/system/app/CMFileManager",
"/system/app/CMWallpapers",
"/system/app/Eleven",
"/system/app/Email",
"/system/app/Exchange2",
"/system/app/Galaxy4",
"/system/app/Gallery2",
"/system/app/HoloSpiralWallpaper",
"/system/app/LatinIME",
"/system/app/LiveWallpapers",
"/system/app/LiveWallpapersPicker",
"/system/app/Microbes",
"/system/app/NoiseField",
"/system/app/PhaseBeam",
"/system/app/PhotoPhase",
"/system/app/PhotoTable",
"/system/app/PicoTts",
"/system/app/VisualizationWallpapers",
"/system/app/WhisperPush"
);
delete_recursive(
"/system/priv-app/AudioFX",
"/system/priv-app/CellBroadcastReceiver",
"/system/priv-app/Mms",
"/system/priv-app/MmsService",
"/system/priv-app/OmniSwitch",
"/system/priv-app/Trebuchet",
"/system/priv-app/Wallet"
);
set_progress(0.9);
set_metadata_recursive("/system/addon.d", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0755, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/app", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/etc/permissions", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0755, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/etc/preferred-apps", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0755, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/framework", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/priv-app", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
ui_print("-Unmounting system partition.");
run_program("/sbin/busybox", "umount", "/system");
run_program("/sbin/busybox", "umount", "/data");
ui_print("");
ui_print("Done debloating your device!");
ui_print("@Finished Install");
set_progress(1);
Is it possible to add your script to the updater.script ? What part should i copy ? And also can i just add the /script folder into my zip flash file ?
These are the 2 files i use to edit build.prop :
Code:
ui_print("Persistant DPI mod by volle");
ui_print(" Mounting /system");
ifelse(is_mounted("/system"), unmount("/system"));
mount("ext4", "EMMC", "/dev/block/platform/msm_sdcc.1/by-name/system", "/system");
ui_print(" Extracting backupscript");
package_extract_file("script/99-DPI.sh", "/system/addon.d/99-DPI.sh");
set_perm(0, 0, 0777, "/system/addon.d/99-DPI.sh");
ui_print(" Running backupscript");
assert(run_program("/system/addon.d/99-DPI.sh","restore"));
ui_print(" Unmounting /system");
unmount("/system");
ui_print("Everything done");
Code:
#!/sbin/sh
# persistant dpi by volle
# credits: nuclearmistake for ui_print cmd
# Print function
export OUTFD=$(ps | grep -v "grep" | grep -o -E "update_binary(.*)" | cut -d " " -f 3); #BIG props to Chainfire
[ ! $OUTFD ] && export OUTFD=$(ps | grep -v "grep" | grep -o -E "/tmp/updater(.*)" | cut -d " " -f 3); #BIG props nuclearmistake for TWRP-izing
ui_print() { if [ $OUTFD ]; then echo "ui_print $*" 1>&$OUTFD; fi; return 0; }
case "$1" in
pre-backup)
;;
backup)
;;
post-backup)
;;
pre-restore)
;;
restore)
echo "qemu.hw.mainkeys=0" >> /system/build.prop
ui_print " HW Mainkeys set"
;;
post-restore)
;;
*)
ui_print " Unkown command $1"
;;
esac

Related

[Script] Simple tar backup and restore for devs [FINISHED!]

To all of the ROM makers here, please stop using those bonsai data-backup/data-restore scripts, as they don't work. I'm assuming they used to work since everyone here seems to be using them, but something has changed (maybe something in CWM 5.x?) and now all those data-backup and data-restore scripts do is make phones not work.
I've taking those scripts and rewritten them using the tar command. busybox's tar doesn't have many options, but it does preserve file permissions and ownership, so it makes for an adequate backup tool. HUGE thanks to SenseiSimple for the ideas and improvements. See SenseiSimple's post, here.
EDIT: Here is the final version!
updater-script BACKUP EXAMPLE
Code:
ui_print("************************************************");
ui_print(" TAR BACK UP / RESTORE EXAMPLE");
ui_print("************************************************");
show_progress(1.000, 0);
set_progress (0.100);
#EXTRACT BACKUP SCRIPT
ui_print("Preparing tools...");
package_extract_file("tools/busybox", "/tmp/busybox");
package_extract_file("tools/tar-backup", "/tmp/tar-backup");
set_perm(0, 0, 0755, "/tmp/tar-backup");
set_perm(0, 0, 0755, "/tmp/busybox");
#CREATE BACKUP
set_progress (0.350);
ui_print("Backing up - this may take a while...");
run_program("/sbin/mount","/sdcard");
run_program("/sbin/mount","/data");
run_program("/tmp/tar-backup","backup");
unmount("/data");
#RECOVER BACKUP
set_progress (0.600);
ui_print("Recovering backed up data...");
run_program("/sbin/mount","/data");
run_program("/tmp/tar-backup","recover");
# run_program("/tmp/tar-backup","recover","delete");
# run_program("/tmp/tar-backup","recover","archive");
unmount("/data");
set_progress(1.000);
show_progress(1.000, 0);
tar-backup script
edit the value of ROMName=YourROMName (you should only have to edit this file once for all your ROM versions, it's not version-dependent), that's it.
Code:
#!/tmp/busybox sh
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU Library General Public License as published
# by the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# License GPLv2+: GNU GPL version 2 <http://gnu.org/licenses/gpl.html>
#
# toadlife, SenseiSimple, XDA Community, Bonsai
# invoke with
# run_program("/tmp/tar-backup","backup");
# run_program("/tmp/tar-backup","recover" [,"delete"|"archive"]);
# - "delete" option deletes the backup file
# - "archive" option renames the backup file for archiving (otherwise, it is left alone and replaced on next backup/flash)
ROMName=MyAwesomeROM
platbuild=EI22
PATH=/tmp:/sbin:$PATH
datadir=/data
backdir=/sdcard/ROMBackup-$platbuild
backfile=$backdir/$ROMName.tgz
TEST="busybox test"; TAR="busybox tar"; MKDIR="busybox mkdir"
if [ "$1" = "backup" ]; then
rm /data/dalvik-cache/*
rm /data/lost+found/*
rm $backfile
if $TEST -d $datadir ; then
$TEST ! -d $backdir && $MKDIR $backdir
$TAR pczf $backfile $datadir
if $TEST $? -ne 0 ; then
echo "Backup failed!"; exit 1
else
echo "Backup completed"; exit 0
fi
fi
elif [ "$1" = "recover" ]; then
if $TEST -f $backfile; then
$TAR pxzf $backfile
if [ "$2" = "delete" ]; then
rm $backfile;
elif [ "$2" = "archive" ]; then
archdate=`date +%Y%m%d-%I%M`
archfile=$backdir/$ROMName-$archdate.tgz
mv $backfile $archfile
fi
echo "Restore Completed!"; exit 0
else
echo "Restore failed!"; exit 1
fi
else
echo "Backup - Invalid argument"; exit 1
fi
Example CWM package (unsigned) that uses the script.
BTW, I have tested this script several times with test builds of my ROM and also tested it going from SleeperROM 1.x to my ROM. In sleeper ROM I started with blank slate, installed a few apps, configured my email and set a wallpaper. I then installed a test build of my ROM CleanGB with this backup restore script and I had no problems after flashing; all of my data and settings, including the apps in /data from sleeper ROM came over.
Thank you for this. I proposed this to ERA for Legendary and also to the Bonsai crew.
Sent from my SPH-D700 using XDA App
UNIFIED BACKUP SCRIPT - INSTRUCTIONS/DIFFERENCES
SUMMARY The motivation is threefold, as Toadlife initiated with the purpose of modernizing the backup scripts to better protect the data file attributes in backup by using Tar rather than streaming to Cpio, it's possible with adding this improvement to add new functionality and prevent cluttering up users' sdcards with various ROM folders/editions. They will now all be located by ROM name (i.e. SleeperROM, CleanGB, StarskyROM, RandomROM, LegendaryROM *.tgz) in the /sdcard/ROMBackup-EI22/*.tgz directory.
In your ROM package
1. REPLACE /tools/data-backup and /tools/data-restore
2. WITH /tools/tar-backup (script below)
3. UPDATE ROMName=CleanGB with your rom name
in your updater-script, replace
Code:
package_extract_file("tools/data-backup", "/tmp/data-backup");
package_extract_file("tools/data-restore", "/tmp/data-restore");
set_perm(0, 0, 0755, "/tmp/data-backup");
set_perm(0, 0, 0755, "/tmp/data-restore");
with
Code:
package_extract_file("tools/tar-backup", "/tmp/tar-backup");
set_perm(0, 0, 0755, "/tmp/tar-backup");
updater-script USAGE:
1. REPLACE: run_program("/tmp/data-backup");
2. WITH run_program("/tmp/tar-backup", "backup");
3. REPLACE: run_program("/tmp/data-restore");
4a. WITH run_program("/tmp/tar-backup", "recover"); - Leave the backup in place, will be overwritten in the future
4b. OR run_program("/tmp/tar-backup", "recover","delete"); To delete the backup file when complete
4c. OR run_program("/tmp/tar-backup", "recover","archive"); To archive (with date) the backup file when complete
MINIMAL updater-script BACKUP EXAMPLE
Code:
ui_print("************************************************");
ui_print(" TAR BACK UP / RESTORE EXAMPLE");
ui_print("************************************************");
show_progress(1.000, 0);
set_progress (0.100);
#EXTRACT BACKUP SCRIPT
ui_print("Preparing tools...");
package_extract_file("tools/busybox", "/tmp/busybox");
[B]package_extract_file("tools/tar-backup", "/tmp/tar-backup");[/B]
[B]set_perm(0, 0, 0755, "/tmp/tar-backup");[/B]
set_perm(0, 0, 0755, "/tmp/busybox");
#CREATE BACKUP
set_progress (0.350);
ui_print("Backing up - this may take a while...");
run_program("/sbin/mount","/sdcard");
run_program("/sbin/mount","/data");
[B]run_program("/tmp/tar-backup","backup");[/B]
unmount("/data");
#RECOVER BACKUP
set_progress (0.600);
ui_print("Recovering backed up data...");
run_program("/sbin/mount","/data");
[B]run_program("/tmp/tar-backup","recover");
# run_program("/tmp/tar-backup","recover","delete");
# run_program("/tmp/tar-backup","recover","archive");[/B]
unmount("/data");
set_progress(1.000);
show_progress(1.000, 0);
FILE: /tools/tar-backup
edit the value of ROMName=YOURROMNAME (you should only have to edit this file once for all your ROM versions, it's not version-dependent), that's it.
Code:
#!/tmp/busybox sh
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU Library General Public License as published
# by the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# License GPLv2+: GNU GPL version 2 <http://gnu.org/licenses/gpl.html>
#
# toadlife, SenseiSimple, XDA Community, Bonsai
# invoke with
# run_program("/tmp/tar-backup","backup");
# run_program("/tmp/tar-backup","recover" [,"delete"|"archive"]);
# - "delete" option deletes the backup file
# - "archive" option renames the backup file for archiving (otherwise, it is left alone and replaced on next backup/flash)
[B]ROMName=CleanGB[/B]
platbuild=EI22
PATH=/tmp:/sbin:$PATH
datadir=/data
backdir=/sdcard/ROMBackup-$platbuild
backfile=$backdir/$ROMName.tgz
TEST="busybox test"; TAR="busybox tar"; MKDIR="busybox mkdir"
if [ "$1" = "backup" ]; then
rm /data/dalvik-cache/*
rm /data/lost+found/*
rm $backfile
if $TEST -d $datadir ; then
$TEST ! -d $backdir && $MKDIR $backdir
$TAR pczf $backfile $datadir
if $TEST $? -ne 0 ; then
echo "Backup failed!"; exit 1
else
echo "Backup completed"; exit 0
fi
fi
elif [ "$1" = "recover" ]; then
if $TEST -f $backfile; then
$TAR pxzf $backfile
if [ "$2" = "delete" ]; then
rm $backfile;
elif [ "$2" = "archive" ]; then
archdate=`date +%Y%m%d-%I%M`
archfile=$backdir/$ROMName-$archdate.tgz
mv $backfile $archfile
fi
echo "Restore Completed!"; exit 0
else
echo "Restore failed!"; exit 1
fi
else
echo "Backup - Invalid argument"; exit 1
fi
Example CWM package (unsigned) to augment these instructions - pay attention to your version of Busybox vs the one included.
SenseiSimple said:
Thanks, i'll be giving it a spin for the next release!
I'm wondering, should we perhaps standardize the directory the backups go into and name the actual backup file accordingly?
I for one hate my sd card filling up with a bunch of random folders, backups included. (i know this is trivial, but since you've provided a good change to the backup method...)
will put the backup into /sdcard/EI22_ROM_Backup/CleanGB.tgz
since we don't automatically delete the backup, i assume for precautionary reasons, best for them to pile up in one place, no?
Click to expand...
Click to collapse
Couldn't agree more. Seems like I'm constantly cleaning backup files off my sdcard.
Why not delete the backup file after the restore? Otherwise a flashaholic will have a whole bunch of these files on their card as well as their nandroids, titanium backups, ROMs, pics etc. Just add a delete to the script.
kennyglass123 said:
Why not delete the backup file after the restore? Otherwise a flashaholic will have a whole bunch of these files on their card as well as their nandroids, titanium backups, ROMs, pics etc. Just add a delete to the script.
Click to expand...
Click to collapse
That's my mentality on it. But in case something goes wrong with the restore, maybe, you have the whole backup file to dissect? that was the only reason i could think of to keep all the cruft in which case, at least have them all consolidated.
I will definitely include this in my rom. Thanks
Sent from my SPH-D700 using XDA App
SenseiSimple said:
That's my mentality on it. But in case something goes wrong with the restore, maybe, you have the whole backup file to dissect? that was the only reason i could think of to keep all the cruft in which case, at least have them all consolidated.
Click to expand...
Click to collapse
Everyone should already be making a nandroid before flashing anything and then can always use advanced restore data. My issue is until you start looking at your sd card, you don't know ROMs have left backups behind. Nuke em...lol.
SenseiSimple said:
Thanks, i'll be giving it a spin for the next release!
I'm wondering, should we perhaps standardize the directory the backups go into and name the actual backup file accordingly?
I for one hate my sd card filling up with a bunch of random folders, backups included. (i know this is trivial, but since you've provided a good change to the backup method...)
(my edits in bold)
Click to expand...
Click to collapse
Sounds good to me. Putting them both in one script would be easier too. I'll use the second revision. You could allways pass another varible to the script to tell it weather or not to delete the backup.
SenseiSimple said:
That's my mentality on it. But in case something goes wrong with the restore, maybe, you have the whole backup file to dissect? that was the only reason i could think of to keep all the cruft in which case, at least have them all consolidated.
Click to expand...
Click to collapse
Ten years sysadminning had led me to be extremely wary of deleting data, so I'm always inclined to keep backups.
Ten years sysadminning had led me to be extremely wary of deleting data, so I'm always inclined to keep backups.
Click to expand...
Click to collapse
I know that personally if something messed up with the re-install phase of the flashing, i'd want the backup file to still be available... it would be nice to have a unified backup dir, and maybe even an option in CWM to delete backups left by roms - it becomes somewhat of a redundancy of CWM's backup at that point, but it's not as if we can invoke the CWM backup routine from script anyway...
toadlife said:
Sounds good to me. Putting them both in one script would be easier too. I'll use the second revision. You could allways pass another varible to the script to tell it weather or not to delete the backup.
Click to expand...
Click to collapse
i deleted my script from the post, on testing, i just can't get it to run - in theory it's a great idea - the single script file is sound but running it from the updater_script with run_program("/tmp/data_save","backup"); for example, just doesn't run it... i've tried variations using
run_program("/sbin/sh","/tmp/data_save","backup");
run_program("/tmp/busybox","sh","/tmp/data_save","backup");
each are no-go...
individually, the scripts work... is there a limitation that the only way run_program can pass arguments is to a binary and not a shell script? that's all i can think of
EDIT:
I GOT IT, will post up the revision in a moment
SenseiSimple said:
EDIT:
I GOT IT, will post up the revision in a moment
Click to expand...
Click to collapse
Crud. I just posted updated version at the top that contains a variable to control deletion of the backup file.
Can you update the script to take a variable that controls whether or not the backup file gets deleted?
It may be worthwhile to add the current date to the filename - it keeps the current backup and restore for a flash fresh, but allows archival copies to be trivially stored ala Nandroid.
k0nane said:
It may be worthwhile to add the current date to the filename - it keeps the current backup and restore for a flash fresh, but allows archival copies to be trivially stored ala Nandroid.
Click to expand...
Click to collapse
This could be done right after the restore finishes...if the file is not set to be deleted...
Code:
date=`date +.%m.%d.%Y.%I:%M`;
newromname={$romname}{$date}
newbackfile=/sdcard/${build}_ROM_Backup/$newromname.tgz
mv $backfile $newbackfile
SenseiSimple said:
EDIT:
I GOT IT, will post up the revision in a moment
Click to expand...
Click to collapse
Sorry, I got impatient and rolled them into one script myself. It tags the files with the date if the delete option is not set. The script is in the first post.
toadlife said:
To all of the ROM makers here, please stop using those bonsai data-backup/data-restore scripts, as they don't work. I'm assuming they used to work since everyone here seems to be using them, but something has changed (maybe something in CWM 5.x?) and now all those data-backup and data-restore scripts do is make phones not work.
I've taking those scripts and rewritten them using the tar command. busybox's tar doesn't have many options, but it does preserve file permissions and ownership, so it makes for an adequate backup tool.
EDIT: I've rewritten the scripts so that both backup and restore functionality are in one script. Thanks SenseiSimple for the idea!
tar-backup
Code:
#!/tmp/busybox sh
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU Library General Public License as published
# by the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# License GPLv2+: GNU GPL version 2 <http://gnu.org/licenses/gpl.html>
#
#
# tar data backup and restore
# based on bonsai data backup/restore scripts
# by toadlife , SenseiSimple and the Epic 4G XDA community
#
# Call from your updater script like so...
#
# Backup: run_program("/tmp/tar-backup", "backup");
# Restore: run_program("/tmp/tar-backup", "restore"[, "delete"]);
#
# optional "delete" switch will cause the backup file to be deleted after
# restore
#
#
romname=CleanGB
build=EI22
datadir=/data
PATH=/tmp:/sbin:$PATH
BB=/tmp/busybox
backfile=/sdcard/${build}_ROM_Backup/$romname.tgz
if [ "$1" = "backup" ]; then
$BB rm /data/dalvik-cache/*
$BB rm /data/lost+found/*
$BB rm $backfile
if $BB test -d $datadir; then
$BB test ! -d /sdcard/${build}_ROM_Backup && $BB mkdir /sdcard/${build}_ROM_Backup
$BB tar pczf $backfile $datadir
if $BB test $? -ne 0; then
echo "Backup failed!"
exit 1
else
echo "Backup completed"
exit 0
fi
fi
fi
if [ "$1" = "restore" ]; then
if $BB test -f $backfile; then
$BB tar pxzf $backfile
echo Restore Completed!
if [ "$2" = "delete" ]; then
rm $backfile
else
DATE=`date +%Y.%m.%d.%I%M`;
newromname=$romname.$DATE
newbackfile=/sdcard/${build}_ROM_Backup/$newromname.tgz
mv $backfile $newbackfile
fi
exit 0
else
echo Restore failed!
exit 1
fi
fi
Here is an example package that uses the script.
Click to expand...
Click to collapse
From looking at it, it doesn't look like there should be issues... Nice work!
and with the improved handling of tarballs through CWM, this thing should be nice and fast! =)
Your version still didn't work for me, same issue i was facing with mine.
I updated post #4 with an updated version based on a combination of yours and the one i was late providing, i've tested it several times with the three options.
What are you thoughts? Try it out and if it works update your code detail with it, my mini-tutorial can be linked complementary to it
EDIT I just remembered/experienced that CWM (5.0.2.7 afaik) has a bug in which it doesn't provide the right datetime. So the archive feature may be broken until that is fixed. http://forum.xda-developers.com/showthread.php?p=19689193#post19689193 - mine shows several years off "jan 01, 2005 01:00" and the archives overwrite themselves... perhaps we need to serialize/number rather than date
SenseiSimple said:
Your version still didn't work for me, same issue i was facing with mine.
Click to expand...
Click to collapse
What issue? It worked great for me.
SenseiSimple said:
EDIT I just remembered/experienced that CWM (5.0.2.7 afaik) has a bug in which it doesn't provide the right datetime. So the archive feature may be broken until that is fixed. http://forum.xda-developers.com/showthread.php?p=19689193#post19689193 - mine shows several years off "jan 01, 2005 01:00" and the archives overwrite themselves... perhaps we need to serialize/number rather than date
Click to expand...
Click to collapse
IIRC, Jan 1 2005 is the date you get when you pull the battery. Apparently it resets the internal clock on the device. When doing a normal reboot or power down the current date is retained.
Anyhow, yours looks fine. I'll test it out later today and will edit my top post with your revision.
toadlife said:
What issue? It worked great for me.
IIRC, Jan 1 2005 is the date you get when you pull the battery. Apparently it resets the internal clock on the device. When doing a normal reboot or power down the current date is retained.
Anyhow, yours looks fine. I'll test it out later today and will edit my top post with your revision.
Click to expand...
Click to collapse
Cool thanks, sorry for the delay. about the time, i had indeed recently pulled the battery without booting in between.
The issue i had with my original script and yours was something to do with busybox applets/builtins between /tmp/busybox and /sbin/busybox... i'm not sure what version of busybox i had included with my rom, but i substituted mine with yours (mine was 1.9MB which i've noticed in a few different roms, yours and the one in ICS releases are 2MB), and for good measure combined our two scripts, everything magically came together, oddly enough with the combined script, both busybox versions work.

Editing build.prop via flashable zip

Hey folks,
to avoid doing this manually with every nightly, I wanted to change some build.prop values via a flashable zip, which doesn't seem to work.
I used the script from here and modified it for my needs. It doesn't throw an error in recovery, but doesn't change any values, either.
Here are my files:
updater-script
Code:
ui_print("fixer");
ui_print("Mounting System partition...");
#mount("ext4", "EMMC", "/dev/block/platform/msm_sdcc.1/by-name/system", "/system");
#Properly unmounting to avoid issues
run_program("/sbin/busybox", "umount", "/system");
run_program("/sbin/busybox", "mount", "/system");
ui_print("bloat removal..");
delete_recursive("/system/app/Apollo");
delete_recursive("/system/app/BasicDreams");
delete_recursive("/system/app/Browser");
delete_recursive("/system/app/Calculator");
delete_recursive("/system/app/CMHome");
delete_recursive("/system/app/CMWallpapers");
delete_recursive("/system/app/Development");
delete_recursive("/system/app/Email");
delete_recursive("/system/app/Galaxy4");
delete_recursive("/system/app/GoogleTTS");
delete_recursive("/system/app/HoloSpiralWallpaper");
delete_recursive("/system/app/Launcher3");
delete_recursive("/system/app/LiveWallpapers");
delete_recursive("/system/app/NoiseField");
delete_recursive("/system/app/OmaDmclient");
delete_recursive("/system/app/OpenWnn");
delete_recursive("/system/app/PrebuildExchange3Google");
delete_recursive("/system/app/PhaseBeam");
delete_recursive("/system/app/PhotoTable");
delete_recursive("/system/app/PicoTts");
delete_recursive("/system/app/PrintSpooler");
delete_recursive("/system/app/SprintHiddenMenu");
delete_recursive("/system/app/Stk");
delete_recursive("/system/app/Trebuchet");
delete_recursive("/system/app/UpdateSetting");
delete_recursive("/system/app/VisualizationWallpapers");
delete_recursive("/system/priv-app/CellBroadcastReceiver");
delete_recursive("/system/priv-app/CMUpdater");
delete_recursive("/system/priv-app/GoogleFeedback");
delete_recursive("/system/priv-app/VoiceDialer");
delete("/system/media/audio/ui/camera_click.ogg");
delete("/system/media/audio/ui/camera_focus.ogg");
ui_print("tweaking build.prop...");
package_extract_dir("tmp", "/tmp");
set_perm(0, 0, 0777, "/tmp/mytweaks.sh");
run_program("/tmp/mytweaks.sh", "mytweak");
unmount("/system");
run_program("/sbin/busybox", "umount", "/system");
ui_print("Completed.");
mytweaks.sh
Code:
#!/sbin/sh
bp="/system/build.prop"
busybox mount /system
busybox mount /data
if [ -f /system/build.prop.bak ];
then
rm -rf $bp
cp $bp.bak $bp
else
cp $bp $bp.bak
fi
echo " " >> $bp
echo "# build.prop editor" >> $bp
echo " " >> $bp
for mod in misc;
do
for prop in `cat /tmp/$mod`;do
export newprop=$(echo ${prop} | cut -d '=' -f1)
sed -i "/${newprop}/d" /system/build.prop
echo $prop >> /system/build.prop
done
done
misc
Code:
ro.sf.lcd_density=420
drm.service.enabled=false
wifi.supplicant_scan_interval=60
dalvik.vm.isa.arm.features=lpae,div
dalvik.vm.dexopt-flags=m=y,v=a,o=v,u=y
Furthermore, my device runs on TWRP 2.8.1.0 and CM12. I suspect the path to the shell is wrong, but couldn't find anything on that. Any suggestions?
Anyone?
I haven't time to troubleshoot your zip and script but attached is the one I wrote. In the uodater-script, its the part after wireless charging you want. I've removed my files that I also flash via this zip, but left the shell script.
In the shell, the sed lines are original_value/new_value and the echo lines add new lines at the bottom.
Hope this helps.
Not sure but if you unmount the system can you modify after that?
Sent from my Nexus 5 using XDA Free mobile app
shri_chanakya said:
Not sure but if you unmount the system can you modify after that?
Sent from my Nexus 5 using XDA Free mobile app
Click to expand...
Click to collapse
You'll need /system mounted to make changes in the /system/build.prop (good point)
rootSU said:
I haven't time to troubleshoot your zip and script but attached is the one I wrote. In the uodater-script, its the part after wireless charging you want. I've removed my files that I also flash via this zip, but left the shell script.
In the shell, the sed lines are original_value/new_value and the echo lines add new lines at the bottom.
Hope this helps.
Click to expand...
Click to collapse
THank you, that worked marvellously!
anon768 said:
THank you, that worked marvellously!
Click to expand...
Click to collapse
No probs;
I know this is an old thread, but I have a question for Dan or whomever else could answer it.
I was trying to integrate this script into another updater-script that I use for other stuff. so (since it uses the new updater-binary) I put these lines in it
set_metadata_recursive("/system/build_prop.sh", "uid", 0, "gid", 0, "dmode", 0777, "fmode", 0777, "capabilities", 0x0, "selabel", "ubject_r:system_file:s0");
run_program("sbin/sh", "/system/build_prop.sh");
delete("/system/build_prop.sh");
It works sort of fine. All the sed lines replace some text with some other text as expected. However, the echo lines, rather than appending the build.prop file, instead make a totally new build.prop file, with an identical name, sitting right next to it. I didn't even know that could happen.
Any thoughts on how to fix it?
oh ps an example of a line that works and one that doesn't are as follows
sed -i 's/telephony.lteOnCdmaDevice=0/telephony.lteOnCdmaDevice=1/g' /system/build.prop;
echo -e "telephony.lteOnGsmDevice=1" >> /system/build.prop
nevermind. turns out the echo lines were just missing semicolons. at first I thought it was a permissions issue on build.prop, so i set it to universal read/write then set it back to what it was supposed to be after script finishes
set_metadata("/system/build_prop.sh", "uid", 0, "gid", 0, "mode", 0777, "selabel", "ubject_r:system_file:s0", "capabilities", 0x0)
set_metadata("/system/build.prop", "uid", 0, "gid", 0, "mode", 0777, "selabel", "ubject_r:system_file:s0", "capabilities", 0x0)
run_program("sbin/sh", "/system/build_prop.sh");
delete("/system/build_prop.sh");
set_metadata("/system/build.prop", "uid", 0, "gid", 0, "mode", 0644, "selabel", "ubject_r:system_file:s0", "capabilities", 0x0)

[MOD][Mar 30]Modpack for HTC Sense 7.0

SoLdieR9312's Modpack for Android 5.0.2 HTC Sense 7
What you will get:
% battery icon
4G Icon to LTE icon
sdcard rw permissions fix
hide adb icon in statusbar
latest hosts file for adblock
chrome command line for permanent desktop mode in chrome/chrome beta
You should be on 1.32.401.15 base. If not, you should update first.
Mod will flash 1.32.401.15 build.prop, if you are on a provider,
copy your build.prop into the zip, open and add:
Code:
#Disable USB Debugging Icon
persist.adb.notify=0
at the end of your build.prop and save it.
Download: SoLdieR9312s Modpack #002 - Download provided by renovate-themes.de
As always, please do a nandroid before. Files got tested, but sometimes something goes wrong. Thanks.
Nice!
If I can help you with some tweaks/mods
,feel free to pm me...
#002:
-fixed 4G to LTE icon (device is using CID specific default.xml, so i had to change all of them)
If you wipe your dhalvik cache after doing this systemui.apk also doesn't load.
Love odex.
Instead of replacing the entire build.prop files (which is a bit silly considering carrier specific and different file versions) it would be easier to run a bash script to check the existence of persist.adb.notify and if its =1 change it to =0. If its not there at all then you can echo the 2 lines needed.
For example something like this:
Code:
#!/sbin/sh
if grep -Fxq "persist.adb.notify" /system/build.prop
then
sed -i '/persist.adb.notify/s/1/0/g' /system/build.prop
else
echo " " >> /system/build.prop
echo "# WiFi Calling " >> /system/build.prop
echo "persist.adb.notify=0" >> /system/build.prop
echo " " >> /system/build.prop
fi
To run this from the updater-script name it as build.sh and put it in Extras/Scripts folder then add this to the updater-script:
Code:
package_extract_file("Extras/Scripts/build.sh", "/tmp/build.sh");
set_perm(0, 0, 0777, "/tmp/build.sh");
run_program("/tmp/build.sh");
Jonny said:
Instead of replacing the entire build.prop files (which is a bit silly considering carrier specific and different file versions) it would be easier to run a bash script to check the existence of persist.adb.notify and if its =1 change it to =0. If its not there at all then you can echo the 2 lines needed.
For example something like this:
Code:
#!/sbin/sh
if grep -Fxq "persist.adb.notify" /system/build.prop
then
sed -i '/persist.adb.notify/s/1/0/g' /system/build.prop
else
echo " " >> /system/build.prop
echo "# WiFi Calling " >> /system/build.prop
echo "persist.adb.notify=0" >> /system/build.prop
echo " " >> /system/build.prop
fi
To run this from the updater-script name it as build.sh and put it in Extras/Scripts folder then add this to the updater-script:
Code:
package_extract_file("Extras/Scripts/build.sh", "/tmp/build.sh");
set_perm(0, 0, 0777, "/tmp/build.sh");
run_program("/tmp/build.sh");
Click to expand...
Click to collapse
Thanks mate, will change it today.
SoLdieR9312 said:
Thanks mate, will change it today.
Click to expand...
Click to collapse
I just realised that the set_perm line shouldn't be used anymore - its set_metadata instead (sorry, still have old files on my HHD)
just replace that line with:
Code:
set_metadata("/tmp/build.sh", "uid", 0, "gid", 0, "mode", 0777, "capabilities", 0x0);
Nice work, Thx

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

{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
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.
Click to expand...
Click to collapse
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):
• 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
Click to expand...
Click to collapse
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");
Click to expand...
Click to collapse
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"
);
Click to expand...
Click to collapse
3/ Extract the system files I want to install
package_extract_dir("system", "/system/");
Click to expand...
Click to collapse
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");
Click to expand...
Click to collapse
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");
Click to expand...
Click to collapse
6/ Unmount the modified partitions
run_program("/sbin/busybox", "umount", "/data");
run_program("/sbin/busybox", "umount", "/system");
Click to expand...
Click to collapse
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
}
Click to expand...
Click to collapse
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
;;
Click to expand...
Click to collapse
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.
View attachment 4182479
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.
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
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;
Click to expand...
Click to collapse
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;
Click to expand...
Click to collapse
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;
Click to expand...
Click to collapse
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.
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?
raimopeku said:
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?
Click to expand...
Click to collapse
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
}
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!");
mixtapes08 said:
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!");
Click to expand...
Click to collapse
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.
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
mixtapes08 said:
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
Click to expand...
Click to collapse
Of course. Do not forget to remove run_program lines if you already have them in the other file :good:
Thanks. Man.
Sent from my Nexus 5
PART 3 added to create and sign your flashable zip.
Primokorn said:
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
}
Click to expand...
Click to collapse
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 said:
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?
Click to expand...
Click to collapse
Can you post your whole script? Are you using other scripts?
Primokorn said:
Can you post your whole script? Are you using other scripts?
Click to expand...
Click to collapse
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
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
Primokorn said:
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
Click to expand...
Click to collapse
Ok, thanks m8! I updated my script, after next rom update ill report if it works
*** NEW ***
How to edit your build.prop in post 2.
The "Template" (MEGA) download link in the OP is dead. Please re-upload, thanks.
blowtorch said:
The "Template" (MEGA) download link in the OP is dead. Please re-upload, thanks.
Click to expand...
Click to collapse
I've uploaded my latest custom scripts. I also updated OP.
Primokorn said:
I've uploaded my latest custom scripts. I also updated OP.
Click to expand...
Click to collapse
I was wondering if there is any way you can help me with a flashable zip i am working on cant seem to get it to flash correctly I get the following error each time;
Updater process ended with signal:11
maxmotos said:
I was wondering if there is any way you can help me with a flashable zip i am working on cant seem to get it to flash correctly I get the following error each time;
Updater process ended with signal:11
Click to expand...
Click to collapse
Share your files and I'll have a look as soon as I can.

Using command echo .sh file doesn't work in recovery

I'm trying to understand why using echo command in sh file doesn't work in recovery.
I've made a flashable zip with 7-zip, it contains a shell script.
The updater-script is
Code:
ui_print("");
run_program("/sbin/busybox", "mount", "/system");
run_program("/sbin/busybox", "mount", "/data");
package_extract_dir("test", "/tmp");
set_perm(0, 0, 0777, "/tmp/test.sh");
run_program("/tmp/test.sh");
delete_recursive("/tmp");
unmount("/system");
unmount("/data");
and my test.sh is like this :
Code:
#!/sbin/sh
rm -rf /system/app/YouTube
echo "Delete Youtube"
test.sh deletes Youtube folder but echo command doesn't work.
I use TWRP 3.2.3.0 recovery
Echo is a command for windows command line. In recovery you use: ui_print("<message goes here");
In recovery the language used is called Edify.
Read a bit about it here:
https://forum.xda-developers.com/wiki/Edify_script_language
joluke said:
Echo is a command for windows command line. In recovery you use: ui_print("<message goes here");
In recovery the language used is called Edify.
Read a bit about it here:
https://forum.xda-developers.com/wiki/Edify_script_language
Click to expand...
Click to collapse
you use ui_print in updater-script ?
but in sh file how to print on screen if echo doesn't work in recovery ?
kramer04 said:
you use ui_print in updater-script ?
but in sh file how to print on screen if echo doesn't work in recovery ?
Click to expand...
Click to collapse
Sh use the commands you use in linux
And yes ui_print is for updater-script
joluke said:
Sh use the commands you use in linux
And yes ui_print is for updater-script
Click to expand...
Click to collapse
Ok trying to use echo in sh file doesn't work for me.
So I don't understand how to do .
Any suggestions?
kramer04 said:
Ok trying to use echo in sh file doesn't work for me.
So I don't understand how to do .
Any suggestions?
Click to expand...
Click to collapse
Use Linux commands only. Echo is for Windows command line.
I don't have the skills to help you but googling "Linux commands for console" should help
joluke said:
Use Linux commands only. Echo is for Windows command line.
I don't have the skills to help you but googling "Linux commands for console" should help
Click to expand...
Click to collapse
So googling linus commands but I don't find how to use echo in a sh file in recovery.
If you have time try yourself echo command .
I've no idea why it doesn't work.
ECHO is a command for windows command line dude! Why do you insist on using echo? Echo is for windows command line? Got it now?
You need to use other commands according to the system you are using. and in android you use bash language on .sh files!
joluke said:
ECHO is a command for windows command line dude! Why do you insist on using echo? Echo is for windows command line? Got it now?
You need to use other commands according to the system you are using. and in android you use bash language on .sh files!
Click to expand...
Click to collapse
but i don't understand why it doesn't work
else i don't know how to replace echo by an other command
Thanks for help
kramer04 said:
but i don't understand why it doesn't work
else i don't know how to replace echo by an other command
Thanks for help
Click to expand...
Click to collapse
Every programming language uses its own commands...
Maybe because of that?
After some research
i change a little my script to see if command echo works
code in updater-script
Code:
ui_print("*************************");
ui_print("sh10");
ui_print("*************************");
unmount("/system");
unmount("/data");
#ui_print("-- Montage partitions...");
run_program("/sbin/busybox", "mount", "/system");
run_program("/sbin/busybox", "mount", "/data");
package_extract_dir("test", "/tmp");
set_perm(0, 0, 0777, "/tmp/test.sh");
run_program("/tmp/test.sh");
#ui_print("Extracting files ...");
#package_extract_dir("system", "/tmp/update");
#set_perm(0, 0, 0755, "/tmp/update/myscript.sh");
#run_program("/tmp/update/myscript.sh");
#delete_recursive("/tmp*");
ui_print("END OF PROCESS");
ui_print("*************************");
unmount("/data");
unmount("/system");
code in test.sh file
Code:
#!/sbin/sh
#echo on
#function to display commands
exe() { echo "\$ [email protected]" ; "[email protected]" ; }
OUTFD=$2
ui_print() {
if [ $OUTFD != "" ]; then
echo "ui_print ${1} " 1>&$OUTFD;
echo "ui_print " 1>&$OUTFD;
else
echo "${1}";
fi;
}
#rm -rf /system/app/YouTube
echo "hello world !, using echo" >tong.txt
exe echo "Delete YouTube, using exe echo"
echo "Delete YouTube, using echo" >>tong.txt
printf "hello world, using printf" >>tong.txt
cat tong.txt
ui_print "hello world! using ui_print"
echo command doesn't print on screen but it creates tong.txt and pass in results.
We can see it works in recovery.log
I:Set page: 'install'
I:Set page: 'flash_confirm'
I:Set page: 'flash_zip'
Iperation_start: 'Flashing'
Installing zip file '/external_sd/Custom Rom/test.zip'
Checking for Digest file...
Skipping Digest check: no Digest file found
I:Update binary zip
Verifying package compatibility...
Package doesn't contain compatibility.zip entry
I:Zip does not contain SELinux file_contexts file in its root.
I:has_legacy_properties: Found legacy property match!
I:Legacy property environment initialized.
*************************
sh10
*************************
unmount of /system failed; no such volume
about to run program [/sbin/busybox] with 3 args
about to run program [/sbin/busybox] with 3 args
minzip: Extracted file "/tmp/test.sh"
about to run program [/tmp/test.sh] with 1 args
$ echo Delete YouTube, using exe echo
Delete YouTube, using exe echo
hello world !, using echo
Delete YouTube, using echo
hello world, using printfsh: : unknown operand
hello world! using ui_print
END OF PROCESS
*************************
script result was [/system]
I:Updater process ended with RC=0
I:Legacy property environment disabled.
I:Install took 0 second(s).
Updating partition details...
I:mount -o bind '/data/media/0' '/sdcard' process ended with RC=0
Someone has an idea why echo doesn't print on screen in TWRP recovery; else it works...
weird for me
kramer04 said:
After some research
i change a little my script to see if command echo works
code in updater-script
Code:
ui_print("*************************");
ui_print("sh10");
ui_print("*************************");
unmount("/system");
unmount("/data");
#ui_print("-- Montage partitions...");
run_program("/sbin/busybox", "mount", "/system");
run_program("/sbin/busybox", "mount", "/data");
package_extract_dir("test", "/tmp");
set_perm(0, 0, 0777, "/tmp/test.sh");
run_program("/tmp/test.sh");
#ui_print("Extracting files ...");
#package_extract_dir("system", "/tmp/update");
#set_perm(0, 0, 0755, "/tmp/update/myscript.sh");
#run_program("/tmp/update/myscript.sh");
#delete_recursive("/tmp*");
ui_print("END OF PROCESS");
ui_print("*************************");
unmount("/data");
unmount("/system");
code in test.sh file
Code:
#!/sbin/sh
#echo on
#function to display commands
exe() { echo "\$ [email protected]" ; "[email protected]" ; }
OUTFD=$2
ui_print() {
if [ $OUTFD != "" ]; then
echo "ui_print ${1} " 1>&$OUTFD;
echo "ui_print " 1>&$OUTFD;
else
echo "${1}";
fi;
}
#rm -rf /system/app/YouTube
echo "hello world !, using echo" >tong.txt
exe echo "Delete YouTube, using exe echo"
echo "Delete YouTube, using echo" >>tong.txt
printf "hello world, using printf" >>tong.txt
cat tong.txt
ui_print "hello world! using ui_print"
echo command doesn't print on screen but it creates tong.txt and pass in results.
We can see it works in recovery.log
I:Set page: 'install'
I:Set page: 'flash_confirm'
I:Set page: 'flash_zip'
Iperation_start: 'Flashing'
Installing zip file '/external_sd/Custom Rom/test.zip'
Checking for Digest file...
Skipping Digest check: no Digest file found
I:Update binary zip
Verifying package compatibility...
Package doesn't contain compatibility.zip entry
I:Zip does not contain SELinux file_contexts file in its root.
I:has_legacy_properties: Found legacy property match!
I:Legacy property environment initialized.
*************************
sh10
*************************
unmount of /system failed; no such volume
about to run program [/sbin/busybox] with 3 args
about to run program [/sbin/busybox] with 3 args
minzip: Extracted file "/tmp/test.sh"
about to run program [/tmp/test.sh] with 1 args
$ echo Delete YouTube, using exe echo
Delete YouTube, using exe echo
hello world !, using echo
Delete YouTube, using echo
hello world, using printfsh: : unknown operand
hello world! using ui_print
END OF PROCESS
*************************
script result was [/system]
I:Updater process ended with RC=0
I:Legacy property environment disabled.
I:Install took 0 second(s).
Updating partition details...
I:mount -o bind '/data/media/0' '/sdcard' process ended with RC=0
Someone has an idea why echo doesn't print on screen in TWRP recovery; else it works...
weird for me
Click to expand...
Click to collapse
You are probably going to have to go in a little different direction. See this thread where update-binary is used in place of update-script.
Tulsadiver said:
You are probably going to have to go in a little different direction. See this thread where update-binary is used in place of update-script.
Click to expand...
Click to collapse
Thanks for your answer but could you add the link
kramer04 said:
Thanks for your answer but could you add the link
Click to expand...
Click to collapse
Sorry, lol!
https://forum.xda-developers.com/an...-complete-shell-script-flashable-zip-t2934449
Tulsadiver said:
Sorry, lol!
https://forum.xda-developers.com/an...-complete-shell-script-flashable-zip-t2934449
Click to expand...
Click to collapse
Thanks, but this isn't exactly what i'm looking for even if it's very interesting.
I would like to know how to display on recovery screen
I tryed with echo command but it doesn't work
For example running this script in sh file on recovery TWRP
Code:
#!/sbin/sh
csc_id=`cat /efs/imei/mps_code.dat`
echo "==== Your active csc is $csc_id ====="
echo do displays this
==== Your active csc is BTU ====
on recovery screen
but not displays anything.
Is there a way to activate it ?
kramer04 said:
Thanks, but this isn't exactly what i'm looking for even if it's very interesting.
I would like to know how to display on recovery screen
I tryed with echo command but it doesn't work
For example running this script in sh file on recovery TWRP
Code:
#!/sbin/sh
csc_id=`cat /efs/imei/mps_code.dat`
echo "==== Your active csc is $csc_id ====="
echo do displays this
==== Your active csc is BTU ====
on recovery screen
but not displays anything.
Is there a way to activate it ?
Click to expand...
Click to collapse
Echo has never worked on my phones. ui_print works on my pixel and pixel 2. It stopped working on my pixel 3 XL but that is because I haven't found a way to mount system using toybox. Pixel 3 XL won't mount using BusyBox.
Tulsadiver said:
Echo has never worked on my phones. ui_print works on my pixel and pixel 2. It stopped working on my pixel 3 XL but that is because I haven't found a way to mount system using toybox. Pixel 3 XL won't mount using BusyBox.
Click to expand...
Click to collapse
I know echo works because i see it in recovery log but it doesn't display anything on recovery screen
And i don't understand why;
Maybe it's because of recovery ?
I use TWRP
kramer04 said:
I know echo works because i see it in recovery log but it doesn't display anything on recovery screen
And i don't understand why;
Maybe it's because of recovery ?
I use TWRP
Click to expand...
Click to collapse
Most everyone uses TWRP. I believe for recovery screen, echo must be passed on to ui_print. Try this for an explanation:
https://forum.xda-developers.com/showthread.php?t=1023150&page=1
Tulsadiver said:
Most everyone uses TWRP. I believe for recovery screen, echo must be passed on to ui_print. Try this for an explanation:
https://forum.xda-developers.com/showthread.php?t=1023150&page=1
Click to expand...
Click to collapse
yes. totaly true
finaly i resolved my problem using code from Chainfire
Code:
#!/sbin/sh
OUTFD=1
readlink /proc/$$/fd/$OUTFD 2>/dev/null | grep /tmp >/dev/null
if [ "$?" -eq "0" ]; then
# rerouted to log file, we don't want our ui_print commands going there
OUTFD=0
# we are probably running in embedded mode, see if we can find the right fd
# we know the fd is a pipe and that the parent updater may have been started as
# 'update-binary 3 fd zipfile'
for FD in `ls /proc/$$/fd`; do
readlink /proc/$$/fd/$FD 2>/dev/null | grep pipe >/dev/null
if [ "$?" -eq "0" ]; then
ps | grep " 3 $FD " | grep -v grep >/dev/null
if [ "$?" -eq "0" ]; then
OUTFD=$FD
break
fi
fi
done
fi
ui_print() {
echo -n -e "ui_print $1\n" >> /proc/self/fd/$OUTFD
echo -n -e "ui_print\n" >> /proc/self/fd/$OUTFD
}
Thanks to all
https://forum.xda-developers.com/android/software-hacking/dev-complete-shell-script-flashable-zip-t2934449/page37
kramer04 said:
yes. totaly true
finaly i resolved my problem using code from Chainfire
Code:
#!/sbin/sh
OUTFD=1
readlink /proc/$$/fd/$OUTFD 2>/dev/null | grep /tmp >/dev/null
if [ "$?" -eq "0" ]; then
# rerouted to log file, we don't want our ui_print commands going there
OUTFD=0
# we are probably running in embedded mode, see if we can find the right fd
# we know the fd is a pipe and that the parent updater may have been started as
# 'update-binary 3 fd zipfile'
for FD in `ls /proc/$$/fd`; do
readlink /proc/$$/fd/$FD 2>/dev/null | grep pipe >/dev/null
if [ "$?" -eq "0" ]; then
ps | grep " 3 $FD " | grep -v grep >/dev/null
if [ "$?" -eq "0" ]; then
OUTFD=$FD
break
fi
fi
done
fi
ui_print() {
echo -n -e "ui_print $1\n" >> /proc/self/fd/$OUTFD
echo -n -e "ui_print\n" >> /proc/self/fd/$OUTFD
}
Thanks to all
https://forum.xda-developers.com/android/software-hacking/dev-complete-shell-script-flashable-zip-t2934449/page37
Click to expand...
Click to collapse
That works on my pixel and pixel 2 but not my pixel 3 XL. But on my pixel 3 XL I also have to use toybox to mount instead of BusyBox
run_program("/sbin/toybox", "mount", "/system");

Categories

Resources