Hi, I am doing na updater-script for flashable zip package, but I am stuck on certain point:
I would like to make changes in following location:
Code:
/res/customconfig/
so I need to execute (in my script)
Code:
run_program ("/sbin/busybox", "mount", "/?????");
what I need to know how can I determine what to mount to get access to the /res/customconfig/, e.g. if there is a command I can use to determine using terminal etc ...
Thanks for answer
Related
Hi, i'm trying to access /system/app/ so i can put apps in there, since i couldt figure out how to install apk files form Eclipse. I'm running Eclipse with the SDK installed, any help or example would be awesome. Thanks
/system is typically read-only (is on every android I know of). On many (most?) devices, the partition containing /system is also write-locked in the eMMC firmware. User apps should be installed into the /data partition.
What do you mean by installing from eclipse? Eclipse uses adb to push the package to the device and launch the package installer.
Please use the Q&A Forum for questions Thanks
Moving to Q&A
There are two ways that may be of help that I know of.
ADB Install:
1. In your Android SDK manager you should have a tool called ADB (Google how to add it to your system path to make life easier)
2. Navigate to your apk file you are trying to install and shift right click in the windows explorer windo and select Open Command line here.
3. then using command line (Console) type in:
Code:
adb install nameofapphere.apk
Note: If the app has spaces in the installer name either take out the spaces or add quotes to the command line as shown below.
Code:
adb install "name of app here.apk"
Second choice is gaining command line root and remounting the system directory with rw permissions.
1. Gain console root access.
2. in console type in:
Code:
adb shell
Note if you see $ you are not in root and # if you are in root.
3. (Please double check)
Code:
mount -o remount,rw /dev/null /system
This will remount your system drive so you have read/write access to it.
4. Push the file to /system/app
5. Set the permissions you want for the application
JavaChips said:
There are two ways that may be of help that I know of.
ADB Install:
1. In your Android SDK manager you should have a tool called ADB (Google how to add it to your system path to make life easier)
2. Navigate to your apk file you are trying to install and shift right click in the windows explorer windo and select Open Command line here.
3. then using command line (Console) type in:
Code:
adb install nameofapphere.apk
Note: If the app has spaces in the installer name either take out the spaces or add quotes to the command line as shown below.
Code:
adb install "name of app here.apk"
Second choice is gaining command line root and remounting the system directory with rw permissions.
1. Gain console root access.
2. in console type in:
Code:
adb shell
Note if you see $ you are not in root and # if you are in root.
3. (Please double check)
Code:
mount -o remount,rw /dev/null /system
This will remount your system drive so you have read/write access to it.
4. Push the file to /system/app
5. Set the permissions you want for the application
Click to expand...
Click to collapse
What i mean i'm writing an app in eclipse. And i have a listview with the apk's, i want when the user clicks on the items, it gets installed. Any ideas?
spxc said:
What i mean i'm writing an app in eclipse. And i have a listview with the apk's, i want when the user clicks on the items, it gets installed. Any ideas?
Click to expand...
Click to collapse
Why did this thread get moved. Took me forever to find it.
Anyway, it seems you want to programmatically install an APK from within an android app, is that correct? Just launch an intent with the package installer as a target:
Code:
Intent installIntent = new Intent(Intent.ACTION_VIEW);
installIntent.setDataAndType("/path/to/my/apk","application/vnd.android.package-archive");
startActivity(installIntent);
Moderator: this is definitely development related. Why was it moved to Q&A?
Gene Poole said:
Code:
Intent installIntent = new Intent(Intent.ACTION_VIEW);
installIntent.setDataAndType("/path/to/my/apk","application/vnd.android.package-archive");
startActivity(installIntent);
Moderator: this is definitely development related. Why was it moved to Q&A?
Click to expand...
Click to collapse
I'll agree, and secondly I think it was moved to Q&A because the original question was asked in a way that was not clear to it's intents.
So yeah, just pointing the apks to be run by the package installer via intent will launch the installer and install the app selected.
Can anyone kind enough show me how to copy files from my app assets folder to /system folder? I know how to get root access and all. For example: I want to copy file from "/assets/lib/libs.so" and check if this file already exist, if it does replace it to new "/system/lib/libs.so".
I think You could create a script (its language should not be too difficult) and make it start on every boot (every scripter Can do this) But I don't know how much time it would take and if You reboot often... Try to look for an app that runs script programmatically
Sent from R'lyeh using Cthulhu app
tsirhcitna said:
I think You could create a script (its language should not be too difficult) and make it start on every boot (every scripter Can do this) But I don't know how much time it would take and if You reboot often... Try to look for an app that runs script programmatically
Sent from R'lyeh using Cthulhu app
Click to expand...
Click to collapse
Sorry I haven't been clearly state that I want to write an app that does this, like in java.
Ooops my fault! I know java for PC but I never studied it for Android (when I tried to program for android the emulator taking twenty minutes to start stopped me). I don't know how to help you but seeing nobody is answering I can suggest you to go on Stack Overflow, it's all about coding, and all the answer I've seen on it where very good (You can also look for file manipulation on some android java tutorial)
Sorry I can't help you more
tsirhcitna said:
Ooops my fault! I know java for PC but I never studied it for Android (when I tried to program for android the emulator taking twenty minutes to start stopped me). I don't know how to help you but seeing nobody is answering I can suggest you to go on Stack Overflow, it's all about coding, and all the answer I've seen on it where very good (You can also look for file manipulation on some android java tutorial)
Sorry I can't help you more
Click to expand...
Click to collapse
can u write java code that wrap around command line that copy file to system folder? this will work, cos i can get su, just need to mount rw /system/lib then copy file from my app assets folder and replace the file in /system/lib
homi3kh said:
Can anyone kind enough show me how to copy files from my app assets folder to /system folder? I know how to get root access and all. For example: I want to copy file from "/assets/lib/libs.so" and check if this file already exist, if it does replace it to new "/system/lib/libs.so".
Click to expand...
Click to collapse
I suppose you're getting Root Permission running su command with Runtime.getRuntime().exec... right?
That's fine, you now need to run another commands:
To check if /assets/lib/libs.so (or any other file) exists:
Code:
ls /assets/lib | grep libs.so
If the file exists, you'll get "libs.so" as output of that command (otherwise, you will not get anything).
To remount /system in RW mode:
Code:
mount -o rw, remount -t yaffs2 /dev/block/mtdblock4 /system
Ok, now you can copy your file (or files, I dunno):
Code:
cp /assets/lib/libs.so /system/lib/libs.so
And finally, remount /system in RO mode again:
Code:
mount -o ro, remount -t yaffs2 /dev/block/mtdblock4 /system
Pretty easy, it isn't? :highfive:
Note: I highly recommend you to use RootTools, it's a lib to run commands as root very easily
RoberGalarga said:
I suppose you're getting Root Permission running su command with Runtime.getRuntime().exec... right?
That's fine, you now need to run another commands:
To check if /assets/lib/libs.so (or any other file) exists:
Code:
ls /assets/lib | grep libs.so
If the file exists, you'll get "libs.so" as output of that command (otherwise, you will not get anything).
To remount /system in RW mode:
Code:
mount -o rw, remount -t yaffs2 /dev/block/mtdblock4 /system
Ok, now you can copy your file (or files, I dunno):
Code:
cp /assets/lib/libs.so /system/lib/libs.so
And finally, remount /system in RO mode again:
Code:
mount -o ro, remount -t yaffs2 /dev/block/mtdblock4 /system
Pretty easy, it isn't? :highfive:
Note: I highly recommend you to use RootTools, it's a lib to run commands as root very easily
Click to expand...
Click to collapse
yes this is what i'm asking for but can you wrap it with RootTools code for me too? it's a bit confusing cos I don't know much about command line.
Ok. It's kinda easy, BTW:
To grant root permissions (If you already have root permissions in other way, you don't need to do this again):
Code:
if (RootTools.isAccessGiven()) {
// your device is rooted!! The fun can begin :)
}else{
// Not rooted... no fun here :(
}
Now, an example using 1 command (you'll need to develop the rest). Checking if /assets/lib/libs.so exists:
Code:
try {
List<String> output = RootTools.sendShell("ls /assets/lib | grep libs.so",-1);
if (output.get(0).equals("libs.so")){ //output.get(0) is the way to read 1 line of the command output
//the file exist... you can continue
}else{
//something is wrong, or the file is missing... =/
}
} catch (Exception e) {
// something went wrong, deal with it here
}
Proceed in the same way to run the other commands. Note that there are ways to run several commands using RootTools, you can check them in the Usage Page (I think will be a bit easy, since you don't need to read the output of the other commands).
Hi Everyone!
I want to make a .sh file which I am going to flash by CWM. I need your help in that.
1) In updater-script, when I extract it to /tmp, what permissions should I give to .sh file by set_perm?
2) I want it to execute "tar" command ("su" command that is root is not required) to operate on file from sdcard (/sdcard).
Can anyone tell me what should be the contents of .sh file.
I don't know much but I created this, and gave (0,0,0777) permissions but I am not getting required result. Please correct my script.
Code:
#!/sbin/sh
#Script to Odinize boot.img by [email protected] 2014
cd sdcard
tar -cf boot-sgy.tar boot.img
Above command works when I type it from terminal emulator, but does not work when flashed.
Please help me, I don't know anything about .sh but I have good knowledge of terminal commands & edify commands.
Hi, I want to show you how to make a flashable system.img - the copy/backup of your system.
Useful if you create a custom ROM. No need to use a backup of TWRP.
*for other phones than G2M: check the right partition of system by this command:
cat /proc/partitions
Click to expand...
Click to collapse
in terminal (first give permission by typing su)
1. Download Terminal Emulator: from Google Play
2. Open it and type
Code:
su
press 'Enter'.
3. Now type:
Code:
dd if=/dev/block/mmcblk0p32 of=/sdcard/system.img
You must wait some time. For example file of stock system can weigh even 2GB.
You can minimalize Terminal window and check in file manager how big is file after every second.
4. If you have system.img you can make flashable zip.
This simple script will be useful:
Code:
show_progress(1.0, 5);
ui_print("Welcome!");
ui_print("System Installation");
delete_recursive("/system");
package_extract_file("system.img", "/dev/block/platform/msm_sdcc.1/by-name/system");
unmount("/system");
ui_print("100% Reboot your phone...");
*dont forget about right kernel [boot.img] or if you flash stock LG base - cust.bin
Code:
package_extract_file("boot.img", "/dev/block/platform/msm_sdcc.1/by-name/boot");
package_extract_file("cust.bin", "/dev/block/platform/msm_sdcc.1/by-name/cust");
template-META-INF for DOWNLOAD
Very well.
One small note: dd will pull the whole partition (default: 2GB), including empty blocks (unused space).
WYPIERDAALAAC said:
Hi, I want to show you how to make a flashable system.img - the copy/backup of your system.
Useful if you create a custom ROM. No need to use a backup of TWRP.
*for other phones than G2M: check the right partition of system by this command:
in terminal (first give permission by typing su)
1. Download Terminal Emulator: from Google Play
2. Open it and type
Code:
su
press 'Enter'.
3. Now type:
Code:
dd if=/dev/block/mmcblk0p32 of=/sdcard/system.img
You must wait some time. For example file of stock system can weigh even 2GB.
You can minimalize Terminal window and check in file manager how big is file after every second.
4. If you have system.img you can make flashable zip.
This simple script will be useful:
Code:
show_progress(1.0, 5);
ui_print("Welcome!");
ui_print("System Installation");
delete_recursive("/system");
package_extract_file("system.img", "/dev/block/platform/msm_sdcc.1/by-name/system");
unmount("/system");
ui_print("100% Reboot your phone...");
*dont forget about right kernel [boot.img] or if you flash stock LG base - cust.bin
Code:
package_extract_file("boot.img", "/dev/block/platform/msm_sdcc.1/by-name/boot");
package_extract_file("cust.bin", "/dev/block/platform/msm_sdcc.1/by-name/cust");
template-META-INF for DOWNLOAD
Click to expand...
Click to collapse
do i have to add a mount line in the script?
ArchGaming16 said:
do i have to add a mount line in the script?
Click to expand...
Click to collapse
No.
If anything, you may have to unmount /system
Though, it shouldn't be needed.
On the recovery script, of course
Hi, I'd like to ask a general question about device boot. I've made some changes in init.rc and I packed again boot.img. In particular, I've added a .sh script to ramdisk root directory.
The script is named mount_partitions.sh and it does just this task. However, boot.img needs a shell to execute it, but /system is not mounted yet, at that point. So, I need to add a shell to to ramdisk root directory so that init executable can run the .sh script.
Exactly, how I could add shell support in boot.img without mounting the system partition? Any ideas?
Solved
I've found a way to use a shell before mounting system partition. Essentially, it's possible to place a busybox binary (i.e. taken from /system/xbin directory located in another android phone with installed busybox) into ramdisk root directory of boot.img, giving it execute permission in init.rc by chmod command, after remounted ramdisk root directory in read-write mode (by mount command put always in init.rc). It could be also be needed to give execute permission to the shell script (always by chmod command).
Then, it's needed run the shell script by busybox ash command, putting it into init.rc. The line looks like as following:
Code:
exec /busybox ash /myscript.sh
Don't forget to put also a line for remounting ramdisk root directory in read-only mode, after ash shell finished to execute the script (always using mount command in init.rc).
Remember to use the following shebang at the beginning of the shell script:
Code:
#!/busybox sh
shouldn't the shebang end with "ash" instead of just "sh"?
it's just a sh script but it could be true.