[Help] Execute a shell script from updater-script in recovery flashable zip? - Nexus 6 Q&A, Help & Troubleshooting

I'm trying to create a flashable zip that executes a shell script when it's flashed. I figured that the Edify Script command was this:
Code:
run_program("/path/to/shell/script/file.sh");
I've tried this in my flashable zip but it doesn't work. Am I using the wrong command? Any help would be appreciated!

Did you set permissions to 755 on the script after it was extracted? If not, that is probably why it didn't work as zip files won't preserve file permissions, so it would have been extracted at 644 most likely, making it unexecutable. What you have listed should work though. Here is a decent reference on the updater-script.

imnuts said:
Did you set permissions to 755 on the script after it was extracted? If not, that is probably why it didn't work as zip files won't preserve file permissions, so it would have been extracted at 644 most likely, making it unexecutable. What you have listed should work though. Here is a decent reference on the updater-script.
Click to expand...
Click to collapse
Yeah I set perms to 755. Here's the exact code I use:
Code:
show_progress(0.99, 30);
run_program("/sbin/busybox", "mount", "/system");
package_extract_dir("system", "/system");
set_perm(0, 0, 0755, "/system/etc/init.d/FixGSv4.sh");
run_program("/system/etc/init.d/FixGSv4.sh", "execute");
show_progress(1.0, 1);
unmount("/system");
Not sure what else to do to make it work. Do you think that it might be because the code in the shell script are commands like this?
Code:
#!/system/bin/sh
pm disable com.google.android.gms/.ads.settings.AdsSettingsActivity
pm disable com.google.android.gms/com.google.android.location.places.ui.aliaseditor.AliasEditorActivity
Can pm commands not be run from recovery?

Try running the commands via adb shell and see if it works that way. Also, why do you have "execute" in the same line as the script? That may be the issue as well, but it should just throw a warning. Also, is there anything in the recovery log?
Sent from my Nexus 6

Related

[INFO] Edify scripts in CWM recovery

Hi, I haven't seen any good resources for how to edit edify scripts, so I thought I would create this thread so we can pool our knowledge on the subject.
Intro
Inside your typical CWM zip there is a folder called META-INF, inside that there is a folder called com and come CERT files, inside that com folder there is a google folder, inside that is an android folder containing an update-binary file and an updater-script. If you only see an update-script, that means you are back in the Android 1.5 era and need to move on.
The updater-script
The updater-script file is a text file, it is linux formatted with regard to end of line conventions. If you use Windows then you have to edit the file using a program that keeps line feeds the way they are and has options for doing the conversion from <CR><LF> to just <LF>.
Like lisp, the contents of the text file evaluate to one big expression, but it does have the ";" end of command convention to make things more familiar, it just means perform the action on the left. (ref. google source README) You can ignore that and just treat everything as a series of commands for all practical purposes. I mention it because you need not worry about having too large a procedural block or worry about having extra spaces or worry about ending on a line boundary. You could have your entire script on one giant line and it wouldn't matter.
There are around a dozen commands, it's not terribly difficult to learn.
The updater-binary
There are a lot of updater-binary files out there in the wild, each manufacturer basically compiles there own with every other OTA update. Success in flashing your CWM zip is determined by picking the right one that works with what you are trying to do. If your knowledge says mount needs 4 arguments and the binary only supports 3, then you need to change your script to use 3 and vice versa. If you are trying to flash a radio, the updater-binary might have been recompiled to allow for that specific functionality and you will get a status 6 error when trying to flash it unless you use that update-binary. You will see the write_raw_image() function not supporting "/dev/block/mmcblk0p8" but instead "logo.bin".
However, by and large, the generic functionality is the same across the board.
​Updater-script functions (In order of interest)​
ui_print(msg1, .. msgN); This is the means you have to display something on the screen in CWM, it takes a series of comma separated arguments, each comma needs to have a space after it, this applies to all commands.
Ex. ui_print("Your version is: ", file_getprop("/system/build.prop", "ro.build.id"));
show_progress(TOTALAMOUNT, TIMEINSEC); This command and the following command control what you see in the progress bar at the bottom. It is not necessary to use it, it's just another way to display information.TIMEINSEC refers to how long it will take for the progress bar to move to the AMOUNT specified. You would use this perhaps when something is taking a long time, you know approximately how long and want the screen to keep showing something while it is going on. If you use zero for TIME then nothing is done, you have just set the maximum amount for use with set_progress. The amount is a decimal number, 0.5 would be half the progress bar being filled.
Ex. show_progress("0.300000", 10);
set_progress(AMOUNT); This command sets the pointer or fill amount of the progress bar according to the last show_progress command. It should never be greater than the total of the show_progress amount.
Ex. show_progress("0.300000", 0);
set_progress("0.15");
mount(TYPE, DEV, PATH); This is one version of the mount command. The TYPE arg is usually "MTD", which refers to memory technology device. The DEV for a MTD would be something like "system", "userdata", "cache", and the PATH would be "/system", "/data", or "/cache". You will also see TYPE be "vfat".
mount(FSTYPE, TYPE, DEV, PATH); This seems to be the more current mount command. It adds in the file system type. Ex. "ext3", "yaffs". TYPE with this command can be "MTD" or "EMMC". You would use "EMMC" with "/dev/block/mmcblk0p8".
umount(PATH); This simply removes a previous mounted PATH from the system. Ex. umount("/system"); You'll notice the double quotes around command arguments, they are not strictly necessary. Unless it's a reserved word (if then else endif) then they can be anything. "consisting of only letters, numbers, colons, underscores, slashes, and periods". So if you just spend 10 minutes uploading your zip to your phone and notice that your unmount command is umount(/system);, it will work just fine.
sleep(SECS); Simply pauses for SECS seconds.
package_extract_file(FILE, FILEWITHPATH); This command extracts one of your files from the CWM zip package and save it to the phone.
Ex. package_extract_file("bootanimation.zip", "/system/media/bootanimation.zip");
package_extract_dir(ZIPPATH, PATH); This command extracts an entire folder in your CWM zip to a folder on your phone.
Ex. package_extract_dir("system", "/system"); *This is where having system mounted would be handy, without it being mounted, the files would be copied to the ramdisk /system.
write_raw_image(PATH, PARTITION); This is one of those tricky ones, the PATH is somewhere on your phone with the image to be flashed to a PARTITION on your phone. The trouble is, how do you specify what partition gets flashed? Is there any restriction on where the file has to be? If MTD conventions are used, you are looking for "system", "boot", "recovery", "logo.bin". (All this means that each partition has a name stored somewhere, and if you know it, you can write to it.) Maybe it will accept device references like /dev/block/mmcblk0p8. This depends on the update-binary file you are using.
Ex. write_raw_image("/tmp/logo.bin", "logo.bin");
Ex. write_raw_image("/tmp/logo.bin", "/dev/block/mmcblk0p8");
write_firmware_image(PATH, PARTITION); You would think it would be the same as write_raw_image. Not sure what the difference is.
run_program(PROG, ARG1, .., ARGN); Pretty self explanatory, This command allows you to execute a program or script on the phone. Instead of all the bits of the command being separated by spaces, commas are used. It returns an error code as a string.
Ex. run_command("ls", "-R", "/system");
Assert(condition); You'll see this one a lot in OTA updates, all it does is abort the script if something goes wrong. If condition is false, the script ends displaying a description on the phone of what command caused the exit. You can put in more than one statement here, separated by ";", if any one of them returns with an error, the script exits.
Ex. Assert(mount("ext3", "EMCC", "/dev/block/mmcblk0p12", "/system")); *If you can't mount /system and your CWM zip only writes to system, you might as well stop it before continuing on to write to the ramdisk.
ifelse(condition, true path, false path); This is your basic conditional statement, the tricky bit is to figure out what statements in edify can trigger a true of false condition. As for the rest of it, the commas separate the two blocks.
Ex. ifelse(file_getprop("/system/default.prop", "ro.build.id") == "OLYFR1.2.3.4", ui_print("yes"), ui_print("false"));
abort(); This stops the script, useful with ifelse.
file_getprop(PATH, VALUE); This command looks for a text file containing A=B pairs and returns B if it can find an A.
Ex. file bob.txt exists in /tmp, it contains cool=yes, and dorky=true123 each on separate lines.
file_getprop("/tmp/bob.txt", "cool") == "yes"
file_getprop("/tmp/bob.txt", "dorky") == "true123"
getprop(VALUE); Functions the same as file_getprop, without the file part. It looks through the system value pairs for a matching value.
Ex. getprop("ro.build.id") == "OLYEM1.2.3.4"
delete(PATH1, ...,PATHN); Nothing to see here, just a delete command, full path to the file(s) as argument(s).
delete_recursive(PATH1, ...,PATHN); It's a delete everything in a folder, including subfolders command. The folder itself is deleted as well.
set_perm(UID, GID, MODE, PATH1, ..., PATHN); Set the linux permissions on a file, ownership and flags at the same time. Equivalent to chown and chmod in the one command.
Ex. set_perm(0, 0, 06755, /system/bin/su, /system/bin/shsu); *0 stands for root, so it would be owned by root, of the group root, with suid bit set and standard executable bits set.
set_perm_recursive(UID, GID, DIRMODE, FILEMODE, PATH1, ...,PATHN); Same as above except with folders instead of files. Use the DIRMODE to set the permissions and ownership of the folders themselves, and FILEMODE to set the permissions of the files within them.
symlink(TARGET, LINK1, ...,LINKN); It's the equivalent to the linux ln -s command. For our purposes, it might as well be called busybox install.
Ex. symlink("/system/bin/busybox", "/system/bin/awk", "/system/bin/wget", "/system/bin/sed");
To Be Continued..
​
References
http://devphone.org/development/edify-script-syntax-explained/
http://www.synfulgeek.com/main/index.php/articles/76-scratchpad-documenting-edify-commands-for-android-updater-scritps-based-off-of-kernel-source-code
https://github.com/koush/android_bootable_recovery/blob/eclair/edify/README
http://tjworld.net/wiki/Android/UpdaterScriptEdifyFunctions​
Tips:
You can use the abort() command to step through your updater script, for instance if you wanted to check various combinations on syntax for write_raw_image();
In /tmp there is a text file called recovery.log, do a cat /tmp/recovery.log to see extra output of your script from failed commands.
NFHimself said:
The updater-script file is a text file, it is linux formatted with regard to end of line conventions. If you use Windows then you have to edit the file using a program that keeps line feeds the way they are and has options for doing the conversion from <CR><LF> to just <LF>.
Click to expand...
Click to collapse
If you are in windows, I have found that notepad++ does the job just fine.
http://notepad-plus-plus.org/
what about the FORMAT command?
actually i have error on a CM installation, its says
Code:
format() expects 3 args, got 2.
but my format command have 3 args:
Code:
format("ext4", "/dev/block/mmcblk0p10", "/system");
NFHimself said:
Hi, I haven't seen any good resources for how to edit edify scripts, so I thought I would create this thread so we can pool our knowledge on the subject.
Intro​
Click to expand...
Click to collapse
Thanks for this... but I do have a question....
I am attempting to see if busybox is installed on a device, and if not install it, or proceed
so, so far I have:
Code:
ifelse(
BUSYBOX DOESNT EXIST,
(
ui_print("* Did not find it. Installing...");
set_perm(0, 1000, 0755, "/system/xbin/busybox");
symlink("/system/xbin/busybox", "/system/bin/busybox");
run_program("/system/xbin/busybox", "--install", "-s", "/system/xbin");
),
(
ui_print("* Found it. Proceeding...");
)
);
You can see where I'm lost I was thinking of using assert to run_program("/system/xbin/busybox", "vi", "/system/xbin"); just as a simple check... but from what I can see, if the assertion fails it will stop the script, and print out the failure message, which of course is not what I am after here... or maybe I am, can it be used to do a check rather than stop the script?​
Just an idea (ie. untested):
Code:
ifelse(
run_program("/system/bin/sh", "-c", "test -e /system/xbin/busybox")
...
)
ravilov said:
Just an idea (ie. untested):
Code:
ifelse(
run_program("/system/bin/sh", "-c", "test -e /system/xbin/busybox")
...
)
Click to expand...
Click to collapse
trying to run that in adb sheel, and don't get a response, but it does seem like a good idea... I assume Edify would return a 1/0 or true/false string from it, and I can just check for that?
EDIT: Maybe I do get something back... after running that in adb shell my next line looks like the following:
Code:
1|[email protected]:/ #
Am I right in assuming that "1" is the output?
Yes. The command won't ever return any output, it only returns the exit status. Your shell is obviously set so it includes a non-zero exit status in the prompt. (Non-zero traditionally means error.)
ravilov said:
Yes. The command won't ever return any output, it only returns the exit status. Your shell is obviously set so it includes a non-zero exit status in the prompt. (Non-zero traditionally means error.)
Click to expand...
Click to collapse
that prompt means that the test failed, and I don't have busybox installed?
I'm just a tad confused... (this is my first full-on edify script), and I do have busybox installed
I appreciate the help, and once I get my tapatalk working right on my phone, I'll give ya all the "thanks" for the help with this
Eh... everything I 'test' returns the same thing
Code:
1|[email protected]:/ #
Hm, weird. It works for me...
Code:
# /system/bin/sh -c 'test -e /system/xbin/busybox'; echo $?
0 [color=silver]<-- no error - file exists[/color]
# /system/bin/sh -c 'test -e /system/xbin/busybox1'; echo $?
1 [color=silver]<-- error - file does not exist[/color]
I didn't try it in an edify script because I don't feel like rebooting my phone right now, but I don't see why it wouldn't work.
Try running the "sh -c test ..." command in adb shell while in recovery and see what happens.
Also, just a side note: backslash is NOT the same as slash. If you are going to write shell/edify scripts, you need to know at least that distinction. That is why your
Code:
tags are not working right.[/b][/i][/size]
ravilov said:
Hm, weird. It works for me...
Code:
# /system/bin/sh -c 'test -e /system/xbin/busybox'; echo $?
0 [color=silver]<-- no error - file exists[/color]
# /system/bin/sh -c 'test -e /system/xbin/busybox1'; echo $?
1 [color=silver]<-- error - file does not exist[/color]
I didn't try it in an edify script because I don't feel like rebooting my phone right now, but I don't see why it wouldn't work.
Try running the "sh -c test ..." command in adb shell while in recovery and see what happens.
Also, just a side note: backslash is NOT the same as slash. If you are going to write shell/edify scripts, you need to know at least that distinction. That is why your
Code:
tags are not working right.[/b][/i][/size][/QUOTE]
I see, I wasn't doing the echo, and what you posted shows exactly what you posted. DOH on the CODE :good:
So I have it on record (for my own personal reference)
[CODE]
ifelse(
((run_program("/system/bin/sh", "-c", "test -e /system/xbin/busybox; echo $?") == 1 ||
(run_program("/system/bin/sh", "-c", "test -e /system/bin/busybox; echo $?") == 1 ||
(run_program("/system/bin/sh", "-c", "test -e /system/xbin/busibox; echo $?") == 1 ||
(run_program("/system/bin/sh", "-c", "test -e /system/bin/busibox; echo $?") == 1),
(
ui_print("* Did not find it. Installing...");
set_perm(0, 1000, 0755, "/system/xbin/busybox");
symlink("/system/xbin/busybox", "/system/bin/busybox");
run_program("/system/xbin/busybox", "--install", "-s", "/system/xbin");
),
(
ui_print("* Found it. Proceeding...");
)
);
and yes, I meant the 'busibox' part, because I have seen that in some roms
Click to expand...
Click to collapse
You guys know way more about this stuff than I do... although i am a programmer
could I get some insight over here: http://forum.xda-developers.com/showthread.php?t=2796055
having an issue getting my shell scripts to actually run...
Rockin' it from my Smartly GoldenEye 35 NF1 (muchas gracias:* @iB4STiD @loganfarrell @muniz_ri @Venom0642 @ted77usa @rebel1699* @iB4STiD) ~ 20GB free cloud https://copy.com?r=vtiraF
Check me out online @ http://kevin.pirnie.us
note: the scripts do run in adb shell
published API docs
NFHimself said:
Hi, I haven't seen any good resources for how to edit edify scripts, so I thought I would create this thread so we can pool our knowledge on the subject.
Click to expand...
Click to collapse
I found some official documentation of the API on the Android Web site here:
https://source.android.com/devices/tech/ota/inside_packages.html
NFHimself said:
[*]write_raw_image(PATH, PARTITION); This is one of those tricky ones, the PATH is somewhere on your phone with the image to be flashed to a PARTITION on your phone. The trouble is, how do you specify what partition gets flashed? Is there any restriction on where the file has to be? If MTD conventions are used, you are looking for "system", "boot", "recovery", "logo.bin". (All this means that each partition has a name stored somewhere, and if you know it, you can write to it.) Maybe it will accept device references like /dev/block/mmcblk0p8. This depends on the update-binary file you are using.
Ex. write_raw_image("/tmp/logo.bin", "logo.bin");
Ex. write_raw_image("/tmp/logo.bin", "/dev/block/mmcblk0p8");
[*]write_firmware_image(PATH, PARTITION); You would think it would be the same as write_raw_image. Not sure what the difference is.
Click to expand...
Click to collapse
I didn't do a line by line comparison between your description and theirs, but I noticed this part because I was trying to find information about these functions. Only write_raw_image() is a published API function. This is the description:
write_raw_image(filename_or_blob, partition)
Writes the image in filename_or_blob to the MTD partition. filename_or_blob can be a string naming a local file or a blob-valued argument containing the data to write. To copy a file from the OTA package to a partition, use: write_raw_image(package_extract_file("zip_filename"), "partition_name");​
Probably write_firmware_image() is used internally. It could be removed at any time, or it even could be a stub - not a good idea to use it.

[devs][unsolved] just coping init.d script in its folder works

hey devs , i came above something made me thinking , if i just copy the init.d scripts in their folder in a rom made of flashable zip ex.cm10 the permition of these files doesnt be the same if i install the musing pimp my rom aroma ,, is these permition neccesary to scripts to work ??, if yes how can i set them right
rrgrrg said:
hey devs , i came above something made me thinking , if i just copy the init.d scripts in their folder in a rom made of flashable zip ex.cm10 the permition of these files doesnt be the same if i install the musing pimp my rom aroma ,, is these permition neccesary to scripts to work ??, if yes how can i set them right
Click to expand...
Click to collapse
Permissions are important yes (Sometimes more permissions than necessaries are given to account for differences across devices and they will change per script)
Are they not working, since your asking?
If they aren't run, there are a few things I can think of.
You need to mod the ramdisk to run the scripts on startup or make a file that is already being run on startup to run the scripts in init.d. (CM10 already has it included, don't think any repack got it included - didn't check all of them, so some might have)
The permission the scripts are being run at are the same as what the permissions are from what executed them. Most tweaks need to be run from root so make sure that they are being executed as root if they don't need to be executed as root and aren't run with root permissions make sure that they have sufficient permissions to be run as that user.
Making init.d scripts run a echo command to a file is a good way to check if they are being executed.
And that's what I can think of at the moment.
ok so how can i apply their permitions from the zip of the rom ,, what lines should i add to the updater-script that fixes their permition ? ,, also im using cm10 as a base so its ok with the ramdisk
Code:
set_perm(0, 0, 0755, "/system/etc/init.d");
Ilko said:
Code:
set_perm(0, 0, 0755, "/system/etc/init.d");
Click to expand...
Click to collapse
this to be in the updater-script right ??..
,, i already have these both lines in my cwm script
set_perm_recursive(0, 2000, 0755, 0755, "/system/etc/init.d");
set_perm(0, 0, 0755, "/system/etc/init.d");
Click to expand...
Click to collapse
in your code perms are set two times (first line is useless I think and may apply wrong perms on the etc dir). I don't have much knowledge about these kind of scripts, but I can say that the recursive parameter is used for direcories. also, perms have to be set at the end of scripts (before unmountin of course) so they're applied permanently.
it must be something like this (in short) :
Code:
# mount
run_program("/sbin/busybox", "mount", "/system");
# remove previous bin
delete("/system/etc/init.d");
# copy file from source
package_extract_file("system", "/system/etc/init.d");
# ser perm
set_perm(0, 0, 0755, "/system/etc/init.d");
# unmount
run_program("/sbin/busybox", "umount", "/system");

Fast Superuser for ICSROM [21 Feb 2013]

I may have fixed the lag in Root Explorer and other apps on ICSROM. No need to continue reading unless you also have this problem.
Not much in the way of Atrix rootin’ guides of late, so I downloaded Chainfire's latest UPDATE-SuperSU-v1.04.zip here: http://forum.xda-developers.com/showthread.php?t=1538053
Direct link: http://download.chainfire.eu/310/SuperSU/UPDATE-SuperSU-v1.04.zip
knowing that…
Chainfire quote: “ZIP does not work on all devices, needs fix. Note that if you are already rooted, installing through Market is by far the easiest way to install SuperSU !”
True to these sage words, the CWM install crashed. And /tmp/recovery.log showed no details.
So I switched to Ubuntu and tried the same thing. Same results.
So I opened the zip and found:
Reference to a /tools directory not contained in the zip
Many lines of code for manual deletion of superuser related files
Temporary rearrangement of heavyweight apps to make room for 2MB of superuser files
Broken update-binary
So I completely re-designed it.
Code:
/META-INF/com/google/android/updater-script:
assert(getprop("ro.product.device") == "olympus" || getprop("ro.build.product") == "olympus");
ui_print(" ");
ui_print("Fast Superuser for Atrix 4g ICS!");
ui_print("Initial Release: 21 Feb 2013");
ui_print("sendust7 @ xda-developers");
ui_print("Credits: Chainfire (SuperSU v1.04)");
ui_print(" ");
ui_print(" Removing old superuser files from /system, /cache,");
ui_print(" /data and /preinstall");
package_extract_file("find-rm-su.sh", "/tmp/find-rm-su.sh");
set_perm(0, 0, 0777, "/tmp/find-rm-su.sh");
run_program("/sbin/busybox", "sh", "/tmp/find-rm-su.sh", "/dev/block/mmcblk0p12","/system");
run_program("/sbin/busybox", "sh", "/tmp/find-rm-su.sh", "/dev/block/mmcblk0p15","/cache");
run_program("/sbin/busybox", "sh", "/tmp/find-rm-su.sh", "/dev/block/mmcblk0p16","/data");
run_program("/sbin/busybox", "sh", "/tmp/find-rm-su.sh", "/dev/block/mmcblk0p17","/preinstall");
ui_print(" ");
ui_print(" Mount /system and /data");
run_program("/sbin/busybox", "mount", "/system");
run_program("/sbin/busybox", "mount", "/data");
ui_print(" ");
ui_print(" Extract new superuser files");
package_extract_dir("system", "/system");
ui_print(" ");
ui_print(" Set permissions");
set_perm(0, 0, 06755, "/system/xbin/su");
set_perm(0, 0, 0644, "/system/app/Superuser.apk");
set_perm(0, 0, 0644, "/system/app/Supersu.apk");
ui_print(" ");
ui_print(" Unmount /system and /data");
unmount("/system");
unmount("/data");
ui_print(" ");
ui_print(" Done... Reboot and enjoy!");
and…
Code:
find-rm-su.sh:
#!/system/bin/sh
# Find and remove all instances of superuser in ROM
# sendust7 @ xda-developers
MOUNT_DEVICE=$1
MOUNT_POINT=$2
if [ -d "${MOUNT_POINT}" ]
then
echo "Directory: ${MOUNT_POINT} exists (OK)"
else
mkdir ${MOUNT_POINT}
fi
mount -t ext4 ${MOUNT_DEVICE} ${MOUNT_POINT}
/sbin/busybox find ${MOUNT_POINT} -name su -exec rm {} \;
/sbin/busybox find ${MOUNT_POINT} -name *[Ss][Uu]per[Ss][Uu]* -exec rm -r {} \;
/sbin/busybox find ${MOUNT_POINT} -name *[Ss][Uu]per[Uu][Ss]* -exec rm -r {} \;
umount ${MOUNT_POINT}
Superuser-Atrix-ICS-v1.0.zip: http://www.mediafire.com/?34tka3vjlfyj8fv
CWM flash and voila... root returns to ICSROM. And Root Explorer now opens in the blink of an eye.
Then I ported Superuser-Atrix-ICS to SD with a few small changes to updater-script:
Superuser-Atrix-ICS-v1.0-SD.zip: http://www.mediafire.com/?6d75i66d02liejh
Superuser-Atrix-ICS-v1.0.zip and Superuser-Atrix-ICS-v1.0-SD.zip are tested working on my dual boot configuration: ICSROM (EMMC) and MROM ICS (SD) --- though I didn’t see any improvement on MROM since root apps already load fast on it.
I have not observed any degradation in performance thus far.
Tips:
A second reboot may be needed to smooth things out.
If adb hangs after entering “su”, look at your phone and see if adb is requesting superuser. This one is easy to miss since we tend to be watching our adb computer screen instead of phone.
ICSROM 146 defaults to “USB connected as mass storage” so you can easily drag-drop files to/from computer. But for development I think it is better to initialize to “Media Device MTP” so apps like Root Explorer can access memory.
You can selectively turn off superuser notifications by going to SuperSU > Apps. This page displays apps that have already requested SU permission. Alternatively you can turn off SU request notifications globally with SuperSU Settings > Show notifications.
Lessons learned: Do what Chainfire says and download/install his SuperSU from Google Play, lol. OR... if you’re curious like me and want to know what’s going on inside the black box, you tear into the zip file and do it the hard way -- After all, that is often how we learn
Enjoy.
Credits: Chainfire (SuperSU)
Nice work. Keep it up.
saintmonte said:
Nice work. Keep it up.
Click to expand...
Click to collapse
I probably won't ever use this but I know that others surely will, and for that, YOU are the man sendust7!
constructive criticism:
You can use -iname In the find to make it case insensitive search.
Your searching the entire mount points which can take a while and is a bit dangerous. You only need to search /data/app and /system/app for apks.
you only need to search /system/*bin for su.
you should use -depth in your find to prevent cascading down directories.
The thing is your script still isn't universal because a developer can name the super user apk ANYTHING in their rom. just mentioning.
I commend for taking initiative though.
<ducks and runs>
calisro said:
constructive criticism:
You can use -iname In the find to make it case insensitive search.
Your searching the entire mount points which can take a while and is a bit dangerous. You only need to search /data/app and /system/app for apks.
you only need to search /system/*bin for su.
you should use -depth in your find to prevent cascading down directories.
The thing is your script still isn't universal because a developer can name the super user apk ANYTHING in their rom. just mentioning.
I commend for taking initiative though.
<ducks and runs>
Click to expand...
Click to collapse
Thanks for the CC...
Actually the -iname option is unnecessarily expansive since it would desensitize the "per" in Superuser and SuperSU.
Also it is necessary to search all mount points --- including preinstall --- since superuser apk's and binaries may be hiding there as well (see ICSROM ramdisk).
I deliberately did not use the -depth option for the reason given immediately above. The idea is to not only remove superuser files with ".apk" extension, but all data associated with them as well.
Finally, I did not intend for this version to be universal as it applies strictly to Atrix 4g running ICS. But I did post the source code to help explain what I did and to enable easier porting to another ROM or device.
Thanks again, and have a great day!
sendust7 said:
Thanks for the CC...
Actually the -iname option is unnecessarily expansive since it would desensitize the "per" in Superuser and SuperSU.
Also it is necessary to search all mount points --- including preinstall --- since superuser apk's and binaries may be hiding there as well (see ICSROM ramdisk).
I deliberately did not use the -depth option for the reason given immediately above. The idea is to not only remove superuser files with ".apk" extension, but all data associated with them as well.
Finally, I did not intend for this version to be universal as it applies strictly to Atrix 4g running ICS. But I did post the source code to help explain what I did and to enable easier porting to another ROM or device.
Thanks again, and have a great day!
Click to expand...
Click to collapse
sure...
I tested it for you but as you can see it will delete things it shouldn't.
# find / -name *[Ss][Uu]per[][Uu]*
system/app/Superuser.apk
data/data/com.android.browser/app_databases/localstorage/http_superuser.com_0.
alstorage
data/data/com.estrongs.android.pop/cache/.apps/s.system.app.Superuser.apk
data/data/com.estrongs.android.pop/cache/.apps/s.sdcard.AndroZip.system.app.Supuser.apk
data/data/com.estrongs.android.pop/cache/.apps/ssystem.app.Superuser.apk
data/data/eu.chainfire.exynosabuse/files/superuser.png
cache/dalvik-cache/[email protected]@[email protected]
I know your offended but I was just trying to help others not have unintended consequences.
You can search all mount points but you should narrow the scope down to required directories.
also rom developers will also call supersu SUPERSU.apk which why I mentioned iname.
oh well.
Thanks again.
calisro said:
sure...
I tested it for you but as you can see it will delete things it shouldn't.
# find / -name *[Ss][Uu]per[][Uu]*
system/app/Superuser.apk
data/data/com.android.browser/app_databases/localstorage/http_superuser.com_0.
alstorage
data/data/com.estrongs.android.pop/cache/.apps/s.system.app.Superuser.apk
data/data/com.estrongs.android.pop/cache/.apps/s.sdcard.AndroZip.system.app.Supuser.apk
data/data/com.estrongs.android.pop/cache/.apps/ssystem.app.Superuser.apk
data/data/eu.chainfire.exynosabuse/files/superuser.png
cache/dalvik-cache/[email protected]@[email protected]
I know your offended but I was just trying to help others not have unintended consequences.
You can search all mount points but you should narrow the scope down to required directories.
also rom developers will also call supersu SUPERSU.apk which why I mentioned iname.
oh well.
Thanks again.
Click to expand...
Click to collapse
Thanks! I will have another look at the zip in light of all your comments.
BTW, I am not offended
sendust7 said:
Thanks! I will have another look at the zip in light of all your comments.
BTW, I am not offended
Click to expand...
Click to collapse
thx Sendust. I'm sorry I assumed you may be. :beer:

[SOLVED] Can't install the 1.1 update.zip - "Installation Aborted"

Okay guys I will come straight to the point... 5 days back I announced that I will release an update for Sami OS.. In fact I was uploading the zip file.. but while uploading the zip I decided to flash the zip and try it out by myself in my phone and IT DID NOT WORK!
This is exactly what CWM says:
Code:
Installing: /sdcard/SOS_UPDATE_1.1.zip
Finding update package...
Opening update package...
Installing update...
Installation aborted.
And this is what TWRP says:
Code:
Installing '/external_sd/SOS_UPDATE_1.1.zip'...
Checking for MD5 file...
I:Cannot find file /external_sd/SOS_UPDATE_1.1.zip.md5
Skipping MD5 check: no MD5 file found.
Error flashing zip '/external_sd/SOS_UPDATE_1.1.zip'
Updating partition details...
As you can see, I tried flashing my zip file in both recoveries.. TWRP says "Failed" in Red color and CWM says "Installation aborted"..
I've attached recovery.log file from both TWRP and CWM.. I've also uploaded the entire zip file (33 MB) and its updater-script... So can anyone please take a look at them and tell me what's wrong and is causing this issue... PS: I've tried all my modified apks and jars separately in my phone and they all worked without any errors...
LINKS:
- http://www.mediafire.com/view/ticvtrx7w81s58a/recovery_TWRP.log
- http://www.mediafire.com/view/ni778ths21indzw/recovery_cwm.log
- http://www.mediafire.com/download/scpk5z4cb1pu52y/updater-script
- http://www.mediafire.com/download/t73a89f92812j35/SOS_UPDATE_1.1.zip
Thanks in advance
META-NF?!
I would add a "I" (I'm gonna try in some seconds, but should be that)
(You wrote a lot in updater-script, many things are not necessary)
Sent from Italy using Tapatalk
Toni5830 said:
META-NF?!
I would add a "I" (I'm gonna try in some seconds, but should be that)
(You wrote a lot in updater-script, many things are not necessary)
Sent from Italy using Tapatalk
Click to expand...
Click to collapse
HOLY SH*T!
LOL I DID NOT NOTICE THAT AT ALL!! Thanks man
Anyways what can I remove from my updater-script to trim or shorten it?
Sami Kabir said:
HOLY SH*T!
LOL I DID NOT NOTICE THAT AT ALL!! Thanks man
Anyways what can I remove from my updater-script to trim or shorten it?
Click to expand...
Click to collapse
LOL .
You don't need to delete every file you are updating as these will be overwritten (here my example https://www.dropbox.com/s/jm6u0istpqxvj5b/updater-script ) I also added a line to delete a lib file, polaris*something*.so (11mb), you won't need it if you delete polaris viewer
I could not test because editing updater-script whit phone caused a different error: status 6, I'm redownloading it, having a shower and then I'll try
(I flashed your rom this afternoon, I see you've worked a lot on it to change graphic and modding apk (wait me, I'll pm you when I'll need to disable animation from toggles ))
Sent from Italy using Tapatalk
iiD4x said:
LOL .
Click to expand...
Click to collapse
I'm a human.. and humans do make mistakes :silly:
Toni5830 said:
You don't need to delete every file you are updating as these will be overwritten (here my example https://www.dropbox.com/s/jm6u0istpqxvj5b/updater-script ) I also added a line to delete a lib file, polaris*something*.so (11mb), you won't need it if you delete polaris viewer
I could not test because editing updater-script whit phone caused a different error: status 6, I'm redownloading it, having a shower and then I'll try
(I flashed your rom this afternoon, I see you've worked a lot on it to change graphic and modding apk (wait me, I'll pm you when I'll need to disable animation from toggles ))
Sent from Italy using Tapatalk
Click to expand...
Click to collapse
Thanks man! I'll look into it asap
Status 6 error
Worked with:
Code:
run_program("/sbin/busybox", "mount", "/system");
package_extract_dir("system", "/system");
run_program("/sbin/busybox", "umount", "/system");
You just need to add "delete" line
Sent from Italy using Tapatalk
I got some free time to work on my ROM"s zip file.. I solved the problems I had earlier but now new problems came up
Now when I flash my zip file, TWRP says "error executing update-binary".. I've tried replacing it with many other update-binary files BUT none of them work! I took a look at recovery.log file and it says this at the end:
Code:
Installing '/external_sd/SOS_UPDATE_1.1.zip'...
Checking for MD5 file...
I:Cannot find file /external_sd/SOS_UPDATE_1.1.zip.md5
Skipping MD5 check: no MD5 file found.
I:Zip does not contain SELinux file_contexts file in its root.
[B]line 40 col 9: syntax error, unexpected STRING, expecting $end[/B]
1 parse errors
E:Error executing updater binary in zip '/external_sd/SOS_UPDATE_1.1.zip'
Error flashing zip '/external_sd/SOS_UPDATE_1.1.zip'
Updating partition details...
I looked at line 40 in my updater-script and it looks fine to me.. line 40 is this only:
Code:
ui_print(" ");
Now I don't know what to do.. so @Toni5830 and @mr.harsh, can you guys help me solve this problem..
I've attached my new recovery.log file and my updater-script below..
Sami Kabir said:
I got some free time to work on my ROM"s zip file.. I solved the problems I had earlier but now new problems came up
Now when I flash my zip file, TWRP says "error executing update-binary".. I've tried replacing it with many other update-binary files BUT none of them work! I took a look at recovery.log file and it says this at the end:
Code:
Installing '/external_sd/SOS_UPDATE_1.1.zip'...
Checking for MD5 file...
I:Cannot find file /external_sd/SOS_UPDATE_1.1.zip.md5
Skipping MD5 check: no MD5 file found.
I:Zip does not contain SELinux file_contexts file in its root.
[B]line 40 col 9: syntax error, unexpected STRING, expecting $end[/B]
1 parse errors
E:Error executing updater binary in zip '/external_sd/SOS_UPDATE_1.1.zip'
Error flashing zip '/external_sd/SOS_UPDATE_1.1.zip'
Updating partition details...
I looked at line 40 in my updater-script and it looks fine to me.. line 40 is this only:
Code:
ui_print(" ");
Now I don't know what to do.. so @Toni5830 and @mr.harsh, can you guys help me solve this problem..
I've attached my new recovery.log file and my updater-script below..
Click to expand...
Click to collapse
add ";" at the end of 39th line.
mr.harsh said:
add ";" at the end of 39th line.
Click to expand...
Click to collapse
Thanks for your reply mate, but I have already figured it out.. I didn't have the time to reply or edit my first post earlier - sorry for that.. Anyways I think this issue was caused because TWRP starts counting lines from 0 onward whereas Notepad++ starts counting them from 1 onward...
Anyways now I have another problem.. The installation of my ROM now aborts in the middle.. While setting default permission, the installation aborts and this is what I found in recovery.log:
Code:
set_perm: chown of 0644 to 0 0 failed: No such file or directory
set_perm: chmod of 0644 to 755 failed: No such file or directory
script aborted: set_perm: some changes failed
set_perm: some changes failed
E:Error executing updater binary in zip '/external_sd/SOS_UPDATE_1.1.zip'
Error flashing zip '/external_sd/SOS_UPDATE_1.1.zip'
Updating partition details...
I honestly have no idea what the first 4 lines mean.. But as far as I know that update-binary file is totally compatible with SGSA..
Sami Kabir said:
Thanks for your reply mate, but I have already figured it out.. I didn't have the time to reply or edit my first post earlier - sorry for that.. Anyways I think this issue was caused because TWRP starts counting lines from 0 onward whereas Notepad++ starts counting them from 1 onward...
Anyways now I have another problem.. The installation of my ROM now aborts in the middle.. While setting default permission, the installation aborts and this is what I found in recovery.log:
Code:
set_perm: chown of 0644 to 0 0 failed: No such file or directory
set_perm: chmod of 0644 to 755 failed: No such file or directory
script aborted: set_perm: some changes failed
set_perm: some changes failed
E:Error executing updater binary in zip '/external_sd/SOS_UPDATE_1.1.zip'
Error flashing zip '/external_sd/SOS_UPDATE_1.1.zip'
Updating partition details...
I honestly have no idea what the first 4 lines mean.. But as far as I know that update-binary file is totally compatible with SGSA..
Click to expand...
Click to collapse
Probably you are doing chmod on a file or folder that is not in your ROM.
Hmmm, but all are there. Try to remove those chmod parts, and see if installation is ok without it.
Problem should be this line
Code:
set_perm(0, 0, 0755, 0644, "/system/etc/hosts");
I think it should be
Code:
set_perm(0, 0, 0644, "/system/etc/hosts");
(Or, as shut_down said, remove that line if it still gives errors, it's not necessary)
Sent from Italy using Tapatalk
@shut_down and @Toni5830,
As you guys said, I've corrected the Permission problems in my updater-script.. and now the finally zip flashes.. but now my phone won't boot to system.. it just boots to Recovery [TWRP]..
I wonder what went wrong this time... Should I pull a logcat or something? But I don't know if it will work or not because the phone directly boots to Recovery mode after the Samsung splash screen
EDIT: I tried wiping Cache and Dalvik, still no help...
Sami Kabir said:
@shut_down and @Toni5830,
As you guys said, I've corrected the Permission problems in my updater-script.. and now the finally zip flashes.. but now my phone won't boot to system.. it just boots to Recovery [TWRP]..
I wonder what went wrong this time... Should I pull a logcat or something? But I don't know if it will work or not because the phone directly boots to Recovery mode after the Samsung splash screen
EDIT: I tried wiping Cache and Dalvik, still no help...
Click to expand...
Click to collapse
This is what happens when you delete googleserviceframework.apk
Sent from Italy using Tapatalk
Sami Kabir said:
@shut_down and @Toni5830,
As you guys said, I've corrected the Permission problems in my updater-script.. and now the finally zip flashes.. but now my phone won't boot to system.. it just boots to Recovery [TWRP]..
I wonder what went wrong this time... Should I pull a logcat or something? But I don't know if it will work or not because the phone directly boots to Recovery mode after the Samsung splash screen
EDIT: I tried wiping Cache and Dalvik, still no help...
Click to expand...
Click to collapse
Code:
delete("/system/app/SystemUI.apk","/system/app/SecSettings.apk","/system/app/PolarisViewer.apk","/system/app/MtpApplication.apk","/system/app/Disable_service.apk","/system/app/SyncmlDM.apk");
delete("/system/framework/android.policy.jar","/system/framework/core.jar","/system/framework/framework2.jar","/system/framework/framework-res.apk","/system/framework/services.jar","/system/framework/twframework.jar");
delete("/system/etc/hosts","/system/etc/init.d/01_zipalign","/system/etc/init.d/02_sqlite_optimize","/system/etc/init.d/03_tweaks","/system/etc/init.d/06_MramLlag","/system/build.prop");
Remove the delete commands. When you flash the files will be automatically replaced. Only delete the files which are not going to be replaced
And instead of
Code:
package_extract_dir("system/app", "/system/app");
package_extract_dir("system/etc", "/system/etc");
package_extract_dir("system/framework", "/system/framework");
package_extract_dir("system/build.prop", "/system/build.prop");
Code:
package_extract_dir("system", "/system");
this will be enough
and as toni said above change the permission of /system/app and /system/framework and /system/etc to 755.
You can also use fix permission from CWM recovery to set permission right.
Dont use twrp.
anantttt said:
Code:
delete("/system/app/SystemUI.apk","/system/app/SecSettings.apk","/system/app/PolarisViewer.apk","/system/app/MtpApplication.apk","/system/app/Disable_service.apk","/system/app/SyncmlDM.apk");
delete("/system/framework/android.policy.jar","/system/framework/core.jar","/system/framework/framework2.jar","/system/framework/framework-res.apk","/system/framework/services.jar","/system/framework/twframework.jar");
delete("/system/etc/hosts","/system/etc/init.d/01_zipalign","/system/etc/init.d/02_sqlite_optimize","/system/etc/init.d/03_tweaks","/system/etc/init.d/06_MramLlag","/system/build.prop");
Remove the delete commands. When you flash the files will be automatically replaced. Only delete the files which are not going to be replaced
And instead of
Code:
package_extract_dir("system/app", "/system/app");
package_extract_dir("system/etc", "/system/etc");
package_extract_dir("system/framework", "/system/framework");
package_extract_dir("system/build.prop", "/system/build.prop");
Code:
package_extract_dir("system", "/system");
this will be enough
and as toni said above change the permission of /system/app and /system/framework and /system/etc to 644.
You can also use fix permission from CWM recovery to set permission right.
Dont use twrp.
Click to expand...
Click to collapse
Are you sure that those files will be replaced automatically?
And what code do you think I should use to set the permission to 644, should it be this one?
PHP:
set_perm_recursive(0, 0, 0755, 0644, "/system");
Sami Kabir said:
Are you sure that those files will be replaced automatically?
And what code do you think I should use to set the permission to 644, should it be this one?
PHP:
set_perm_recursive(0, 0, 0755, 0644, "/system");
Click to expand...
Click to collapse
Yup,it'll replace/append files.It'll set permission of all sub folders to 755 and all files to 644.But be careful because init.d script requires 777 permission (depends on ramdisk).And it is better to set 777 permission to /system/bin and /system/xbin.And yeah su binary wants 06755 permission else it won't work.
Sami Kabir said:
Are you sure that those files will be replaced automatically?
And what code do you think I should use to set the permission to 644, should it be this one?
PHP:
set_perm_recursive(0, 0, 0755, 0644, "/system");
Click to expand...
Click to collapse
Late to reply. Yes it would replace the files.
Edit: In detail, see the above post.
mr.harsh said:
Yup,it'll replace/append files.It'll set permission of all sub folders to 755 and all files to 644.But be careful because init.d script requires 777 permission (depends on ramdisk).And it is better to set 777 permission to /system/bin and /system/xbin.And yeah su binary wants 06755 permission else it won't work.
Click to expand...
Click to collapse
Um, I was just going through my ROM's original updater-script (the one in SOS 1.0).. in there I used 755 permission in "/system/bin" and in "/system/xbin".. It was like this:
Code:
set_perm_recursive(0, 2000, 0755, 0755, "/system/bin");
set_perm_recursive(0, 2000, 0755, 0755, "/system/xbin");
And my ROM worked with no problems.. so should I use that or should I set it as 777 as you said above?
Sami Kabir said:
Um, I was just going through my ROM's original updater-script (the one in SOS 1.0).. in there I used 755 permission in "/system/bin" and in "/system/xbin".. It was like this:
Code:
set_perm_recursive(0, 2000, 0755, 0755, "/system/bin");
set_perm_recursive(0, 2000, 0755, 0755, "/system/xbin");
And my ROM worked with no problems.. so should I use that or should I set it as 777 as you said above?
Click to expand...
Click to collapse
@Sami
Buddy if you need any help with testing let me know...
I have been using and doing roms for more than a year....[currently modifying Omni for myself]
Anyways thanks for the rom.....

[Edify question]-piping not working-how to selectively chmod certain files?

I am trying to get my android updater-script to selectively change permissions based on filename. I want all files under a certain subdirectory following the naming pattern "A.xy" set to 0755 and all other files set to 0644
So I first set all of them to 0644, then tried to selectively set the rest to 0755 by piping commands using xargs and exec. However, neither of the following commands worked but neither of them gave an error. Does anyone have a better way of doing this, or have an idea why neither of these worked?
run_program("/sbin/busybox", "find", " /data/app", "-name", "A.xy", "-type", "f", "-print0", "|", "/sbin/busybox", "xargs", "-0", "chmod", "0644");
run_program("/sbin/busybox find /data/app -name A.xy -type f -exec chmod 0644 {} \;");
It seems like update-binary doesn't allow piping? It doesn't give an error though.
Any idea how I can set all files of one type to be one permission, and all files of another type to be a different permission?
Thread closed.
Please see the continuation of this topic here: http://forum.xda-developers.com/android/help/edify-question-how-to-pipe-t3509804
Thanks!

Categories

Resources