[TOOL] Flashize: Turn Shell Scripts Into Flashable Recovery Zips - Android Software/Hacking General [Developers Only]

Flashize: Turn Shell Scripts Into Flashable Recovery Zips
Highlights
Automatically convert shell scripts to flashable zips with a single command.
Don't mess with 'ui_print' crap: standard output and error streams will work just fine.
Can be configured to create a logfile of the execution of the script.
Free software: uses GPL and LGPL version 3 and later licenses.
This is a discussion thread. New versions will not be announced here.
Please 'watch' the Github project to receive notifications. Thank you!
More Info -> HERE
Downloads -> HERE
XDA:DevDB Information
flashize, Tool/Utility for all devices (see above for details)
Contributors
Lanchon
Version Information
Status: Testing
Created 2016-02-12
Last Updated 2016-03-19

Flashize
Downloads -> HERE

Reserved

Wow this is awesome Lanchon!
Sent from my Nexus 6P using Tapatalk

This is so awesome! Thank you!

Lanchon said:
Flashize: Turn Shell Scripts Into Flashable Recovery Zips
Features
Automatically convert shell scripts to flashable zips with a single command.
Don't mess with 'ui_print' crap: standard output and error streams will work just fine.
Displays the script exit code and reports it back to recovery.
The script receives the full path of the zip being flashed as its first parameter.
(Other parameters reserved for future use.)
Free software: uses GPL and LGPL version 3 and later licenses.
For Linux and Un*x-like systems only: requires 'Bash' shell.
(It would be very easy to port to Windoze proprietary crapware, but I won't do it.)
Usage
flashize <input-script> [<output-zip>]
XDA:DevDB Information
flashize, Tool/Utility for all devices (see above for details)
Contributors
Lanchon
Version Information
Status: Testing
Created 2016-02-12
Last Updated 2016-02-12
Click to expand...
Click to collapse
thanks bro brilliant idea works perfect going to share on my Google +

I'd love for a way to use this script without having to use my computer and use my phone instead. I already placed the flashize script file into /data/local/Flashize and set it to 0755 perms. I noticed, though, that in order to execute the script, that the syntax of
Code:
./data/local/Flashize/flashize test.sh testing.zip
doesn't work. Also, just doing
Code:
flashize test.sh testing.zip
doesn't work either while I'm already in the directory. Now, I noticed that if I rename the file to flashize.sh and run the command
Code:
sh flashize.sh
it says this as the output:
Code:
Flashize (2016-02-12)
Usage: <input-script> [<output-zip>]
That means that it should work when I do
Code:
sh flashize.sh test.sh testing.zip
but it does not work. Instead I get this error:
Code:
mkdir: '/tmp' : Read-only file system
Any idea how I can make this script work on my phone? Is there a different location where I should put this script where this will work?

misterpyrrhuloxia said:
I'd love for a way to use this script without having to use my computer and use my phone instead. I already placed the flashize script file into /data/local/Flashize and set it to 0755 perms. I noticed, though, that in order to execute the script, that the syntax of
Code:
./data/local/Flashize/flashize test.sh testing.zip
doesn't work. Also, just doing
Code:
flashize test.sh testing.zip
doesn't work either while I'm already in the directory. Now, I noticed that if I rename the file to flashize.sh and run the command
Code:
sh flashize.sh
it says this as the output:
Code:
Flashize (2016-02-12)
Usage: <input-script> [<output-zip>]
That means that it should work when I do
Code:
sh flashize.sh test.sh testing.zip
but it does not work. Instead I get this error:
Code:
mkdir: '/tmp' : Read-only file system
Any idea how I can make this script work on my phone? Is there a different location where I should put this script where this will work?
Click to expand...
Click to collapse
you could remount rootfs rw, it's a ramdrive anyway
mount -o remount,rw / /
then the script could create /tmp like it wants to.
you might have to run it in a chroot though, cm and busybox only fill so many of the gaps between android and Linux.

bigsupersquid said:
you could remount rootfs rw, it's a ramdrive anyway
mount -o remount,rw / /
then the script could create /tmp like it wants to.
you might have to run it in a chroot though, cm and busybox only fill so many of the gaps between android and Linux.
Click to expand...
Click to collapse
I don't know what rootfs is... And is that the exact command I should run on my phone?

misterpyrrhuloxia said:
I don't know what rootfs is... And is that the exact command I should run on my phone?
Click to expand...
Click to collapse
exact
Code:
su
mount -o remount,rw / /

Please help us Windows guys with this. I have a bricked g stylo.This sounds like it could be my salvation!! Thanks either way.
Sent from my N9521 using Tapatalk

bigsupersquid said:
exact
Code:
su
mount -o remount,rw / /
Click to expand...
Click to collapse
So that got rid of that error but now I'm getting a new error:
Code:
[email protected]:/data/local/Flashize # sh flashize test.sh testing.zip
flashize[113]: zip: not found
Not sure what that means.

misterpyrrhuloxia said:
So that got rid of that error but now I'm getting a new error:
Code:
[email protected]:/data/local/Flashize # sh flashize test.sh testing.zip
flashize[113]: zip: not found
Not sure what that means.
Click to expand...
Click to collapse
are you running stock rom? older cm?
it can't find the zip utility. there may not be one.
newer cm can unzip and zip in terminal.
regardless, the android command line environment you're working with might not be complete enough for the script to work.

misterpyrrhuloxia said:
I'd love for a way to use this script without having to use my computer and use my phone instead. I already placed the flashize script file into /data/local/Flashize and set it to 0755 perms. I noticed, though, that in order to execute the script, that the syntax of
Code:
./data/local/Flashize/flashize test.sh testing.zip
doesn't work. Also, just doing
Code:
flashize test.sh testing.zip
doesn't work either while I'm already in the directory. Now, I noticed that if I rename the file to flashize.sh and run the command
Code:
sh flashize.sh
it says this as the output:
Code:
Flashize (2016-02-12)
Usage: <input-script> [<output-zip>]
That means that it should work when I do
Code:
sh flashize.sh test.sh testing.zip
but it does not work. Instead I get this error:
Code:
mkdir: '/tmp' : Read-only file system
Any idea how I can make this script work on my phone? Is there a different location where I should put this script where this will work?
Click to expand...
Click to collapse
the script doesnt work because its a BASH script. bash is the most common shell in linux. stupid google doesnt want GPL code in userland android so it cant be part of android, just like busybox cant.
it doesnt start because the first line "#!/bin/bash" tells the kernel that bash should be used to open it, and obviously bash is not found in /bin/bash in your phone.
you dont need to rename or chmod the script, you can just invoke it with "sh <name>". but then ASH, a different shell part of busybox, is running it. it was not designed to be run with ash, so no idea whether it should work.
DO NOT mount your system RW and run inappropriate scripts!!!! you can kill you OS!
ill take a look sometime and see if it can be hosted in android.
but first, one question: what is the use case? no use case, no code

bigsupersquid said:
you could remount rootfs rw, it's a ramdrive anyway
mount -o remount,rw / /
then the script could create /tmp like it wants to.
You might have to run it in a chroot though, cm and busybox only fill so many of the gaps between android and linux.
Click to expand...
Click to collapse
do not do this!

misterpyrrhuloxia said:
I don't know what rootfs is... And is that the exact command I should run on my phone?
Click to expand...
Click to collapse
in my script change the line:
td="/tmp/lanchon-flashize"
to some writeable folder you want to use, such as:
td="/sdcard/lanchon-flashize"

misterpyrrhuloxia said:
So that got rid of that error but now I'm getting a new error:
Code:
[email protected]:/data/local/Flashize # sh flashize test.sh testing.zip
flashize[113]: zip: not found
Not sure what that means.
Click to expand...
Click to collapse
and now you need to have the 'zip' binary installed. CM11 has it. dont ask me how to get one!

Lanchon said:
do not do this!
Click to expand...
Click to collapse
I've not had issues myself with overwriting the initrd files even since they reset to the stored boot.img versions on reboot.
but creating things in / would use ram at the least, and I imagine there's devices with overwriteable rootfs, so I definitely understand your warning.
apologies, didn't mean to hijack.

bigsupersquid said:
I've not had issues myself with overwriting the initrd files even since they reset to the stored boot.img versions on reboot.
but creating things in / would use ram at the least, and I imagine there's devices with overwriteable rootfs, so I definitely understand your warning.
apologies, didn't mean to hijack.
Click to expand...
Click to collapse
no prob, its just dangerous

Lanchon said:
in my script change the line:
td="/tmp/lanchon-flashize"
to some writeable folder you want to use, such as:
td="/sdcard/lanchon-flashize"
Click to expand...
Click to collapse
Lanchon said:
and now you need to have the 'zip' binary installed. CM11 has it. dont ask me how to get one!
Click to expand...
Click to collapse
So I got it working in Android!! First of all, I had to change in the script the line
Code:
td="/tmp/lanchon-flashize"
to
Code:
td="/sdcard/lanchon-flashize"
Then I installed a zip utility for Android that I downloaded from here. Then I decided that I wanted a flashable zip. So attached below is a flashable zip that does these things:
Places your Flashize script in /data/local/Flashize.
Installs the Android Zip utility to be able to zip files in the terminal (like unto the utility in CM that you mentioned above).
Creates a command line alias in /system/etc/mkshrc so that way all you have to do to execute the Flashize script is type the command "flashize" in the terminal. This is the same type of aliasing that's common in Linux systems with the ~/.bashrc file.
So after flashing this, all you have to do on your phone to create a flashable zip with Flashize is to navigate to the directory where your shell script is, and run the same command as what's in the OP:
Code:
su
flashize <input-script> [<output-zip>]
What do you think, @Lanchon?
If this helped you out, hit thanks!
This has only been tested on the Motorola Nexus 6 running Pure Nexus rom.

Related

is it possible to do aliases with busybox?

i want to alias ls='ls --color=always'. is there something like a .bashrc file for busybox sh?
bilclintonsdaman said:
i want to alias ls='ls --color=always'. is there something like a .bashrc file for busybox sh?
Click to expand...
Click to collapse
Just had a look at the busybox source and it says it uses the contents of environment variable ENV as a startup script so you could do
Code:
ENV=/system/sd/.bashrc ash
and it'll read /system/sd/.bashrc for your startup commands. Altrernatively, if you invoke it as a login shell (ash -l), it'll source /etc/profile then .profile from the current directory so if you create /system/sd/.profile to contain alias ls='ls --color=always' then as long as you do this
Code:
cd /system/sd
ash -l
you'll have your alias (I just tried this with JF1.51 and it worked great).
I also saw that it will record command history to the file named in HISTFILE so you may want to make your startup script look like this
Code:
alias ls='ls --color=always'
HISTFILE=/system/sd/.histfile
Also, keep in mind that this isn't bash -- you need to use ash shell scripting semantics.
Sweet! Thanks so much
~/.PROFILE
if you edit (may need to create it first) the .profile file in your home directory you shouldn't have an issue
i have the following in my ~/.profile file:
Code:
alias dir='ls -Alp'
alias cls='clear'
The next time you log in, you'll have your alias's
pre-compiled gnu bash
I can't remember where I found it, however, if you know enough to set it up, I have a pre-compiled gnu bash 3.2 file that allows you to execute something like this:
su -c '/path/to/bash --rcfile /path/to/.bashrc'
in the terminal emulator and you'll execute a bash shell with the .bashrc
I attached the pre-compiled gnu bash 3.2 in a zip file on the post, good luck getting it running! google is your friend!
I also compiled bash 4.0 for myself to use, but its kind of buggy since it was actually one of the first binaries that i've ever compiled on linux but it works! its just really slow >.>
I followed this tutorial to compile it
http://www.kbrandt.com/category/bash

Ash as login shell

Hi All,
The Ash shell provides a few advantages over the Android default sh shell such as command history and cursor handling at the prompt. There are other benefits, but these are the first that come in most handy (to me).
The following tutorial will get you ash as the login shell with as yet no ill effects:
Note: that in my case, I'm using my android2sd construct and thus this modification is being done to my active overlay profile setup, thus to undo it I can simply boot into "safe\\normal" mode and undo the changes without possibly locking me out of the console should it have failed (which it didn't) But you can edit the Android /system/bin/sh file in this manner directly.
Ash as Login Shell:
OK, make the /system fs read-write:
mount -o remount,rw /system
Click to expand...
Click to collapse
Note: that the fs type is not needed, and in my case is not yaffs but ext3, Android will figure it out proper.
Next,
cp -a /system/bin/sh /system/bin/sh0
Click to expand...
Click to collapse
(this is for backup purposes and allows us to undo the change if so desired, or delete it if no longer needed).
Note: I'm using JF1.51 roms, so busybox ash is available as /system/xbin/bb/ash, so that is what I am using here; use ash however you are able to access it.
echo "#!/system/xbin/bb/ash">/system/bin/sh
echo "/system/xbin/bb/ash \[email protected]">>/system/bin/sh
Click to expand...
Click to collapse
Please note the use of (redirect\\overwrite)> and (redirect\\append)>>.
This will overwrite sh with a script to load the desired shell, executing any command-line arguments passed, and preserve the permissions of the original sh file. You can manually set the permissions the same as they are for our sh0 backup if the permissions (root.shell)(0755) don't seem to keep.
Finally reset the read-only state of /system:
mount -o remount,ro /system
Click to expand...
Click to collapse
Now if you shell-in\\telnet-in you should get the ash prompt which unlike the Android sh default prompt, includes the present working directory(pwd) ie: '/#' instead of just '#'.
Note: A reboot should not cause the loss of the modification, but if does, copy the new sh script to your /data/local/bin location or something and copy it back via boot script or something.
Shell Scripts:
If you're like me, you discovered that Android didn't need the interpreter declaration comment in scripts, and thus may not have used them...Well, you will need to update your scripts to include them by adding something similar to the following as the first line of your scripts:
#!/system/xbin/bb/ash
Click to expand...
Click to collapse
Again, please note that I am using JF1.51 roms and the location of the busybox ash shell is what I'm listing; put the full location to the shell you intend to use as this location.
Without the interpreter declaration, ash simply complains 'not found' at the first command, as ash doesn't know how to interpret the script, and doesn't seem to default to the login shell.
Hope someone finds this helpful!
sweet. This is going to be very useful
BAM. thats sexy. i just did this on CM3.6.7.1. works like a charm.
scratches head. i'm lost. what does this do and how does this make my g1 better?
temporizer said:
scratches head. i'm lost. what does this do and how does this make my g1 better?
Click to expand...
Click to collapse
im not sure about the other features, but the one i installed it for is to have your working directory in front of ur prompt. ex:
Code:
/# cd /sdcard
/sdcard # cd /system/sd
/system/sd #
etc...
EDIT: Also, if you use ConnectBot, you'll notice with the regular sh, if u scroll up with tracball, you get BS characters on the prompt. with THIS one, when you scroll up, you get last command entered. VERY handy for when you mistype one character on a long-ass command.
I love you
Couldn't you do this?
Code:
mv /system/bin/sh /system/bin/sh0
ln -s /system/xbin/bb/ash /system/bin/sh
great job, i'm going to get ash working on my G1 (CM-3.6.7.1)
Thanks.
kanstin said:
Couldn't you do this?
Code:
mv /system/bin/sh /system/bin/sh0
ln -s /system/xbin/bb/ash /system/bin/sh
Click to expand...
Click to collapse
I tried this and it worked even after a reboot...
Sweet, I love the scroll back with trackball in the terminal!!! Me thinks this should get absorbed into the next Cyan release.
kanstin said:
Couldn't you do this?
Code:
mv /system/bin/sh /system/bin/sh0
ln -s /system/xbin/bb/ash /system/bin/sh
Click to expand...
Click to collapse
Yes, I reckon you could. Though I had done a few experiments where the symlink failed, but I'm fairly sure it was do to the link: /system/xbin/bb/ash -->../busybox and /system/bin/../busybox not existing...so I did it via script. Many ways to skin a cat they say.
Thank you all... this is fricken awesome!!
temporizer said:
scratches head. i'm lost. what does this do and how does this make my g1 better?
Click to expand...
Click to collapse
It gives a more advanced shell for when you use the command line interface or telnet into your G1. If you don't use the command line a lot, it won't help you.
As for specific benefits to the advanced version, it was listed in the first post.
Hi,
imho this is rather a hack that exposes you to the risk at least on CM to loose your
shell during boot as xbin.sqf the compressed squashfs filesystem containing
busybox is mounted rather late in the boot process. A cleaner solution would be to
move busybox to system/bin and link it to sh. That way you ensure that sh will
always be accessible during boot and also later on, thus not interfering with
further developments. A alternative could be to compile a standalone version
of busybox containing only ash (for size reasons, as size in /system/bin is precious)
copy that to /system/bin and link sh to it.
Seems to work fine on Dude's. Not really sure how it should open, but I type "ash" at the prompt and I get the /$ and /# if superuser. I also get the command history by rolling the trackball, which is a very nice feature.
Can i install this without using my PC?
temporizer said:
Can i install this without using my PC?
Click to expand...
Click to collapse
Should work using terminal.
Tried it on JACHero 2.7.1
I tried the hard link one and I get a read only fs error on the first move command. What should I chmod to get past that?
mugafuga said:
I tried the hard link one and I get a read only fs error on the first move command. What should I chmod to get past that?
Click to expand...
Click to collapse
Do this first before the mv and the symlink.
mount -o remount,rw /system
farmatito said:
Hi,
imho this is rather a hack that exposes you to the risk at least on CM to loose your
shell during boot as xbin.sqf the compressed squashfs filesystem containing
busybox is mounted rather late in the boot process. A cleaner solution would be to
move busybox to system/bin and link it to sh. That way you ensure that sh will
always be accessible during boot and also later on, thus not interfering with
further developments. A alternative could be to compile a standalone version
of busybox containing only ash (for size reasons, as size in /system/bin is precious)
copy that to /system/bin and link sh to it.
Click to expand...
Click to collapse
Is this in any way accurate? I dedicate my g1 to cyan's roms and wouldn't want anything to hinder any of the goodness that is cyanogenMod. Advice?
Load ash when terminal is started?
temporizer said:
Is this in any way accurate? I dedicate my g1 to cyan's roms and wouldn't want anything to hinder any of the goodness that is cyanogenMod. Advice?
Click to expand...
Click to collapse
Safest method will be to change to ash shell once terminal app is started (same as typing "ash" to switch shell from sh to ash). I don't know how to do it in android (in linux you could add it to your login script).
So if someone knows how to execute a command when we login using the terminal app, then switching to ash shell would work without fear of breaking any other functionality.

