[ZIP] Dynamic automated build.prop editing

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


  • Total voters
    146
Search This thread

kl3

Senior Member
Sep 9, 2013
145
175
Versioin 0.5.8 has again been replaced since not passing BACKUP= at all resulted in failure instead of just not backing up. This is fixed now and custom paths are checked properly now (hopefully).

I highly recommend using either /system/build.prop.backup or /sdcard/build.prop.backup as custom paths. /storage/emulated/0/foo/bar/foo.bar will fail! If you encounter issues when using backups, please try using one of the recommend paths first before reporting. Some paths vary across different devices/ROMs.

After all, BACKUP=y is probably the safest and easiest way to safe your original build.prop file.
 

O-T

Senior Member
Sep 28, 2010
934
389
Versioin 0.5.8 has again been replaced since not passing BACKUP= at all resulted in failure instead of just not backing up. This is fixed now and custom paths are checked properly now (hopefully).

I highly recommend using either /system/build.prop.backup or /sdcard/build.prop.backup as custom paths. /storage/emulated/0/foo/bar/foo.bar will fail! If you encounter issues when using backups, please try using one of the recommend paths first before reporting. Some paths vary across different devices/ROMs.

After all, BACKUP=y is probably the safest and easiest way to safe your original build.prop file.

A typo is detected in tweakprop-0.5.9a.zip folder name
Code:
META-INF_a
- can be renamed by users with tool 7-zip to correct folder name
Code:
META-INF

Variable to backup or not is identical to backupPATH in tweak.prop:
Code:
BACKUP=y|Y|yes|Yes|YES
BACKUP=/foo/bar/foo.bar

That's why 0.5.9 failed. /sdcard/tweak.prop was found having a single line to add including BACKUP=Y. I expected by default a backup to be placed in same folder. That's why I kept the 2nd setvar BACKUP commented.
See attached images.

e7c311ab200c99195e7cd4d9add426e7.jpg

abe7ae7fcebdec7fa2d618665ced01f7.jpg


- how about using different name to avoid confusion of what is what:
Code:
BACKUP=y|Y|yes|Yes|YES
BACKPATH=/foo/bar/foo.bar
 
Last edited:

jsylvia007

Senior Member
Dec 4, 2010
229
48
38
Seekonk
www.jacobsylvia.com
A typo is detected in tweakprop-0.5.9a.zip folder name
Code:
META-INF_a
- can be renamed by users with tool 7-zip to correct folder name
Code:
META-INF
Variable to backup or not is identical to backupPATH in tweak.prop:
Code:
BACKUP=y|Y|yes|Yes|YES
BACKUP=/foo/bar/foo.bar
- how about using different name to avoid confusion of what is what:
Code:
BPATH=/system

So... I made the change to the file using 7zip, and commented out ALL lines in the internal tweak.prop file.

At the end of tweak.prop, I added:

dalvik.vm.dexopt-flags=v=n,o=v,m=y
ro.sf.lcd_density=380

