FORUMS

 View Poll Results: What about an app? See post #90 for more infos, let me know what you think!

The hell yeah!
 
113 Vote(s)
81.29%
cool idea, but not really neccessary.
 
24 Vote(s)
17.27%
nope, wouldn't even try..
 
2 Vote(s)
1.44%

[ZIP] Dynamic automated build.prop editing

145 posts
Thanks Meter: 179
 
By kl3, Senior Member on 27th February 2014, 08:23 PM
Post Reply Email Thread
Hey,

since I'm flashing nightlies on a regular basis and also want to use my own custom /system/build.prop file, there are a few ways to accomplish both things as easy as possible:

Backing up /system/build.prop through a script in /system/addon.d
Flashing my own file using a zip after every update
Restoring previous build.prop using a Editor app and reboot
Manually change or add every desired entry and reboot

For most of you one of these ways should absolutely do the trick, but my problem was either things like build version, date, etc. got stuck at my custom file's one or I had to reboot after manually updating it, which got really annoying after several times.

So I decided to create my own flashable zip which works as follows:

Somewhere on the device is a simple text file in which are all those entries that shall be changed,added to or removed from /system/build.prop (In my case it's /sdcard/tweak.prop)
After mounting /system and /data (not if they are already) and setting write permissions to /system/build.prop the zip extracts a shell script to /tmp/tweakprop.sh
It This script scans the text file (aborts if not found) and looks for changed, new or unwanted entries in /system/build.prop in order to apply them. Changed entries will be overridden, new ones will be added, unwanted get removed and entries existing in /system/build.prop but not in your personal file will be ignored
When tweaking is done, it just removes /tmp/tweakprop.sh and unmounts /system and /data (only if they weren't mounted before) and reverts /system/build.prop's permissions to rw-r--r--

-> (See content of example.txt for more detailed examples and syntax!)

Using this method, you can not only forget about manually updating versions and/or lame reboots after updates for changes to take effect, but also edit your personal text file at any time without root rights beeing required. Once set up to be flashed after every update, your /system/build.prop is always tweaked as you wish and looks like a stock one (ROM version, etc. under About Phone).

The zip flashes well on all recoveries. Make sure your tweak.prop file ends with an empty line, otherwise the last line will be ignored!

I hope some of you can use this zip, it's free to modify. If you have any suggestions, let me know.

This project has been moved to a git repo at https://notabug.org/kl3/tweakprop. Please refer to it in the future to get updates as this is much easier for me to maintain. Upcoming changelog can be found here.
The Following 107 Users Say Thank You to kl3 For This Useful Post: [ View ] Gift kl3 Ad-Free
1st March 2014, 02:23 PM |#2  
OP Senior Member
Thanks Meter: 179
 
More
Changelog
Changelog
Quote:

version 0.1:

  • initial release


version 0.2:
  • ignore lines in personal file not matching a valid entry pattern (someVAR=someVAL) to not mess up /system/build.prop and support personal structuring inside the file like "# media tweaks #", "# dalvik section #", etc.
  • code cleaned up


version 0.2.1:
  • typo fixed in line 24 of tweakprop.sh so the if-statement asks for the correct file (thanks to the_pirate_predator)


version 0.3:
  • changed the while-loop to get it's input directly from sed, which makes a second buffer file obsolete


version 0.3.5:
  • example.txt provided as tweak.prop template
  • ignore lines beginning with # or being empty


version 0.4:
  • instead of a fixed path, the personal file gets searched on internal storage (file name can be set in the script) so you can put your file anywhere - no more problems with /sdcard/ or /sdcard/0/ on different devices
  • personal file must not be empty, otherwise script aborts#
  • only override really different entry values in order to prevent "... value of someVAR overridden" spam in recovery log


version 0.4.5:
  • fixed last line of personal file being ignored due to deleting all empty lines before
  • speed up search for personal file, now looking on internal storage and even on external SD card if nothing was found before (ext. SD neither gets checked if present, nor mounted or unmounted, just trying to search on it silently)


version 0.4.5a:
  • same as 0.4.5a, but personal file is inside the zip and gets extracted to /tmp/tweak.prop, no need to have one on the internal storage


version 0.4.6(a):
  • output not shown in TWRP fixed, now works as it should


version 0.5:

  • code cleanup: everything's now in the update-binary, resulting in much less code and faster execution time
  • output to recovery should now work on all device-recovery combinations


version 0.5.1:

  • lines beginning with ! will be removed globally
  • little code-cleanup


version 0.5.2
:

  • lines beginning with @ will append the string after | to values of existent entries
  • slight changes in code structure


version 0.5.3
:

  • lines beginning with $ will change the value to the string after | only if the entry already exists, hence $telephony.lteCdmaDevice|1 is nothing but a more explicit approach of telephony.lteCdmaDevice=1, as the first one will only make changes but no new entries


version 0.5.4
:

  • the build.prop file can now be backed up before editing using a BACKUP= line, see example.txt for details
  • tiny bug fixed


version 0.5.4a
:

  • tweak.prop file (example.txt) is included, no personal file on your device's storage is used. Edit the zip's content before flashing!


version 0.5.9(a)
:

  • Error handling fixed, script properly exits now if anything failes and won't make further changes
  • More verbose output
  • Date and tweak.prop version added to backup files to keep track of them
  • Special characters like / are now escaped and handled correctly by sed
  • Slight changes in coding style as it's good practise

The Following 20 Users Say Thank You to kl3 For This Useful Post: [ View ] Gift kl3 Ad-Free
10th March 2014, 01:58 AM |#3  
paxy97's Avatar
Senior Member
Flag Novi Sad
Thanks Meter: 536
 
More
Such Awesome, much appreciate i wanted to make one too, but never got the time to.

Sent from my Xperia V using XDA Premium 4 mobile app
10th March 2014, 03:33 AM |#4  
jonwgee's Avatar
Member
Flag Dekalb
Thanks Meter: 22
 
More
What should my text file look like if I just want to add one line of text at the end of my build.prop? For example,
qemu.hw.mainkeys=0
to activate softkeys on a device with capacitive buttons?
Thanks

Sent from my XT912 using Tapatalk
the_pirate_predator
10th March 2014, 04:05 AM |#5  
Guest
Thanks Meter: 0
 
More
Audio Need some information
I need explanation for the following lines of code.
Code:
## your personal file with tweaks and custom entries/values
tweak=/sdcard/0/tweak.prop
## abort execution if $tweaks not found
if [ ! -e $tweaks ]
then
	ui_print "ERROR: Personal file not found. No changes were made."
	ui_print "Script aborted. Check file path and flash again."
	exit 0
fi

## read only lines matching any valid entry pattern (someVAR=someVAL), e.g.
## net.bt.name=Android, omni.device=n7100, url.legal=http://www ...
sed '/.*=.*/!d' $tweak > /tmp/tweak.prop
tweaks=/tmp/tweak.prop
You are giving a condition loop without even declaring the variable "tweaks" at first. You have declared only after the loop ends. Then that means, the code in the loop never executes. I think this is a small mistake you did with the code. Make sure you correct those.

But else, a great work!!
10th March 2014, 05:55 AM |#6  
Senior Member
Thanks Meter: 3,140
 
More
Info 2
Sorry, but stick to one variable, "tweak", or "tweaks".

Otherwise, its a very simple, yet efficient algorithm.
10th March 2014, 10:02 AM |#7  
OP Senior Member
Thanks Meter: 179
 
More
Quote:
Originally Posted by jonwgee

What should my text file look like if I just want to add one line of text at the end of my build.prop? For example,
qemu.hw.mainkeys=0
to activate softkeys on a device with capacitive buttons?

Just a simple text file containing your mentioned line. Any other empty or non-entry lines will be ignored by my script anyway.

Quote:
Originally Posted by the_pirate_predator

I need explanation for the following lines of code.

Code:
## your personal file with tweaks and custom entries/values
tweak=/sdcard/0/tweak.prop
## abort execution if $tweaks not found
if [ ! -e $tweaks ]
then
    ui_print "ERROR: Personal file not found. No changes were made."
    ui_print "Script aborted. Check file path and flash again."
    exit 0
fi

## read only lines matching any valid entry pattern (someVAR=someVAL), e.g.
## net.bt.name=Android, omni.device=n7100, url.legal=http://www ...
sed '/.*=.*/!d' $tweak > /tmp/tweak.prop
tweaks=/tmp/tweak.prop
You are giving a condition loop without even declaring the variable "tweaks" at first. You have declared only after the loop ends. Then that means, the code in the loop never executes. I think this is a small mistake you did with the code. Make sure you correct those.

But else, a great work!!

You're right. It's a typo, I'm correcting it now. Thanks for your advice.

Quote:
Originally Posted by thewisenerd

Sorry, but stick to one variable, "tweak", or "tweaks".

Otherwise, its a very simple, yet efficient algorithm.

I use a second buffer file that is a cleaned version of the original one. If I find a smarter way, I will.
The Following 2 Users Say Thank You to kl3 For This Useful Post: [ View ] Gift kl3 Ad-Free
10th March 2014, 12:31 PM |#8  
Member
Flag Lisboa
Thanks Meter: 4
 
More
I was searching for something like this for ages.

But i have a nob question! lol

I need to create a text file with all the lines i want to add to my built.prop file, so where I put the text file? And i have to give a certain name to that file or any name will do?

Hugo
10th March 2014, 12:56 PM |#9  
OP Senior Member
Thanks Meter: 179
 
More
Quote:
Originally Posted by oguh

I need to create a text file with all the lines i want to add to my built.prop file, so where I put the text file? And i have to give a certain name to that file or any name will do?

My script searches for a file called tweak.prop located at your internal storage (storage/emulated/0/tweak.prop or sdcard/tweak.prop or sdcard/0/tweak.prop), but you can freely change the line
PHP Code:
tweak=/sdcard/0/tweak.prop 
to any path you want your personal file to be.
The Following 2 Users Say Thank You to kl3 For This Useful Post: [ View ] Gift kl3 Ad-Free
10th March 2014, 12:59 PM |#10  
Member
Flag Lisboa
Thanks Meter: 4
 
More
Quote:
Originally Posted by klenamenis

My script searches for a file called tweak.prop located at your internal storage (storage/emulated/0/tweak.prop or sdcard/tweak.prop or sdcard/0/tweak.prop), but you can freely change the line

PHP Code:
tweak=/sdcard/0/tweak.prop 
to any path you want your personal file to be.

Thx for the quick response, and for your great work.

hugo
10th March 2014, 01:38 PM |#11  
bnbagiz's Avatar
Senior Member
Thanks Meter: 19
 
More
Sorry but i don't get it.
i need to create a txt file called tweak.prop and place it where i want, for example /sdcard/tweak.prop
after extracting the tweakprop-0.3.zip for editing the line /tmp/tweakprop.sh

Code:
## your personal file with tweaks and custom entries/values
tweak=/sdcard/tweak.prop
zipping meta-inf and tmp folder and finally flashing this zip.. am i doing something wrong ?
because it takes no changes.

got this line in tweak.prop at /sdcard/tweak.prop

Code:
ro.sf.lcd_density=400
sorry, i really dont get it.
Post Reply Subscribe to Thread

Tags
build.prop, flash, script, tweak, zip

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes