[Q] Executing an sh script from a flashable zip - Android Q&A, Help & Troubleshooting

I want to change the screen resolution of my device and I have an sh script for it.
Code:
#!/system/bin/sh
am display-size 1280x800
am display-density 160
How do I create a flashable zip file that can execute this script?

supersapien said:
I want to change the screen resolution of my device and I have an sh script for it.
Code:
#!/system/bin/sh
am display-size 1280x800
am display-density 160
How do I create a flashable zip file that can execute this script?
Click to expand...
Click to collapse
It will be something like this:
Code:
# u have to get your mount point this is just example
mount("ext4", "EMMC", "/dev/block/mmcblk0p9", "/system");
package_extract_file("xxx.sh", "/tmp/xxx.sh");
set_perm(0, 0, 0777, "/tmp/xxx.sh");
run_program("/tmp/xxx.sh");
delete("/tmp/xxx.sh");
unmount("/system");

s3icc0 said:
It will be something like this:
Code:
# u have to get your mount point this is just example
mount("ext4", "EMMC", "/dev/block/mmcblk0p9", "/system");
package_extract_file("xxx.sh", "/tmp/xxx.sh");
set_perm(0, 0, 0777, "/tmp/xxx.sh");
run_program("/tmp/xxx.sh");
delete("/tmp/xxx.sh");
unmount("/system");
Click to expand...
Click to collapse
Thanks a lot. I came up with something similar but I missed the set_perm option.

Related

[Q] Edify commands for making flashable ZIP

I'm planning on using the UpdatezipCreator from this thread http://forum.xda-developers.com/show....php?t=1274736 to build an update script for some APK updates I want to package up. It appears this app has the ability to build a update-binary file for you.
I have APK files in both the system/app and data/app that I want to be copied to my phone. I'm confused on a few things.
First thing, can I have multiple destinations for the files in the script? I haven't found any examples with two destinations and there doesn't seem to be a spot to configure the source which makes me think it just takes everything in the zip and puts it in the folder you specifiy in the package_extract_dir function and that adding a second "package_extract_dir" function would confuse it.
The second question is I keep running across scripts that us busybox instead of the built in commands. Why would you need to/want to do that?
This is what I would think would work for my script:
Code:
ui_print("Preparing to update");
ui_print("Copying files..");
package_extract_dir("system", "/system");
package_extract_dir("data", "/data");
ui_print("Done! You can reboot your system now!");
I know I need a mount command before the package_extraction but I don't know which I should use and if I need a second mount for the /data/app folder as well.
"run_program("/sbin/busybox", "mount", "/system");"
or
"mount("/dev/block/stl6", "system", "/system", "rw");"
The folder structure of my zip is;
Zip
/system/app/apk files
/data/app/apk files
/META-INF
Do this in your updater-script:
Code:
run_program("/sbin/busybox", "mount", "/data");
run_program("/sbin/busybox", "mount", "/system");
ui_print("Preparing to update");
ui_print("Copying files..");
package_extract_dir("system", "/system");
package_extract_dir("data", "/data");
run_program("/sbin/busybox", "umount", "/data");
run_program("/sbin/busybox", "umount", "/system");
ui_print("Done! You can reboot your system now!");

Flashable zip help

