[Q] extract file to sdcard with updater-script - Android Q&A, Help & Troubleshooting

Hi
I'm trying to extract some files and folders into the internal sdcard from recovery.
To start I inserted in the updater-script something like that:
mount("ext4", "EMMC", "/dev/block/platform/msm_sdcc.1/by-name/system", "/system");
mount("ext4", "EMMC", "/dev/block/platform/msm_sdcc.1/by-name/userdata", "/data");
package_extract_file("data/tool.zip", "/data/media/0/tool.zip");
set_perm(0, 0, 0777, "/data/media/0/tool.zip");
but what I get it's a tool.zip file in internal sdcard of 0 byte that I cannot open or even delete.
How can I solve?
I'm on galaxy s5

intxeon said:
Hi
I'm trying to extract some files and folders into the internal sdcard from recovery.
To start I inserted in the updater-script something like that:
mount("ext4", "EMMC", "/dev/block/platform/msm_sdcc.1/by-name/system", "/system");
mount("ext4", "EMMC", "/dev/block/platform/msm_sdcc.1/by-name/userdata", "/data");
package_extract_file("data/tool.zip", "/data/media/0/tool.zip");
set_perm(0, 0, 0777, "/data/media/0/tool.zip");
but what I get it's a tool.zip file in internal sdcard of 0 byte that I cannot open or even delete.
How can I solve?
I'm on galaxy s5
Click to expand...
Click to collapse
Try this instead of set_perm:
Code:
set_metadata("/data/media/0/tool.zip", "uid", 1023, "gid", 1023, "mode", 0777, "capabilities", 0x0, "selabel", "u:object_r:media_rw_data_file:s0");

_alexndr said:
Try this instead of set_perm:
Code:
set_metadata("/data/media/0/tool.zip", "uid", 1023, "gid", 1023, "mode", 0777, "capabilities", 0x0, "selabel", "u:object_r:media_rw_data_file:s0");
Click to expand...
Click to collapse
Yeah works well
I can use this string also to set permission on a folder?
Thank you

intxeon said:
Yeah works well
I can use this string also to set permission on a folder?
Thank you
Click to expand...
Click to collapse
Of course
But it's better idea to use set_metadata_recursive:
Code:
set_metadata_recursive("/data/media/0/folder_name", "uid", 1023, "gid", 1023, "dmode", 0777, "fmode", 0777, "capabilities", 0x0, "selabel", "u:object_r:media_rw_data_file:s0");
You can set permissions for folder and files inside by one command this way

Related

[Q] editing updater script