[APP] Zipalign binary and script - Optimize installed applications

Hey everyone,
wesgarner said:
Zip Align reduces the amount of RAM used during processing running for a major speed increase in running the apps: http://developer.android.com/guide/developing/tools/zipalign.html
Click to expand...
Click to collapse
I had been messing about with a script to pull apks off my phone, zipalign them and then push them back, but then I saw wesgarner's CM build with a binary and script for use on your phone. I don't really want to mess round with flashing a ROM just for that though, so I've ripped them out and uploaded them below. Another reason is I want to run this manually (with GScript) rather than on boot (as it does in wesgarner's ROM).
I take no credit for this, the binary and script were both taken from wesgarner's CM buiild.
To "install" this, just adb push the two files in the zip below onto your phone with:
Code:
adb shell mount -o remount,rw /system
adb push zipalign /system/bin
adb push zipalign_apks /system/sd/zipalign_apks.sh
adb shell chmod 755 /system/bin/zipalign /system/sd/zipalign_apks.sh
adb shell mount -o remount,ro /system
Then anytime you want to run the script just do:
Code:
adb shell sh /system/sd/zipalign_apks.sh
Or in terminal:
Code:
su
sh /system/sd/zipalign_apks.sh
Has been tested on CM 4.2.7.1
ZipAlign
senab said:
Hey everyone,
I had been messing about with a script to pull apks off my phone, zipalign them and then push them back, but then I saw wesgarner's CM build with a binary and script for use on your phone. I don't really want to mess round with flashing a ROM just for that though, so I've ripped them out and uploaded them below. Another reason is I want to run this manually (with GScript) rather than on boot (as it does in wesgarner's ROM).
I take no credit for this, the binary and script were both taken from wesgarner's CM buiild.
To "install" this, just adb push the two files in the zip below onto your phone with:
Code:
adb shell mount -o remount,rw /system
adb push zipalign /system/bin
adb push zipalign_apks.sh /system/sd
adb shell chmod 755 /system/bin/zipalign /system/sd/zipalign_apks.sh
adb shell mount -o remount,ro /system
Then anytime you want to run the script just do:
Code:
adb shell /system/sd/zipalign_apks.sh
Or in terminal:
Code:
su
sh /system/sd/zipalign_apks.sh
Has been tested on CM 4.2.7.1
Click to expand...
Click to collapse
i do not even know what zipalign does .. but i did add this to my script
# lucid -z
so .. what does it do exactly?
Sweet... Thanks...
I was surprised that more than half of the Apps I have were already ZipAligned...
LucidREM said:
i do not even know what zipalign does .. but i did add this to my script
# lucid -z
so .. what does it do exactly?
Click to expand...
Click to collapse
APKs (as you probably already know) are just zip files. zipalign simply aligns the APK on 4-byte boundaries which Android is more efficient wrt memory access.
You can read more from Jean-Baptiste Queru at http://android-developers.blogspot.com/2009/09/zipalign-easy-optimization.html
Vermithrax said:
Sweet... Thanks...
I was surprised that more than half of the Apps I have were already ZipAligned...
Click to expand...
Click to collapse
Since the 1.6 SDK was released, the ADT does this automatically on APK export. Therefore any app which has been updated since ~September (and was developed using the ADT Eclipse plugin) will be zipalign'd. I was more surprised that 12 out of the 43 apps on my phone weren't aligned!
ZipAlign
senab said:
APKs (as you probably already know) are just zip files. zipalign simply aligns the APK on 4-byte boundaries which Android is more much efficient wrt memory access.
You can read more from Jean-Baptiste Queru at http://android-developers.blogspot.com/2009/09/zipalign-easy-optimization.html
Click to expand...
Click to collapse
that's awesome .. thanks for the link .. i hadn't read about that
Thanks much for this!
Here is a simple gscript to install zipalign after a wipe or new build flash.
You must first create directory /sdcard/zipalign and place zipalign from the zip in the OP there. Path to the file should now be /sdcard/zipalign/zipalign.
Place this script in your gscript folder (after removing .txt from the name) and load it in gscript with su permissions.
I also find it easier to run the script in the zip from the OP in Gscript as well. Instead of placing it in /system/sd run this (assumes zipalign_apks.sh is at root of C:\)
Code:
adb remount
adb push C:\zipalign_apks.sh /sdcard/gscript/zipalign_apks.sh
Then just load it into Gsrcipt with su permissions as with the other script.
Easiest of all may just be to use the commands within Lucid's script. But, I'm comfortable with Gscript, and I can make it 2 clicks away.
EDIT: First execution, you may want to run the original way, because guess what? Gscript isn't zipaligned. But it worked fine just the same.
worked great thanks.
Thanks. I didn't want to flash whole ROM to zipalign apps, so script was very handy.
Actually I've zipaligned only 2 apps, one of them was everybody loved Linda
so anyone wanna bless me with a terminal code to install the script?
garz said:
so anyone wanna bless me with a terminal code to install the script?
Click to expand...
Click to collapse
Read, its on the first post....xD
ZipAlign
garz said:
so anyone wanna bless me with a terminal code to install the script?
Click to expand...
Click to collapse
# lucid -z
yeah so su? then #lucid -z? cause that did nothing for me...
LucidREM said:
i do not even know what zipalign does .. but i did add this to my script
# lucid -z
so .. what does it do exactly?
Click to expand...
Click to collapse
I put a quick explanation of my script on my ROM page: here ya go (rough explanation)
Zip Align reduces the amount of RAM used during processing running for a major speed increase in dex-opt and running the apps, along with the RAM hack and a CC (or your userinit) boots speeds incredibly and better usability of apps (boot and system) in Android: http://developer.android.com/guide/d.../zipalign.html
Most developers have not used this yet (CM does ZipAlign his apps), but this does for the system apps provided from the now old Google Apps
Click to expand...
Click to collapse
senab said:
Since the 1.6 SDK was released, the ADT does this automatically on APK export. Therefore any app which has been updated since ~September (and was developed using the ADT Eclipse plugin) will be zipalign'd. I was more surprised that 12 out of the 43 apps on my phone weren't aligned!
Click to expand...
Click to collapse
Agreed. The Market won't let non-zipaligned apps be uploaded.
AndroidAppCritic said:
Agreed. The Market won't let non-zipaligned apps be uploaded.
Click to expand...
Click to collapse
it will really, it doesn't detect the diff
Also, SDK4 didn't really include an enforced ZipAlign like SDK5 (eclair) does
Plus I built the ZipAlign from source from eclair - so this script may not update them all perfectly
garz said:
yeah so su? then #lucid -z? cause that did nothing for me...
Click to expand...
Click to collapse
Unzip the files to your SD Card, then:
Code:
su
mount -o remount,rw /system
mv /sdcard/zipalign /system/bin
mv /sdcard/zipalign_apks /system/sd/zipalign_apks.sh
chmod 755 /system/bin/zipalign /system/sd/zipalign_apks.sh
mount -o remount,ro /system
Post deleted becoz it was redundant
can someone make a script for windows or a bat file that can zipalign a batch of apks? I am not that ofay with line commands and when i create a new theme (which i often do), i then have to go and zipalign every single apk i have altered 1 at a time..... i do:
Code:
zipalign -f -v 4 E:\app\theapp.apk E:\app\theapp.apk.out
senab said:
Unzip the files to your SD Card, then:
Code:
su
mount -o remount,rw /system
cp /sdcard/zipalign /system/bin
cp /sdcard/zipalign_apks.sh /system/sd
chmod 755 /system/bin/zipalign /system/sd/zipalign_apks.sh
mount -o remount,ro /system
Click to expand...
Click to collapse
This isnt working for me bc of the .sh after zipalign_apks .. do i rename the zipalign_apks to zipalign_apks.sh after unzipping?
edit:that worked THANKS!

