How to change permission of System File without Android initialize? - Android Q&A, Help & Troubleshooting

Hello,
My device is Chinese and has no brand. (with Android 4.0)
I changed some things in framework-res.apk, but not set the permission to 755 before saving in /system/framework/
so now the phone keeps resetting! :crying:
How do I change the permission of this file without the device to start??
Tanks.

If it gets to the bootanimation, you can use ADB
These are the commands you'll need
adb remount
adb shell
su
cd /system/framework
chmod 755 framework-res.apk
Should work that way, didn't test it.

Lesicnik1 said:
If it gets to the bootanimation, you can use ADB
These are the commands you'll need
adb remount
adb shell
su
cd /system/framework
chmod 755 framework-res.apk
Should work that way, didn't test it.
Click to expand...
Click to collapse
But how do initialize phone in Debug Mode without initialize the Android system?

daniel.uramg said:
But how do initialize phone in Debug Mode without initialize the Android system?
Click to expand...
Click to collapse
If your device has a recovery, ADB should work through that.

Lesicnik1 said:
If your device has a recovery, ADB should work through that.
Click to expand...
Click to collapse
On press "Vol- + Power" system initialize on "Android System Recovery <3e>", but the computer recognized "USB Mass Storage Device"

Have to create a Shell Script with the command chmod 755 /system/framework/framework-res.apk, and save to update.zip, and run on Recovery System?
Does it work?

I make this file update.zip
with the original system/framework/frameword-res.apk of the my backup
META-INF/com/google/android/updater-script with the commands:
Code:
ui_print("Unlock the Phone");
ui_print("Mounting system...");
run_program("/sbin/busybox", "mount", "/system");
show_progress(1, 15);
package_extract_dir("system/framework", "/system/framework");
set_perm(0, 0, 0755, "/system/framework/framework-res.apk");
ui_print("Unmounting system...");
run_program("/sbin/busybox", "umount", "/system");
ui_print("Unlocking complete!");
I followed this tutorial to sign the file: http://forum.xda-developers.com/showthread.php?t=1610121
But when I try to recover the device shows the error: "Invalid OTA package"
Need META-INF/com/google/android/update-binary ?
Because several update.zip file I downloaded from the Internet have different sizes.
I do not know what to do!

daniel.uramg said:
I make this file update.zip
with the original system/framework/frameword-res.apk of the my backup
META-INF/com/google/android/updater-script with the commands:
Code:
ui_print("Unlock the Phone");
ui_print("Mounting system...");
run_program("/sbin/busybox", "mount", "/system");
show_progress(1, 15);
package_extract_dir("system/framework", "/system/framework");
set_perm(0, 0, 0755, "/system/framework/framework-res.apk");
ui_print("Unmounting system...");
run_program("/sbin/busybox", "umount", "/system");
ui_print("Unlocking complete!");
I followed this tutorial to sign the file: http://forum.xda-developers.com/showthread.php?t=1610121
But when I try to recover the device shows the error: "Invalid OTA package"
Need META-INF/com/google/android/update-binary ?
Because several update.zip file I downloaded from the Internet have different sizes.
I do not know what to do!
Click to expand...
Click to collapse
when i want to change setting background
menu image i have chang framework.apk and i replae that file in
system/framework and now my phone is just boot looping.i have also
take backup i have also restore it but no luck
i am thinking that if i change the file permission than i will be
successfully booted so i have attached one image too you can see that
i can't change file permission please help me bro

Bhg73 said:
when i want to change setting background
menu image i have chang framework.apk and i replae that file in
system/framework and now my phone is just boot looping.i have also
take backup i have also restore it but no luck
i am thinking that if i change the file permission than i will be
successfully booted so i have attached one image too you can see that
i can't change file permission please help me bro
Click to expand...
Click to collapse
Hello, I used Auto-Sign to sign the package.
Or change recovery.bin to an alternative that allows you to do the update.zip without signing

similar question to OP, if we are using ADB in recovery, then the system protection should be down (Hopefully). Shouldn't we then be able to modify the /system/xbin folder permissions to rwx using chmod command? I am asking because I have an old ZTE Z750c which is known for system protection issues. I have tried temp-root via Cydia Impactor then re-run.bat command to disable system protection and it still won't perm-root. I've noticed that some needed root apps (SuperSU, Busybox) need rwx access to /system/xbin. So my hypothetical thinking is that if we mod the folder permissions in recovery, that should trick the system protection.

