First and foremost I take no credit for the majority of this thread. I am merely posting this here as a reference for you all. I had to dig around a lot for this information and piece it together from several different threads as well as pull examples from updater-scripts in several different roms/theme/etc. Everyone else put in the work, I am just trying to make it easier for the rest of us .
Mounting Partitions:
MTD:
Code:
mount("MTD", "system", "/system");
mount("MTD", "userdata", "/data");
mount("MTD", "cache", "/cache");
mount("MTD", "sdcard", "/sdcard");
EMMC with EXT3 and EXT4 file systems:
Code:
mount("ext4", "EMMC", "/dev/block/mountpoint", "/system");
mount("ext4", "EMMC", "/dev/block/mountpoint", "/data");
mount("ext4", "EMMC", "/dev/block/mountpoint", "/cache");
Code:
mount("ext3", "EMMC", "/dev/block/mountpoint", "/system");
mount("ext3", "EMMC", "/dev/block/mountpoint", "/data");
mount("ext3", "EMMC", "/dev/block/mountpoint", "/cache");
“mountpoint” will vary from device to device. Decide what partition you want to mount, find where it mounts (there will be resources in the second post, and paste it in place of “mountpoint” in your script.
Mounting system, data, and cache on the EVO 3D
Code:
mount("ext4", "EMMC", "/dev/block/mmcblk0p23", "/system");
mount("ext4", "EMMC", "/dev/block/mmcblk0p24", "/data");
mount("ext4", "EMMC", "/dev/block/mmcblk0p25", "/cache");
Amend
Code:
[I][COLOR="Gray"]none[/COLOR][/I]
Unmounting Partitions:
MTD and EMMC:
Code:
unmount("/system");
unmount("/data"); [COLOR="Red"]OR[/COLOR] unmount("/userdata");
unmount("/cache");
unmount("/sdcard");
Amend
Code:
[I][COLOR="Gray"]none[/COLOR][/I]
Format Partitions:
MTD:
Code:
format("MTD", "system");
format("MTD", "cache");
format("MTD", "data");
format("MTD", "boot");
EMMC EXT3/4:
Code:
format("ext4", "EMMC", "/dev/block/mountpoint");
Code:
format("ext3", "EMMC", "/dev/block/mountpoint");
Formatting system, data, cache, and boot on EVO 3D.
Code:
format("ext4", "EMMC", "/dev/block/mmcblk0p23");
format("ext4", "EMMC", "/dev/block/mmcblk0p24");
format("ext4", "EMMC", "/dev/block/mmcblk0p25");
format("ext4", "EMMC", "/dev/block/mmcblk0p22");
Amend:
Code:
[I][COLOR="Gray"]format SYSTEM:
format DATA:
format BOOT:
format CACHE:[/COLOR][/I]
Copy files from .zip file to phone partition or sd card:
Code:
package_extract_dir("Source", "Destination");
“Source” = folder in .zip file. "Destination" = partition to copy to,
Code:
package_extract_dir("system", "/system");
package_extract_dir("data", "/data");
package_extract_dir("sdcard", "/sdcard");
Amend:
Code:
[I][COLOR="Gray"]copy_dir PACKAGE:system SYSTEM:
copy_dir PACKAGE:data DATA:
copy_dir PACKAGE:sdcard SDCARD:
[/COLOR][/I]
Write an .img file:
MTD:
Code:
assert(package_extract_file("boot.img", "/tmp/boot.img"),
write_raw_image("/tmp/boot.img", "boot"),
delete("/tmp/boot.img"));
EMMC:
Code:
package_extract_file("boot.img", "/dev/block/mountpoint");
Amend
Code:
[I][COLOR="Gray"]write_raw_image PACKAGE:boot.img BOOT:[/COLOR][/I]
Output a line of text:
MTD/EMMC:
Code:
ui_print("Text Here");
Amend
Code:
[I][COLOR="Gray"]none[/COLOR][/I]
Delete a file:
Use delete for a single file. Use delete recursive for an entire folder.
Code:
delete_recursive("file/path");
Code:
delete("/path/to/file");
Amend
Code:
[I][COLOR="Gray"]delete_recursive PARTITION:path/to/file[/COLOR][/I]
Code:
[I][COLOR="Gray"]delete PARTITION:path/to/file[/COLOR][/I]
Set ownership and permissions for folder:
Code:
set_perm_recursive(uid, gid, dmode, fmode, “/path/to/folder”);
Amend
Code:
[COLOR="Gray"]set_perm_recursive uid gid dmode fmode PARTITION:path[/COLOR]
Set ownership and permissions for a file:
Code:
set_perm(uid, gid, mode, “/path/to/file”);
Amend
Code:
[COLOR="Gray"]set_perm uid gid mode PARTITION:file[/COLOR]
Run a program:
Code:
run_program("programtorun");
Amend
Code:
[I][COLOR="gray"]run_program PACKAGE:programtorun[/COLOR][/I]
Creating symlinks:
Code:
symlink("/path/to/file", "/path/tofile");
Amend
Code:
[COLOR="gray"][I]symlink /path/to/file PARTITION:path/to/file[/I][/COLOR]
Progress bar:
Code:
show_progress(fraction, duration);
Amend
Code:
[COLOR="gray"][I]show_progress fraction, duration[/I][/COLOR]
Mount points for selected devices:
Evo 3D
Code:
mmcblk0p21 /boot
mmcblk0p23 /system
mmcblk0p24 /data
mmcblk0p25 /cache
Evo Shift 4G
Code:
mmcblk0p22 /boot
mmcblk0p26 /system
mmcblk0p27 /data
mmcblk0p28 /cache
Nexus S
Code:
mtdblock4 /cache
platform/s3c-sdhci.0/by-name /system
platform/s3c-sdhci.0/by-name /userdata
reserved for more info at a later date
excellent tutorial. answered a lot of questions i had
w00t w00t! thanks for this, dude!
http://forum.xda-developers.com/showthread.php?t=936175
A lot of information in there that I have bookmarked and used without problems.
raiden89 said:
http://forum.xda-developers.com/showthread.php?t=936175
A lot of information in there that I have bookmarked and used without problems.
Click to expand...
Click to collapse
Thanks. Will update. Just wanted to post something for the EVO users so we have our own thread to reference.
EDIT: Also, looks like he might be missing a few commands. Not a big deal. Any and all help is appreciated.
Oh yeah. Of course. I know some stuff is missing, but I also like the color coding of it and showing what the Amend syntax is compared to the Edify. So, I thought I would post it. It's been useful to me.
thank you so much for making this. now people will stop bothering me and tiffany about our fantastic zips not working in cwm 3.+
Some more resources for you all...
Here and here (source code is included if you would like to see the conversions being done).
=]
Is there any way to change the color of text output in ui_print?
droidzone said:
Is there any way to change the color of text output in ui_print?
Click to expand...
Click to collapse
I believe that is dependent on how your recovery is built.
Sent from my PC36100 using XDA Premium App
droidzone said:
Is there any way to change the color of text output in ui_print?
Click to expand...
Click to collapse
Karadorde said:
I believe that is dependent on how your recovery is built.
Click to expand...
Click to collapse
If you rebuild the recovery it can be changed, but there are no options built in that will allow you to change the colors.
I'm of course referring to ClockworkMod recovery, since Amon_RA's github is outdated, I haven't really looked through his code.
=]
Anyone know the arguments/parameters to format boot to ext4?
The Desire S is Ext4 by default but i keep getting a status 1 error code when using Ext4, however Ext3 works fine.
Ive tried mounting and unmounting prior to format but no luck what so ever
You can find the partition information for the DS here:
http://forum.xda-developers.com/showthread.php?t=1057342
Thanks for the guide. This will help a lot in the future
Sent from my xEVO using XDA premium app
ooh i see you've updated for the evo 3d
One trick I used in creating the superuser and gapps ZIPs:
Code:
run_program("/sbin/busybox", "mount", "/system");
It runs just fine on both eMMC and MTD devices, and the only prerequisites are that the recovery has busybox, and already knows the mount points (which any good recovery should). Been working on Amon_RA, ClockworkMod 2-4, and TWRP.
Great tutorial!
Just one question, the # symbol preceeding a line is used for comments, right?
Thanks!!
splattx_x said:
Just one question, the # symbol preceeding a line is used for comments, right?
Click to expand...
Click to collapse
Yes, if the 1st char in the line is '#' that line is a comment.
=]
nubecoder said:
Yes, if the 1st char in the line is '#' that line is a comment.
=]
Click to expand...
Click to collapse
Awesome! Thanks. Now I have to figure out why I can't flash any zip in my phone with CWM.
This guide is very helpful. Any chance anyone knows where to get the update-binary? I know I can get it from a ROM but I'd like to learn so I can cook my own ROM from scratch.
Hi,
Iam trying to start a fullwipe.sh during the updater-script prozess. It works on the Optimus Speed, but it doesn't work on the DEFY. I know that the file is copied in the right folder because I tried it also with an SDCard, but it doesn't get executed.
Code:
ui_print("Mounte Partitionen...");
run_program("/sbin/busybox", "mount", "/system");
run_program("/sbin/busybox", "mount", "/dbdata");
run_program("/sbin/busybox", "mount", "/cache");
run_program("/sbin/busybox", "mount", "/data");
run_program("/sbin/busybox", "mount", "/sdcard");
# Fullwipe
delete_recursive("/tmp/vorkKernel");
package_extract_dir("tmp", "/tmp");
set_perm(0, 0, 0777, "/tmp/vorkKernel/busybox");
set_perm(0, 0, 0777, "/tmp/vorkKernel/fullwipe.sh");
run_program("/tmp/vorkKernel/fullwipe.sh");
As I said it works flawless on the Optimus Speed and maybe somebody know why it doesn't work on the Defy. Are there maybe different mounts or different names for some codes.
It works until it should run_program and it doesn't have to do something with the fullwipe script because I tried it even without any code only giving out some ui_print and it didn't work.
Hopefully somebody can help, because I am getting tired of trying. The fullwipe.sh is added to this post
Are you sure the script has right partitions because the updater script itself looks good as long as the binary matches it
TweetyPeety said:
Hi,
Iam trying to start a fullwipe.sh during the updater-script prozess. It works on the Optimus Speed, but it doesn't work on the DEFY. I know that the file is copied in the right folder because I tried it also with an SDCard, but it doesn't get executed.
Code:
ui_print("Mounte Partitionen...");
run_program("/sbin/busybox", "mount", "/system");
run_program("/sbin/busybox", "mount", "/dbdata");
run_program("/sbin/busybox", "mount", "/cache");
run_program("/sbin/busybox", "mount", "/data");
run_program("/sbin/busybox", "mount", "/sdcard");
# Fullwipe
delete_recursive("/tmp/vorkKernel");
package_extract_dir("tmp", "/tmp");
set_perm(0, 0, 0777, "/tmp/vorkKernel/busybox");
set_perm(0, 0, 0777, "/tmp/vorkKernel/fullwipe.sh");
run_program("/tmp/vorkKernel/fullwipe.sh");
As I said it works flawless on the Optimus Speed and maybe somebody know why it doesn't work on the Defy. Are there maybe different mounts or different names for some codes.
It works until it should run_program and it doesn't have to do something with the fullwipe script because I tried it even without any code only giving out some ui_print and it didn't work.
Hopefully somebody can help, because I am getting tired of trying. The fullwipe.sh is added to this post
Click to expand...
Click to collapse
Sent from my MB520 using XDA App
You mean the run_program mount scripts? But they worked usually everytime and the tmp folder and the script should even start but it even doesn't start. I will try tonight something different and mount it with old stuff. What's strange ist that it says run_program and than sbin/busybox but I looked on the defy after it and on my Speed, but there is no busybox file in the sbin???? How this can work or isn't needed.
Sent from my Optimus 2X using Tapatalk
I think it has to be xbin instead of sbin
thanks for the help, but I tried it also with xbin and nothing. I tried nearly everything and wanted to test if a normal shell script even works.
Code:
#!/system/bin/sh
mount /system
rm /system/app/Email.apk
unmount /system
or something like this
Code:
#!/system/bin/sh
mount -o rw /system
rm /system/app/Email.apk
unmount /system
nothing, if I execute this Shell Script at the boot with the normal firstboot in the ini.t folder it does nothing. This is a desaster, is something different with MIUI and Shell Scripts or why any Shell Scripts doesn't work in the bloody phone.
Do I have to mount differently, to I have to use another sh Folder. I checkt every bin and xbin folder and tried different folders, nothing.
ANY IDEA:???
Try a different binary and edify script... there are like 4 different kinds, all with different mount codes
Sent from my MB520 using XDA App
rdannar said:
Try a different binary and edify script... there are like 4 different kinds, all with different mount codes
Sent from my MB520 using XDA App
Click to expand...
Click to collapse
Can you tell me them?
Sent from my Optimus 2X using Tapatalk
Do a search for updater zips on xda... there are several good tutorials each binary has to have matching mounts to that particular binary
TweetyPeety said:
Can you tell me them?
Sent from my Optimus 2X using Tapatalk
Click to expand...
Click to collapse
Sent from my MB520 using XDA App
just in case which someone else had this issue
in update binary
Code:
assert(run_program("/tmp/install.sh") == 0);
and this is the content of the install.sh
Code:
#!/sbin/sh
dd if=/tmp/boot.img of=/dev/block/platform/msm_sdcc.1/by-name/boot || exit 1
exit 0
hi this is part of my updater-script
Code:
#Updater-script
set_progress(0.00);
ui_print("Checking Model ID");
assert(getprop("ro.product.device") == "grouper" || getprop("ro.build.product") == "grouper" || getprop("ro.product.board") == "grouper");
ui_print("Success!");
ui_print("Model ID - grouper");
ui_print("Ok to proceed");
ui_print("Now flashing Kaos Droid");
ifelse(is_mounted("/system") == "/system", unmount("/system"));
ifelse(is_mounted("/data") == "/data", unmount("/data"));
ifelse(is_mounted("/cache") == "/cache", unmount("/cache"));
set_progress(0.01);
############################## OPTIONAL FULL WIPE ##############################
if
file_getprop("/tmp/aroma-data/wipe.prop","selected.0") == "2"
then
set_progress(0.01);
ui_print("@Executing Full Wipe");
ui_print("--Erasing & formatting /cache as EXT4");
run_program("/sbin/erase_image", "cache");
format("ext4", "EMMC", "/dev/block/platform/sdhci-tegra.3/by-name/CAC");
run_program("/sbin/sleep", "2");
set_progress(0.02);
ui_print("-- Erasing & formatting /system as EXT4");
run_program("/sbin/erase_image", "system");
format("ext4", "EMMC", "/dev/block/platform/sdhci-tegra.3/by-name/APP");
run_program("/sbin/sleep", "2");
set_progress(0.03);
ui_print("-- Erasing & formatting /data as EXT4");
delete_recursive("/data/app-asec");
delete_recursive("/data/app-private");
delete_recursive("/data/backup");
delete_recursive("/data/data");
delete_recursive("/data/dalvikcache");
delete_recursive("/data/dontpanic");
delete_recursive("/data/drm");
delete_recursive("/data/gps");
delete_recursive("/data/lightsensor");
delete_recursive("/data/local");
delete_recursive("/data/lost+found");
delete_recursive("/data/misc");
delete_recursive("/data/property");
delete_recursive("/data/resource-cache");
delete_recursive("/data/sensors");
delete_recursive("/data/ssh");
delete_recursive("/data/system");
delete_recursive("/data/tf");
delete_recursive("/data/user");
run_program("/sbin/sleep", "2");
set_progress(0.05);
ui_print("-- Removing system files from SD Card");
delete_recursive("/sdcard/.android_secure");
delete_recursive("/sdcard/.bookmark_thumb1");
delete_recursive("/sdcard/Android/data/com.google.android.apps.maps");
delete_recursive("/sdcard/LazyList");
delete_recursive("/sdcard/LOST.DIR");
delete_recursive("/sdcard/.android_secure");
run_program("/sbin/sleep", "2");
ui_print("Wipe Complete");
set_progress(0.06);
ui_print("Checking filesystems for errors");
run_program("/sbin/e2fsck", "-p", "/dev/block/platform/sdhci-tegra.3/by-name/UDA");
run_program("/sbin/e2fsck", "-p", "/dev/block/platform/sdhci-tegra.3/by-name/CAC");
run_program("/sbin/e2fsck", "-p", "/dev/block/platform/sdhci-tegra.3/by-name/APP");
run_program("/sbin/sleep", "2");
endif;
set_progress(0.07);
show_progress(0.07, 9);
ui_print("@Installing ROM");
ui_print(" ");
ui_print("--Writing System");
mount("ext4", "EMMC", "/dev/block/platform/sdhci-tegra.3/by-name/UDA", "/data");
run_program("/sbin/sleep", "2");
mount("ext4", "EMMC", "/dev/block/platform/sdhci-tegra.3/by-name/APP", "/system");
run_program("/sbin/sleep", "2");
package_extract_dir("system", "/system");
run_program("/sbin/sleep", "2");
Now obviously if i format /data i loose every thing on my sdcard however when this script runs it hangs on boot screen (colourful X) but if i # out the lines with /data/some_folder it boots fine just wondered why this would be and is there a way to get around this issue now i understand i could # out 1 line 1 by 1 but this would take a lot of time and when i find out which line(s) it would not help me understand why this is doing what it is plus other devs wouldn't be aware of this issue
Hoping someone could shed some light Thanks in advance
edit: when i adb shell in recover it shows /system as empty however /data is full
format("ext4", "EMMC", "/dev/block/platform/sdhci-tegra.3/by-name/UDA"); so this removes everything in /data which includes our sd card partition but if you use
format("ext4", "EMMC", "data"); it seems like it leaves /data/media untouched (sdcard) but seems to still cuse the boot loop this is very strange imo
if i reflash the rom without seletcing full wip ie format("ext4", "EMMC", "data"); it works fine no boot loop
Is there any script to share one directory /data/app to all NativeSD ROMs?
NativeSD makes you more likely to change the roms but they re doing backup and restore application is annoying.
If they modify NativeSD installation script to using shared EXT partition or directory /data/app on ext (symlinks)? This will be a cool option in Aroma Installer.
Something like mod mount_NativeSD.sh form /kernel directory:
Code:
#!/sbin/sh
# Get $ROM_NAME from ROM_NAME.prop
ROM_NAME=`cat '/tmp/aroma/ROM_NAME.prop' | sed 's/ROM_NAME=//g'`
http://forum.xda-developers.com/editpost.php?do=editpost&p=42598125
# Mount the SD-EXT partition
# Done by SD-EXT_mounter.sh
STATUS=`cat '/tmp/mount.prop' | sed 's/status=//g'`
if [ "$STATUS" = "mounted" ]; then
mkdir -p /NativeSD/$ROM_NAME/system
mkdir -p /NativeSD/$ROM_NAME/data
[COLOR="Lime"][B]mkdir -p /NativeSD/sharedata[/B][/COLOR]
mount --bind /NativeSD/$ROM_NAME/system /system
mount --bind /NativeSD/$ROM_NAME/data /data/[COLOR="Red"][B]data[/B][/COLOR] #? for separated app settings
[COLOR="lime"][B] mount --bind /NativeSD/sharedata /data[/B][/COLOR]
mkdir -p /sdcard/NativeSD/$ROM_NAME
mkdir -p /boot
mkdir -p /boot_dir
mount --bind /sdcard/NativeSD/$ROM_NAME /boot
mount --bind /sdcard/NativeSD /boot_dir
# delete the old system
rm -rf /system/*
echo "NativeSD=true" >> /tmp/nfo.prop
else
# no SD-EXT partition found
echo "NativeSD=false" >> /tmp/nfo.prop
fi
And something like mod updater-script to choose other /data location:
Code:
ui_print("@ Copying files...");
package_extract_file("kernel/boot_NativeSD/initrd.gz", "/boot/initrd.gz");
package_extract_file("kernel/boot_NativeSD/initrd.gz", "/boot_dir/initrd.gz");
package_extract_file("kernel/zImage", "/boot/zImage");
package_extract_file("kernel/zImage", "/boot_dir/zImage");
package_extract_dir("sdcard", "/sdcard");
package_extract_dir("system", "/system");
# package_extract_dir("data", "/data");
[B][COLOR="SeaGreen"] package_extract_dir("data", "/NativeSD/sharedata");
[/COLOR][/B] package_extract_dir("customize/wallpaper", "/sdcard");
package_extract_file("mods/app/NativeSDBootV10.apk", "/system/app/NativeSDBootV10.apk");
show_progress(0.1, 5);
EDIT:
It seems to that it will be a problem with the system apps when they have the same / data.
/data/data would have to stay in their own rom directory (/NativeSD/$ROM_NAME/data).
EDIT2:
I found this:
http://forum.xda-developers.com/showpost.php?p=33174514
http://forum.xda-developers.com/showthread.php?t=1869673&page=52
Anyone with updater-script knowledge would be helpful.
I'm trying to make changes to my updater-script in my ROM to mount /system and /data in EXT4 or F2FS accordingly. This is to reduce the number of ROMs I have to upload (one for each file system type), plus it saves time for people who switch back and forth. And I believe this could help other ROMs also
So far I've come up with this ifelse condition:
Code:
ifelse(mount("ext4", "EMMC", "/dev/block/platform/msm_sdcc.1/by-name/system", "/system"),
# /system EXT4 mount
ui_print("Mounting /system in EXT4 mode");
sleep(1),
# /system F2FS mount
ui_print("Mounting /System in F2FS mode");
mount("f2fs", "EMMC", "/dev/block/platform/msm_sdcc.1/by-name/system", "/system");
sleep(1));
The main idea behind this is the recovery (I'm using TWRP, so I can't speak for Philz or CWM) will attempt to mount /system in EXT4 first. If it succeeds in the initial mount, it should print out the "mount in EXT4" line, which in testing has worked for me. I am in F2FS and I see that the initial mount fails and goes to the second mount. More of my testing with "is_mounted()" shows that if I go to the F2FS part, /system is not mounted yet until it runs mount with F2FS as the argument.
I made a test zip that, after this line, pushes a test file to /system/bin and also changes it's permissions successfully. I'll include it to download for anyone else who can test this for me.
Can anyone think of reasons why this is bad in practice? Or if this will cause any issues? The goal is that this will end up in a ROM's updater-script so I'd like to know anything before I start testing this myself. Thank you!