yashsingh1/xdaforums huggingface dataset:
[G1 Android Development] sub501:
Installing kernel modules via update.zip

Hello there,

I have o problem with an update script.

This is my package layout:

./META-INF

./META-INF/com

./META-INF/com/google

./META-INF/com/google/android

./META-INF/com/google/android/update-script

./system

./system/etc

./system/etc/init.d

./system/etc/init.d/98mods00

./system/etc/init.d/98mods01_screenstate_scaling

./system/lib

./system/lib/modules

./system/lib/modules/cpufreq_powersave.ko

./system/lib/modules/cpufreq_interactive.ko

The update-script :

------------

show_progress 0.1 0

copy_dir PACKAGE:system SYSTEM:

show_progress 0.1 10

-------------

/system/etc/init.d/ scripts are installed but not the /system/lib/modules

Any idea? Thanks.
[G1 Android Development] Firerat:
you proved it wasn't working by?

I bet you are flashing to a rom which has the kernel modules in sqf format

and if your flashing to some random rom, are you really expecting the modules to work?
[G1 Android Development] aspira:
Hello,

can anybody explain me what is the difference between the two scripts update-script and updater-script? I read that updater-script has the instructions to mount the devices. Can't it also do all the inscructions of update-script (set permissions, copy, delete, etc...)?

Bye.
[G1 Android Development] aspira:
Hi again,

I tried to write an update-script and run it on my HTC Tattoo. here is the code, really simple:

show_progress 0.1 0

ui_print "Test UI print"

show_progress 2.0 0

It is in the directory META-INF/com/google/android/. After signing it, I launch it on the phone in recovery mode. I get this log on the screen:

.
Verifying update package
...
E: No signature (5files)
E: Verification failed
Installation aborted.

I signed with several certificate/keys: self created, or testkey.x509.pem and testkey.pk8 from my Android SDK. Here is the way I sign:

java -jar signapk.jar ~/android/build/target/product/security/testkey.x509.pem ~/android/build/target/product/security/testkey.pk8 update-unsigned.zip update.zip

I also tried testsign.jar from a post of this forum.

I never succeed to launch the update.zip. Does the problem come from the phone, or from my signature?

I join the zip files I produce. Could someone knows where is my problem?

Thanks.
[G1 Android Development] twon23:
remove apps from /data/app

This is handy if you want your script to delete apk's off /data/app useful if you are updating system apps and want to remove the old apk's saving memory for more apps, well thats what i have used it for :)

To remove apps from /data/app

mount("MTD", "userdata", "/data");
delete("/data/app/someapp.apk");
unmount("/userdata");
[G1 Android Development] fredapied:
hello i need your help.

i want to write an update script to make a backup of a file

here is my script, but i have a syntax error

i tryied :

but doesn't work too :( always syntax error)
[G1 Android Development] RichieDaze:
Try this!

To my knowledge, there is no command to MV files. Only if you pull it to cache then replace the files back to /system /data,etc..

What you could do is make a script then "run_program" to achive your goals with your 'mv' command.

Also, does this script install anything??? If it doesn't, you can do it in the terminal.
[G1 Android Development] fredapied:
perhaps to "force" the copy ?

