[Q] Script that can be run in Android to create a zip file? [Solved] - Android Software/Hacking General [Developers Only]

I'm trying to write a .sh script for SL4A that would do the following:
1. Unzip XXX.zip to directory YYY (which contains other files)
2. Create a new ZZZ.zip file using all of the contents in directory YYY (new and old files)
I see that busybox has gzip/gunzip/unzip commands, but I'm not really familiar with them, and my brief experimentation hasn't yielded great results. I've figured out step #1, which is just
Code:
unzip XXX.zip -d ./YYY/
Can anyone help me on step two?

I'd also be willing to install a 3rd party app to assist with this task, so long as that app can be automated.
I can, of course, manually extract and zip files in Root Explorer, but I'm looking for a way to automate that functionality.

If it doesn't have to be .zip, you can use tar..
tar xf XXX.tar -C /YYY
tar cf ZZZ.tar /YYY/

Thank you, but unfortunately it has to be zip.
Basically, I'd like to be able to set up a script that creates flashable zips on the phone.
I would have a couple uses for this, but one specific example is for using ZipThemer. ZipThemer still creates flashable zip packages using the old amend scripting, but I am using new CWM that requires edify scripting. The developer is aware of this change, but hasn't yet updated ZipThemer. My idea therefore was to create a script that extracts the needed files from the ZT zip and then puts them into a new flashable package with working edify scripts (that I keep elsewhere on the phone).
So far, all of the amend>edify solutions I've seen are desktop solutions. Since the packages I'd need to create are quite simple, I can keep various edify scripts in sdcard folders, ready to be packaged, but doing this manually all the time is frustrating.

I don't think busybox has a zip command for some reason, gzip/gunzip aren't the same thing. Since you're using SL4A, there may be a way to do it with python or perl or something.

Thanks, fubaya, and good call. I found this which I was able to successfully use:
How do I zip the contents of a folder using python

byrong said:
ZipThemer still creates flashable zip packages using the old amend scripting, but I am using new CWM that requires edify scripting. The developer is aware of this change, but hasn't yet updated ZipThemer.
Click to expand...
Click to collapse
ZipThemer 1.8 was released today with support for Edify scripting. See the ZipThemer User Manual for more information.
Ken

Related

How do I create an update-script in Linux?

How do I create an update-script in Linux? I'd like to create my own ROM, but I need to find a way to create my own update-script for the update.zip.
hotweiss said:
How do I create an update-script in Linux? I'd like to create my own ROM, but I need to find a way to create my own update-script for the update.zip.
Click to expand...
Click to collapse
I have never actually used it but you get one when you compile the androids source
http://source.android.com/download
perhaps you could just compile that one thing.
edit: Its named of course make-update-script
I've started to play around with the scripts that others have created... they always fail for me when a symlink is being created between toolbox and what ever file...
Yeah, I have only made realy simple update.zip scripts. one liners. I could try my compiled make-update-script and see if it does what its supposed to
I've tried it a very limited amount now and all I can say is that it seems to be doing stuff correct, but not all the way, so my assumption is that the "scene" people or what I should call them, use a modified version of this, when I ran it against fatal1tys hero1.4 or gave me a filesize of 0.98KB whereas fatal1tys version is 13.2KB, of course he has both system and data in his, but it still don't add up.
I can't figure out why symlink isn't working? Am I missing something?
Here's what I did so far:
1) copied xbin into my system directory
2) created META-INF folder and subfolder
3) pasted my update-script
I'm afraid I cannot help you much I don't know what xbin is supposed to to with the update-script. But are you creating symlinks through the update-script?
You have to look at another update-script and compare it... and you have to look which symlinks you need!

[MOD] Theme updater for Windows/Linux

Hi everyone,
Imagine that you are updating two or more themes for roms like OpenDesire/Defrost/CyanogenMod (I'm pretty sure that this updater works for every AOSP rom but I didn't try), that in one week can be updated at least 4 times. Don't get me wrong, the updates are appreciated, but updating all the themes for all the new versions gets old in no time.
So, I made myself two scripts, one that runs on Windows (this is the first one so is no so updated, but if I see that people use this I'll be willing to create a C# version) and another for linux (bash script), that do this work for me.
This scripts, decompile, copy the modded file (for the status battery), compile the framework again and then add the new images to the framework. After all that it generates the update.zip file for each mod so they can be flash using the recovery (Clockworkmod/Amon Ra/even the default recovery).
Windows Version 1.0
Linux Version 1.0
In the second post, I'll put instructions explaining how to configure the scripts.
Credits :
Brut.all for APKTool.
Daneshm90 for the APKManager (It give me the basic knowledge to create the first versions of the scripts).
Instructions :
Windows.-
If you want to update more than one mod at the same time, you need to edit the script.bat file and modify the "start:" seccion like this :
Code:
:Start
if "%jumpmod%"=="0" set mod=MOD1
if "%jumpmod%"=="1" set mod=MOD2
if "%jumpmod%"=="2" set mod=MOD3
if "%jumpmod%"=="3" set mod=MOD4
if "%jumpmod%"=="4" goto end
set jump=0
goto Create
In order for this to work you need to put the original framework-res.apk in the folder "original"
The mod files have to be in MOD/Images (images you add) and MOD/Xml (xml to recompile). Right now the script is only prepare to recompile the xml for the status battery.
If you add more than one mod, the folders name must be the same as in the start seccion (MOD1, MOD2, MOD3...)
You must have installed Java JRE
Once you configure the script, run it, wait for it to be done. Then go to the result folder and you will find the update.zip file/s.
Linux.-
If you want to update more than one mod at the same time, you need to add as much folders as mods you want in the mods folder. The new folders must have the same structure as the default one.
The mod folders contains one folder to put the images to add after the framework have been recompile (MODNAME/add/drawable-hdpi) and one folder for the file that are used to make the mod (MODNAME/mod/drawable for the XML and MODNAME/mod/drawable-hdpi for the necessary images).
In order for this to work you need to put the original framework-res.apk in the folder "original" or you can download the original Rom by using the script (it extracts the framework-res.apk from /system/framework/).
YOU MUST configure the variables within the script.sh to set the initial path of the script and the path to copy the resulting update.zip files.
In order for this to work you must be ROOT (This is because the apktool, if anyone have a workaround please let me know)
You must copy the following files to /usr/local/sbin/ for this to work :
Code:
/theme_updater/other/7za
/theme_updater/other/aapt
You must have installed openjdk
Windows.-
Version 1.0 - Initial release
Linux.-
Version 1.0 - Initial release
thanks Zeussn, it worked like a charm when i was using it yesterday

Custom clockworkmod compatible update.zip

Hello, I would like to create my own update.zip that would be compatible with clockwork mod. I have several files in several locations that I manually copy over after new installs like multicolored bash nano iwconfig iwlist etc. And I think it would be much easier to create a installable package for that, I also delete a number of built I. Apps like tweeter amazon etc. And I have seen the scripts inside oyhers update.zip's that I could add the bash commands to remove those things as well.unfortunately I know nothing about what clockworkmod wants and I see binarys inside these zips dont know if those are customized for each zip or the same in all of them, I dont know what files or information is absolutely required. The best possible solution is if I had a blank update.zip that held all of the required files settings and all I needed to do was add my files and asd a few lines to a preexisting script to remove sum stock apps.thinking back I might have seen a file containing all the files names and md5 chucksums for each as well which if necessary I can do. Is there something like this available for download sumwhere? If not ajy resources to learn the required information and find the required binarys.thank you in advance.
Sent from my Droid using Tapatalk
Hi,
I've been trying to learn the same thing. I'm curious if you found anything useful since posting this.
Of course, if I find anything, i'll post back here too.
Thanks.
Same problem here
Good to hear someone with same problems. I want to create a generic ROM for myself and I want to use ClockworkMod to help flash it instead of using fastboot.
Well, I have found no documentation about what ClockworkMod may need for a zip file.
But I guess it could be possible to just replace them with your own by downloading an existing zip file created by someone else.
I'll try it to see if that works or not. Of course, a documentation would be better.
I regularly flash a new CM7 Nightly as they are released and I have to manually modify some things each time a new rom is flashed. I change screen density and add a notification ringtone that CM7 does not have. I wanted to automate that. Since I have to reflash the Google Apps each time anyway, I thought why not modify the gapps zip to include my changes. After searching the web I found a little info about how to do it. I just modify the zip on my computer using WinRar, copy the file to my device and re-sign the package using signapktic which is free on the market. Then flash using CWM. It worked great. No more manual adjustments. There are some instructions here which helped me:
http://forum.cyanogenmod.com/topic/15030-moving-apps-to-system/
I been getting into the kitchen
http://forum.xda-developers.com/showthread.php?t=633246
So far i`ve managed to integrate a few apps , ringtone should be easy
next the fonts from utmost rom
thanks to the kitchen, Im now running at script kiddie level

AutoMod [Modding Tool] [Script] [Linux/OSX]

AutoMod BETA 1.6 by MAD Industries
-----------------------------------------------------------------------------------------------------------------------------------
First off, this is not another APK Manager, this is also not Auto APK Tool. These two tools focus on the decompiling and recompiling of APK and jar files. AutoMod intends to bring a new paradigm to modding. That is, there are mods and there are roms. AutoMod makes them friendly with eachother. APKs are handled internally by the script.
I wrote this tool because as a developer who was using APK Manager, I ran into several obstacles along the way. One of them was that I liked to be able to take requests from users and personalize the mod to their tastes. Unless I was impeccable with my folder organization, it very quickly got out of hand with people asking for personalizations based on other personalizations. I would find myself decompiling a version I made the day before so I could remember what was in it and create yet another version on top of it. All this back and forth and I would end up with a mess of recompiled, decompiled, original, custom, extracted, etc files all over the place taking unnecessary HD space. On top of that, every step of the way required user input in the form of a yes/no prompt or selected a menu option for decompiling/recompiling/keep folders/signing/etc. And then I would manually create a flashable zip file for each version. AutoMod solves many of this issues in it's current BETA state. When it is finished, it will have solved all of them.
Features for End-Users:
Mods are dynamically applied to your ROM (this allows mods to stay up-to-date with the ROM without original developer support)
Mods often work across multiple similar ROMs (easy porting)
Mods are stored in what I call "opensource" format which means it is very easy to dig into the Mod package and change things to your personal preferences with very little knowledge modding
Only the modified files within the apk are stored in a mod package. This greatly reduces filesize
AutoMod encourages backups at every major step in the process
Backups are dynamic, meaning it will only backup the files which are modified
Backups are automatically saved as a flashable zip file so you can have it ready if a mod does not successfully integrate
AutoMod always keeps itself up-to-date with the latest features
Distribution of AutoMod requires only the script itself
AutoMod has the ability to accept a ROM Install file or an actual device as a base for creating a flashable zip file out of any mod package
Supported devices can have mods applied instantly and automatically over adb
Features for Developers
Since mod packages only contain changed files, you no longer have to hunt through hundreds of files to find a single png (such as when creating five different colored versions of a theme)
Easy packaging of mods for redistribution for this tool as well as update.zip format
AutoMod can "install" multiple ROMs into it's system so you can make a mod once, and then distrubute it for several ROMs at the same time
If you run nightly builds of your own ROM, AutoMod will soon include a scriptable feature which will allow you to release nightly themes, mods, etc with no extra effort
Much of the developer features are yet to come (such as quick prototyping of mods and parallel device/ROM support)
---------------------------------------------------------------------------------------------------------------------------------------
Tutorial written by mybook4 on post #16 (be sure to thank him)
---------------------------------------------------------------------------------------------------------------------------------------
1) Download automod.sh script and place it into an appropriate directory (I used one called AutoModTest)
2) Download the ROM Install zips you would like
3) Create your mod package (see below)
4) Run automod by typing “bash automod.sh” in a terminal
5) Select option 5 (Install a new ROM file into AutoMod), and follow the script's directions (copying your ROM zip, to the directory, not moving it or it will be overridden)
6) Select option 4 (Install a new mod package into Automod), and follow the script's directions (copying your mod zip, to the directory, not moving it or it will be overridden)
7) Select option 3 (Use a ROM Install zip + mod to create a flashable zip for another ROM/device), choosing the appropriate ROM and mod package.
8) Out came the zip! This makes things soooooooooooo much easier and more manageable!
Notes about automod mod packages:
1) A mod file is structured as a zip file with the extension .zip replaced with .mod (so as to separate it from flashable zips with the same name)
2) In the mod file is a directory with the name of the mod.
3) In the directory with the name of the mod is a directory tree leading to the files within the specific apk you would like to modify. For example, in the ICSBlueFull.mod file, the directory tree is as follows: ICSBlueFull, system, app, SystemUI (the apk being modified), res, directories with modified files (images, xml files, etc).
4) Just to be safe (and to match the ICSBlueFull mod supplied), I set permissions on all folders in my mod to 755 and all files to 644 (if these numbers don't mean much to you, open a terminal and type “man chmod”)
5) There is a command to package mods you have made into .mod files. This can be found in the developer menu. (option 11)
6) Spaces in file name are currently not handled very well. Try and name your mods accordingly.
---------------------------------------------------
How To Create A Mod
click to enlarge
---------------------------------------------------
Download the script here: http://cl.ly/code/463B1C3B123i
Note: Proper syntax is 'bash automod.sh'
Download an example mod here (for stock GS3 touchwiz based ROMs) [Fixed!]: https://github.com/downloads/MADindustries/automod/ICSBlueFull.mod
Original thread for this mod can be found here: http://forum.xda-developers.com/showthread.php?t=1775235
View the source/branch it here: https://github.com/MADindustries/automod (check this to see if using a 'forceupdate' would add features/functions)
awesome work dude!
invisiblek said:
awesome work dude!
Click to expand...
Click to collapse
Thanks. Btw you are in the credits on the script itself. (even if it was a couple binaries haha)
Wow. Great work. Can't wait to see more!
Ta very much indeed.
ALQI
Sent from my SCH-I535 using xda app-developers app
Nice job buddy..No Windows support?
This is amazing. +100000000000
Sent from my SCH-I535 using xda app-developers app
incubus26jc said:
Nice job buddy..No Windows support?
Click to expand...
Click to collapse
Not just yet. I'm on Mac personally which makes it not too difficult to see some Linux support as well. But Windows would be a completely new write from what i can tell. It will likely happen after this is out of beta unless a Windows dev feels like working with me on it. Obviously everything is open source and i would love to see a port pop up before i get around to it.
Sent from my Galaxy Nexus using Tapatalk 2
Very cool indeed.
Tried to download the example mod but appears it's down/not available.
Definitely want to give this a try.
Thanks for sharing
MAD Industries said:
Not just yet. I'm on Mac personally which makes it not too difficult to see some Linux support as well. But Windows would be a completely new write from what i can tell. It will likely happen after this is out of beta unless a Windows dev feels like working with me on it. Obviously everything is open source and i would love to see a port pop up before i get around to it.
Sent from my Galaxy Nexus using Tapatalk 2
Click to expand...
Click to collapse
It might work on windows with the right install of cygwin. I'd have to create a windows VM to test it out and I'm not all that familiar with cygwin anymore, any windows devs out there good with cygwin?
Sent from my SCH-I535 using xda app-developers app
alquimista said:
It might work on windows with the right install of cygwin. I'd have to create a windows VM to test it out and I'm not all that familiar with cygwin anymore, any windows devs out there good with cygwin?
Sent from my SCH-I535 using xda app-developers app
Click to expand...
Click to collapse
Oh yeah! I totally forgot about cygwin. Yeah that should do it. It has all dependencies packaged with it except java and wget/curl. And only java is really necessary if you kinda know your way around.
Nice! Another great tool for the community!
Just what ive been waiting for
---------- Post added at 08:40 PM ---------- Previous post was at 08:32 PM ----------
Looks like running with cygwin gives unknown operating system. Can't proceed after that.
clark44 said:
Just what ive been waiting for
---------- Post added at 08:40 PM ---------- Previous post was at 08:32 PM ----------
Looks like running with cygwin gives unknown operating system. Can't proceed after that.
Click to expand...
Click to collapse
Oh yeah, that will have to be changed. run the command 'echo $(uname)' in a cygwin terminal and let me know what it outputs. I'm guessing just cygwin. Then i'll update the script to support it.
Any chance anyone has the example mod posted in the first post available on another hosting provider? It's been down for 2 days
myn said:
Any chance anyone has the example mod posted in the first post available on another hosting provider? It's been down for 2 days
Click to expand...
Click to collapse
Fixed it! Sorry about that. I don't know what happened with cloud.
Automod works great! Thanks so much! Here are the steps I took to create a quick little test mod to enable a 40x38px navigation bar and have only the wifi, bluetooth, gps, rotation, sync status bar toggles for Beans R8. I'm on Beans R3.1, so I didn't get a chance to test the zip in CWM.
1) Download automod.sh script and place it into an appropriate directory (I used one called AutoModTest)
2) Download the ROM Install zips you would like
3) Create your mod package (see below)
4) Run automod by typing “bash automod.sh” in a terminal
5) Select option 5 (Install a new ROM file into AutoMod), and follow the script's directions (copying your ROM zip, to the directory, not moving it or it will be overridden)
6) Select option 4 (Install a new mod package into Automod), and follow the script's directions (copying your ROM zip, to the directory, not moving it or it will be overridden)
7) Select option 3 (Use a ROM Install zip + mod to create a flashable zip for another ROM/device), choosing the appropriate ROM and mod package.
8) Out came the zip! This makes things soooooooooooo much easier and more manageable!
Notes about automod mod packages:
1) A mod file appears to be structured as a zip file with the extension .zip replaced with .mod
2) In the mod file is a directory with the name of the mod.
3) In the directory with the name of the mod is a directory tree leading to the files within the specific apk you would like to modify. For example, in the ICSBlueFull.mod file, the directory tree is as follows: ICSBlueFull, system, app, SystemUI (the apk being modified), res, directories with modified files (images, xml files, etc).
4) Just to be safe (and to match the ICSBlueFull mod supplied), I set permissions on all folders in my mod to 755 and all files to 644 (if these numbers don't mean much to you, open a terminal and type “man chmod”)
The 5StatusBarNavBar mod package for Beans R8
The CWM zip for the above mod package
MAD Industries said:
Oh yeah, that will have to be changed. run the command 'echo $(uname)' in a cygwin terminal and let me know what it outputs. I'm guessing just cygwin. Then i'll update the script to support it.
Click to expand...
Click to collapse
CYGWIN_NT-6.1-WOW64 (edit: uname -o will just return Cygwin)
Took a quick look at your script and I don't think it will too much of effort to offer cygwin support. Package manager by default will install bash, and curl/wget is available as well. You would need to install java naively on OS (it is accessible via your bash shell). Also to note don't think it will be required for your script based on my quick look, but you could always use the built in 'cygpath' command to convert windows<->unix paths if necessary.
Unfortunately only have a Windows box at work so can't spend to much time on but if no one gets to it I will take a stab later this week time permitting.
incubus26jc said:
Nice job buddy..No Windows support?
Click to expand...
Click to collapse
Linux is free and easy to dual boot. Nothing stopping you.
Or just run Linux from a VM. You can even forward the USB ports with Vitualbox.
mybook4 said:
Automod works great! Thanks so much! Here are the steps I took to create a quick little test mod to enable a 40x38px navigation bar and have only the wifi, bluetooth, gps, rotation, sync status bar toggles for Beans R8. I'm on Beans R3.1, so I didn't get a chance to test the zip in CWM.
1) Download automod.sh script and place it into an appropriate directory (I used one called AutoModTest)
2) Download the ROM Install zips you would like
3) Create your mod package (see below)
4) Run automod by typing “bash automod.sh” in a terminal
5) Select option 5 (Install a new ROM file into AutoMod), and follow the script's directions (copying your ROM zip, to the directory, not moving it or it will be overridden)
6) Select option 4 (Install a new mod package into Automod), and follow the script's directions (copying your ROM zip, to the directory, not moving it or it will be overridden)
7) Select option 3 (Use a ROM Install zip + mod to create a flashable zip for another ROM/device), choosing the appropriate ROM and mod package.
8) Out came the zip! This makes things soooooooooooo much easier and more manageable!
Notes about automod mod packages:
1) A mod file appears to be structured as a zip file with the extension .zip replaced with .mod
2) In the mod file is a directory with the name of the mod.
3) In the directory with the name of the mod is a directory tree leading to the files within the specific apk you would like to modify. For example, in the ICSBlueFull.mod file, the directory tree is as follows: ICSBlueFull, system, app, SystemUI (the apk being modified), res, directories with modified files (images, xml files, etc).
4) Just to be safe (and to match the ICSBlueFull mod supplied), I set permissions on all folders in my mod to 755 and all files to 644 (if these numbers don't mean much to you, open a terminal and type “man chmod”)
The 5StatusBarNavBar mod package for Beans R8
The CWM zip for the above mod package
Click to expand...
Click to collapse
Thank you so much for writing this! I am adding it to the OP. (let me know if you want me to take it down for some reason though)
Quick note, I think step 6 was supposed to be copy mod file to install directory? Also, a .mod file is exactly that; a zip file renamed to .mod. I did this to differentiate it from flashable zip files because the two would likely have the same name and it would cause confusion yet I still wanted to keep the .mod format easily modifiable/not proprietary. And one last thing, there is a hidden command called "packagemod" which can be used after you create your own mod to zip it up properly for distribution. It is entered at the main menu in place of choosing an option. Syntax: 'packagemod ICSBlueFull'.
lowg said:
CYGWIN_NT-6.1-WOW64 (edit: uname -o will just return Cygwin)
Took a quick look at your script and I don't think it will too much of effort to offer cygwin support. Package manager by default will install bash, and curl/wget is available as well. You would need to install java naively on OS (it is accessible via your bash shell). Also to note don't think it will be required for your script based on my quick look, but you could always use the built in 'cygpath' command to convert windows<->unix paths if necessary.
Unfortunately only have a Windows box at work so can't spend to much time on but if no one gets to it I will take a stab later this week time permitting.
Click to expand...
Click to collapse
Thanks for the tips. I have next to no experience with cygwin so this information is very helpful. I'll look into adding support to the next release.

[Request]Full tutorial to make flashable zip FROM SCRATCH

Hii devs,
I'm a budding developer. I've been trying to make a flashable zip since long time. Came across many tutorials, resources, apps, and a lot more! But none of them seemed to help me make a flashable zip from scratch.. All tutorials either provide a dummy (sample) zip or suggest an app or are incomplete.. But still I haven't been able to find a helpful resource..
My situation:
I made two directories: META-INF & data.
Wrote the updater-script
Added it in META-INF/com/google/android
Verified the syntax of updater-script, everything seemed fine.
Added the required stuff in the data directory.
Compressed the directories (both using normal "New Zip Archive" from Desktop as well as 7Zip).
Signed the zip.
[*]NOW COMES THE PROBLEM: THE update-binary
Tried a lot of resources to obtain the update-binary, took it from a cm nightly for my device, from a dummy zip (which I was able to flash successfully), downloaded it from a tutorial, used an app to make a flashable zip and took out the update-binary from it
BUT STILL NO LUCK
I always get an error in the TWRP recovery:
Code:
E: Error executing update-binary in xxx.zip
Even posted threads in XDA forums, but got replies suggesting me to use ZipMe app..
I humbly request you to provide me a full-fledged tutorial for making a flashable zip, or correct me if I'm going wrong in any step..

Categories

Resources