[DEV] Apps2SD and Darchstar-2.1 ROM

The focus of this thread is to sort out the Apps2SD issue in cyanogenmod-darch 2.1 ROM (like the title says). Please do not post here unless it relates to this issue.
That being said, here is where I was at in the original darchstar 2.1 thread:
watzone69 said:
Taken from the instructions darchstar gave in the first post of his thread...
Code:
adb remount
adb push e2fsck /system/bin
adb shell
cd /system/bin
chmod a+x e2fsck
a2sd
reboot
First, the "chmod a+x e2fsck" command doesn't work for me (EDIT: I discovered that it WILL work in recovery mode). I had to use "chmod 777 e2fsck". After entering "a2sd" it gets enabled. After rebooting, apps2SD is NOT enabled anymore. I realized this by doing this test:
Code:
adb shell
cd /data/app
pwd
If your apps2sd is enabled, you will get "/system/sd/app" returned to you.
If you get "/data/app" returned instead then apps2sd is NOT enabled!
Click to expand...
Click to collapse
Gbhil then replied...
gbhil said:
After you restart, can you re-enable a2sd by running a2sd from a terminal as root?
If so, do all your apps still appear and are they usable?
If the above is true, try adding this to the end of gumbo.sh
Code:
su -C a2sd
for a quick fix.
Start a thread (to keep things less cluttered) about it and I'll help you guys dig into the boot image and see why it's not sticking.
Click to expand...
Click to collapse
So, I rebooted and tried to run "a2sd" from the android terminal but it spits out a long string of errors:
Code:
--- Checking ext filesystems
e2fsck 1.41.6 (30-May-2009)
ext2fs_check_if_mount: Can't check if filesystem is mounted due to missing mtab file while determining whether /dev/block/mmcblk0p2 is mounted.
/dev/block/mmcblk0p2: clean, 13/249856 files, 31387/499713 blocks
mount: permission denied. (are you root?)
chown: /system/sd: Read-only file system
chmod: /system/sd: Read-only file system
mkdir failed for /system/sd/app, Read-only file system
chown: /system/sd/app: No such file or directory
chmod: /system/sd/app: No such file or directory
cp: cannot create '/system/sd/app/android.tether.apk': No such file or directory
cp: cannot create '/system/sd/app/android.tether.usb.apk': No such file or directory
cp: cannot create '/system/sd/app/at.abraxas.mountusb.apk': No such file or directory...
(etc.)
...rm: cannot remove '/data/app/org.gmote.client.android.apk': Permission denied
rm: cannot remove '/data/app/org.hermit.substrate.apk': Permission denied
rm: cannot remove '/data/app/org.iplatform.android.apk': Permission denied
rm: cannot remove '/data/app/org.mikeyin.livewallpaper.apk': Permission denied
mkdir failed for /system/sd/app-private, Read-only file system
chown: /system/sd/app-private: No such file or directory
chmod: /system/sd/app-private: No such file or directory
cp: can't open '/data/app-private/com.android.aldiko.apk': Permission denied
cp: can't open '/data/app-private/com.protocol.x.su.fbs.apk': Permission denied
cp: can't open '/data/app-private/com.rerware.android.MyBackupPro.apk': Permission denied
rm: cannot remove '/data/app-private/com.android.aldiko.apk': Permission denied
rm: cannot remove '/data/app-private/com.protocol.x.su.fbs.apk': Permission denied
rm: cannot remove '/data/app-private/com.rerware.android.MyBackupPro.apk': Permission denied
ln: /data/app/app: Permission denied
ln: /data/app-private/app-private: Permission denied
+++ Apps-to-SD successfully enabled
So, there is no "app" or "app-private" in the "system/sd". Is a2sd supposed to generate those directories or are they supposed to be there before hand?
Anyway, the result is that I lose all of my shortcuts to the apps and market shows them as not installed even though they are.
BTW, I am not a dev or even that great at code or linux but I can usually pick stuff up fairly quickly. Just want to help fix this!
EDIT: The only thing I have found to work is to flash this kernel:
http://forum.xda-developers.com/showpost.php?p=5712377&postcount=1406
However, some people get stuck in a boot loop after flashing this.
Running into the same issues as Watzone so I can confirm that he is doing it correctly. =P
Here are all of the related commands that have been suggested whenever the question of apps2sd has come up in the darchstar 2.1 thread.
Code:
adb remount
adb shell
mkdir /system/sd
Code:
adb remount
adb shell
busybox --install /system/xbin
a2sd
Code:
cd C:\android-sdk-windows\tools
adb remount
adb shell
chown system.system /data/app
chmod 0771 /data/app
For the next command, boot into recovery and do the following:
Code:
adb shell
mount /system
exit
adb push e2fsck /system/bin
adb shell
cd /system/bin
chmod 777 e2fsck
Now, boot normally and go back to your CMD prompt...
Code:
adb remount
adb shell
a2sd
EDIT: In other threads I have seen the command...
Code:
apps2sd on
...used to enable apps2sd.
Doing all of these WILL allow the final "a2sd" command to enable (testing with the "pwd" command) but it all goes KAPUT after a reboot.
why it's not being enabled at boot time is because the init.rc isn't calling /system/etc/init.d/04apps2sd . I'll be sure that we fix that in my next release
And there you go.
It works here, but now I know why. I'm still using an old version of the boot image that looks for /system/bin/a2sd to load it, and an older version of the ROM. No sense in me to keep flashing fixes until I'm done tweaking the kernel. When darch says the kernel is good, then I'll catch up lol.
We might as well use this thread to learn to play with the boot image though, that is if you guys want to.
Awesome can't wait for the next release then! Lotsa apps out there calling out to me! Thanks guys =)
gbhil said:
We might as well use this thread to learn to play with the boot image though, that is if you guys want to.
Click to expand...
Click to collapse
You bet. It's about time I got my hands dirty.
I'm game let me know if you need me to test anything!
Cool deal. You need Linux to extract and compress the boot.img, and you need to be current with Perl and running jre5 or higher.
Ubuntu 9.04+ is set up out of the box, but any version can be made to work.
Then grab these files from Lox -
http://forum.xda-developers.com/attachment.php?attachmentid=231902&d=1254004933
http://forum.xda-developers.com/attachment.php?attachmentid=234040&d=1254622769
and extract them into your sdk/tools dir. (or any dir in your path)
get all that, then pick a boot.img from a rom and put it in a work folder.
Holler when you get that far, or if you have any q's.
I wanna learn myself. This should apply to mac os as well?
I have Mint on another machine. Gimme a bit to get caught up...
david279 said:
I wanna learn myself. This should apply to mac os as well?
Click to expand...
Click to collapse
Darwin might work. Never tried
watzone69 said:
I have Mint on another machine. Gimme a bit to get caught up...
Click to expand...
Click to collapse
np. I'm @work so going slow is better anyway lol.
ok i just ran the files in terminal. so i guess it might work.
I'm back
Inisde the work folder you dropped the boot.img into, run this from a term:
extract-kernel.pl boot.img
extract-ramdisk.pl boot.img
it will give you several files and a new directory. That dir is the unpacked ramdisk. The init.rc file is the one we're looking for. Open it with a Unicode editor and read it. It has it's own syntax, but it's almost like bash and not too hard to figure out. Hopefully you loaded a bootimg that has a2sd in it. Look near the bottom of the file for the a2sd start up line. It will have a2sd, apps2sd, a2sd004 or something like that. Once you find it so you can see the name used, search the rest of the file for that name.
Those lines will show you how a service gets declared and called at boot time.
I'm up and running now. I downloaded python 2.6.4. Do I need to install it or just extract it somewhere? Please forgive my linux noobness.
The other 2 zip files are extracted and in my tools folder. I'm getting the boot.img now.
idk if this will work as i too am a newb to android and the way they deal with the boot process is somewhat a bit different from what i'm used to, but heres a new boot.img if you guys want to flash it to see if apps2sd works. note, this is not a zip, remove that suffix.
to flash it to your phone just move the boot image to your sdcard then reboot into recovery. from there go into adb and mount your sdcard, then flash the new boot image.
Code:
adb shell
mount /sdcard
flash_image boot /sdcard/newBoot2.img
reboot
tell me if it fixes your apps2sd problem or not.
watzone69 said:
I'm up and running now. I downloaded python 2.6.4. Do I need to install it or just extract it somewhere? Please forgive my linux noobness.
The other 2 zip files are extracted and in my tools folder. I'm getting the boot.img now.
Click to expand...
Click to collapse
try it without doing anything to Python first....especially since I meant perl
Just try my last post and see if it works for ya. I'll edit my first post
gbhil said:
try it without doing anything to Python first....especially since I meant perl
Just try my last post and see if it works for ya. I'll edit my first post
Click to expand...
Click to collapse
Nope, I got "command not found" both times.
darchstar said:
idk if this will work as i too am a newb to android and the way they deal with the boot process is somewhat a bit different from what i'm used to, but heres a new boot.img if you guys want to flash it to see if apps2sd works. note, this is not a zip, remove that suffix.
to flash it to your phone just move the boot image to your sdcard then reboot into recovery. from there go into adb and mount your sdcard, then flash the new boot image.
Code:
adb shell
mount /sdcard
flash_image boot /sdcard/newBoot2.img
reboot
tell me if it fixes your apps2sd problem or not.
Click to expand...
Click to collapse
Thanks darchstar, I'll try that in a bit.
watzone69 said:
Nope, I got "command not found" both times.
Click to expand...
Click to collapse
you gotta make it executable
inside the directory with the perl scripts do this
Code:
chmod a+x ./