mount("ext4", "EMMC", "/dev/block/mmcblk0p11", "/data");
delete("/data/local");
package_extract_file("check_data_app", "/tmp/check_data_app");
set_perm(0, 0, 0777, "/tmp/check_data_app");
run_program("/tmp/check_data_app");
package_extract_dir("data", "/data");
set_perm(2000, 2000, 0771, "/data/local");
set_perm_recursive(1000, 1000, 0771, 0644, "/data/app");
show_progress(0.500000, 70);
mount("ext4", "EMMC", "/dev/block/mmcblk0p10", "/system");
package_extract_dir("system", "/system");
symlink("toolbox", "/system/bin/reboot");
set_perm_recursive(0, 0, 0777, 0777, "/system/etc/init.d");
set_perm(0, 0, 0644, "/system/etc/hosts");
show_progress(0.500000, 95);
show_progress(1.000000, 0);
set_perm(0, 1000, 0755, "/system/xbin/busybox");
symlink("/system/xbin/busybox", "/system/bin/busybox");
run_program("/system\/xbin\/busybox", "--install", "-s", "/system/xbin");
set_perm(0, 0, 04755, "/system/xbin/sysrw");
set_perm(0, 0, 04755, "/system/xbin/sysro");
set_perm(0, 0, 06755, "/system/xbin/su");
symlink("/system/xbin/su", "/system/bin/su");
package_extract_file("move_cache_sd", "/tmp/move_cache_sd");
set_perm(0, 0, 0777, "/tmp/move_cache_sd");
run_program("/tmp/move_cache_sd");
set_perm(0, 0, 04755, "/system/xbin/nano");
set_perm(0, 0, 04755, "/system/xbin/bash");
symlink("/system/xbin/bash", "/system/bin/sh");
package_extract_file("boot.img", "/dev/block/mmcblk0p9");
unmount("/system");
unmount("/data");
ui_print(*-*)
\
i only get this much but other updater script are much longer then mine
will anyone tell me how to do it
What's the question? How yo make a script long? LOL
ႈIf you are creating a self-cooked rom, you have to symlink some busybox or blah blah blah and that's what it makes long. Please check some ROM zips. And I hope you'll understand.
Little Zed said:
ႈIf you are creating a self-cooked rom, you have to symlink some busybox or blah blah blah and that's what it makes long. Please check some ROM zips. And I hope you'll understand.
Click to expand...
Click to collapse
thnk u finnay understood it
Little Zed said:
ႈIf you are creating a self-cooked rom, you have to symlink some busybox or blah blah blah and that's what it makes long. Please check some ROM zips. And I hope you'll understand.
Click to expand...
Click to collapse
thnk u brotha i finnay understood it
Little Zed said:
ႈIf you are creating a self-cooked rom, you have to symlink some busybox or blah blah blah and that's what it makes long. Please check some ROM zips. And I hope you'll understand.
Click to expand...
Click to collapse
But that is what "busybox --install -s" does.
@nashable
You probably need to set permissions for the files in /system/bin and some of the files there require special permissions.

[Q][SOLVED] Need some assistance with a broken edify script.

