[INTRODUCTION] Updater script - Samsung Galaxy R i9103

Hi guys this is a small intro to updater script by a newbie for a newbie to understand more and more what it has and what it means:highfive::highfive::highfive:
now what is the updater-script and update-binary present in the META-INF>com>google>android in any flashable zip package
1. updater-script - it is just a text file which contains all the commands which tells the clockworkmod what to do with the given
zip file. the updater-script is written in the edify scripting language.
2. update-binary - it is a binary which is requiered by the clockworkmod to translate the human readable format of the updater-
script to machine readable format for execution of the updater-script in our device.
exploring the updater-script:
now let's start exploring the updater-script !
1. open the updater script with notepad++ (strongly recommended)
2. now i will try and explain commands generally used in the updater-script,
assert(getprop("ro.product.device") == "ST15i" || getprop("ro.build.product") == "ST15i" ||
getprop("ro.product.device") == "ST15a" || getprop("ro.build.product") == "ST15a" ||
getprop("ro.product.device") == "smultron" || getprop("ro.build.product") == "smultron");
the above bunch of lines checks the device model to confirm that the zip file is flashed on the device
for which it is specifically created for. These bunch of lines are very important because it prevents
flashing of zip file which is not intended for the device hence avoiding any problems due to flashing
the wrong zip. for example the above lines checks for the value of "ro.product.device" and
"ro.build.product"in the build.prop file of the already existing rom in the device, if any of the three
defined values ST15i, ST15a, smultron are found it will continue with the next line of updater-script
otherwise flashing gets aborted with error in getprop.
format("yaffs2", "MTD", "system", "/system");
the above command explains itself, it is used to format the specified partition
syntax explanation:
format - the main command to direct the cwm to format using the following parameters
"yaffs2" - filesystem type used in the device
"MTD" - type of the partition used in the file system
"system" - location of the partition to be formatted
"/system" - name of the partition to be formatted
ui_print("Format Completed");
the above command is also self explanatory, it directs the cwm to display the following text
enclosed in double quotes in the user interface (display).
after succesful formatting it displays "Format Completed" in the device screen.
mount("yaffs2", "MTD", "system", "/system");
the mount command directs the cwm to mount the following file system and the following partition
the syntax is just as explained in the format command except that this command mounts the
defined partition whereas the format command formats the defined partition.
let's review what we have done till now,
1. we have checked the device to confirm that this is the device for which we created the zip.
2. we have formatted the system partition of the device.(this is only done when a new complete rom is being flashed, for flashing mods you
should never format the system partition!)
3. we have mounted the system partition of the device.
now let's continue,
package_extract_dir("system", "/system");
this command searches for the directory (folder) named "system" in the root of the zip file and
copies all the content of the "system" folder from the zip file into the "/system" partition
which is already mounted by the previous mount command.
remember the structure of the file system in the zip file and the "/system" partition of the device must be always identical.
for eg., you have created a mod by editing the systemUI.apk and you want to flash it, the system UI.apk resides in "/system/app"
so the structure of the file system in the update zip should be "/system/app/systemUI.apk"
ie., the update zip should contain folder named "system" at the root of it and folder named "app" inside the "system" folder and the
modded "systemUI.apk" must be placed inside the "app" folder.
package_extract_file("autoroot.sh", "/tmp/autoroot.sh");
this command searches for the file named "autoroot.sh" in the root of the zip file and
copies the file to "/tmp" folder and names it as "autoroot.sh" (here it does not change the name)
symlink("mksh", "/system/bin/sh");
the above command creates a symlink.
okay, now let's see about symlinks,
symlink is nothing but shortcuts, for example if a file is requiered in two different places instead of copy pasting the file
in two different locations, the file is copied to one of the two locations and in the other location a shortcut to the file(symlink)
is created. the source and the symlink can have different names (actually this is the prime use of symlinks).
to explain in a noob friendly manner,
take the above symlink, it creates a shortcut(symlink) for the command "mksh" and places it in the path of the operating system.
the shortcut(symlink) directs to the file "/system/bin/sh" , so whenever the os gets a request to execute the "mksh" command, the actual
binary that gets excuted will be "/system/bin/sh" .
creating symlinks saves a lot of space because instead of copying the whole file and placing it in requiered places we are just
creating shortcuts which directs to the source file which can be placed anywhere in the file system (generally placed in the path of the os).
set_perm_recursive(0, 0, 0755, 0644, "/system");
the above command is used to set permission recursively for the files and folders present inside a folder (in this case for "/system" folder).
syntax explanation:
0 - uid - it defines that the following permission is set for the user id 0 .
0 - gid - it defines that the following permission is set for the group id 0 .
0775 - dirmode - it defines that 0775 permission to set to directories contained within the specified directory.
0644 - filemode - it defines that 0644 permission to set to files contained within the specified directory.
"/system" - target directory to set the above mentioned permissions.
set_perm(0, 3003, 06755, "/system/bin/ip");
the above command is used to set permission for a individual file (in this case for "/system/bin/ip" file).
syntax explanation:
0 - uid - it defines that the following permission is set for the user id 0 .
3003 - gid - it defines that the following permission is set for the group id 3003 .
06775 - it defines that 06775 permission to set to the specific file.
"/system/bin/ip" - target file to set the above mentioned permissions.
run_program("/tmp/autoroot.sh");
remember the file autoroot.sh from package_extract_file command?
that file is supposed to be a shell script, the above command directs cwm to execute the "autoroot.sh" shell script present in "/tmp" folder.
unmount("/system");
the unmount command directs the cwm to unmount the following partition
the syntax is just as explained in the mount command except that this command unmounts the
defined partition whereas the mount command mounts the defined partition.
Okay now going into slightly complex and/or not widely used updater-script commands,
Ifelse
Syntax:
Ifelse(condition),(do_this),(else_do_this);
Example:
ifelse mount("yaffs2", "MTD", "system", "/system") == "system", ui_print("Mounted!"), ui_print("Mount Failed!");
Ifelse command can be explained simply as asking the system to do something based on the result of a condition.
From the example:
The ifelse command would attempt to mount the MTD partition named "system" to "/system".
If the mounting process succeeds (the condition), the script will display "Mounted!", else it will display "Mount Failed!"
abort()
It just abort's the script execution
Note: it is usually paired with some other command for example the getprop command or with ifelse.
Independently specifying abort() in the updater-script will kill the script abruptly right there so use this command carefully.
ALWAYS LEAVE A BLANK LINE AT THE END OF THE update-script (if the code contains 50 lines then 51 lines should be visible
in the notepad++ including a blank line after the end of the script)
ALWAYS REMEMBER TO SET THE EOL (end of line) CONVERSION OF updater-script
IN UNIX FORMAT BEFORE SAVING (notepad++ > edit > EOL conversion > UNIX format)
the above mentioned commands are just basic edify scripting commands which are generally used in updater-script.
for detailed scripting and coding in edify scripting language check out the following sources:
source of update-binary
introdution to edify
http://forum.xda-developers.com/wiki...cript_language
scratchpad-documenting-edify-commands-for-android-updater-scritps
http://forum.xda-developers.com/show....php?t=1290062

Broken Links!!!
source of update-binary
introdution to edify
http://forum.xda-developers.com/wiki...cript_language
scratchpad-documenting-edify-commands-for-android-updater-scritps
http://forum.xda-developers.com/show....php?t=1290062[/QUOTE]
broken links!!! :silly:

Dude cut the reply short
Sent from my Droid Bionic using xda app-developers app

Sorry brother! i mean these links are not working!!
Current Device : MT11i Xperia Neo V
ROM : Xperia Ultimate HD ™
Build Number : 2.0.3
Kernel : Suave Kernel
Root Status : Rooted
Bootloader : Unlocked
Previous Devices : Samsung Galaxy Y
GT-5360(Sold)
Sent from my MT11i using XDA Premium HD app

tharu_roxx said:
Sorry brother! i mean these links are not working!!
Sent from my MT11i using XDA Premium HD app
Click to expand...
Click to collapse
Dont quote large posts on a whole...be specific...if u dont be specific..it may annoy others and even may affect the beauty of XDA... Next time do take a note of this....
Now please modify ur post..and keep only those links that u were referring to...
-via my "Galaxy Royale"

First i noticed it dude! When um gonna edit it, xda doesn't allowed me(as i was a new member) now it's ok....thanx!!!
Current Device : MT11i Xperia Neo V
ROM : Xperia Ultimate HD ™
Build Number : 2.0.3
Kernel : Suave Kernel
Root Status : Rooted
Bootloader : Unlocked
Previous Devices : Samsung Galaxy Y
GT-5360(Sold)
Sent from my MT11i using XDA Premium HD app