I decided to give this a try.
Its a very simple flash and I guess an easy beginner task.
All I'm doing is adding S_opener.ogg to the notifications directory.
It's not in FJs AOSP rom and I just want to flash it after flashing his updates.
I found a tool that makes creating the zip pretty easy AFAIK
http://forum.xda-developers.com/showthread.php?t=1248486
I want to mount the system, copy the file, unmount.
The default script is below.
I have three questions before I create and flash this....don't wanna brick it
1)What's our mount point?
2)On the extract directory, can I use the parent like it is or do I have to specify by drilling down? (/system/media/audio/notifications)
3)Does it unmount? Is that part of the extract command?
THANKS!
Here's the script:
ui_print("Preparing to update");
# mounting system as r/w - ATTENTION - set the the mount point
# to the proper for your device! Example mountr command is
# mounting system for Samsung GT-I5800 aka Galaxy 3
mount("/dev/block/stl6", "system", "/system", "rw");
ui_print("Copying....");
# copy system content to the system directory on your device
package_extract_dir("system", "/system");
ui_print("Done! You can reboot your system now!");
Cool project. Good luck.
Yea. I thought it would be a cool way to get a better idea of what it takes for these developers.
Any developers able to lend me a hand here?
I think my questions are clear....
I'd appreciate it.
Thanks!
Why not team up with Jessooca. She wants to learn too. Plus I think she will get more attention than you.
1) I find it easiest to use the "busybox" mount
-- this will always be compatible with just about any custom ROM. (no need to know the mount partition)
2) Yes, just use the parent directory
3) No, it doesn't unmount automatically (not that it really needs to anyway)
If copying system apps, you can also save some time by wiping dalvik-cache and rebooting right here in the script.
Here is a generic script good for just about anything you might want to throw into system/
Code:
ui_print("Updating System...");
show_progress(0.1, 0);
ui_print(" ");
run_program("/sbin/busybox", "mount", "/system");
package_extract_dir("system", "/system");
run_program("/sbin/busybox", "umount", "/system");
ui_print(" ");
ui_print("Wiping Cache & Rebooting...");
run_program("/sbin/busybox", "mount", "/data");
delete_recursive("/data/dalvik-cache");
run_program("/sbin/busybox", "umount", "/data");
run_program("/sbin/reboot");
Hope this is helpful for you
Thanks! I found busy box in xbin. I also looked at fjs rom script and that's what he uses. I'll give it a shot
Sent from my SAMSUNG-SGH-I717 using xda premium
Bummer. I feel like I'm so close...
I have flashed three times and luckily no side effects but the file isn't there....
sbin doesn't have busybox in it but system/xbin does
So I did this:
Code:
ui_print("Preparing to update");
ui_print("Updating System...");
show_progress(0.1, 0);
ui_print("Coying Opener Notification");
run_program("/system/xbin/busybox", "mount", "/system");
package_extract_dir("system", "/system");
run_program("/system/xbin/busybox", "umount", "/system");
ui_print(" ");
ui_print("Done! You can reboot your system now!");
And that doesn't work either...
The cool thing is that I'm learning quite a bit with all these failures
That's why I chose a 'simple' task
Tried this to but it didn't work.
It flashed and said it went but the file isn't there....
Guess I'll try again tomorrow.
Code:
ui_print("Preparing to update");
ui_print("Updating System...");
show_progress(0.1, 0);
mount("/dev/block/mmcblk0p24", "system", "/system");
ui_print("Copying files Opener Notification");
package_extract_dir("system", "/system");
unmount("/system");
ui_print("Done! You can reboot your system now!");
You see /system/xbin/busybox while booted normally; however
when booted in recovery it sees /sbin -- trust me on this.
If you still want to use standard partition mounting try this:
Code:
mount("ext4", "EMMC", "/dev/block/mmcblk0p24", "/system");
Thanks for your help on this. I'll try sbin today. I trust ya
I did try that string but it threw an error and said I had four variables and it only wanted three.
Sent from my SAMSUNG-SGH-I717 using xda premium
hmm yeah well I just plucked that one out of a ROM installer
the /sbin/busybox mount has worked well for me over lots of zip and lots of different ROMs
Yep, that did it! Thanks
My first successful zip
Now to figure out how to make that the default notification.
It looks like it's in the build.prop but I haven't searched enough on xda yet.
I found the default notification for the ROM in build.prop but can't find where the current default notification is.
Is that in a file similar to build.prop?

[Q]Installing kernel modules with CWM zip succedes, but ko can't be found in modules!

