# Edify script help



## killabyte (Jan 22, 2012)

Here's my updater-script for overwriting my /system/app/ and /system/framework/ folder. I've deodexed those apk's and jars and i'm trying to get them installed by an update.zip. The script seems to run fine but it doesn't seem to overwrite the app and framework files on the phone. I also call in a script to delete all the odex files from /app and /framework but it's not working either apparently.

The de-odex.sh script is placed into "tmp" in the root of the update.zip file. I have app and framework inside of "system" which is also in the root of the update.zip. There are not errors given by the script or cwm recovery.

Here's the updater-script:


```
<br />
ui_print("deodexing system files...");<br />
show_progress(1.000000, 0);<br />
<br />
ui_print("starting process");<br />
set_progress(0.2);<br />
<br />
ui_print("mounting SYSTEM...");<br />
mount("yaffs2", "MTD", "system", "/system");<br />
ui_print("deleting odexes...");<br />
package_extract_file("/tmp/de-odex.sh", "/tmp/de-odex.sh");<br />
set_perm(0, 0, 0777, "/tmp/de-odex.sh");<br />
run_program("/tmp/de-odex.sh");<br />
set_progress(0.4);<br />
<br />
ui_print("installing deodexed system");<br />
package_extract_dir("system", "/system");<br />
set_progress(0.6);<br />
<br />
unmount("/system");<br />
set_progress(0.8);<br />
<br />
ui_print("finished");<br />
show_progress(0.100000, 0);<br />
<br />
```
and here's the contents de-odex.sh file in the /tmp directory


```
<br />
#!/bin/sh<br />
rm -rf /system/app/*.odex<br />
rm -rf /system/framework/*.odex<br />
```


----------



## killabyte (Jan 22, 2012)

Ok so I changed the way it mounted /system and it copied the files. It didnt delete the odex files tho which is what the script i called was supposed to do. Ill figure it out hopefully. If anyone knows what i did wrong please let me know.


----------



## jess086 (Sep 26, 2011)

Is ur script set to excutable before u put it in the zip? Will it run if u push it to ur phone by way of adb?


----------



## killabyte (Jan 22, 2012)

I'm not sure... I thought that's what setting the permissions with 755 did? What would be the command for deleting all odex files in those dirs with edify?


----------



## killabyte (Jan 22, 2012)

Anyone? Still can't seem to get this script to run. I don't think the script is even being executed. There is no tmp folder being created as far as I can tell. Since there is no command to delete it afterwards it should be there somewhere, right? It's not a major deal cause I can delete the odex files in one swipe through terminal but i'd like to get this whole thing going as a package.


----------



## times_infinity (Aug 6, 2011)

Afaik, our system partition is ext4 not yaffs2. Also we're EMMC not MTD. Also in the deodex script try changing /bin/sh to /sbin/sh

Sent from my Galaxy Nexus using RootzWiki


```
<br />
ui_print("deodexing system files...");<br />
show_progress(1.000000, 0);<br />
ui_print("starting process");<br />
set_progress(0.2);<br />
ui_print("mounting SYSTEM...");<br />
mount("EXT4", "EMMC", "/dev/block/platform/omap/omap_hsmmc.0/by-name/system", "/system");<br />
ui_print("deleting odexes...");<br />
package_extract_dir("/tmp", "/tmp");<br />
set_perm(0, 0, 0777, "/tmp/de-odex.sh");<br />
run_program("/tmp/de-odex.sh");<br />
set_progress(0.4);<br />
ui_print("installing deodexed system");<br />
package_extract_dir("system", "/system");<br />
set_progress(0.6);<br />
unmount("/system");<br />
set_progress(0.8);<br />
ui_print("finished");<br />
show_progress(0.100000, 0);<br />
```


```
<br />
#!/sbin/sh<br />
rm -rf /system/app/*.odex<br />
rm -rf /system/framework/*.odex<br />
```
Try both scripts like that. they SHOULD work.

The reason why the scripts weren't working the way you wanted them to, was because system more than likely wasn't getting mounted.
Also the reason why bin won't work for the shell script is because in android the bin directory in root is symlinked to /system/bin. /sbin is located in the ramdisk. so it'll be there in recovery as well, while you would need system to be mounted in recovery to access /system/bin for sh.


----------



## killabyte (Jan 22, 2012)

Thanks dude. I had already figured out the mounting problem by looking at the script in one of Pete's roms. I'm pretty sure I tried switching from /bin/sh to /sbin/sh and also have tried /system/bin/sh. I will try again tomorrow just in case i'm remembering something that didn't happen. I tried a lot of different things and I could've easily gotten it mixed up.

Could I just use the delete command to wipe the odex files? Maybe something like:


```
<br />
ui_print("deleting odexes...");<br />
delete("/system/app/*.odex");<br />
delete("/system/framework/*.odex");<br />
```


----------



## times_infinity (Aug 6, 2011)

You might be able to. You could even probably get away with using the delete recursive command on /system/app and /system/framework and then have the script copy the deodexed files over

Sent from my Galaxy Nexus using RootzWiki


----------



## killabyte (Jan 22, 2012)

Ok I have tried it about every way possible. I just can't seem to get that script to run. I have tried /bin/sh, /sbin/sh, /system/bin/sh. I also tried it your way with extract_package_dir with it just extracting /tmp to /tmp. Either way there's no tmp dir being created because it should be there when I boot back up since there is no command given to delete the tmp directory, right? I can't find a tmp dir anywhere.