kartiknnn said:
Dude cut the reply short
Sent from my Droid Bionic using xda app-developers app
Click to expand...
Click to collapse
Thanks kartik for the thread...
Learnt some new stuff...thank you...
I would suggest u to add some ready made zips with standard updater scripts... So that people can use them for faster modding...
What say?
Sent from my GT-I9103 using xda app-developers app

bhargav143 said:
Thanks kartik for the thread...
Learnt some new stuff...thank you...
I would suggest u to add some ready made zips with standard updater scripts... So that people can use them for faster modding...
What say?
Sent from my GT-I9103 using xda app-developers app
Click to expand...
Click to collapse
Try these threads
http://forum.xda-developers.com/showthread.php?t=1561463
http://forum.xda-developers.com/showthread.php?t=732957
Hit thanks if i helped!!
Current Device : MT11i Xperia Neo V
ROM : Xperia Ultimate HD ™
Build Number : 2.0.3
Kernel : Suave Kernel
Root Status : Rooted
Bootloader : Unlocked
Previous Devices : Samsung Galaxy Y
GT-5360(Sold)
Sent from my MT11i using XDA Premium HD app

Lemme see guys will try and upload them today
Sent from my GT-I9103 using xda premium

kartiknnn said:
Dude cut the reply short
Sent from my Droid Bionic using xda app-developers app
Click to expand...
Click to collapse
dont you have your exams buddy..
Sent from my GT-I9103 using xda premium

Yup formative 2 be exact
Sent from my GT-I9103 using xda premium

Where to get the update-binary file from???

prohank said:
Where to get the update-binary file from???
Click to expand...
Click to collapse
Read the second paragraph.
Sent from my CM10.1-powered GT-I9103

2. update-binary - it is a binary which is requiered by the clockworkmod to translate the human readable format of the updater-
script to machine readable format for execution of the updater-script in our device.
Click to expand...
Click to collapse
you mean this one?
It says what it is but where to get it from?

prohank said:
you mean this one?
It says what it is but where to get it from?
Click to expand...
Click to collapse
its in any CWM zip of Galaxy R. check in Meta-info/...../Android

prohank said:
you mean this one?
It says what it is but where to get it from?
Click to expand...
Click to collapse
This:
now what is the updater-script and update-binary present in the META-INF>com>google>android in any flashable zip package
Click to expand...
Click to collapse
Sent from my CM10.1-powered GT-I9103

Related

[BASH][CWM] BASH shell for android, credit: nubecoder