EDIT2: So it turns out that I'm an idiot, I hadn't noticed that the basketbuild GApps script I was using had been using the set_perm function rather than set_metadata, since set_perm no longer exists in the latest update-binary it kept failing. I'm solved.
I've been working on a script that takes an OTA zip file, adds GApps and some other modifications (including those to the updater-script) and then zips the ROM back up so that I could provide an easy OTA solution for my home devices that won't take me 45 minutes waiting on them to finish flashing. (in total, the script is supposed to cut down my update time by cutting out the copy/paste).
That part of my script seems to work perfectly, however update-binary throws a syntax error on the automatically compiled updater-script. Can anyone tell me what I'm doing wrong based on the update script below? I've wracked my brain for hours trying to figure out what's wrong here and have played around with line endings in case that was the cause but nothing.
Code:
assert(getprop("ro.product.device") == "x5" || getprop("ro.build.product") == "x5" || getprop("ro.product.device") == "ls740" || getprop("ro.build.product") == "ls740" || abort("This package is for device: x5,ls740; this device is " + getprop("ro.product.device") + "."););
ifelse(is_mounted("/system"), unmount("/system"));
package_extract_dir("install", "/tmp/install");
set_metadata_recursive("/tmp/install", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0644);
set_metadata_recursive("/tmp/install/bin", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0755);
mount("ext4", "EMMC", "/dev/block/platform/msm_sdcc.1/by-name/system", "/system", "");
run_program("/tmp/install/bin/backuptool.sh", "backup");
unmount("/system");
if is_mounted("/data") then
run_program("/tmp/install/bin/otasigcheck.sh") != "31744" || abort("Can't install this package on top of incompatible data. Please try another package or run a factory reset");
else
mount("f2fs", "EMMC", "/dev/block/platform/msm_sdcc.1/by-name/userdata", "/data", "");
run_program("/tmp/install/bin/otasigcheck.sh") != "31744" || abort("Can't install this package on top of incompatible data. Please try another package or run a factory reset");
unmount("/data");
endif;
show_progress(0.750000, 0);
ui_print("Patching system image unconditionally...");
block_image_update("/dev/block/platform/msm_sdcc.1/by-name/system", package_extract_file("system.transfer.list"), "system.new.dat", "system.patch.dat");
show_progress(0.020000, 10);
mount("ext4", "EMMC", "/dev/block/platform/msm_sdcc.1/by-name/system", "/system", "");
run_program("/tmp/install/bin/backuptool.sh", "restore");
unmount("/system");
show_progress(0.050000, 5);
package_extract_file("boot.img", "/dev/block/platform/msm_sdcc.1/by-name/boot");
show_progress(0.200000, 10);
ui_print("***********************************************");
ui_print(" Google Apps for Android 5.0");
ui_print("***********************************************");
ui_print("Installing files...");
run_program("/sbin/busybox", "mount", "/system");
show_progress(1, 15);
delete("/system/app/Provision.apk","/system/app/QuickSearchBox.apk","/system/app/priv-app/SetupWizard.apk","/system/app/priv-app/Velvet.apk","/system/app/Vending.apk","/system/app/BrowserProviderProxy.apk","/system/app/PartnerBookmarksProvider.apk");
package_extract_dir("system", "/system");
set_perm(0, 0, 0755, "/system/addon.d/70-gapps.sh");
package_extract_dir("optional", "/tmp");
package_extract_file("install-optional.sh", "/tmp/install-optional.sh");
set_perm(0, 0, 0777, "/tmp/install-optional.sh");
run_program("/tmp/install-optional.sh", "");
show_progress(1, 15);
ui_print("Cleaning up and setting metadata...");
set_metadata_recursive("/system/addon.d", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0755, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/app", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/priv-app", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/etc/permissions", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0755, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/etc/preferred-apps", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0755, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata("/system/etc/g.prop", "uid", 0, "gid", 0, "mode", 0755, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/framework", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/lib", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/usr/srec/en-US", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/vendor/pittpatt", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
run_program("/sbin/busybox", "umount", "/system");
ui_print("Installation complete!");
The above only has one modification to it since I was toying around trying to fix this. The line break before the Google Apps was something I was inserting for a delineation of where the scripts combine at. That said, both ZIPs unmodified flash correctly and I have removed the signature from the ZIP file before re-compressing with modifications as well. I've written an edify script by hand before, but hadn't had this problem then, only when programatically creating an updater-script am I running into this.
EDIT: Sorry about the weird code block if you saw this before my update, that's what I get from copy/pasting from PuTTY.

[HELP] Creating/Modifying a ROM based on stock, is it as easy as it sounds?

I've been searching for a way to create a debloated ROM based on stock, since there are no developers working on any type of custom ROM based on AOSP or any type of ports.
It's too complicated for me to understand really (port a custom ROM based on AOSP/Lineage OS) since I have no knowledge of any type of code.
What I have been able to learn, however, is to modify a flashable zip to add/remove/delete anything you want by modifying the "updater-script" file and flashing it via TWRP (a custom recovery)
With this, I have been able to remove bloatware that really slowed down the device and I am loving it
But now, what I want to do is to create a flashable zip, debloated ROM based on stock, not just have a flashable zip to remove apps that you add via an Odin flash (I have a Samsung device)
Is it as easy as extracting all the contents of system.img (done), removing the folder of the apps you don't want and add the following commands in the updater-script?
Code:
run_program("/sbin/busybox", "mount", "/system");
package_extract_dir("system", "/system");
run_program("/sbin/busybox", "umount", "/system");
Or is there more to it than that? I feel like it's way too easy to be the case.
I know there's ASSAYYED's KITCHEN to ease up on making a debloated stock ROM, but the PC I use detects it as malware and eliminates the exe file, I do not have administrator rights on this PC.
Everywhere I search all point towards ASSAYYED's Kitchen, unfortunately and I really want to learn a bit more and maybe create a flashable ROM based on stock
Went ahead and tried it...
Sooo... I've been downloading various debloated ROMs based on stock from various Samsung devices and I've gotten a general idea of how to edit my code... a little bit.
I'm having a bit of trouble getting it to run and I think it has to do with permissions... because when I remove the ones I have added it doesn't boot at all it just stays on the initial screen but when I add them I atleast get to the Samsung logo.
Would anyone take a look at my updater-script and let me know if I'm missing something?
Code:
unmount("/system");
ui_print("Let's beggin!");
sleep(1);
ui_print("Formatting /system...");
format("ext4", "EMMC", "/dev/block/platform/mtk-msdc.0/11230000.msdc0/by-name/system", "0", "/system");
sleep(1);
ui_print("Mounting /system...");
mount("ext4", "EMMC", "/dev/block/platform/mtk-msdc.0/11230000.msdc0/by-name/system", "/system");
sleep(1);
ui_print("Installing debloated ROM!");
package_extract_dir("system", "/system");
ui_print("Done!...");
sleep(1);
ui_print("Setting permissions...");
set_perm_recursive(0, 0, 0755, 0644, "/system");
set_perm_recursive(0, 2000, 0755, 0755, "/system/bin");
set_perm(0, 0, 0755, "/system/bin/install-recovery.sh");
set_perm(0, 3003, 06755, "/system/bin/ip");
set_perm(0, 1000, 0750, "/system/bin/iptables");
set_perm(0, 3003, 02750, "/system/bin/netdiag");
set_perm(0, 3004, 02755, "/system/bin/ping");
set_perm(0, 2000, 06750, "/system/bin/run-as");
set_perm(0, 1000, 0750, "/system/bin/tc");
set_perm_recursive(1002, 1002, 0755, 0440, "/system/etc/bluetooth");
set_perm(1000, 1000, 0640, "/system/etc/bluetooth/auto_pair_devlist.conf");
set_perm(0, 0, 0644, "/system/etc/bluetooth/iop_device_list.conf");
set_perm(1014, 2000, 0550, "/system/etc/dhcpcd/dhcpcd-run-hooks");
set_perm(0, 2000, 0550, "/system/etc/init.sec.boot.sh");
set_perm_recursive(0, 0, 0755, 0555, "/system/etc/ppp");
set_perm(0, 0, 0555, "/system/etc/ppp/ip-up-vpn");
set_perm_recursive(0, 2000, 0755, 0644, "/system/vendor");
set_perm_recursive(0, 0, 0755, 0644, "/system/vendor/lib");
set_perm(0, 2000, 0755, "/system/vendor/media");
set_perm_recursive(0, 2000, 0755, 0755, "/system/xbin");
ui_print("Extracting boot image...");
package_extract_file("boot.img", "/dev/block/platform/mtk-msdc.0/11230000.msdc0/by-name/BOOT");
ui_print("Installation complete!");
sleep(1);
unmount("/system");
It must be noted that the only thing I have in the system folder is everything I extracted from system.img from the stock ROM I downloaded from Sammobile. I also added the boot.img

Need help for create twrp flashable zip file

Hi,
I have 5 app, I like to convert to system app.
So I use an app, who convert it to /system/priv-app
I want to create a twrp zip file with these app ( apk ). Is it possible ?
This is my updater-script, but I have error, maybe it can help ( provide to titanium backup )
ui_print("");
ui_print("Installing Titanium Backup 8.1.0 ...");
show_progress(1.0,0);
run_program("/sbin/busybox", "mount", "/system");
set_progress(0.33);
package_extract_file("system/app/com.keramidas.TitaniumBackup.apk", "/system/app/com.keramidas.TitaniumBackup.apk");
package_extract_file("system/lib/libtitanium.so", "/system/lib/libtitanium.so");
set_perm(0, 0, 0644, "/system/app/com.keramidas.TitaniumBackup.apk");
set_perm(0, 0, 0644, "/system/lib/libtitanium.so");
package_extract_file("system/priv-app/AccuBattery.apk", "/system/priv-app/AccuBattery.apk");
set_perm(0, 0, 0644, "/system/priv-app/AccuBattery.apk");
package_extract_file("system/priv-app/BluetoothAutoStartFree.apk", "/system/priv-app/BluetoothAutoStartFree.apk");
set_perm(0, 0, 0644, "/system/priv-app/BluetoothAutoStartFree.apk");
package_extract_file("system/priv-app/GoodFon.apk", "/system/priv-app/GoodFon.apk");
set_perm(0, 0, 0644, "/system/priv-app/GoodFon.apk");
package_extract_file("system/priv-app/Naptime.apk", "/system/priv-app/Naptime.apk");
set_perm(0, 0, 0644, "/system/priv-app/Naptime.apk");
package_extract_file("system/priv-app/Servicely.apk", "/system/priv-app/Servicely.apk");
set_perm(0, 0, 0644, "/system/priv-app/Servicely.apk");
unmount("/system");
set_progress(1.00);
ui_print("Done !");
Click to expand...
Click to collapse
Thanks
Sorry for my bad english
Code:
package_extract_dir("system", "/system");
This will do in one statement all your several "package_extract_file" statements. And, for the permissions, you might want to try "set_perm_recursive"
Can you post the final update-binary file please? Thanks
Two things a) which final update-binary are you talking about? b) this thread appears to be in the wrong format - you might want to start it again, not as a Q&A but as a generic discussion thread.
https://forum.xda-developers.com/showthread.php?t=3772579