"No such file or directory" if tried run binary file in TWRP

I need to run a binary file, dalvikvm which located in /system/bin from TWRP terminal, but no matter what, it says, "No such file or directory found", and then I found that this is link file located another directory, I cd'd there and tried, but still the same result
I can be able to run the same file in Termux without any issues
Can anybody please help me on this?
Thanks
Hi, I think you need to mount the system partition before being able to access it. It's not mounted by default on TWRP, but when the phone is on it is (otherwise Android wouldn't work)
If you need help on how to mount partitions on TWRP, ring me (or google it, it's actually pretty simple)
Raiz said:
Hi, I think you need to mount the system partition before being able to access it. It's not mounted by default on TWRP, but when the phone is on it is (otherwise Android wouldn't work)
If you need help on how to mount partitions on TWRP, ring me (or google it, it's actually pretty simple)
Click to expand...
Click to collapse
Thanks for replying, it wasn't mounted at first, so I had mounted, still it didn't work, while some of the files in bin do work, some don't.
Then I copied the file to /sdcard and /tmp, and tried execute from these folders, still
Well, if when you're free, can you confirm if it's running on yours?
File: /system/bin/dalvikvm
Thanks once again
mizzunet said:
Thanks for replying, it wasn't mounted at first, so I had mounted, still it didn't work,
...
Thanks once again
Click to expand...
Click to collapse
I didn't found it inside, but it may be because I'm not rooted.
While searching around I've found this :
No such file or directory while running dalvikvm
I built AOSP Android and push the dalvik virtual machine in my device just to see if my built dalvik vm runs properly. I pushed it my device /opt directory but when I run dalvikvm, I get the error...
stackoverflow.com
It might get you out of trouble
Raiz said:
I didn't found it inside, but it may be because I'm not rooted.
While searching around I've found this :
No such file or directory while running dalvikvm
I built AOSP Android and push the dalvik virtual machine in my device just to see if my built dalvik vm runs properly. I pushed it my device /opt directory but when I run dalvikvm, I get the error...
stackoverflow.com
It might get you out of trouble
Click to expand...
Click to collapse
I looked into it.
I had no opt folder in root directory. So I made one, and moved dalvikvm to there and tried execute this time, it said permission denied, so I gave it chmod 755. But after that, it says "there no such file or directory".
Well, do you telegram account, so I could contact you there.
Thanks
Raiz said:
I didn't found it inside, but it may be because I'm not rooted.
While searching around I've found this :
No such file or directory while running dalvikvm
I built AOSP Android and push the dalvik virtual machine in my device just to see if my built dalvik vm runs properly. I pushed it my device /opt directory but when I run dalvikvm, I get the error...
stackoverflow.com
It might get you out of trouble
Click to expand...
Click to collapse
And even "file" binary, it says, there no file.
mizzunet said:
I looked into it.
I had no opt folder in root directory. So I made one, and moved dalvikvm to there and tried execute this time, it said permission denied, so I gave it chmod 755. But after that, it says "there no such file or directory".
Well, do you telegram account, so I could contact you there.
Thanks
Click to expand...
Click to collapse
This is really curious, tbh I'm not an expert around that subject, idk what's wrong with this binary...
Hopefully someone who knows more may help you with that. Have a nice day
This is because the binary you are trying to execute was compiled to run in the Android context, but you're trying to execute it in the TWRP one. Each binary has a path to a linker used during execution. The problem is that it refers to a linker that doesn't exist in TWRP.
Suppose we want to execte a binary file and obviously we can't:
Bash:
x00h:/ # /system/bin/awk
/sbin/sh: /system/bin/awk: No such file or directory
Let's take a look to its linker:
Bash:
x00h:/ # strings /system/bin/awk | head -n 1
/system/bin/linker64
Then, you will actually discover that it's sym linked to a linker that is available only when Android is running:
Bash:
x00h:/ # ls -ald /system/bin/linker64
lrwxr-xr-x 1 root shell 38 2009-01-01 00:00 /system/bin/linker64 -> /apex/com.android.runtime/bin/linker64
Since TWRP comes with its linker in /sbin/linker64, we can sym link it to /system/bin/linker64.
So, the hack:
Bash:
x00h:/ # mkdir -p /apex/com.android.runtime/bin/
x00h:/ # ln -s /sbin/linker /apex/com.android.runtime/bin/linker
x00h:/ # ln -s /sbin/linker64 /apex/com.android.runtime/bin/linker64
Retry, and it works:
Bash:
x00h:/ # /system/bin/awk
usage: /system/bin/awk [-F fs] [-v var=value] [-f progfile | 'prog'] [file ...]
Pray to God the TWRP's linker will be compatible and do the job (most binaries works fine), but sometimes you may get CANNOT LINK EXECUTABLE.

Categories

Resources