Lesicnik1 said:
If it gets to the bootanimation, you can use ADB
These are the commands you'll need
adb remount
adb shell
su
cd /system/framework
chmod 755 framework-res.apk
Should work that way, didn't test it.
Click to expand...
Click to collapse
thank you so much !!!!

Related

Help With an Edify Error

Okay, I have done this before and it worked fine. This time it's not working.
In my script I put :
Code:
package_extract_file("scripts/touchfiles.sh", "/tmp/touchfiles.sh");
set_perm(0, 0, 0777, "/tmp/touchfiles.sh");
run_program("/tmp/touchfiles.sh");
touchfiles.sh has this inside:
Code:
#!/sbin/sh
#
#
#
touch /tmp/aroma/themenew.prop
touch /tmp/aroma/stocknew.prop
touch /tmp/aroma/themestock.prop
touch /tmp/aroma/stockstock.prop
exit 0
The result is file not found when it gets to the run_program part.
I can adb shell in and cd to /tmp and see the file. I can cat the file. But when I attempt to execute it, I get file not found.
I know it's something stupid that too many hours behind the keyboard is preventing me from seeing.
Anybody see what's wrong?
Thanks!
D
.
Wait a sec,the script start but don't find the /tmp/aroma/.. or the touchfiles.sh don't start?
I don't have understand this.
dsb9938 said:
Okay, I have done this before and it worked fine. This time it's not working.
In my script I put :
Code:
package_extract_file("scripts/touchfiles.sh", "/tmp/touchfiles.sh");
set_perm(0, 0, 0777, "/tmp/touchfiles.sh");
run_program("/tmp/touchfiles.sh");
touchfiles.sh has this inside:
Code:
#!/sbin/sh
#
#
#
touch /tmp/aroma/themenew.prop
touch /tmp/aroma/stocknew.prop
touch /tmp/aroma/themestock.prop
touch /tmp/aroma/stockstock.prop
exit 0
The result is file not found when it gets to the run_program part.
I can adb shell in and cd to /tmp and see the file. I can cat the file. But when I attempt to execute it, I get file not found.
I know it's something stupid that too many hours behind the keyboard is preventing me from seeing.
Anybody see what's wrong?
Thanks!
D
.
Click to expand...
Click to collapse
Can you paste the error?
Sent from my Galaxy Nexus using xda premium
Running shell scripts
I'm not sure, but
1. I don't think you can execute shell scripts directly.
2. to run a shell script the shell needs to be available, so /system needs to have been mounted
Try something like (no need to make the script executable):
# ensure /system is mounted (replace the mount parameters with the ones for your system)
ifelse( is_mounted("/system") == "/system",
ui_print(" /system already mounted!"),
ifelse (mount("ext4", "EMMC", "/dev/block/stl12", "/system") == "/system",
ui_print(" Successfully mounted /system" ),
ui_print(" Could not mount, aborting") ) );
assert( is_mounted("/system") == "/system" );
package_extract_file("scripts/touchfiles.sh", "/tmp/touchfiles.sh");
run_program( "/system/bin/sh", "/tmp/touchfiles.sh");

[TUT] [for NOOB] editing updater-script for noobs!