Hi,
after reading about Full NTFS Read/Write support for Xperia 2011 devices I discovered that it was possible to add in my sk17i modules missing in the stock GB firmware.
I've seend the zips attached to the above linked thread, and those inside the USB OTG Helper thread and I wanted to build the modules I needed starting from my kernel sources, and so I did: I downloaded 4.0.2.A.0.58 kernel sources, and built all the modules I wanted (FUSE, USB STORAGE, NTFS, CIFS+MD4, NLS_UTF8, EXT4).
Then I made a ZIP to install those modules with CWM and I checked the How to Write an Update-Script with Edify Code to be sure not to miss anything (even if the syntax is really easy to understand), and signed the ZIP with the APK Multi Tool.
I then booted my rooted sk17i into CWM (installed with the Xperia CWM Auto-Installer), selected install zip from sdcard, and browsed to the ZIP I built: it printed the messages and no error was shown. I though: "done!".
I rebooted normally, loaded the Android Terminal Emulator and tapped:
Code:
ls /system/lib/modules
and the result is that I only see the 3 stock modules, and none of my own .ko that should have been installed with CWM.
I also tried
Code:
su
ls /system/lib/modules
and I still see only the 3 stock modules.
I double checked everything, re-read tutorials and sample zips from the threads I linked above, but I can't get what's wrong.
Finally, after the long preamble, here is the question: why the modules are not available where they should be (inside /system/lib/modules)? What (stupid, I'm sure) thing am I missing?
I know that I could put modules inside that folder with other means (eg: ADB) but I want to understand why it isn't working with the CWM update zip.
I have attached the ZIP I made to this post.
Any help is really appreciated.
I'm wondering if I didn't post this thread in the wrong forum.
This question is not really Xperia Mini Pro specific (even if I'm surfacing the problem on a sk17i), but it is more a CWM/Edify script question.
Maybe I should have posted it in the Android Software and Hacking general forum? If a moderator reads this, and thinks I posted it in the wrong area, maybe it can be moved to the other forum? (I can't do it myself as a normal user).
Thanks
No, the section is fine as it is related to our phones only.
From your update-script, I see only
Code:
mount("MTD", "system", "/system");
However, from what I know, you need to have
Code:
format("MTD", "system");
before that first code. At least I have seen it so in most flashable zips.
Give it a try and let me know.
Someguyfromhell said:
No, the section is fine as it is related to our phones only.
From your update-script, I see only
Code:
mount("MTD", "system", "/system");
However, from what I know, you need to have
Code:
format("MTD", "system");
before that first code. At least I have seen it so in most flashable zips.
Give it a try and let me know.
Click to expand...
Click to collapse
If this is a joke, you have a quite a bad taste at doing jokes
Format is supposed to be used to FORMAT the filesystem and erase all its contents, and it's not going to help me, because I'm only trying to write some additional modules.
I'm not trying to write the full "system" folder contents!
didn't see anything wrong with the script.
btw try these
Code:
ui_print(" FUSE, USB OTG, NTFS (rw) ");
ui_print(" CIFS+MD4, NLS_UTF8, EXT4 ");
ui_print(" and TUN Modules for Xperia 2011 ");
ui_print("GB, from Kernel src v4.0.2.A.0.58");
ui_print("=================================");
show_progress(1.000000, 0);
ui_print("Installation started");
set_progress(0.125000);
ui_print(" Mounting SYSTEM...");
mount("MTD", "system", "/system");
ui_print(" Extracting files to System...");
package_extract_dir("system", "/system");
ui_print(" Setup permission...");
set_perm(0, 0, 0644, "/system/lib/modules/cifs.ko");
set_perm(0, 0, 0644, "/system/lib/modules/ext4.ko");
set_perm(0, 0, 0644, "/system/lib/modules/fuse.ko");
set_perm(0, 0, 0644, "/system/lib/modules/md4.ko");
set_perm(0, 0, 0644, "/system/lib/modules/nls_utf8.ko");
set_perm(0, 0, 0644, "/system/lib/modules/ntfs.ko");
set_perm(0, 0, 0644, "/system/lib/modules/tun.ko");
set_perm(0, 0, 0644, "/system/lib/modules/usb-storage.ko");
set_progress(0.375000);
ui_print(" Unmounting SYSTEM...");
unmount("/system");
set_progress(0.750000);
ui_print("Installation finished!");
set_progress(1.000000);
zxp said:
If this is a joke, you have a quite a bad taste at doing jokes
Format is supposed to be used to FORMAT the filesystem and erase all its contents, and it's not going to help me, because I'm only trying to write some additional modules.
I'm not trying to write the full "system" folder contents!
Click to expand...
Click to collapse
And I have no f**king idea, why I posted that.
I completely messed up myself with a different language, that I have been learning...
an0nym0us_ said:
didn't see anything wrong with the script.
btw try these
Code:
ui_print(" FUSE, USB OTG, NTFS (rw) ");
ui_print(" CIFS+MD4, NLS_UTF8, EXT4 ");
ui_print(" and TUN Modules for Xperia 2011 ");
ui_print("GB, from Kernel src v4.0.2.A.0.58");
ui_print("=================================");
show_progress(1.000000, 0);
ui_print("Installation started");
set_progress(0.125000);
ui_print(" Mounting SYSTEM...");
mount("MTD", "system", "/system");
ui_print(" Extracting files to System...");
package_extract_dir("system", "/system");
ui_print(" Setup permission...");
set_perm(0, 0, 0644, "/system/lib/modules/cifs.ko");
set_perm(0, 0, 0644, "/system/lib/modules/ext4.ko");
set_perm(0, 0, 0644, "/system/lib/modules/fuse.ko");
set_perm(0, 0, 0644, "/system/lib/modules/md4.ko");
set_perm(0, 0, 0644, "/system/lib/modules/nls_utf8.ko");
set_perm(0, 0, 0644, "/system/lib/modules/ntfs.ko");
set_perm(0, 0, 0644, "/system/lib/modules/tun.ko");
set_perm(0, 0, 0644, "/system/lib/modules/usb-storage.ko");
set_progress(0.375000);
ui_print(" Unmounting SYSTEM...");
unmount("/system");
set_progress(0.750000);
ui_print("Installation finished!");
set_progress(1.000000);
Click to expand...
Click to collapse
I tried, and changing the show_progress() with set_progress() didn't help at all. Thanks for trying anyway!
Solved!!
I finally found what's wrong!!
It helped me lots an option in CWM recovery: Advanced => Report Log (or something like this), that writes a debug log to /sdcard/clocworkmod/recovery.log .
The following are meaningful excerpts from the log:
recovery filesystem table
=========================
0 /tmp ramdisk (null) (null)
1 /cache yaffs2 cache (null)
2 /data yaffs2 userdata (null)
3 /system yaffs2 system (null)
4 /sdcard vfat /dev/block/mmcblk0p1 /dev/block/mmcblk0
5 /sd-ext auto /dev/block/mmcblk0p2 (null)
(..)
"" size 1975545856 not a multiple of io_buffer_size 524288
Failed to mount /dev/block/mmcblk1p21 on /system: No such file or directory
mtd mount of system failed: No such file or directory
(..)
unmount of /system failed; no such volume
Click to expand...
Click to collapse
This means there was a problem with the mount() instruction!
I first tried changing it from
Code:
mount("MTD", "system", "/system");
to
Code:
mount("MTD", "/dev/block/mtdblock0", "/system");
and it still returned me some error, something telling me that MTD wasn't able to mount the given device.
And so I tried to tell mount() that the system fs is yaffs2, and so I used
Code:
mount("yaffs2", "/dev/block/mtdblock0", "/system");
..and..it worked!!!
So, the zip files now install successfully to system
Updated zip posted
If anyone is interested in the working CWM zip, plus an uninstaller ZIP, I've posted them in a new thread.

Clear data and system in updater-script w/o clearing sdcard?

Every time I flash a ROM I'm playing with, using the clear data options I added, it clears the sdcard too?
I'm using this code with the AROMA installer:
Code:
# Clear Data
if file_getprop("/tmp/aroma/clear.prop","selected.1") == "1"
then
ui_print("@Wiping Data...");
delete_recursive("/system");
delete_recursive("/data");
delete_recursive("/preload");
endif;
ui_print("@Clearing Cache and Dalvik...");
delete_recursive("/cache");
delete_recursive("/data/dalvik-cache");
delete_recursive("/dalvik/dalvik-cache");
The only instance of format I have is here:
Code:
format("ext4", "EMMC", "/dev/block/mmcblk0p9", "0");
mount("ext4", "EMMC", "/dev/block/mmcblk0p9", "/system");
mount("ext4", "EMMC", "/dev/block/mmcblk0p12", "/data");
mount("ext4", "EMMC", "/dev/block/mmcblk0p7", "/cache");
run_program("/sbin/mount", "/dev/block/mmcblk0p12", "/dalvik");
run_program("/sbin/busybox", "mount", "/sdcard");
Which is confusing me a lot
Bump
Can someone please shed some sort of light as to why this deletes the contents of the SD card?
Is it possible to clear system and data within an updater-script WITHOUT killing my internal sd card?
I think its the
Code:
delete_recursive("/preload");
line thats doing it - i don't have that line, neither do any of the other Roms updater scripts that ive looked at
Remove it and see what happens
MattBooth said:
Every time I flash a ROM I'm playing with, using the clear data options I added, it clears the sdcard too?
I'm using this code with the AROMA installer:
Code:
# Clear Data
if file_getprop("/tmp/aroma/clear.prop","selected.1") == "1"
then
ui_print("@Wiping Data...");
delete_recursive("/system");
delete_recursive("/data");
delete_recursive("/preload");
endif;
ui_print("@Clearing Cache and Dalvik...");
delete_recursive("/cache");
delete_recursive("/data/dalvik-cache");
delete_recursive("/dalvik/dalvik-cache");
The only instance of format I have is here:
Code:
format("ext4", "EMMC", "/dev/block/mmcblk0p9", "0");
mount("ext4", "EMMC", "/dev/block/mmcblk0p9", "/system");
mount("ext4", "EMMC", "/dev/block/mmcblk0p12", "/data");
mount("ext4", "EMMC", "/dev/block/mmcblk0p7", "/cache");
run_program("/sbin/mount", "/dev/block/mmcblk0p12", "/dalvik");
run_program("/sbin/busybox", "mount", "/sdcard");
Which is confusing me a lot
Click to expand...
Click to collapse
Such an old thread, just trying my luck.
How were you able to run the function "delete_recursive" in updater-script?
I dont see it as part of the official functions list.
Nikil07 said:
How were you able to run the function "delete_recursive" in updater-script?
I dont see it as part of the official functions list.
Click to expand...
Click to collapse
Write such a function at your own
Syntax
delete_recursive <file-or-dir1> [... <file-or-dirN>]
Example
Code:
delete_recursive()
{
for d in "[email protected]"; do rm -rf "$d" 2>/dev/null; done
}
jwoegerbauer said:
Write such a function at your own
Syntax
delete_recursive <file-or-dir1> [... <file-or-dirN>]
Example
Code:
delete_recursive()
{
for d in "[email protected]"; do rm -rf "$d" 2>/dev/null; done
}
Click to expand...
Click to collapse
Hey, thanks for the response.
But how will I be able to run these functions as part of the updater-script?
And also, regular unix commands like ls, rm are not available in recovery.
1. You add these lines of code to the very beginning of the updater script, but after the line #!/sbin/sh or similar one
2. Recovery ( at least the Stock Recovery ) merely is a menu what offers you some options, it's not an Android terminal

[Q] [RECOVERY][ZIP]script lines for copy, move, rename files.

So as I see in a flashable zip there is:
META-INF\com\google\android\
where you have updater-script.
Mine contains this:
ui_print("text_to_write");
run_program("/sbin/busybox", "mount", "/cache");
run_program("/sbin/busybox", "mount", "/data");
run_program("/sbin/busybox", "mount", "/system");
ui_print("");
package_extract_dir("cache", "/cache");
package_extract_dir("data", "/data");
package_extract_dir("system", "/system");
unmount("/cache");unmount("/data");
unmount("/system");
ok, basically this mounts the cache, data, system partition.
Now I want to do something like:
got a file in /system/media/sounds/ui/lock.ogg
I want it to rename it to /system/media/sounds/ui/lock.ogg.back
as I searched the forum, I need to run a bash script, something like:
for file in *.html; do
mv "$file" "`basename $file .html`.txt"
or simply
mv Lock Lock_old
now my question
what to write in update script to rename these files before copying the actual files.
What to write in the the update-script to run the bash.
as I understand I should paste a new line
run_program("/sbin/busybox", "mount", "/system");
ui_print(""); <-right here the script line
package_extract_dir("cache", "/cache");
the main goal is this:
copy for example Lock.ogg to system/media/ui/
but before copying rename the existing Lock.ogg to Lock.ogg.back or Lock_old.ogg.
Please help

Categories

Resources