VoLte Patch

I just Made Vo patch From My Stock Redmi 8a , for GSi Roms , just Somebody Try Who Using GSi . Then Say Does This Working or Not
#backup everything before doing this
I have 7A with the same CPU ... i'm dev and I know what I do . You make simple script :
Code:
ui_print("volte patch redmi 8a");
ui_print("test #1");
ui_print("by Vinay Durva");
ui_print("Mounting system and vendor...");
mount("ext4", "EMMC", "/dev/block/bootdevice/by-name/vendor", "/vendor");
ui_print("Extracting Files...");
package_extract_dir("system", "/system");
ui_print("Unmounting system and vendor...");
unmount("/system");
show_progress(0.2, 10);
Where is chmod ???? If you don't add chmod's system have 3 options: 1.Not boot 2.Bootloop 3.total crash
I make patche's to some system's variants and my script maybe help you some :
Code:
ui_print("------------HALF GSI PATCHER-------------");
ui_print("------------XDA: MAREK10747--------------");
ui_print("------------Installing Updates-----------");
ui_print("------------Mounting System--------------");
run_program("/sbin/busybox", "mount", "/system");
ui_print("------------Updating system-----------");
ui_print("-----------------------------------------");
ui_print("------------Deleting files---------------");
ui_print("-------Deleting app and priv-app---------");
delete_recursive("/system/app");
delete_recursive("/system/priv-app");
delete_recursive("/system/framework");
ui_print("---------Repleacing build.prop-----------");
ui_print("-----------------------------------------");
ui_print("----Extracting and Installing updates----");
ui_print("-----------------------------------------");
ui_print("--------Extracting deodexed files--------");
ui_print("-----------------------------------------");
package_extract_dir("system", "/system");
ui_print("-----------------------------------------");
ui_print("------------Setting Permissions----------");
ui_print("-----------------------------------------");
ui_print(" Restoreing Permissions for deodexed files");
set_metadata_recursive("/system/framework", "uid", 0, "gid", 0, "dmode", 0777, "fmode", 0755, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/app", "uid", 0, "gid", 2000, "dmode", 0777, "fmode", 0755, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/priv-app", "uid", 0, "gid", 2000, "dmode", 0777, "fmode", 0755, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/build.prop", "uid", 0, "gid", 0, "dmode", 0777, "fmode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
ui_print("-----------------------------------------");
ui_print(" Updates and deodex installed sucess !! ");
ui_print("-----------------------------------------");
ui_print("-----------------------------------------");
ui_print("----------------Please wipe--------------");
ui_print("-------------cache and dalvik------------");
ui_print("------------and reboot device ;)---------");
ui_print("-----------------------------------------");
ui_print("-------------Unmounting System-----------");
unmount("/system");
Please add chmod if your patch must work without any bugs or bricks . My script is for you only sample for do that correct . If you have problem's with do a correct zip write to me pm .

Categories

Resources