Hi friends of XDA,
I created this tutorial especially for noobs who would like to know how the clockworkmod uses the .zip
file and what and all goes into the process of flashing a .zip file and mainly about the format and syntax used in updater-script.
first is first!
#include
/*
* I am not responsible for bricked devices, dead SD cards or
* thermonuclear war.
* do some research if you have any concerns.
* YOU are choosing to make these modifications.
* yes, i copied this disclaimer from FXP because it is cool and i am lazy!
*/
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" - name of the partition to be formatted
"/system" - location 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/Edify_script_language
scratchpad-documenting-edify-commands-for-android-updater-scritps
http://forum.xda-developers.com/showthread.php?t=1290062
HIT THANKS IF I HAVE HELPED YOU!
Nice tut bro
bandarigoda123 said:
Nice tut bro
Click to expand...
Click to collapse
thanks friend
Great piece of work buddy.... :good:
This is good for me:beer:
Sent from my HTC EVO 3D X515m using xda app-developers app
What l must to change here? I got error 7
Sent from my HTC EVO 3D X515m using xda app-developers app
analoncarkg said:
What l must to change here? I got error 7
Sent from my HTC EVO 3D X515m using xda app-developers app
Click to expand...
Click to collapse
Have you set the eol conversion to Unix format as described?
Have you left a blank line as described?
Make sure that Cyanogenmod Rom is for your device. Then try flashing again.
If the above mentioned steps fails and you still get a status 7 error or assert failed error then make SURE that the Rom is really specific for your device and remove the first three lines from the script
Remove lines starting From "assert" to "smultron");
Make sure that after removing the above specified three lines there is no blank line at the start of the script And flash again
Usually status 7 errors are due to bad formatting of the updater-script or in rare cases it is due to corrupted or incomplete download of the Rom.
hit thanks if I've helped!
sent from my smultron
here are some more commands if you like:
sleep();
show_progress(1.0, "1000"); more on this here: http://forum.xda-developers.com/showthread.php?t=1290062
if/ then/ endif; syntax
iONEx said:
here are some more commands if you like:
sleep();
show_progress(1.0, "1000"); more on this here: http://forum.xda-developers.com/showthread.php?t=1290062
if/ then/ endif; syntax
Click to expand...
Click to collapse
Thanks iONEX I knew them before but didn't add sleep and show_progress because they are just mere cosmetic changes and don't serve any serious purpose anyways I'll add them after understanding and testing
And about if/then/endif/ifelse , generally they are used rarely in updater-script but I'll add them anyways after understanding testing!
Thanks!
hit thanks if I've helped!
sent from my smultron
If anyone is interested in the source of the update-binary, I've added the link to it in the first post
hit thanks if I've helped!
sent from my smultron
Hello! How exactly should I write in the updater-script if I need to make the system folder rewriteable and then delete the existing framework-res.apk from system/framework and then copy a new framework-res.apk from the .zip file, then change the permissions of it and finally make the system folder write-only again?
My "idea" is something like this:
1. Content of the updater-script:
ui_print("Please wait...");
mount("MTD", "system", "/system");
delete("/system/framework/framework-res.apk");
package_extract_dir("system", "/system");
set_perm(0, 0, 04755, "/system/framework/framework-res.apk");
ui_print("Done");
unmount("/system");
2. Make a signed .zip file that would contain:
- system\framework\framework-res.apk
- META-INF\com\google\android\updater-script
3. Run the .zip from memory card via recovery
Would it work like this?
Note: My phone is bricked because of framework-res.apk and USB debugging is off, so this is the only way I could unbrick it.
You must have a unmodified updater-script in your meta-inf folder right?? Paste the "mount" command syntax here. It must be in the first few lines.
#pitchblack5691#
Actually I don't. I have to create it from scratch.
No. . . You need a meta-inf folder to work with which contains the signature files and a update-binary to create a flashable zip.
#pitchblack5691#
I only created those folders and an updater-script file and then I packed it & signed it using Update Zip Packager 3.0. The only update-binary file that I have is the one that's included with Update Zip Packager.
Code:
mount("MTD", "system", "/system");
ui_print("started. . . .");
delete("/system/framework/framework-res.apk");
package_extract_dir("system", "/system");
set_perm(0, 0, 0644, "/system/framework/framework-res.apk");
unmount("/system");
ui_print("finished");
This should work and you need a meta-inf folder extracted from some flashable zip. You can't create a meta-inf folder from scratch without using signature files and update-binary.
EDIT: what you said above will work. You either should have a meta-inf folder with signature files or a signing software.
And you don't have to give 755 permissions to an app because even though they are apps, technically they are not executed and only read from so no need for 755 permission. 644 permission should suffice and it's the default permission for a system app. . . 755 permissions is only useful for executable binaries and scripts.
#pitchblack5691#
I've just tried it. It returns this error:
...
Installing update...
E:Error in /tmp/sideload/package.zip
(Status 2)
Installation aborted.
E:Can't find misc
What does it mean please?
What code exactly you are using in the updater-script?? Paste the full code and paste the name of files present in the zip file in a hierarchical order.
#pitchblack5691#
The .zip contains these files:
Code:
META-INF\CERT.RSA
META-INF\CERT.SF
META-INF\MANIFEST.MF
META-INF\com\google\android\update-binary
META-INF\com\google\android\updater-script
system\framework\framework-res.apk
The code of updater-script:
Code:
mount("MTD", "system", "/system");
ui_print("started. . . .");
delete("/system/framework/framework-res.apk");
package_extract_dir("system", "/system");
set_perm(0, 0, 0644, "/system/framework/framework-res.apk");
unmount("/system");
ui_print("finished");
Bootloader unlocked?? Custom kernel?? Or installed cwm in a bootloader locked phone??? Looks like your cwm is not working properly. . .
#pitchblack5691#

[Q] Installing an App from CWM via a shell command