I also tried using the delete command with the *.odex and it doesn't appear to work. Tried it with delete_recursive and *.odex as well and no go there either. I guess i'm going to try the delete_recursive method and then have it copy the deodexed files over, to make sure it is working right. I'm certain it copied the deodexed apks and jars over because I deleted all the odex files manually and everything still works. Before if I did that everything that I tried to run would force close.


----------



## BMc08GT (Jun 23, 2011)

killabyte said:


> Ok I have tried it about every way possible. I just can't seem to get that script to run. I have tried /bin/sh, /sbin/sh, /system/bin/sh. I also tried it your way with extract_package_dir with it just extracting /tmp to /tmp. Either way there's no tmp dir being created because it should be there when I boot back up since there is no command given to delete the tmp directory, right? I can't find a tmp dir anywhere.
> 
> I also tried using the delete command with the *.odex and it doesn't appear to work. Tried it with delete_recursive and *.odex as well and no go there either. I guess i'm going to try the delete_recursive method and then have it copy the deodexed files over, to make sure it is working right. I'm certain it copied the deodexed apks and jars over because I deleted all the odex files manually and everything still works. Before if I did that everything that I tried to run would force close.


Pastebin your updater-script and I'll take a look

PowerBoosted from Rootz


----------



## BMc08GT (Jun 23, 2011)

killabyte said:


> Ok I have tried it about every way possible. I just can't seem to get that script to run. I have tried /bin/sh, /sbin/sh, /system/bin/sh. I also tried it your way with extract_package_dir with it just extracting /tmp to /tmp. Either way there's no tmp dir being created because it should be there when I boot back up since there is no command given to delete the tmp directory, right? I can't find a tmp dir anywhere.
> 
> I also tried using the delete command with the *.odex and it doesn't appear to work. Tried it with delete_recursive and *.odex as well and no go there either. I guess i'm going to try the delete_recursive method and then have it copy the deodexed files over, to make sure it is working right. I'm certain it copied the deodexed apks and jars over because I deleted all the odex files manually and everything still works. Before if I did that everything that I tried to run would force close.


If you have no tmp dir its because you didnt specify to create itbefote extracting that package. 

```
<br />
run_program("/sbin/busybox", "mkdir", "-p", "/tmp");<br />
package_extract_dir("tmp", "/tmp");<br />
```
And for the deodex script being ran

```
<br />
run_program("/sbin/busybox", "sh", "/tmp/de-odex.sh");<br />
```
This should work

PowerBoosted from Rootz


----------



## killabyte (Jan 22, 2012)

Ok i'll try that just as soon as lunch is over. I'll also post the things i've been trying. Is there a way to create a dir without using busybox? I was going to share this with a few friends and some of them may not have or want to use busybox.


----------



## killabyte (Jan 22, 2012)

I figured it out. The main problem were the package_extract_file and dir lines. They start with /tmp instead of just tmp. After fixing that typo (that I can't believe I overlooked dozens of times now) I am able to get it to copy the script directly to /system using extract_file or I can copy the tmp directory to /system using extract_dir. I can only copy to the system folder (obviously) but I would like to be able to copy the file to the "sdcard" and run it from there or perhaps to the root directory of the phone. I've read that you can't set permissions for files on the sdcard, but in another thread jess086 said you could by going through /data/media which would involve mounting the data partition.

Looking back on the whole thing it just seems like it would be much smarter to do a recursive wipe of the app and framework directories and then copy the deodexed files over but since i've put this much time into figuring this out i'm going to at least see the damn script run one time before going with the better solution.

Just for my future reference, if anyone knows how to mount /sdcard or / so that I can copy the tmp dir or file there I would love to know.


----------



## BMc08GT (Jun 23, 2011)

killabyte said:


> I figured it out. The main problem were the package_extract_file and dir lines. They start with /tmp instead of just tmp. After fixing that typo (that I can't believe I overlooked dozens of times now) I am able to get it to copy the script directly to /system using extract_file or I can copy the tmp directory to /system using extract_dir. I can only copy to the system folder (obviously) but I would like to be able to copy the file to the "sdcard" and run it from there or perhaps to the root directory of the phone. I've read that you can't set permissions for files on the sdcard, but in another thread jess086 said you could by going through /data/media which would involve mounting the data partition.
> 
> Looking back on the whole thing it just seems like it would be much smarter to do a recursive wipe of the app and framework directories and then copy the deodexed files over but since i've put this much time into figuring this out i'm going to at least see the damn script run one time before going with the better solution.
> 
> Just for my future reference, if anyone knows how to mount /sdcard or / so that I can copy the tmp dir or file there I would love to know.


run_program("/sbin/busybox", "mount", "/sdcard");

Change the perms in system or tmp and then cp them to /sdcard

run_program("/sbin/busybox", "cp", "-rf", "/tmp", "/sdcard/tmp")

That should do the trick then

run_program("/sbin/busybox", "sh", "/sdcard/de-odex.sh");

PowerBoosted from Rootz


----------



## killabyte (Jan 22, 2012)

Is there a way to do it without busybox? Trying to learn how to do as much as possible without relying on things that may not be there.


----------