(and a blank line like originally stated in the OP...

Neither of those changes makes it into my build.prop, yet no errors are indicated in TWRP.

What am I doing wrong?
 

Killerdog

Senior Member
Aug 15, 2009
266
94
Cannes
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.

Hi kl3

i want to ask some question :

can we use your script as an init.d so the system parse it at each boot and correct the change made by flashing an update ROM ?

i want to include it in my rom so when an update is done via OTA it automaticaly change the entry in the build.prop without any intervention.
my init.d script is located into "/data/local" so it survive after OTA.
The OTA file don't come from me, it's why i need to change build.prop after update.

thanks
 
Last edited:

phpbb3

Senior Member
I have read through the thread, and I believe I understand the concept. I wasn't sure how to use the "a" version, so I deleted the entire folder from the zip. I then created a tweak.prop file out of the example in the same directory that the zip was in, and added qemu.hw.mainkeys=1 and a blank line. When I ran the zip via TWRP, this was the result
Code:
 Installing zip file '/data/media/0//tweakprop-3e33ec320f.zip'
Installing '/data/media/0//tweakprop-3e33ec320f.zip'...
Checking for MD5 file...
Skipping MD5 check: no MD5 file found
I:Zip does not contain SELinux file_contexts file in its root.
I:Legacy property environment initialized.
 
###############################
#       tweakprop 0.5.9       #
#         --by kl3--          #
###############################
 
Mount /system partition...
/system mounted rw
Mount /data partition...
/data remounted rw
Set write permissions for /system/build.prop...
searching personal file...
../data/media/0/tweak.prop found and not empty
sh: #n|N|no|No|NO: unknown operand
/tmp/updater: line 74: can't create y
#n|N|no|No|NO		# same as commented out, just there for completeness
#/foo/bar/foo.bar	# chose your own path: nonexistent directory
ERROR: Cannot write to backup file yE:unknown command [#n|N|no|No|NO		#]
E:unknown command [#/foo/bar/foo.bar	#]

I:Legacy property environment disabled.
E:Error executing updater binary in zip '/data/media/0//tweakprop-3e33ec320f.zip'
E:Error installing zip file '/data/media/0//tweakprop-3e33ec320f.zip'
Done processing script file
And then my phone wouldn't boot, I had to restore my /system. I erased everything from tweak.prop and re-added the qemu line, hit enter twice, and saved and tried again. The error was a little different, but once again I found myself having to restore my /system in order to boot. Could I get some help please?
 

vandermark

Senior Member
Sep 5, 2012
136
23
Wageningen
www.bartvandermark.nl
@kl3 I still don't know what the exact procedure is: keep bootlooping and having to restore nandroid backup.

I only need to add the following line to my buil.prop:

qemu.hw.mainkeys=1

Do I need to change the tweak.prop in the temp dir of the zip file?
Do I need to place this tweak.prop file on my sdcard also?

I am quite confused, please help. These are my tweak.prop contents:

# ======================================
# | Dynamic automated build.prop editing |
# | --by kl3-- |
# ======================================
#
# Personal file located at /sdcard/0/tweak.prop
#
# For help, please create an issue on https://notabug.org/kl3/tweakprop
# or visit the official XDA-Thread http://forum.xda-developers.com/showthread.php?p=2664332
#
# If you want to backup your build.prop before editing, uncomment the following line
# or specify a custom path. Already existing backup files will be overridden.
#

BACKUP=y # creates /sdcard/build.prop.backup since tweak.prop resides there
#BACKUP=n|N|no|No|NO # same as commented out, just there for completeness
#BACKUP=/foo/bar/foo.bar # chose your own path

#
# simply add your entries below
#

# set exactly this entry even if it overrides the already existing value
qemu.hw.mainkeys=1

# remove every entry containing the string "debug.egl"
#!debug.egl

# append the string ",ppp0" to the value string of the variable "mobiledata.interfaces" if it exists
#@mobiledata.interfaces|,ppp0

# Override the value of the variable "telephony.lteOnCdmaDevice" to "1" if and only if the entry already exists
#$telephony.lteOnCdmaDevice|1
 
Last edited:
  • Like
Reactions: phpbb3

phpbb3

Senior Member
@kl3 I still don't know what the exact procedure is: keep bootlooping and having to restore nandroid backup.

I only need to add the following line to my buil.prop:

qemu.hw.mainkeys=1

Do I need to change the tweak.prop in the temp dir of the zip file?
Do I need to place this tweak.prop file on my sdcard also?

I am quite confused, please help. These are my tweak.prop contents:

# ======================================
# | Dynamic automated build.prop editing |
# | --by kl3-- |
# ======================================
#
# Personal file located at /sdcard/0/tweak.prop
#
# For help, please create an issue on https://notabug.org/kl3/tweakprop
# or visit the official XDA-Thread http://forum.xda-developers.com/showthread.php?p=2664332
#
# If you want to backup your build.prop before editing, uncomment the following line
# or specify a custom path. Already existing backup files will be overridden.
#

BACKUP=y # creates /sdcard/build.prop.backup since tweak.prop resides there
#BACKUP=n|N|no|No|NO # same as commented out, just there for completeness
#BACKUP=/foo/bar/foo.bar # chose your own path

#
# simply add your entries below
#

# set exactly this entry even if it overrides the already existing value
qemu.hw.mainkeys=1

# remove every entry containing the string "debug.egl"
#!debug.egl

# append the string ",ppp0" to the value string of the variable "mobiledata.interfaces" if it exists
#@mobiledata.interfaces|,ppp0

# Override the value of the variable "telephony.lteOnCdmaDevice" to "1" if and only if the entry already exists
#$telephony.lteOnCdmaDevice|1

This is exactly what I'm trying to do too!
 

Looki75

Senior Member
Apr 1, 2010
1,708
1,449
@kl3 I still don't know what the exact procedure is: keep bootlooping and having to restore nandroid backup.

I only need to add the following line to my buil.prop:

qemu.hw.mainkeys=1

Do I need to change the tweak.prop in the temp dir of the zip file?
Do I need to place this tweak.prop file on my sdcard also?

I am quite confused, please help. These are my tweak.prop contents:

# ======================================
# | Dynamic automated build.prop editing |
# | --by kl3-- |
# ======================================
#
# Personal file located at /sdcard/0/tweak.prop
#
# For help, please create an issue on https://notabug.org/kl3/tweakprop
# or visit the official XDA-Thread http://forum.xda-developers.com/showthread.php?p=2664332
#
# If you want to backup your build.prop before editing, uncomment the following line
# or specify a custom path. Already existing backup files will be overridden.
#

BACKUP=y # creates /sdcard/build.prop.backup since tweak.prop resides there
#BACKUP=n|N|no|No|NO # same as commented out, just there for completeness
#BACKUP=/foo/bar/foo.bar # chose your own path

#
# simply add your entries below
#

# set exactly this entry even if it overrides the already existing value
qemu.hw.mainkeys=1

# remove every entry containing the string "debug.egl"
#!debug.egl

# append the string ",ppp0" to the value string of the variable "mobiledata.interfaces" if it exists
#@mobiledata.interfaces|,ppp0

# Override the value of the variable "telephony.lteOnCdmaDevice" to "1" if and only if the entry already exists
#$telephony.lteOnCdmaDevice|1

This is exactly what I'm trying to do too!

That should be working...
Please post your zip file (complete zip that you flash) and I can check it for you.
 
  • Like
Reactions: vandermark

Looki75

Senior Member
Apr 1, 2010
1,708
1,449

Attachments

  • tweakprop.zip
    122.6 KB · Views: 401
  • Like
Reactions: vandermark

Looki75

Senior Member
Apr 1, 2010
1,708
1,449
YES!! This worked, many thanks for your persisting efforts.

You're welcome!

I modified the sources in order to have the ability to place the tweak.prop file on internal/external sdcard + corrected some bugs appearing on my TWRP recovery (bug was related to "modify existing lines" and "delete existing lines")...
@kl3 you can check my previously attached file "5. MOD_build_prop.zip" if you want to update your sources.

Cheers
 

Looki75

Senior Member
Apr 1, 2010
1,708
1,449
I couldn't get the log to upload, but here's a pastebin http://pastebin.com/Jut6AZWi TWRP 2.8.7.0 for falcon.

---------- Post added at 06:31 PM ---------- Previous post was at 06:30 PM ----------

If you need the full log I can post from my laptop when I get home from work

You get this error message that I don't know:
Code:
E:request read returned -1, errno: 22, exiting MtpServer::run loop

It seems that the script cannot mount /data.
Do you have another zip file that modifies files in your /data partition and that you know it is working OK?

Thanks
 

Top Liked Posts

  • There are no posts matching your filters.
  • 103
    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.
    20
    Changelog

    Changelog
    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
    3
    Well, this was way easier than I thought at first glance, so why not supporting xda folks instead of gaming, right? :D

    Version 0.5.3 was released, just a minor syntax case added for fixing problems that might occour when flashing the same tweak.prop file on different devices. See the changelog for more infos!

    As usual:
    55132479.jpg
    3
    Thanks for your great feedback, guys! Finally it should really work, I found some typos inside the sed-commands breaking the syntax. Version 0.5.1 is reuploaded again. :eek:

    If you like my work, please share it, name it in your signature or donate some cents - every support is highly appreciated!

    Maybe an additional app to easily edit your tweak.prop file, toggle adding/removing/overriding lines and apply changes would be nice to have? Would do you think?
    2
    Hi k,

    I remember this was something me and Patrics were playing around with for ROMCleaner before life got in the way :(

    Good work, I love little scripts like this and will be sure to play around with it on my next flash.

    I have some suggestions if thats ok?

    Does the answer file have to have the .prop extension?

    We found it was a lot easier for users to use a standard .txt file rather than 'fiddle' with a different extension.

    I know it sounds like a little thing but you'll be surprised at how many dont...

    Can you make the script ignore anything in the file answer file preceded with a #?

    If so you can make a sample file for complete novice users to use and also have the ability to quickly enable/disable edits.

    Something like:

    Code:
    #   !!!ALWAYS USE NOTEPAD++ WHEN EDITING THIS FILE!!!
    #
    #        ===============================================
    #        |                                             |
    #        |         Dynamic build.prop Editor           |
    #        |                     by                      |
    #        |                 klenamenis                  |
    #        |                                             |
    #        ===============================================
    #
    #        For help and support, please visit my thread:
    #
    #			http://forum.xda-developers.com/showthread.php?t=2664332
    #
    #   !!!ALWAYS USE NOTEPAD++ WHEN EDITING THIS FILE!!!
    #
    #
    #==========================================================================================================================
    #
    #	Add your custom build.prop entries to this file to have them automatically
    #	applied to your current build.prop when flashing a new ROM.
    #
    #	After flashing your ROM flash the tweakprop.zip and edits will be applied.
    #
    #	Eg:
    #
    #	To enable an edit:
    #
    #	ro.sf.lcd_density="400"
    #
    #	To disable an edit, precede the line with a hash symbol (#):
    #
    #	#ro.sf.lcd_density="400"
    #
    #==========================================================================================================================
    #
    #	!!! EDITS GO BELOW !!!
    #
    #==========================================================================================================================

    You could also go more adanced and make the .sh dynamic by having some asserts in the updater-script look for the answer file in predefined locations etc

    You can do a lot with scripts like these, just which I had more knowledge of nix scripting :(