The latest version of Google Now (2.1) doesn't like being flashed. If you flash it via CWM it seems to break voice search functionality, causing a force close.
Playing with the adb shell, I discovered that the pm install command works nicely:
Code:
pm install [APKNAME].apk
So, I thought this would be perfect to execute in a shell script via CWM/Edify.
So far I've tried all manner of commands. First I was trying the above command in a install.sh file, before I realised that "pm" wasn't present anywhere in /sbin/ (the header of my shell script is #!/sbin/sh").
So, I've tried this:
Code:
#!/sbin/sh
exec /system/bin/pm install data/media/install/Velvet.apk
Here is the update script:
Code:
ui_print("Mounting system...");
run_program("/sbin/busybox", "mount", "/system");
ui_print("Mounting data...");
run_program("/sbin/busybox", "mount", "/data");
ui_print("Copying files...");
package_extract_dir("ultima/install", "/data/media/install");
package_extract_file("ultima/install.sh", "/tmp/install.sh");
ui_print("Setting perms...");
set_perm(0, 0, 0777, "/tmp/install.sh");
ui_print("Running install...");
run_program("/tmp/install.sh");
ui_print("Done...");
ui_print("Unmounting system...");
unmount("/system");
unmount("/data");
Which, copies the files correctly. This also isn't my first time running scripts in my installer, but this is the first time I've attempted this.
To no avail. This same command works in the adb shell, though.
Is there something I'm missing? Is this even possible?
Also, is there another way of flashing that may work? I heard about putting the original file ("Velvet.apk") in /system/app and then putting the updated version in /data/appcom.google.andorid.googlequicksearch-1.apk but this doesn't work either.
EDIT:
Hmm, running the above script in Busybox installer's script running function also works perfectly.
The only thing it won't do is install from CWM.
I've tried including the pm binary and a few other things
Bump

Error 0 when trying to install update.zip

Whenever I try flash a new nightly, my custom sounds go away. So, I created an update file with the ringtones, and some notification sounds. But every time I try to install the file, I get a error 0 in CWM. Here is my script file, what am I doing wrong. I use Notepad++ for editing the file. Any help is appreciated. Thanks.
ui_print("............................");
ui_print("............................");
ui_print("Mounting system...");
run_program("/sbin/busybox", "mount", "/system");
ui_print("Copying files...");
package_extract_dir("system", "/system");
ui_print("Unmounting system...");
run_program("/sbin/busybox", "umount", "/system");
ui_print("Installation done!.........");
prabs99 said:
Whenever I try flash a new nightly, my custom sounds go away. So, I created an update file with the ringtones, and some notification sounds. But every time I try to install the file, I get a error 0 in CWM. Here is my script file, what am I doing wrong. I use Notepad++ for editing the file. Any help is appreciated. Thanks.
ui_print("............................");
ui_print("............................");
ui_print("Mounting system...");
run_program("/sbin/busybox", "mount", "/system");
ui_print("Copying files...");
package_extract_dir("system", "/system");
ui_print("Unmounting system...");
run_program("/sbin/busybox", "umount", "/system");
ui_print("Installation done!.........");
Click to expand...
Click to collapse
Usually a status 0 error refers an incompatible update-binary in the zip file. I would recommend replacing it with a compatible one (Can be pulled from a ROM or other flashable zip that you know will flash successfully), then re-signing the zip file, will usually fix this error.
Sent from my SCH-I535 using xda premium
I pulled the update-binary from the cm 10.1.2 nightly. I know it works, because I can flash it, but the update file I created does not work.
shimp208 said:
Usually a status 0 error refers an incompatible update-binary in the zip file. I would recommend replacing it with a compatible one (Can be pulled from a ROM or other flashable zip that you know will flash successfully), then re-signing the zip file, will usually fix this error.
Sent from my SCH-I535 using xda premium
Click to expand...
Click to collapse
prabs99 said:
I pulled the update-binary from the cm 10.1.2 nightly. I know it works, because I can flash it, but the update file I created does not work.
Click to expand...
Click to collapse
Interesting, do you have the correct folder structure for the flashable such as META-INF->com->android and google folder->google folder->android->update-binary and updater script? Also do you have the correct folder structure for the ringtones and sounds? If you have named the .zip file update.zip try renaming it to something else (For example ringtonessounds.zip). Finally not that this should make a difference by try replacing:
Code:
run_program("/sbin/busybox", "umount", "/system");
With:
Code:
unmount("/system");
Is busybox installed in your device since you use busybox commands in your updater-script?
Also try to sign your zip file,, download signapk and run this command:
Code:
java -Xmx512M -jar signapk.jar -w testkey.x509.pem testkey.pk8 <Your zip file> <Your result zip file>
ensure you have installed java environment,,
..
shimp208 said:
Interesting, do you have the correct folder structure for the flashable such as META-INF->com->android and google folder->google folder->android->update-binary and updater script? Also do you have the correct folder structure for the ringtones and sounds? If you have named the .zip file update.zip try renaming it to something else (For example ringtonessounds.zip). Finally not that this should make a difference by try replacing:
Code:
run_program("/sbin/busybox", "umount", "/system");
With:
Code:
unmount("/system");
Click to expand...
Click to collapse
It was my directory structure that was bad. Thanks for your help.
Sent from my Galaxy Nexus using xda app-developers app
majdinj said:
Is busybox installed in your device since you use busybox commands in your updater-script?
Also try to sign your zip file,, download signapk and run this command:
Code:
java -Xmx512M -jar signapk.jar -w testkey.x509.pem testkey.pk8 <Your zip file> <Your result zip file>
ensure you have installed java environment,,
..
Click to expand...
Click to collapse
Have busybox installed. I am signing the zip with the test key. I don't have a private key.
Sent from my Galaxy Nexus using xda app-developers app

Creating a Flashable Zip to start a TWRP Restore

Hi everyone.
I have a TWRP backup of Boot, System, and Data that I need to restore to a number of SM-T580 devices.
Typically TWRP requires backup paths to be in the format TWRP/BACKUPS/[android_id]/[whatever], but I have found that if you use the the CLI, you can get generalize the android_id part. IE: something like this works fine from the TWRP terminal:
Code:
twrp restore /sdcard/TWRP/BACKUPS/x/y
Having gotten this far, I'd like to see if I could make this a little easier to run for other members of my team. I've found a number of guides on creating Flashable Zip's which contain scripts in them that could themselves call upon shell scripts, so this looks like it may be the easiest way for my team to run the restore without having to use the terminal or know the android_id of any of the devices.
I borrowed my META-INF\com\google\android\update-binary from this Ultra Lean Rom, and my updater-script looks like this:
Code:
package_extract_dir("META-INF/tmp", "/tmp");
set_perm(0, 0, 0777, "/tmp/restore.sh");
run_program("/tmp/restore.sh");
META-INF/tmp/restore.sh looks like this:
Code:
#!/sbin/sh
/sbin/twrp restore /sdcard/TWRP/BACKUPS/x/y
When I put this on the device and try to run in through the Install process though, it will just sit there trying to "install" indefinitely. The restore.sh does get extracted into /tmp though, and if you run /tmp/restore.sh from the terminal the restore works great, but it just hangs from the Install process.
I have also tried the following lines in place of the above run_program line:
Code:
run_program("/sbin/busybox", "sh", "-c '/sbin/twrp restore /sdcard/TWRP/BACKUPS/x/y'");
run_program("/sbin/busybox", "sh", "/sdcard/restore.sh");
run_program("/sbin/sh -c '/sbin/twrp restore /sdcard/TWRP/BACKUPS/x/y'");
run_program("/sbin/busybox", "sh", "-c 'twrp restore /sdcard/TWRP/BACKUPS/x/y'");
run_program("/sbin/busybox", "sh", "-c", "'", "twrp", "restore", "/sdcard/TWRP/BACKUPS/x/y", "'");
run_program("/sbin/sh", "-c", "'", "twrp", "restore", "/sdcard/TWRP/BACKUPS/x/y", "'");
run_program("/sbin/sh -c 'twrp restore /sdcard/TWRP/BACKUPS/x/y'");
run_program("/sbin/sh", "-c 'twrp restore /sdcard/TWRP/BACKUPS/x/y'");
run_program("/sdcard/restore.sh");
run_program("/sbin/busybox", "sh", "/sdcard/restore.sh");
run_program("/sbin/sh", "/sdcard/restore.sh");
run_program("/sbin/sh", "twrp", "restore", "/sdcard/TWRP/BACKUPS/x/y");
In those cases I had manually put restore.sh in /sdcard/ and chmod'd it ahead of time. I'd also tried all of the above with restore.sh being extracted to /tmp but didn't paste for the sake of redundancy.
I have also tried switching out the top line to "#!/sbin/busybox sh" and "/sbin/twrp" to just "twrp" in recovery.sh, and pretty much every possible combination of all of the above, but only ever getting it the install process to either hang indefinitely or in some cases finish immediately with no errors (but no restore either).
I know this is probably a bit of a longshot as it's probably a niche need, but if anyone has any thoughts on this I'd appreciate it. Thank you in advance for your feedback.

Categories

Resources