always syntax error :(
[G1 Android Development] RichieDaze:
My solution to you

Usually update.zip's go into /cache.img from OTA, but we will use

the /tmp folder to make it easier for you.

This command mounts the system:

mount("MTD", "system", "/system");

This command pulls your apk from system/app and places it in /tmp

package_extract_file("system/app/your.apk", "/tmp/your.apk");

This command pulls your script and places it in /tmp.

The first in this example pulls from mounted file system(.img)

and the second one pulls from the update package.

*Please choose the one you need.*

package_extract_file("location/yourscript.sh", "/tmp/yourscript.sh");

assert(package_extract_file("yourscript.sh", "/tmp/yourscript.sh"),

This command gives read, write and execute(r-w-x) permissions to your script

set_perm(0, 0, 0777, "/tmp/yourscript.sh");

This command runs your script.

With an argument or w/o.

*Please choose the one you need.*

run_program("/tmp/yourscript.sh")

run_program("/tmp/yourscript.sh", "argument");

This command unmount's the file system (system.img) in this example

unmount("/system");
[G1 Android Development] fredapied:
ok, thank you very much for this answer very clear.

i have done an update.zip with 2 files :

update-script :

mount("MTD", "system", "/system");
ui_print("Installing system...");

show_progress(0.100000, 0);
set_progress(1.000000);

package_extract_file("system/app/Email.apk", "/sdcard/Email.apk");

assert(package_extract_file("copie.sh", "/sdcard/copie.sh") ;

set_perm(0, 0, 0777, "/sdcard/copie.sh");

run_program("/sdcard/copie.sh")

ui_print("Bonnard!");

unmount("/system");

and a copie.sh file:

mv "/system/app/Email-Copy.apk" "/system/app/Email.original" ;

the problem is that my galaxy S has no temp directory so i put sdcard instead of temp

but always "syntax error" :mad:

what am i doing wrong ?
[G1 Android Development] Firerat:
just write a shell script and use run program to.. errm run it

example

set_progress(1.000000);
ui_print("CustomMTD Patcher v1.5.5");
ui_print("Test Mode");
ui_print("Extracting Patch Tools...");
package_extract_dir("MTDPartPatcher", "/tmp");
set_perm(0, 0, 0700, "/tmp/patchbootimg.sh");
set_perm(0, 0, 0700, "/tmp/mkbootimg");
set_perm(0, 0, 0700, "/tmp/unpackbootimg");
run_program("/tmp/patchbootimg.sh", "test");

^^ that is the update script in my CustomMTD zip

should be enough for you to figure out what you need to do , if not give up

hint , patchbootimg.sh will need

#!/sbin/sh

as the first line

up to you if you use the .sh script or the updater-script to mount/unmount partitions
[G1 Android Development] fredapied:
i tried your script :

my wish: to make a backup of the file email.apk (without adb shell or terminal on the phone , just with an update.zip )

the update-script file :

mount("MTD", "system", "/system");

set_progress(1.000000);
ui_print("test");

package_extract_file("/system/app/Email.apk", "/tmp/Email.apk");
package_extract_file("copie.sh", "/tmp/copie.sh");

set_perm(0, 0, 0700, "/tmp/copie.sh");

set_perm(0, 0, 0700, "/system/app);
set_perm(0, 0, 0700, "/system/app/Email.apk);

run_program("/tmp/copie.sh", "test");

ui_print("ok!");

unmount("/system");

now the copie.sh

mv "/tmp/Email.apk" "/system/app/Email.original" ;

the tree is:

C:\UPDATE
| CERT.RSA
| CERT.SF
| MANIFEST.MF
|
\---com
\---google
\---android
copie.sh
update-script

when i launch thz zip, it stays on "installing update" for so long time... so i think it freeze...

i have no tmp directory when i use root explorer on my phone

somewhere i found a script based on busybox

mount("MTD", "system", "/system");
mount("MTD", "sbin", "/sbin");

ui_print("coucou");

set_perm(0, 0, 04755, "/sbin");
set_perm(0, 0, 04755, "/system/app");
set_perm(0, 0, 04755, "/sbin/busybox");
set_perm(0, 0, 04755, "/system/app/Email.apk");

run_program("/sbin/busybox","cp","/system/app/Email.apk","/system/app/Email.apk.bak");

ui_print("ok!");

unmount("/system");

but not working too (error status 6)

OH!!!

perhaps it's because i have a samsung galaxy S, and not a HTC ???

i have done a mistake to post in the wrong section... i'm sorry :(
[G1 Android Development] RichieDaze:
Lets say that / is root.

Recovery is a image(.img) that gets mounted on /

So respectfully, your in the recovery file system when your in recovery.

Depending on who's recovery image your on there's a folder called sbin.

Sbin has the executables commands inside. Where toolbox/busybox are placed.

Same goes with system, but you would use bin or xbin to execute your commands.

But you would have to mount it first to use bin or xbin executables.

Most modified recoveries have busybox so you would have to specify busybox before your command. Say mv or cp would be busybox mv or busybox cp.

Say your using recovery for commands...

Your script should start off as

#!/sbin/sh

With system mounted to /

#!/system/bin/sh

These tell the path of the executable commands to run the script.

/tmp is in the recovery.img, unless you specify /system/tmp which it does not have.

I just noticed that your script is in the wrong location.

It doesn't belong in any folder. It goes on the Root / of the zip.

The same folder as META-INF system data boot.img etc....
[G1 Android Development] fredapied:
when you say "your script" you mean the .sh file ?

or the script i have posted with busybox ?

i'm lost and don't know what to use (it's not very easy when you don't know this language : unix...... and english.. because i'm french)

could you please modify my scripts i have written up this page ?

because i 've been trying it to work for long hours.

thank you

fred.
[G1 Android Development] RichieDaze:
Yes the name of your sh(shell) script. "copie.sh" also post your script

What do you want this update-script to do? Remove your original email.apk before your update replaces it?
[G1 Android Development] Firerat:
::facepalm::

you are getting everything totally mixed up

mount("MTD", "system", "/system");

set_progress(1.000000);
ui_print("test");

package_extract_file("system/app/Email.apk", "/tmp/Email.apk");
package_extract_file("copie.sh", "/tmp/copie.sh");

set_perm(0, 0, 0700, "/tmp/copie.sh");

run_program("/tmp/copie.sh" );

ui_print("ok!");

unmount("/system");

copie.sh

#!/sbin/sh
cp /system/app/Email.apk /system/app/Email.apk.orig
cp /tmp/Email.apk /system/app/Email.apk

^^ that script is crap, it assumes you have enough space etc

tbh you probably should learn stuff by doing manually, so you get a 'feel' for how the shell works, then write a script to do it 'in rom' , then re-write that script so it will work in recovery

your trying to fly before you can walk
[G1 Android Development] fredapied:
thank you for your answer.

i always want to make a backup of the email.apk

i tried your script, and always the syntax error

is it because i have a galaxy S rooted Froyo JPM ?

here is the update.zip i use.

perhaps in the line package_extract_file("system/app/Email.apk", "/tmp/Email.apk");

it's not what i want : i haven't a directory system/app on my zip file.

perhaps to put a "/" behind to move the apk of the phone to the temp ?

perhaps a set_perm to the system/app ??

i think it's not so easy.

and you're right i don't know to fly,so i ask for help

fred.
[G1 Android Development] Firerat:
your using updater-script syntax with an update-script

confused?

updater is newer, and it requires the update-bin

anyway, what your doing is simple, but I'm not 100% on what you are actually trying to achieve.. but I've made one for you, this will backup to /data/MyBackup ( since /data will more than likely have space, system might not )

at least you can have a look at it and change it to suit your needs
[G1 Android Development] RichieDaze:
I think he wants to save his old Email.apk before flashing a new rom, so that he doesn't have to replace all the data all over again. If this is true, you would have to save the app's data folder as well...

Other then that, I see no reason to save an apk from recovery.
[G1 Android Development] Firerat:
yeap, I was thinking the same

titanium backup would be much easier

but a script like this

busybox mount -a
EmailDir=$(busybox awk -F\" '/Email.apk/ {print $2 }' /data/system/packages.xml)
busybox tar -c /data/$EmailDir -f /sdcard/email-$(busybox date +%Y%m%d-%k%M).tar

would work

the awk just finds the android name from the apk's name and the andriod name will be the name of the folder in data where , its .. errm data is kept .

But , titanium is much easier..
[G1 Android Development] fredapied:
it's not my job, but after searching and searching.. trying and trying a have finally found the right script myself !!!!

here is my script:

META-INF
| CERT.RSA
| CERT.SF
| MANIFEST.MF
|
\---com
\---google
\---android
update-binary
updater-script

this is ziped and signed

updater-script is like this :

mount("MTD", "system", "/system");
mount("MTD", "sbin", "/sbin");

ui_print("coucou");

set_perm_recursive(0, 0, 0755, 0755, "/sbin");
set_perm_recursive(0, 0, 0755, 0755, "/system/app");

run_program("/sbin/busybox", "cp", "/system/app/Email.apk", "/system/app/Email.apk.bak");
run_program("/sbin/busybox", "cp", "/system/app/Email.apk", "/sdcard/Email.apk.bak");

ui_print("ok!");

unmount("/system");

it needs to have busybox installed

perhaps i could add in this script the busybox and the installer command if i want to give to a friend.

BTW, i would like to thank you all 2 Firerat & RichieDaze , helping me and writting so good answers.

fred.
[G1 Android Development] Firerat:
If a custom recovery doesn't have busybox, it aint worth having

I still have no idea what you have achieved

why do you feel the need to 'backup' Email.apk?
[G1 Android Development] fredapied:
yes, but each script i have tested haven't worked.

so i just can add busybos installer in my script (but it's just for my use, not distribution)

first, to understand and learn

second: because i want to make my own script to customize my phone :

and third: i like testing files that people on this forum are developping... so it's easy to test and then to restaure.

change theme,change boot and shutdown sounds, change email.apk and a lot of other things.

i know i could use titanium backup... but i do prefer making myself

the other thing is that i want to try to make my own zip rom, a real ghost of all directories.

just copy all files/directory to the sdcard, and to simply restaure with a zip.

i know you are going to tell me to use rom manager/clockwork mod , but the big problem i have is that:

if i start to froyo, i can restaure a froyo rom

if i start to eclair, i can restaure a froyo eclair

if i start to froyo, i can't restaure an eclair rom

if i start to eclair, i can't restaure a froyo rom

that's why :)
[G1 Android Development] Firerat:
sorry, I'm still missing it

but enjoy ;)
[G1 Android Development] Binary100100:
I have hit a wall on this. Perhaps I'm overlooking the obvious.

I'm trying to cleanup my update script and currently it's as such:

delete SYSTEM:app/ADWLauncher.apk
delete SYSTEM:app/Browser.apk
delete SYSTEM:app/Calculator.apk
delete SYSTEM:app/Calendar.apk
delete SYSTEM:app/Camera.apk
delete SYSTEM:app/CMParts.apk
delete SYSTEM:app/CMPartsHelper.apk
delete SYSTEM:app/CMWallpapers.apk
delete SYSTEM:app/Contacts.apk
delete SYSTEM:app/DeskClock.apk
delete SYSTEM:app/Email.apk
delete SYSTEM:app/Gallery3D.apk
delete SYSTEM:app/Gmail.apk
delete SYSTEM:app/Mms.apk
delete SYSTEM:app/Music.apk
delete SYSTEM:app/Phone.apk
delete SYSTEM:app/Settings.apk
delete SYSTEM:app/SoundRecorder.apk
delete SYSTEM:app/QuickSearchBox.apk
delete SYSTEM:app/VoiceDialer.apk
delete SYSTEM:framework/framework-res.apk
delete SYSTEM:media/bootanimation.zip
copy_dir PACKAGE:app SYSTEM:app
copy_dir PACKAGE:fonts SYSTEM:fonts
copy_dir PACKAGE:framework SYSTEM:framework
copy_dir PACKAGE:data DATA:
copy_dir PACKAGE:sdcard SDCARD:

And as a result it's messy but it works. I'm not a coder so I have been ultimately satified with the results.

I have also noticed that for G1 users, that if you didn't delete the apps prior to flashing the themed versions then it will not replace all of the apk files. Perhaps due to space limitations. But obviously when you flash the theme it fills the screen with 'DELETING' messages before it updates.

So I've been trying to make another .sh file to specifically remove those apps. I've tried this update-script and several variations:

I've also been trying to set a ui_print message but that always fails as well.

set_progress(1.000000);
ui_print("Welcome to Community Hero Mix!");
package_extract_file("tmp/chmreplacecmfiles.sh", "/tmp/chmreplacecmfiles.sh");
set_perm(0, 0, 0777, "/tmp/chmreplacecmfiles.sh");
run_program("/tmp/chmreplacecmfiles.sh");
copy_dir PACKAGE:app SYSTEM:app
copy_dir PACKAGE:fonts SYSTEM:fonts
copy_dir PACKAGE:framework SYSTEM:framework
copy_dir PACKAGE:data DATA:
copy_dir PACKAGE:sdcard SDCARD:

I can't figure out how to setup the chmreplacecmfiles.sh though.

I assume that I need to use

rm /system/app/ADWLauncher.apk

rm /system/app/Browser.apk

etc... but I keep getting:

"E:Syntax error..." message.

So bottom line.

I would like to have a ui_print text.

I would like to have an editable .sh script to remove the apps prior to flashing the themed versions.

I would like to remove that sh script after the update.

Any pointers?
[G1 Android Development] Binary100100:
Is DATADATA intentional? :confused:
[G1 Android Development] C3P0LOL:
yes, I saw this in another update script that is working the way i want.
[G1 Android Development] Binary100100:
...

format CACHE:

format DATADATA:format DATA:

copy_dir PACKAGE:inti SDCARD:init

set_perm 1000 1000 0771 SDCARD:init

inti = typo? Shouldn't it be init?
[G1 Android Development] RichieDaze:
delete_recursive SDCARD:Android

I never successfully deleted anything reclusive in sdcard.

Someone correct me if it's possible.

-run_program /system/xbin/busybox --install -s /system/xbin

run_program should be a script(.sh) and should be pulled to tmp then granted permissions first, then ran.

format DATADATA:

This should say format DATA:

copy_dir PACKAGE:inti SDCARD:init

As Binary100100 stated the first init is spelled incorrect.

run_program /tmp/updates/redbend_ua restore /tmp/updates/modem.bin /dev/block/bml12
run_program /tmp/updates/redbend_ua restore /tmp/updates/zImage /dev/block/bml7

I never tried to run two programs in one line.
[G1 Android Development] RichieDaze:
delete SYSTEM:app/ADWLauncher.apk
delete SYSTEM:app/Browser.apk
delete SYSTEM:app/Calculator.apk
delete SYSTEM:app/Calendar.apk
delete SYSTEM:app/Camera.apk
delete SYSTEM:app/CMParts.apk
delete SYSTEM:app/CMPartsHelper.apk
delete SYSTEM:app/CMWallpapers.apk
delete SYSTEM:app/Contacts.apk
delete SYSTEM:app/DeskClock.apk
delete SYSTEM:app/Email.apk
delete SYSTEM:app/Gallery3D.apk
delete SYSTEM:app/Gmail.apk
delete SYSTEM:app/Mms.apk
delete SYSTEM:app/Music.apk
delete SYSTEM:app/Phone.apk
delete SYSTEM:app/Settings.apk
delete SYSTEM:app/SoundRecorder.apk
delete SYSTEM:app/QuickSearchBox.apk
delete SYSTEM:app/VoiceDialer.apk
delete SYSTEM:framework/framework-res.apk
delete SYSTEM:media/bootanimation.zip

This is the shortest your getting with update-script, unless you convert to updater-script, it won't get shorter.

copy_dir PACKAGE:app SYSTEM:app
copy_dir PACKAGE:fonts SYSTEM:fonts
copy_dir PACKAGE:framework SYSTEM:framework
copy_dir PACKAGE:data DATA:
copy_dir PACKAGE:sdcard SDCARD:

copy_dir PACKAGE:system SYSTEM:

you don't have to name each folder.

system folder copies everthing in zip/system to /system reclusively.

The same concept goes for data and sdcard.

package_extract_file("tmp/chmreplacecmfiles.sh", "/tmp/chmreplacecmfiles.sh");
set_perm(0, 0, 0777, "/tmp/chmreplacecmfiles.sh");
run_program("/tmp/chmreplacecmfiles.sh");

This is part of the newer updater-script. Convert it to update-script.

I don't know what is in your script so:

In recovery try the log2sd command to see why?

1)You ui_print is written for the newer updater-script, change it.

2)Place your script in the root of the zip. Pull it to tmp, then grant it permissions, then run_program.

3)Since it's in the zip and then moved to tmp, it will never be on the rom!
[G1 Android Development] Binary100100:
Thanks! It sounds like I need to create an updater-script. How do I go about converting this to an updater-script?
[G1 Android Development] RichieDaze:
Try this!

ui_print("Welcome to Community Hero Mix!");
show_progress(0.500000, 0);
mount("MTD", "system", "/system");
delete("/system/app/ADWLauncher.apk", "/system/app/Browser.apk",
"/system/app/Calculator.apk", "/system/app/Calendar.apk",
"/system/app/Camera.apk", "/system/app/CMParts.apk",
"/system/app/CMPartsHelper.apk", "/system/app/CMWallpapers.apk",
"/system/app/Contacts.apk", "/system/app/DeskClock.apk",
"/system/app/Email.apk", "/system/app/Gallery3D.apk",
"/system/app/Gmail.apk", "/system/app/Mms.apk",
"/system/app/Music.apk", "/system/app/Phone.apk",
"/system/app/Settings.apk", "/system/app/SoundRecorder.apk",
"/system/app/QuickSearchBox.apk", "/system/app/VoiceDialer.apk",
"/system/framework/framework-res.apk",
"/system/media/bootanimation.zip");
package_extract_dir("system", "/system");
show_progress(0.200000, 0);
mount("MTD", "userdata", "/data");
package_extract_dir("userdata", "/data");
mount("MTD", "sdcard", "/sdcard");
package_extract_dir("sdcard", "/sdcard");
show_progress(0.200000, 10);
package_extract_file("tmp/chmreplacecmfiles.sh", "/tmp/chmreplacecmfiles.sh");
set_perm(0, 0, 0777, "/tmp/chmreplacecmfiles.sh");
run_program("/tmp/chmreplacecmfiles.sh");
show_progress(0.100000, 0);
unmount("/system");
unmount("/data");
unmount("/sdcard");

Don't forget to add the update-binary to your META folder.

Also the "chmreplacecmfiles.sh" should be on the root directory of your zip.

Tip:If your changing .apk's because of themes, "package_extract_dir("system", "/system");" will replace the old .apk's with your edited ones without having to delete them.
[G1 Android Development] Binary100100:
Thanks! I appreciate this very much!
[G1 Android Development] Binary100100:
Then I don't need the .sh file. I only wanted that to clean up the update-script file because it filled the entire screen with "Deleting files..." when you applied the zip file. It could be intimidating to most newbies. LOL!

So should I just do something like:

ui_print("Welcome to Community Hero Mix!");
show_progress(0.500000, 0);
mount("MTD", "system", "/system");
delete("/system/app/ADWLauncher.apk", "/system/app/Browser.apk",
"/system/app/Calculator.apk", "/system/app/Calendar.apk",
"/system/app/Camera.apk", "/system/app/CMParts.apk",
"/system/app/CMPartsHelper.apk", "/system/app/CMWallpapers.apk",
"/system/app/Contacts.apk", "/system/app/DeskClock.apk",
"/system/app/Email.apk", "/system/app/Gallery3D.apk",
"/system/app/Gmail.apk", "/system/app/Mms.apk",
"/system/app/Music.apk", "/system/app/Phone.apk",
"/system/app/Settings.apk", "/system/app/SoundRecorder.apk",
"/system/app/QuickSearchBox.apk", "/system/app/VoiceDialer.apk",
"/system/framework/framework-res.apk",
"/system/media/bootanimation.zip");
package_extract_dir("system", "/system");
show_progress(0.200000, 0);
mount("MTD", "userdata", "/data");
package_extract_dir("userdata", "/data");
mount("MTD", "sdcard", "/sdcard");
package_extract_dir("sdcard", "/sdcard");
show_progress(0.100000, 0);
unmount("/system");
unmount("/data");
unmount("/sdcard");

Also, how would I go about adding multiple ui_print lines?
[G1 Android Development] RichieDaze:
You are Correct.
[G1 Android Development] Binary100100:
Yeah I figured that out. Sorry, trying to compile CM-6.1.0-DS on my laptop for some minor xml editing, tweet, flash and type all at the same time.

Is it possible to add multiple print_ui messages?

Such as:

ui_print("Welcome to Community Hero Mix!");

ui_print("Designed by Binary100100");

ui_print("Credit to RichieDaze for helping me with this!");
[G1 Android Development] RichieDaze:
Yes it is possible. You could even dictate the process as it progresses.

Say :

ui_print("Visually Optimizing your OS");

or

ui_print("We Thank You for your support while you wait");

Creativity is the key!
[G1 Android Development] Binary100100:
Okay. I tried one after the other like above and it said (Bad).
[G1 Android Development] RichieDaze:
Were they in the begining of the script?