First off, all credit goes to nubecoder. Original post:
[Bash] android_bash: Bash, cross-compiled and modified for the android platform.
Introduction...
Most (All) modern Linux distributions utilize bash (Bourne Again SHell) rather than sh (Bourne SHell). Android, by default uses sh. Bash has numerous advantages over sh, sush as tab completion and history support.
Some ROM developers include bash in their ROMs by default. It makes adb, terminal, and scripted commands much easier and more powerful/flexible. I noticed that Sidekick 4G ROMs don't come with bash, hence this thread.
How to Install BASH...
Simpy flash this zip through Clockworkmod recovery: (if ORANGE, check mounts. Not sure if neccessary, but it doesn't hurt)
android_bash-4.1.11(2)_installer-SK4G.zip
Then load your preffered terminal emulator application, type bash, press enter, and there you go.
What's the difference between the SK4G version, and the original Epic 4G version?
- Modified device/product check in updater-script to "SGH-T839"
- Modified $PATH variable in /data/local/.profile to "/sbin:/system/bin:/system/xbin:/data/local/tmp:/bin"
- Modified $PATH variable in /system/etc/bash.bashrc to "/sbin:/system/bin:/system/xbin:/data/local/tmp:/bin"
- [Personal preference] Add alias su='su -c bash' to /data/local/.bash_aliases
- [Personal preference] Modified $PS1 to PS1="\[$txtgrn\]\w $ \[\e[m\]"
- [Personal preference] Modified root $PS1 to PS1="\[$txtred\]\w # \[\e[m\]"
- [Personal preference] Modified location of .bash_history from /sdcard/.bash_history to /data/local/.bash_history
Click to expand...
Click to collapse
As any experienced bash user should know, if you want to revert/modify my personal preferences, just modify "/data/local/.bashrc", "/data/local/.bash_aliases", or "/system/etc/bash.bashrc" to your liking.
Extras...
mntsystem Make /system partition read-only or read-write. Usage:
# mntsystem [ro|rw|status]
Unzip mntsystem.zip, copy mntsystem to /system/bin, chmod 744 /system/bin/mntsystem
Click to expand...
Click to collapse
defaultshell Replace sh with bash, or revert. Usage:
# defaultshell [bash|sh|current]
Unzip defaultshell.zip, copy defaultshell to /system/bin, chmod 744 /system/bin/defaultshell
Click to expand...
Click to collapse
More extras (bash scripts) to come! Please post you own as well!!
PS: I was confused on where I should post this (General vs. Development), figured it isn't "technically" ROM related, so I posted in General. Please move if necessary. Thanks.
mntsystem extra added!
Awesome
Oh man, I have been missing BASH so much, thank you! Now I will finally have a fully-functioning terminal on my phone. I can't wait to tab-complete (seriously).
One question about installation, though. I'm supposed to "install zip from sdcard" in CWM, correct? Will this replace anything I already have, or just copy over the files for BASH? Does it leave sh as the default shell?
nteleky said:
I'm supposed to "install zip from sdcard" in CWM, correct? Will this replace anything I already have, or just copy over the files for BASH? Does it leave sh as the default shell?
Click to expand...
Click to collapse
Yes, flash through Clockworkmod. And, no it will not replace any files already on your phone (unless you already have bash, or some bash configuration files on your phone). Yes, it will leave sh as the default shell.
I can make a bash script to "replace" sh with bash, and post in the Extras if you want. When I say "replace", I mean backup /system/bin/sh, then symlink bash to /system/bin/sh. Therefore any time you try to execute a script through sh, it actually is executed by bash.
Although, for your information bash is/should-be fully backwards compatible with any sh script. I say should be, because:
Bash (Unix shell) - Wikipedia said:
The vast majority of Bourne shell scripts can be executed by Bash without modification, with the exception of Bourne shell scripts stumbling into fringe syntax behavior interpreted differently in Bash or attempting to run a system command matching a newer Bash builtin, etc.
Click to expand...
Click to collapse
Very rare chance though.
I personally keep sh as the default though, android system level scripts are designed for sh (its works), I just use bash for any script that I decide run (through a shell, or adb). So, I start connectbot with a profile that runs "/system/bin/bash" automatically at start.
New extra!
defaultshell Replace sh with bash, or revert. Usage:
# defaultshell [bash|sh|current]
Unzip defaultshell.zip, copy defaultshell to /system/bin, chmod 744 /system/bin/defaultshell
Click to expand...
Click to collapse
Hey
I'm a noob and I'm curious if this could run on my galaxy s 2 running stock?
The bash binary (with supporting files) should work on any rooted android device, however the flashable zip file I posted WILL ONLY WORK on the sidekick 4g.
If you want to install bash, you can download the flashable zip, extract it and copy the the files to their correct location (Quick, easy solution), or you can modify the update-script to work with your phone. Be sure the mounts are the same! Then alter the device check. (More difficult at first, but results in easily reuseable and distributable, flashable zip)
Sent from my SGH-T839 using XDA App
hey after I go to the emulator and type bash.. what should it read?
Sent from my SGH-T839 using XDA App
Should be a green prompt that reads:
/ #
If you cd to, for example, to /sdcard, then the prompt will read:
/sdcard #
If you enter su, then the prompt will become red and use a $ instead of #.
If your prompt says sh-4.1 # then you invoked bash as sh, ie you symlinked (or renamed) bash to sh (usually /system/bin/sh).
Sent from my SGH-T839 using XDA App
well when i enter bash this comes up... 0localhost:// $
and the last two are green ..
What terminal emulator are you using?
Sent from my SGH-T839 using XDA App
The free one.. lol. Idle I just typed emulator and that's the first one in the list ..
Sent from my SGH-T839 using XDA App
I'm not sure why its doing that. Although, all it means is that bash is being accessed from localhost, aka from the phone itself (not an outside source). It doesn't mean anything is wrong.
If it bothers you, you can use connectbot (free on the market, also includes an ssh client) instead. Just create a profile and make sure its local. Then it will work as expected.
Sent from my SGH-T839 using XDA App
Ok. Thanks .. ill let u know if it works
Sent from my SGH-T839 using XDA App
Well it work. Lol.. thank you
Sent from my SGH-T839 using XDA App
bc54 said:
The bash binary (with supporting files) should work on any rooted android device, however the flashable zip file I posted WILL ONLY WORK on the sidekick 4g.
If you want to install bash, you can download the flashable zip, extract it and copy the the files to their correct location (Quick, easy solution), or you can modify the update-script to work with your phone. Be sure the mounts are the same! Then alter the device check. (More difficult at first, but results in easily reuseable and distributable, flashable zip)
Sent from my SGH-T839 using XDA App
Click to expand...
Click to collapse
I tried doing this for my Droid 3, by changing updater-script file to the values I get from my terminal emulator, like so:
Code:
assert(getprop("ro.product.device") == "cdma_solana" || getprop("ro.build.product") == "solana_vzw");
But CWM tells me it fails because "(bad)". Do you have to somehow change the update-binary file as well?
no i didnt change the update-binary file.
however i think the source of you problem is the "/dev/" names the sidekick uses for its partitions.
for example the sidekick "/dev/" name for the partition mounted to "/system" is "/dev/block/stl9"
the droid 3 most likely uses a different "/dev" naming scheme.
find out the "/dev/" name for "/system" on the droid 3.
in the update-script file, replace "/dev/blocl/stl9" with the corresponding name for the droid 3.
find out the "/dev/" name for the "/data" partition on the droid 3.
in the update-script file, replace "/dev/blocl/stl10" with the corresponding name for the droid 3.
then rezip it, and flash. if that fails, then you could just manually copy the files to their respective location using adb, a terminal emulator app, or even a file manager.

[Guide] Edify Script Tutorial - Replacing the Google Market

Return to Contents Page - doubleshot Developers Reference
This guide will teach you how to write an Edify script that replaces the Google market with a different version.
Big thanks to charlieb620 for posting the new market .apks with different color schemes, see the thread Here for more market colors.
The Google market is a great example for a guide on how to replace an app, because not only is it a system app but it's one with a lot of dependencies and will teach you how to deal with this. This is also an app you can't just install an .apk file for, you have to take specific steps to install it.
If you were going to just install a new Google market, you would have to:
Stop all apps that require market licensure to work, halt the market processes, delete the old vending.apk. Then you have to delete the market data directory at /data/data/com.android.vending and find the dalvik-cache file that belongs to the market ( [email protected]@[email protected] ) and delete that too.
Then you rename the new market .apk file to Vending.apk and use root explorer to copy it into your /system/app directory. Once there, you long-press on the Vending.apk file and select 'permissions' from the menu that pops up.
Change the permissions to read/write for owner, read for group, read for others, and nothing for the bottom 3 check boxes. Now it reads rw-r--r-- like all the other apps in the /system/app directory.
Then you reboot your phone and it should work, but you should clear the whole dalvik-cache in recovery, and you should clear cache in recovery too, so all the dependencies on the market get rebuilt the right way.
Click to expand...
Click to collapse
Who want's to deal with all that, and still have it maybe not work right?
No, the right way to replace the market is while the system is down, so doing it as an update you flash through clockworkmod is really the correct answer.
I will assume a windows computer from here on out - that's what I have.
Let's walk through this, and start by listing what you need to begin:
1 - A program you can write the script in. notepad++ is preferred.
2 - A tool to sign your update package. This one is the one i've been using. XDA link. Must be in your main directory, C:
3 - The right update-binary file to work with the MT4GS. I attached the one i've been using to this thread. Thank computerkid23 for that. Go into your signing tool and go to:
/update/META-INF/com/google/android/
...and replace the update-binary with the new one. Here also:
update-binary
Download Link
MD5: f570141f6c8cf7273a58228d0241704d
Size: 190.04 KB
Or you could hit post 10 of this thread for a flashable zip template file.
4 - Some knowledge of Edify scripting. I wrote up some notes that covers some of it, but also links to other threads around XDA with Edify script information. Read up on it, my link Here
5 - A new market .apk file to play with. Here is where ours came from, and it's called Dark.apk
6 - winrar
7 - A MT4GS phone to test your script on, before releasing it to the community.
Now that that we have that all taken care of, let's get started:
1 - Go to the flashable zip builder folder, go to the update folder, then system, and then make a new folder called app
2 - In this new folder, place the new market.apk and rename it to Vending.apk - the capital V is important.
3 - go back up 2 levels to the update folder, and then go to /META-INF/com/google/android/ and open updater-script in Notepad++
4 - Select all and then delete all the text in the updater-script file. Once done, move on to the next part of the guide.
Writing the script:
Since this is my tutorial, i'm going to pass on a concept that means a lot to me - which is formatting the printed output on the screen during installation to be useful. 23 lines down of 40 characters wide is our window to work with.
We will also be using the printed output to the screen to keep the user updated instead of using a progress bar, it's nice to keep them from thinking their phone froze.
Start out by typing these 3 lines of code:
Code:
ui_print("");
ui_print("MT4GS - Market Update Install");
ui_print("");
The ui_print("") command will print to the screen anything between the quotes in the parenthesis. After about 40 characters it will split your text to a new line, wherever the break happens. Could be in the middle of a word.
The second line is the title of our script. When the script is done running, in clockworkmod 4.0.0.9, this will be at the very top of the screen on the phone.
The third line will print blank, just like the first, and seperates our text output to make it easier to read on the MT4GS screen.
The ; character tells the phone to read the next line of code.
Next, we'll type in this code:
Code:
mount("ext4", "EMMC", "/dev/block/mmcblk0p22", "/system");
ui_print("Removing old market ...");
delete("/system/app/Vending.apk");
unmount("/system");
ui_print("");
The mount command will make a partition ready to do things to. Unmounted partitions can be formatted, for anything else they need to be mounted. The way this mount command is written mounts the /system partition specifically on the MT4GS phone.
Next we print a line saying what we are about to do.
Then we do it, which is to delete the old Vending.apk - this is the market app.
Then we unmount the /system partition, since we are done with it for now. This is a good practice to get into, in my opinion, because you won't forget to unmount the partition when you are done with it and you won't accidentally do something to it while you aren't using it.
Lastly, we print a blank line of text to keep things clean on the output screen. We are up to 5 lines of printed text so far.
Next, we'll type in this code:
Code:
mount("ext4", "EMMC", "/dev/block/mmcblk0p23", "/data");
ui_print("Wiping old market data ...");
delete_recursive("/data/data/com.android.vending");
ui_print("");
ui_print("Wiping dalvik-cache ...");
delete_recursive("/data/dalvik-cache");
unmount("/data");
ui_print("");
Again, mounted the /data partition, called for specifically for the MT4GS phone.
Next we print a line saying what we are about to do.
Then we do it, which is to delete the old market /data directory located at /data/data/com.android.vending
Then we print a blank line of text, and another line saying what we are about to do.
Then we do the next thing, which is to wipe the dalvik cache. It's located at /data/dalvik-cache, so we are just going to delete the whole folder. A new one will be generated by Android on the next boot. This is the same as if you did it from the clockworkmod menu.
Then we unmount the /data partition, since we are done with it.
Lastly, we print a blank line. We are up to 9 printed lines so far.
Next, we'll type in this code:
Code:
mount("ext4", "EMMC", "/dev/block/mmcblk0p24", "/cache");
ui_print("Wiping cache ...");
delete_recursive("/cache");
unmount("/cache");
ui_print("");
Again, mounted the /cache partition, called for specifically for the MT4GS phone.
Next we print a line saying what we are about to do.
Then we do it, which is to wipe the /cache. We just wipe the whole partition with the delete recursive command, it's the same as if you did this from the clockworkmod menu.
Then we unmount the /cache partition, since we are done with it.
Lastly, we print a blank line. We are up to 11 printed lines so far.
Next, we'll type in this code:
Code:
mount("ext4", "EMMC", "/dev/block/mmcblk0p22", "/system");
ui_print("Installing new market ...");
package_extract_dir("system", "/system");
set_perm(0, 0, 0644, "/system/app/Vending.apk");
unmount("/system");
ui_print("");
ui_print("...Finished.");
Again, mounted the /system partition. Notice it's the second time we've mounted the same partition. This time, we are going to put on instead of taking away.
Next we print a line saying what we are about to do.
Then we do it, which is to copy the contents of the /system/app folder included in our script to the /system/app folder on the phone. This puts the new Vending.apk file where it is supposed to be.
Then we set the permissions for the new Vending.apk file, this is a very important step. This makes the permissions description on the file read rw-r--r-- like the rest of the files in the /system/app folder.
Then we unmount the /system partition.
Then we print a blank line, and then the last line which says we are done. This puts us at 14 lines, we still need 9 more.
Since we still ned 9 more lines to fill the output screen so that your script output is all the user sees when it's done, heres what I did:
Code:
ui_print("");
ui_print("New Market application provided by:");
ui_print("");
ui_print("charlieb620 at XDA");
ui_print("");
ui_print("Press your hardware back button, then");
ui_print("select 'reboot system now' from the main");
ui_print("menu to continue.");
ui_print("");
I credited the person who provided the market .apk file, then told the user what to do next now that the script is done.
I am sure you could find a useful way of using any blank space you have, or managing the 23 lines of print you get when it's over.
Reading through my notes thread that I linked should get you set in the right directions for any further information you need about commands or their syntax.
The only thing not covered in-depth yet in any of my guides are permissions as far as this script is concerned, but that's coming. Meantime, you can find the information you need by browsing through XDA.
We have successfully removed the old market, cleared all the temporary files that had old market information, installed the new market in the correct location, and then set the proper permissions for the file.
This script is now a self contained update, where all the user has to do is run this script and then reboot their phone. No need to format this, wipe that, it's all done for them by the script itself.
The last steps in the process to make our zip is to save the file we just edited, which looks like this:
Code:
ui_print("");
uiprint("MT4GS - Market Update Install");
ui_print("");
mount("ext4", "EMMC", "/dev/block/mmcblk0p22", "/system");
ui_print("Removing old market ...");
delete("/system/app/Vending.apk");
unmount("/system");
ui_print("");
mount("ext4", "EMMC", "/dev/block/mmcblk0p23", "/data");
ui_print("Wiping old market data ...");
delete_recursive("/data/data/com.android.vending");
ui_print("");
ui_print("Wiping dalvik-cache ...");
delete_recursive("/data/dalvik-cache");
unmount("/data");
ui_print("");
mount("ext4", "EMMC", "/dev/block/mmcblk0p24", "/cache");
ui_print("Wiping cache ...");
delete_recursive("/cache");
unmount("/cache");
ui_print("");
mount("ext4", "EMMC", "/dev/block/mmcblk0p22", "/system");
ui_print("Installing new market ...");
package_extract_dir("system", "/system");
set_perm(0, 0, 0644, "/system/app/Vending.apk");
unmount("/system");
ui_print("");
ui_print("...Finished.");
ui_print("");
ui_print("New Market application provided by:");
ui_print("");
ui_print("charlieb620 at XDA");
ui_print("");
ui_print("Press your hardware back button, then");
ui_print("select 'reboot system now' from the main");
ui_print("menu to continue.");
ui_print("");
and then go back to the flashable zip builder folder, and then into the update folder. Select both META-INF and system folders, and zip in winrar. ZIP not RAR. Name your zip New_Market.zip
Now move this zip file up one level, to the main flashable zip folder. Drag it onto the DRAGandDROPsignONLY.bat file in the folder.
Wait until the dos prompt finishes and closes.
Go to the _out folder and get your new ready to install update, called New_Market_Signed.zip
That's it, just get that to the phone and flash in clockworkmod recovery.
Hope this was helpful!
*Unzip the update-binary to use.
*Go to charlieb620's Thread for ready-made install scripts for the rest of the market colors.
wow you really put a lot of work into your write ups lol =D. good job.
I don't think I've appreciated a single post on xda more than this one. Thank you. This is the kind of thing I love.
My goodness... you never cease to amaze me Blue. As a developer I've never had much patience for write-ups, so I can applaud your efforts! Learning the hard way blows (although does yield better lessons sometimes)!
On a side note, I applied the Dark Market update zip thinking that it applied the (regular) market... I wasn't really sure what "Dark" stood for. So I opened it and was surprised to see a - you guessed it - DARK version of the newest Market. Anyways, point being is that I opened it, checked it out, closed it and a few minutes later it was uninstalled and replaced with the regular (newest) Market. I like the regular Market, so it worked out for the best, but just figured I'd let you know.
nbetcher said:
My goodness... you never cease to amaze me Blue. As a developer I've never had much patience for write-ups, so I can applaud your efforts! Learning the hard way blows (although does yield better lessons sometimes)!
On a side note, I applied the Dark Market update zip thinking that it applied the (regular) market... I wasn't really sure what "Dark" stood for. So I opened it and was surprised to see a - you guessed it - DARK version of the newest Market. Anyways, point being is that I opened it, checked it out, closed it and a few minutes later it was uninstalled and replaced with the regular (newest) Market. I like the regular Market, so it worked out for the best, but just figured I'd let you know.
Click to expand...
Click to collapse
You know, it's funny - one of those little things that's a D'oh! moment.
When I first saw that, I thought you meant you just installed a different (or your stock) version of the market over it.
I browsed the thread again since I directed someone here and when I got to the bottom I just realized you were letting me know Google forced a market update when you connected to them. Funny I didn't read that right sooner.
Hi guys!
If i want to Freeze some app in updater-script, how could I do it?
What codes i have to use?
THanks!
Thank you blue! You might not know it but you just contributed to the cause of adding devs to the forum. :thumbup:
Achievement unlocked: knowledge acquired!
sent from a Nokia 3210
is there any syntax highlighter + editor for edify script.?
Notepad ++.....but I don't think it highlights
Template: flashable zip update
Return to Contents Page - doubleshot Developers Reference
nfs1mw said:
is there any syntax highlighter + editor for edify script.?
Click to expand...
Click to collapse
Not sure, I use notepad++ in windows and while my preference is ever for the lightest weight program notepad++ is too awesome to not use, it's the only editor of that type you need on windows pretty much.
If the regular windows notepad could do this stuff without destroying the files i'd use that instead, so i've never checked into anything that was like that in notepad++.
I taught myself html in a notebook with a pen way back when, and the advantages of writing the code down and typing it in beyond the memory exercise itself is not having to jog back and forth between another document on your screen(s) and keeping the actual machine in use more clutter free.
(that said - syntax highlighting and end-user formatting to code in editors is so nice...)
Besides, if the internet dies tomorrow your physical notebook that takes nothing more then opening up and looking at will still work. Then again, i'm anal about backups.
In linux I just use gedit.
----
Flashable Zip Template:
unsigned template zip download:
doubleshot_unsigned_flashable-update_template.zip
Download Link
MD5: 7591ff4996f84a394c46ae375c254a4c
Size: 125.64 KB
Edit before flashing.
signed template zip download:
doubleshot_signed_flashable-update_template.zip
Download Link
MD5: afc51c4bf34dcdd76d1d62061fa3ee5b
Size: 124.25 KB
Edit before flashing.
Zip Contains:
- Empty data folder.
- Empty system folder.
- Empty sdcard folder.
- META-INF folder set up, with the correct update-binary and a template updater-script file.
updater-script template:
- wipe cache
- wipe dalvik cache
- wipe data
- wipe system
- wipe sdcard
- extract whatever ends up in the system, data, sdcard folders.
- clean up
Pastebin of updater-script.​Edit before using, otherwise you will erase everything on the device...
...just delete what you don't want and go from there. I got tired of typing the same stuff in all the time so here ya go.
Compatible with all versions of CWM to date (April 2012) - CWM 4xx Recovery versions don't support format correctly and is why it's not here.
Current CWM is 5xx​
Need to sign it? On windows This one is great.
Want to fill those empty folders? Start with system and this thread:
doubleshot de-odexed system images
Is there anybody know this? Or is there anybody know where to ask this question?
in .zip file (for CWM) there is an updater-script file...
I want to delete some files but i dont want to write the exact names of the files... Is there any way to delete some thing like x*.* or t*.apk or talk*.* etc...
for example if i want to delete all the files which starts with "a" letter... How can i do this?
I know
delete("...");
delete_recursive("...");
commands... But i couldn't find out if there is any way to do this?
Thank you for your answers...
Thank you for taking the time to write this. I had some questions regarding editing updater-scripts (for a different device) and this helped me out a lot.
-h311s|DR0ID
.
Quick question, for a delete command can you use a wildcard?
Like this:
delete("/system/app/SamsungHub.*");
I only ask because some roms have .apk and some are .odex (for example). Looking to make one script work for any stock rom on my phone.
Also, according to my TWRP log I'm able to mount /system but /data threw an error:
mount: failed to mount /dev/block/mmcblk0p29 at /data: Device or resource busy
Looks right in the partition area:
Symlink_Path: /data/media/0
Symlink_Mount_Point: /sdcard
Primary_Block_Device: /dev/block/mmcblk0p29
Any thoughts why?
I don't know if there is an option for wild card, never tried. But it can't hurt just to throw in a remove line for both options, simple fix
Being you have an emulated SD, when flashing something from data I believe data partition is mounted by default and that's why it says busy. My best guess is you don't need to add the mount data command
Sent from my Nexus 4 using XDA Premium 4 mobile app

[DEV][SCRIPT] First-Boot App Install

First-Boot Install System​
I have searched Far and wide for something like this since i first put out SleeperROM in November and always come up empty.
So with the latest release, i decided it was finally time to do it myself.
All you have to do is, using the following package as a template either on its own or in your ROM, make sure your batch folder with the .apk's to install are in /data/.firstboot/
Why
Some apps like QuickPic, ConnectBot, TinyFlashlight, Flash, Google Goggles and others that rely on linked libs don't like to simply be copied to their install dir because many won't install their own libs unless the PackageManager does it and/or they won't add themselves to the packages list (like QuickPic). The old solution is to include the lib either in the /data/data/appdir/lib with the rom install OR in /system/lib but this is quite wasteful especially in the case of big apps like Flash where including the libs separately from the app effectively doubles the space taken up on the rom by that single app since the apk still contains the lib files within.
So the solution is to install on first boot by including the apps in a batch folder for the script to process.
How it works
What it does is run from the init scripts, as one of the last scripts to run, it waits until the Android core system is up (checks to be sure by waiting for the SystemUI process is running then waits for an additional 10 seconds)
Then runs /data/.firstboot.sh, which is where you should put your first boot routines. Included in this script is the batch app installer which looks for the apps in /data/.firstboot/ and stores temporary app backups in /cache/tmp -- so be mindful that on MTD roms, the cache partition is smaller so may have to modify the $tmp variable to wherever you want to store temporaries
After installing, it sleeps for a proportional number of seconds (5 seconds per app installed) to ensure there is no race condition between installs or the final permissions_fix, zipalign and tmp cleanup. The /data/.firstboot.sh script removes itself when everything is complete.
The remaining components are kept in there for additional use by the /etc/init.d/Y02firstboot script in the future, so then all that needs to be put on the phone is a new /data/.firstboot/ dir and replacement /data/.firstboot.sh to run a batch of updates.
The Apps MUST be named by their package name.
I.e. Titanium Backup MUST be named com.keramidas.TitaniumBackup.apk
the file name must correspond with the name of the data dir in /data/data/ the script is lazy in that way, i didn't feel like keeping a file manifest of installs, instead just like to drop in apps to install.
The installer
consists of the following components:
- /system/etc/init.d/Y02firstboot
- /system/xbin/rsync
- /system/xbin/fix_permissions
- /system/xbin/batch_zipalign
- /system/xbin/sleeperlog (echos, logcats, and writes a log of activity to /sdcard/sleeperlog.txt)
- /data/.firstboot.sh
- /data/.firstboot/ (batch app directory)
- NOT INCLUDED, there must be a busybox bin somewhere in $PATH - this is not a problem for most roms
See the package link for a ready to use first-boot installer [CWM] flashable. Just drop your apks into /fs/data/.firstboot/ for a batch app updater
Download the template/usable package
DOWNLOAD MOD_CWM-FirstBoot-20120112.zip
File size: 341.07 KB / MD5 23d88c349b8d2fa3cd2f9958ae99a1f6
​
THE MAIN COMPONENTS:
/system/etc/init.d/Y02firstboot
Code:
#!/system/bin/sh
# execute post-install script on First boot
# 01022012 SENSEISIMPLE
SLEEP=3
FBSCR="/data/.firstboot.sh"
BB="busybox"
pg () {
$BB ps | $BB grep "[email protected]" | $BB grep -v "$( echo $BB grep [email protected] )"
}
if [ -f "$FBSCR" ]; then
#install apps on first boot after system services have started
sleeperlog "Found $FBLOC"
sleeperlog "Waiting for system"
$BB chmod 0755 $FBSCR
while : ; do
if pg systemui; then
$BB sleep 10
sleeperlog "system loaded."
log -p i -t boot "Executing $FBSCR script"
sleeperlog "Running FirstBoot init"
$FBSCR
break
fi
sleeperlog "WAITING FOR SYSTEM SERVICE: sleeping for $SLEEP s..."
$BB sleep $SLEEP
done
fi
/data/.firstboot.sh
Code:
#!/system/bin/sh
#
# 20120107 - SENSEISIMPLE
#
log -p i -t init:firstboot "INIT.firstboot BEGIN: USER SCRIPT $FBLOC.sh"
sleeperlog "FirstBoot Script OK TO RUN"
FBLOC="/data/.firstboot"
tmp="/cache/tmp/firstboot"
bak="$tmp/bak/data/data/"
BB="busybox"
RM="$BB rm"
CP="$BB cp"
MV="$BB mv"
MKDIR="$BB mkdir"
LS="$BB ls"
CHMOD="$BB chmod"
SLEEP="$BB sleep"
GREP="$BB grep"
pg () {
$BB ps | $BB grep "[email protected]" | $BB grep -v "$( echo $BB grep [email protected] )"
}
$CHMOD 0777 /data
#install apps on first boot
if [ -d $FBLOC ]; then
sleeperlog "Found $FBLOC"
if [ "$($LS $FBLOC)" ]; then
cd $FBLOC
$MKDIR -p $bak
for pkg in *.apk; do
log -p i -t init:firstboot "INIT.firstboot INSTALLING: $pkg"
sleeperlog "PREPARING: $pkg"
pkgname=${pkg%.*}
sleeperlog "BACKING UP APP DATA - $pkgname"
#back up data, delete the original data dir to prevent install errors (pm isn't very good at what it does)
if [ -d /data/data/$pkgname ]; then
$CP -a /data/data/$pkgname $bak/$pkgname
$RM -rf /data/data/$pkgname
fi
#WAIT, then install, then WAIT SOME MORE
$SLEEP 2
sleeperlog "INSTALLING $pkgname"
pm install -r $FBLOC/$pkg &
$SLEEP 10
#REIntegrate application data
if [ -d "$bak/$pkgname" ]; then
sleeperlog "\nSYNCING APP DATA \n\n$(/system/xbin/rsync -auv --exclude=lib $bak/$pkgname/ /data/data/$pkgname/)\n"
fi
i=$((i+1))
#Move the install .apk to tmp
if $LS /data/app | $GREP "$pkgname"; then
sleeperlog "Package appears to have installed."
$MV "$pkg" $tmp/
fi
#If the firstboot batch dir is empty, delete it now
! [ "$($LS $FBLOC)" ] && $RM -rf $FBLOC
done
#WAIT for [#ofapps x 5 seconds each] to avoid a race condition
waitsecs=$(( i * 5 ))
sleeperlog "Waiting for ${waitsecs}s before Fixing Permissions"
$SLEEP $waitsecs
sleeperlog "Fixing Permissions $(/system/xbin/fix_permissions)"
sleeperlog "Running batch zipalign \n\n $(/system/xbin/zipalign)"
sleeperlog "Clearing tmp $tmp"
fi
fi
sleeperlog "FIRSTBOOT SCRIPT COMPLETE"
log -p i -t init:firstboot "INIT.firstboot SELF DESTRUCT FIRSTBOOTSCRIPT"
if ! [ "$($LS $FBLOC)" ]; then
$MV $0 $tmp/.firstboot
# COMMENT THIS OUT FOR DEBUGGING, TO NOT REMOVE THE TMP DIR
$RM -r $tmp
echo ""
fi
echo -e "#\n#COMPLETED ON $(date)\n#" >> $0
sleeperlog "FirstBoot Apoptosis"
log -p i -t init:firstboot "INIT.firstboot END: USER SCRIPT $FBLOC.sh"
THANKS
CyanogenMod team for the Fix_permissions script
DarkyROM for the Batch Zipalign script
Saving this seat . . .
does this work with a bml rom?
^^^^In theory, it would work with an NTFS rom, if one existed - different filesystems don't [usually] create any changes on the surface... if you try to copy a file from a partition of any file system to a partition of any other file system, you don't have to explicitly tell the system the fs types involved. I haven't looked through the entire script, but if there are any commands that must specify the partition type, it would be a simple matter of changing any occurances of EXT4 to YAFFS2, etc.
This could be a great way to make a clean reinstall with all of your apps intact (minus app data, do a separate backup with your backup app of choice) - first, backup your installed apps by copying them to the appropriate directory, then do a full wipe and install, with the script automatically reinstalling your apps on first boot...
EDIT: I just looked through the script more closely. First, it appears that data is backed up. Second, I can confirm that the standard, non-file system-specific linux commands are used for file operations (cp to copy, etc), so this script shouldn't need any adjustment to accomodate different file systems
Sent from my SPH-D700 using XDA App
Is it possible for someone to develop an application to backup your personal apps and then running a script in clockwork or on first boot that does the same thing as this, alllowing for personal apps to be in the rom directly after flashing. I understand that sometimes apps may not be compatible, but can randomroms rdu script be modified to choose to do this?
Sent From My Cyan4g
Good looking script SenseiSimple!!
Okay, I'm trying to use this script, but you said to put the apps in fs/data/firstboot/ but where is "fs"? I found the "firstboot.sh" file, but I'm sure I can't put the apk's in there...
In loving memory of my son "Jeffrey Ryan Giles" 11/17/1992 to 11/25/2011 :'(
sniperkill said:
Okay, I'm trying to use this script, but you said to put the apps in fs/data/firstboot/ but where is "fs"? I found the "firstboot.sh" file, but I'm sure I can't put the apk's in there...
In loving memory of my son "Jeffrey Ryan Giles" 11/17/1992 to 11/25/2011 :'(
Click to expand...
Click to collapse
If you look at the folder structure inside the SleeperROM zip, you'll see he uses an fs directory to hold his system and data folders for installation. If you're developing a ROM, you can adapt the script to point to wherever your data folder is (most other ROMs just have system and data in the root directory of the zip, so the path would just be data/firstboot/).
EDIT: no need to look in SleeperROM zip, the firstboot zip in the OP has the same folder structure. It just doesn't seem to have the firstboot directory inside data. You'll need to add that.
Sent from my SPH-D700 using XDA App
bbelos said:
If you look at the folder structure inside the SleeperROM zip, you'll see he uses an fs directory to hold his system and data folders for installation. If you're developing a ROM, you can adapt the script to point to wherever your data folder is (most other ROMs just have system and data in the root directory of the zip, so the path would just be data/firstboot/).
EDIT: no need to look in SleeperROM zip, the firstboot zip in the OP has the same folder structure. It just doesn't seem to have the firstboot directory inside data. You'll need to add that.
Sent from my SPH-D700 using XDA App
Click to expand...
Click to collapse
Thanks for the reply buddy, so what I THINK your saying is to create a folder called "first boot" in my data folder?
In loving memory of my son" Jeffrey Ryan Giles" 11/17/1992 to 11/25/2011 - RIP :'(
sniperkill said:
Thanks for the reply buddy, so what I THINK your saying is to create a folder called "first boot" in my data folder?
In loving memory of my son" Jeffrey Ryan Giles" 11/17/1992 to 11/25/2011 - RIP :'(
Click to expand...
Click to collapse
Are you trying to do this in a ROM or on the phone? Sorry if that's a dumb question, but I just want to be sure we're on the same page.
Sent from my SPH-D700 using XDA App
sniperkill said:
Thanks for the reply buddy, so what I THINK your saying is to create a folder called "first boot" in my data folder?
In loving memory of my son" Jeffrey Ryan Giles" 11/17/1992 to 11/25/2011 - RIP :'(
Click to expand...
Click to collapse
bbelos said:
Are you trying to do this in a ROM or on the phone? Sorry if that's a dumb question, but I just want to be sure we're on the same page.
Sent from my SPH-D700 using XDA App
Click to expand...
Click to collapse
i hadn't noticed my zip routine apparently skips empty .folders
in the zip, there SHOULD have been /fs/data/.firstboot into which you place whatever apk files named according to their actual package name i.e. com.keramidas.TitaniumBackup.apk for Titanium Backup, com.alensw.PicFolder.apk for QuickPic and so on...
you can find out this info in Titanium Backup by finding the app in the list and tapping its name to show the data store location.
it HAS to correspond to the actual package name in order to properly back up the data files because the package manager binary as run from a script won't overwrite the data dir so the old data has to be synced back into the new install (rsync)
I am currently refactoring the script to reduce the number of dependencies... the system will then consist of the init.d script, zipalign and rsync bins, and the /data/.firstboot.sh, /data/.firstboot dir all in one place rather than scattered throughout the system.
irule9000 said:
Is it possible for someone to develop an application to backup your personal apps and then running a script in clockwork or on first boot that does the same thing as this, alllowing for personal apps to be in the rom directly after flashing. I understand that sometimes apps may not be compatible, but can randomroms rdu script be modified to choose to do this?
Sent From My Cyan4g
Click to expand...
Click to collapse
it would be possible to create an app to do this, and i considered it because of the need to make sure the android system is fully loaded for package manager to work, but given the requirement for full root access to start running before the system is up without having to worry about android permissions or getting SuperUser approval it's easier/more effective to do it as part of the system init in a script.
as far as randomking's rdu script, they would be compatible, but they exist separately as in one shouldn't interfere with the other, because the firstboot script runs long after install once the system is up and running.
you could modify the rdu setup to include/exclude the /data/.firstboot dir and .firstboot.sh script based on the selected config, since the init script does nothing if it doesn't see the /data/.firstboot.sh file, and the .firstboot.sh script does nothing if it doesn't see the .firstboot dir
SenseiSimple said:
it would be possible to create an app to do this, and i considered it because of the need to make sure the android system is fully loaded for package manager to work, but given the requirement for full root access to start running before the system is up without having to worry about android permissions or getting SuperUser approval it's easier/more effective to do it as part of the system init in a script.
as far as randomking's rdu script, they would be compatible, but they exist separately as in one shouldn't interfere with the other, because the firstboot script runs long after install once the system is up and running.
you could modify the rdu setup to include/exclude the /data/.firstboot dir and .firstboot.sh script based on the selected config, since the init script does nothing if it doesn't see the /data/.firstboot.sh file, and the .firstboot.sh script does nothing if it doesn't see the .firstboot dir
Click to expand...
Click to collapse
Expanding on the rdu script idea, how about a prop variable in the config to specify a user apps directory on the sdcard (best if standardized)? The user can store the apks to be installed after a clean flash in this directory. The rdu script would be modified to copy those apks to the firstboot directory. Although how to handle data? Maybe another script to be run before flashing that checks the apks in the sdcard folder, and copies the current data folder to the sdcard. This data is then restored somehow with the firstboot script. This all can be in addition to the firstboot apps included with the rom.
Sent from my SPH-D700 using XDA App
app
I honestly have no developing experience. To clarify, I was I simply asking if the app could back up the users personal apps/data to the specified folders, to make this script fool proof. Then when a rom is flashed the randomromkings rdu script which currently decides on lite roms or full roms could be modified to either install apps or not install apps depending on the rom compatibility. Finally data is wiped, rom flashes, and your script runs on boot allowing the apps to all be there. Expanding on that if the ROM allows apps to be re installed via your script, through the modified rdu, your script could be moved from one directory to another allowing the process to happen and at the end moves itself back to the original directory. This means that the end user who has no clue how to do anything but flash roms (like myself, but I want to learn) has done nothing accept backing up their apps. I know this is all hypothetical, but would this be possible, and also I have another idea that is probably impossible. If a script could be written so that the apps are backed up when the rom flashes, then the rom automatically does a factory restore and wipes the various caches, meaning that less people are going to have force close issues or other avoidable bugs because they didnt wipe. thanks for all your hard work
Clear Me Here !!
You said that the script (.firstboot.sh) removes itself, but does it remove Y02firstboot script from init.d?? I don't think so, also, there are no disadvantages of this after first boot, as it won't find .firsboot.sh and skip the operation, but why shud it execute unneccesarily everytime??
@OP--Plz. tell me if i am right or wrong.......If right, plz. add a function to remove that script from init.d. However files in /xbin are OK though, so no need to remove them............
Everybody is writing and making this appear as complicated as possible! So let me clarify what I believe the idea is here. First of all, the 'RDU script' I assume you're referring to is simply a flash-able zip to set you phone for a lite or full installation. It sets a config file. I use it in my rom, and I also currently use that config file to set several other features upon installation, and changeable at anytime one of my themes is flashed.
RDU was simply meant to jump start the idea of developers making installations more uniform. Which has happened to various extents, for example, I've used this first-boot install to solve my quickpic(I love the app) and flash pre-install problems. It also fixes usb tether, vlingo, terminal, etc.
SO, what are we saying here? We'd like to be able to backup our apps to the sd card, as many apps can do for us. Then, we'd like to either:
A. Build a script into a rom to restore these apps prior to or upon installation.
or
B. Build a separate script which would be run AFTER a rom installation to restore these apps from CWM.
Yes?
P.S. I see this is very late to the game, didn't realize this thread was being revived...
Still. Neat idea, sorry I hadn't noticed it yet.
+1 Thanks
After integrating this into my custom ROM, my phone (Galaxy S 4G) would only install the first .apk file in the .firstboot directory. After I removed the code which tells it to backup/restore the /data/data directories, it worked fine. I won't need that code since the ROM does a full wipe of /data every time anyway, but I'm not sure why it doesnt work when it's there. I'm not well versed enough with Java's syntax yet to comprehend why.
Also, your first post says that it should record logs to \sdcard\sleeperlog.txt but the script tries to record it to \sdcard\sleeperromlog.txt and neither one of those files actually appear on the sd card.
Edit: I had to remove the check to make sure the .firstboot directory is empty before deleting it, but it works fine on my Galaxy S 4G ROM as long as there are no /data/data directories for the programs I am installing.
does anyone still have a template of this? The link is down.
Edit: nevermind I don't need it anymore.

Make your own updater-script!

To create updater-script or to edit updater-script you need Notepad++ (don’t use notepad). Download it from Here and install in your pc
updater-script is located in Meta-inf/com/google/android/updater-script
To create your own updater-script
Open notepad++ and from file menu select new and create the commands and create your own updater-script with this tutorial
After typing the commands save it as all types(*.*) and name it as updater-script and click save and put it in folder Meta-inf/com/google/android/updater-script
In this tutorial i will explain you all commands used in updater-script so that you can edit or create updater-script
ui_print – This command prints the prints the word inside the quotations
Example – ui_print(“xolo – next level”); prints xolo next level in your cwm recovery
mount – This command mounts the partition, if you want to add files to system partition you have to mount system partition, data for data partition
To mount system - mount(“ext4″, “EMMC”, “/dev/block/mmcblk0p5″, “/system”);
Here mmcblk0p5 is the name of system partition for mtk 6589 chipsets (this name varies from device to device)
To mount data - mount(“ext4″, “EMMC”, “/dev/block/mmcblk0p7″, “/data”); (partition name varies from device to device)
format - This command formats the partition specified
It is highly recommended to include this command to format system and data if you are making updater-script for ROM
To Format system - format(“ext4″, “EMMC”, “/dev/block/mmcblk0p5″, “0″);(partition name varies from device to device)
To Format data - format(“ext4″, “EMMC”, “/dev/block/mmcblk0p7″, “0″);(partition name varies from device to device)
package_extract_dir(” “, “/”) – This command extracts all the files from the folder mentioned inside first quotation to the partition or directory inside second quotation
For system - package_extract_dir(“system”, “/system”);
(this copies all files from system folder in zip to system partition in phone)
For data - package_extract_dir(“data”, “/data”);
package_extract_file(” “,”/”) - This command extract the single file inside between first quotation from zip to the partition or directory inside second quotation
symlink – This command creates links to its executable files
Here is an example
for super su binaries - symlink(“/system/xbin/su”, “/system/bin/su”);
set_perm_recursive - This command sets permission for folders
here android uses unix permission system
in unix
4 – read
2 – write
1 – execute
so
rwx is 4+2+1 = 7
rw is 4+2 = 6
rx is 4+1 = 5
Example - set_perm_recursive(0, 0, 0755, 0644, “/system”);
In this 0 is a user id for owner that refers to root. It means that permission owner for system folder. and 0 is root user means it unrestricted access to system. it is given in order to run programs to run properly
second 0 also refers to root. but here it refers to group id 0
we are only seeing about folders because “set_perm_recursive” is a command that sets permission to folders
next 0755 it means rwxr-xr-x permission has been given to system folder and rw-r-r is set for all folders inside system folder
set_perm – This command sets permission for a specific file
Example - set_perm(1000, 1000, 0640, “/system/etc/bluetooth/auto_pairing.conf”);
here the 1000 refers to user id system and 0640 is rw-r—–
and this command sets the permission rw-r—– for the file auto_pairing.conf
unmount – This command unmounts the partition
Example - unmount(“/system”); – unmounts system
General rule in updater-script – all commands should end with semi colon ; otherwise it will show error and if cwm or twrp shows status 7 error the error is in updater-script:laugh:
try fixing it by going through this thread
Use zipme app from Playstore to Make .Zip Flashable Files....
----------Signature---------
Need Some Cool Guides Visit Hmpshah Guides
Zeuscluts said:
Use zipme app from Playstore to Make .Zip Flashable Files....
----------Signature---------
Need Some Cool Guides Visit Hmpshah Guides
Click to expand...
Click to collapse
i use kitchen always
anyways thanks for the info :good:
and do you know any app to decompile in phone like apk multitool in pc?
Renaming is the Option
pradeepxtremehacker said:
i use kitchen always
anyways thanks for the info :good:
and do you know any app to decompile in phone like apk multitool in pc?
Click to expand...
Click to collapse
Bro its not possible,
but if you rename the .apk to .zip
you can decompile it,
but you need a PC to recompile.
Eg
sms.apk to sms.zip
then just Unzip sms.zip
you can get the Details.
Zeuscluts said:
Bro its not possible,
but if you rename the .apk to .zip
you can decompile it,
but you need a PC to recompile.
Eg
sms.apk to sms.zip
then just Unzip sms.zip
you can get the Details.
Click to expand...
Click to collapse
bro i think you are saying like extract
in fact we no need even to rename to extract we can directly extract with es file explorer from .apk but when we extract the xml will not be editable it will show like boxes
i am asking like a app like apk multi tool
No not Possible in Mobile.
Yet
Hope anyone Make this Possible In Future.
:Fingercrossed:
Let's Hope for the Better. ..
----------Signature---------
Need Some Cool Guides Visit Hmpshah Guides
OK thanks
Sent from my GT-I9070 using xda app-developers app
I have a question, i and my friend both port the rom for HTC One International to HTC One J (the japan variant of HTC One) and we edit the updater-script the same way but then my friend's rom can be flashed without any error and my, it's stuck at format step, the log file say:
Code:
format() expects 4 args, got 5
format() expects 4 args, got 5
here is the command line that was corrupted:
HTML:
format("ext4", "EMMC", "/dev/block/mmcblk0p38", "0", "/system")
my friend use the same and he has no error @@
Can you tell me why i can't make the rom to be able to flashed
Very helpful... Thanks.
KuroKeita said:
I have a question, i and my friend both port the rom for HTC One International to HTC One J (the japan variant of HTC One) and we edit the updater-script the same way but then my friend's rom can be flashed without any error and my, it's stuck at format step, the log file say:
Code:
format() expects 4 args, got 5
format() expects 4 args, got 5
here is the command line that was corrupted:
HTML:
format("ext4", "EMMC", "/dev/block/mmcblk0p38", "0", "/system")
my friend use the same and he has no error @@
Can you tell me why i can't make the rom to be able to flashed
Click to expand...
Click to collapse
The format command depends on the update-binary you are using. If you use the one your friend is using it will probably work with the existing command. If you would like to keep using your existing update-binary, change the above line to
Code:
format("ext4", "EMMC", "/dev/block/mmcblk0p38");
SuperR. said:
The format command depends on the update-binary you are using. If you use the one your friend is using it will probably work with the existing command. If you would like to keep using your existing update-binary, change the above line to
Code:
format("ext4", "EMMC", "/dev/block/mmcblk0p38");
Click to expand...
Click to collapse
Yeah, i changed to that and the rom was flashed properly, thanks guys
Sent from my HTC J One using Tapatalk
Zeuscluts said:
No not Possible in Mobile.
Yet
Hope anyone Make this Possible In Future.
:Fingercrossed:
Let's Hope for the Better. ..
----------Signature---------
Need Some Cool Guides Visit Hmpshah Guides
Click to expand...
Click to collapse
Yes I think so. Even Stericson's NinjaMorph can't do it.
Hello. I am making a flashable zip that flashes a modified build.prop. i dont know much about how to do it. the screenshot attached below, shows the code i already have. All i want is an updater script that will delete the build.prop and replace it with the modified one.
[HELP] generic updater script
I do have a "strange" question: is possible to update (overwrite) just specific files/dir ?
This could allow to make "generic" roms for a whole class of devices (for example all MT65xx).
Thanks in advice for any suggestion you can provide.
How to delete files in order to replace them with new ones? You didn't specify any commands for that one.
Sent from my Nokia_XL
I need help porting a ROM that always gives me status 7 and error setting permissions.
I think it is having problems identifying my device and I might've erased the get_prop commands.
Any help?
thank you
Hey. was wondering if you had any idea what im doind wrong by this log:
AROMA INSTALLER version 2.70B6
(c) 2013 by amarullz xda-developers
ROM Name : Project Unity
ROM Version : Google Apps
ROM Author : LiquidSmokeX64
Device : Any Device
Start at : Sat Aug 9 19:34:06 2014
Installing Google Core Apps
Mounting system...
Copying files...
Extract: /system/app/GoogleContactsSyncAdapter.apk
Extract: /system/etc/permissions/com.google.android.ble.xml
Extract: /system/etc/permissions/com.google.android.camera2.xml
Extract: /system/etc/permissions/com.google.android.maps.xml
Extract: /system/etc/permissions/com.google.android.media.effects.xml
Extract: /system/etc/permissions/com.google.widevine.software.drm.xml
Extract: /system/etc/permissions/features.xml
Extract: /system/etc/preferred-apps/google.xml
Extract: /system/framework/com.google.android.ble.jar
Extract: /system/framework/com.google.android.camera2.jar
Extract: /system/framework/com.google.android.maps.jar
Extract: /system/framework/com.google.android.media.effects.jar
Extract: /system/framework/com.google.widevine.software.drm.jar
Extract: /system/lib/libAppDataSearch.so
Extract: /system/lib/libconscrypt_gmscore_jni.so
Extract: /system/lib/libgames_rtmp_jni.so
Extract: /system/lib/libgcastv2_base.so
Extract: /system/lib/libgcastv2_support.so
Extract: /system/lib/libgmscore.so
Extract: /system/lib/libgoogle_hotword_jni.so
Extract: /system/lib/libgoogle_recognizer_jni_l.so
Extract: /system/lib/libjgcastservice.so
Fixing Permissions...
Installing Google Chrome
package_extract_file: can't open /system/app/Chrome.apk for write: Read-only file system
package_extract_file: can't open /system/lib/libchrome.1985.128.so for write: Read-only file system
Installing Cloud Print
package_extract_file: can't open /system/app/CloudPrint.apk for write: Read-only file system
Installing Google Play Music
package_extract_file: can't open /system/app/Music2.apk for write: Read-only file system
Installing Gmail
package_extract_file: can't open /system/app/Gmail.apk for write: Read-only file system
Installing YouTube
package_extract_file: can't open /system/app/YouTube.apk for write: Read-only file system
package_extract_file: can't open /system/lib/libm2ts_player.so for write: Read-only file system
Fixing permissions again...
Finished
script result was [@Finished]
Installer Sucessfull (Status 0)
End at : Sat Aug 9 19:34:06 2014
Problems with script
Greetings, I am new to the forum and have a question, I use a program to change my boot image, this generates me an update.zip and works perfect, but using as a basis the same script and copy any file to the same path, the script does nothing at all.
this is the script that changes the boot image
ui_print("Flashing logo...");
show_progress(0.200000, 0);
package_extract_file("logo.bin", "/dev/logo");
ui_print("Patched!");
ui_print("");
ui_print("Now you can reboot your phone");
Click to expand...
Click to collapse
and this is my script
ui_print("Flashing logo...");
show_progress(0.200000, 0);
package_extract_file("test.txt", "/dev/test.txt");
ui_print("Patched!");
ui_print("");
ui_print("Now you can reboot your phone");
Click to expand...
Click to collapse
i don't see what the problem is, any ideas?
Gorgonitte said:
Greetings, I am new to the forum and have a question, I use a program to change my boot image, this generates me an update.zip and works perfect, but using as a basis the same script and copy any file to the same path, the script does nothing at all.
this is the script that changes the boot image
and this is my script
i don't see what the problem is, any ideas?
Click to expand...
Click to collapse
if understood correctly, your script should extract to /tmp/scriptname.sh or /temp/scriptname.sh
after which your updater script in you meta-inf/com/google/android directory of your update.zip
need to include instruction to set permission and execute the script that actually performs the function.
m

[MOD][ATT][4.4] Remove unsafe volume warning

I did this for myself, and thought I would share. I got tired of the "Raise volume above safe level?" warning, and I removed it. I like to learn, so rather than use the existing xposed framework mod, I built a flashable zip to make the change via framework-res.apk.
WARNING: I AM NOT RESPONSIBLE IF YOU MESS UP YOUR PHONE
Prerequisite:
ATT Moto X running stock official 4.4 kitkat (140.44.5)
TWRP or CWM (safestrap for those who don't have an unlocked bootloader, thanks Hashcode)
backup all of your data in case something goes horribly wrong
Instructions:
using your choice of file manager, backup /system/framework/framework-res.apk
Download or copy flashable zip (below) to sdcard
Reboot to [safestrap] TWRP recovery
flash zip file
Below are the 'broad strokes' of how I did this in linux: (Each of these steps below require various skills, and my intent is not to do too much 'hand holding.')
DUMP AND DECOMPILE framework-res.apk
make sure java 7 is installed
download/extract apktool_2.0.0b7.jar (thanks brut.all)
move /system/framework/framework-res.apk to apktool directory
install framework: java -jar apktool_2.0.0b7.jar if framework-res.apk
dump framework-res.apk: java -jar apktool_2.0.0b7.jar d framework-res.apk
--
CHANGE SETTING IN TWO FILES:
edit this file: framework-res/res/values/bools.xml
search for the line with this info: config_safe_media_volume_enabled
change the value to: false
repeat with framework-res/res/values-mcc310/bools.xml
--
DELETE DIRECTORY STRUCTURE (not sure why framework wouldn't compile with this, but it is unused on AT&T phones)
delete this directory: framework-res/values-mcc310-1
--
RECOMPILE AND COPY EXISTING SIGNATURE:
recompile: java -jar apktool_2.0.0b7.jar b framework-res -o framework-res-new.apk
move META-INF structure from inside the original framework-res.apk to the new framework-res-new.apk (I used 7z)
--
ZIPALIGN NEW FILE:
zipalign -f -v 4 framework-res-new.apk framework-res.apk
--
CREATE FLASHABLE ZIP WITH NEW framework-res.apk
you can use mine as a template and just replace my framework-res.apk under /system/framework
TWRP/CWM flashable zip: http://www.androidfilehost.com/?fid=23252070760973197
(Replaces /system/framework/framework-res.apk with my modified version.)
Trying this now on my Rogers ATT KK based Moto X. Ill update soon.
Updated script brakes at device check.
Sent from my XT1058 using XDA Premium 4 mobile app
slimdizzy said:
Updated script brakes at device check.
Sent from my XT1058 using XDA Premium 4 mobile app
Click to expand...
Click to collapse
Do you mean the updater-script in the flashable zip? If so, you can modify those checks for your phone if you can see the error. I used twrp->advanced->copy logs to /sdcard to see the error messages.
Ctrl-Freak said:
Do you mean the updater-script in the flashable zip? If so, you can modify those checks for your phone if you can see the error. I used twrp->advanced->copy logs to /sdcard to see the error messages.
Click to expand...
Click to collapse
Will do. Ill post shortly.
Update:
Installing '/sdcard/motox-att-140.44.5-framework-res-1.zip'...
Checking for MD5 file...
I:Cannot find file /sdcard/motox-att-140.44.5-framework-res-1.zip.md5
Skipping MD5 check: no MD5 file found.
I:Zip does not contain SELinux file_contexts file in its root.
script aborted: This package is for "ghost" devices; this is a "xt1060".
This package is for "ghost" devices; this is a "xt1060".
E:Error executing updater binary in zip '/sdcard/motox-att-140.44.5-framework-res-1.zip'
My build.prop shows 1058 for the record.
slimdizzy said:
Will do. Ill post shortly.
Update:
Installing '/sdcard/motox-att-140.44.5-framework-res-1.zip'...
Checking for MD5 file...
I:Cannot find file /sdcard/motox-att-140.44.5-framework-res-1.zip.md5
Skipping MD5 check: no MD5 file found.
I:Zip does not contain SELinux file_contexts file in its root.
script aborted: This package is for "ghost" devices; this is a "xt1060".
This package is for "ghost" devices; this is a "xt1060".
E:Error executing updater binary in zip '/sdcard/motox-att-140.44.5-framework-res-1.zip'
My build.prop shows 1058 for the record.
Click to expand...
Click to collapse
Did you build this from your Rogers framework? (If not, keep in mind my framework-res if from an AT&T phone. I have no idea if there are any differences.)
To continue, you can edit the updater-script and make the change from "ghost to "xt1060".
I have a rogers phone but ATT firmware. This is just what happens when I flash your zip. Your updated script asks for a 1058, which is my model but breaks and says my device is a 1060. That is nowhere in my prop. This should flash no problem and it doesn't. I even tried to manually overwrite using root explorer and my phone wouldn't boot after. I replaced original file and all is well.
Sent from my XT1058 using XDA Premium 4 mobile app
Thanks, this worked like a charm for my Moto G.
I used Advanced ApkTool v2.0.0 to decompile 'framework-res.apk',
I used Notepad++ to set all 'config_safe_media_volume_enabled' entries to false,
After the recompilation, I extracted the content of the original 'framework-res.apk' with 7-zip, and just replaced 'resources.arsc' with the modified one. (can be found in the '\build\apk' directory)
Recompressed again with 7-zip (compression level: store) and used adb to replace the file:
adb push framework-res.apk /sdcard/Download/framework-res.apk
adb shell
Code:
su
mount -o remount,rw -t ext4 /dev/block/platform/msm_sdcc.1/by-name/system /system
mv /system/framework/framework-res.apk /system/framework/framework-res.apk.bak
cat /sdcard/Download/framework-res.apk > /system/framework/framework-res.apk
chmod 644 /system/framework/framework-res.apk
sync
reboot

Categories

Resources