Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,812,386 Members 38,394 Now Online
XDA Developers Android and Mobile Development Forum

[SCRIPTS] ROM, kernel, anykernel updater and Environment-setup scripts

Tip us?
 
laufersteppenwolf
Old
(Last edited by laufersteppenwolf; 11th May 2014 at 01:48 PM.) Reason: Update_kernel
#1  
laufersteppenwolf's Avatar
Forum Moderator / Recognized Developer - OP
Thanks Meter 5,225
Posts: 2,489
Join Date: Jul 2012
Location: Baden-Württemberg

 
DONATE TO ME
Default [SCRIPTS] ROM, kernel, anykernel updater and Environment-setup scripts

Hey guys

I've been working on some scripts to automate my work for quite some time now and thought, why not share it?
So that's what I'm gonna do now

For now, we have three scripts: one to build a ROM, one to compile a kernel, to make an anykernel updater zip and to set up and entire build environment on Arch and Ubuntu-based distros (2nd post). The kernel and anykernel scripts, however, are linked, which means the kernel script automatically executes the anykernel script so as soon as you compile a kernel, you get a recovery flashable zip.

A small note: These scripts were made for the LG Optimus 4x HD, but can easily be modified for any other device.

So, you may ask yourself now 'nice, but what do these script do exactly?' well, that's what I'm gonna tell you now



ROM

The ROM build script can be found HERE
This script is made for CM 11, but can be easily modded to be used with other ROMs. I will also add some more scripts to support more ROMs in the future.

In order to make it compatible with your machine and your device, we have several configurable parameters in the beginning of the script:
Code:
# Configurable parameters
ccache_dir=/home/laufersteppenwolf/ccache/CM11
ccache_log=/home/laufersteppenwolf/ccache/CM11/ccache.log
jobs_sync=30
jobs_build=20
rom=cm
rom_version=11
device_codename=p880
If you want to use a special ccache dir, you can define it using the first parameter. Same for ccache's log.
The "jobs_sync" variable defines how many jobs will be running at the same time while running "repo sync" (---> the -j value)
The "jobs_build" variable defines how many jobs will be used for the make command
"rom" defines the ROM you are trying to compile (used in the lunch command, but also for the zip upload command)
"rom_version" defines the version of the ROM. You can change it to 10.2 or any other version depending on the CM version you are compiling.
Last but not least, the devices codename. In my case it's "p880", but you can just change it to your device (mako, hammerhead, maguro,...) and the lunch as well as the upload command will be changed to your device.

About the upload, if you have a goo.im account and also configured it in your ssh_config, you can just leave it the way it is. However, if you use a different file hoster, please edit the last command to your needs

Furthermore, we have some more features. These, however, don't need to be defined inside the script, but added to the execution command.
You can execute the script with the command:
Code:
. build.sh [-h -n -r -c -ncc -d -j #]
But what do these flags do?
Code:
-h   | --help
shows a help message and exits the script

Code:
-n   | --nosync
skips the "repo sync" command

Code:
-r   | --release
uploads the build when it's done

Code:
-c   | --clean
executes "make clean" instead of "make installclean"

Code:
-ncc | --no_ccache
disables ccache

Code:
-d   | --debug
shows some debug stuff (not really needed for the "normal" user )

Code:
-j #
sets a custom number of jobs for the "make" command


Example:
Code:
. build.sh -c -r
This command syncs the repos, executes "make clean" instead of "make installclean" and uploads the build to the defined file hoster as soon as the build is done.



Kernel

The kernel build script can be found HERE
This script is made for the p880 (aka x3), but can be easily modded to work with your device.

We have 2 configurable parameters in the beginning of the script:
Code:
defconfig=cyanogenmod_x3_defconfig
jobs=32
"defconfig" defines the name of your defconfig to be used
And "jobs" defines the -j value to be used for make

All modules are being copied to ./out/modules/ and the zImage is being copied to ./out/zImage. Which means no more searching for modules inside the various folders, but having everything in one place

If you take a look into the script, the created out dir is after the above command copied to "~/smb/kernel/out". This is where my network drive is mounted. Please change it to a path of your choice.
This folder now needs to have the files from the anykernel folder inside, because the anykernel build script is being executed next. What this script exactly does will be explained later.
When the anykernel updater zip is done, the script cd's back to the place it was initially executed and will then be done.

If you don't want to make an anykernel zip, just remove the commands after
Code:
find -name '*.ko' | xargs -I {} cp {} ./out/modules/
(well, maybe except for the commands that tell you the script it done )



Anykernel updater zip

Wanna know what an anykernel updater zip is?
 
The anykernel updater zip only replaces the actual kernel (zImage) and not the whole boot.img. This means the ramdisk stays the same, which makes the kernel compatible with every ROM and Android version.


The script and it's needed tools can be found HERE

This script creates an anykernel updater zip from a given zImage and modules. The zImage has to be in the same folder as the script itself. The modules have to be in a folder called "modules", which also should be located in the same folder as the script. In the beginning of the script, you can define the name of the zip:
Code:
zipname="WWJB_v009_anykernel.zip"
IMPORTANT:
Please make sure to edit the updater-script so it is compatible with your device! Otherwise you can (hard) brick your device!
I am not responsible for possibly bricked devices!


Another feature of the anykernel updater is, you can mod the ramdisk while flashing (repacking the boot.img). This can be done inside THIS file. By default it creates an unsecured boot image. But you can edit way, way more using this method. For an example what can be done, you might wanna take a look at THIS file

The signapk.jar and the sign keys were taken from the latest CM11 sources.


You have a question, suggestion, bug report? Please feel free to leave a reply in this thread



Many thanks go to @GermainZ and @doixanh for helping me fighting with bash
Thanks also go to Koush, for "inventing" the anykernel updater
Sony Ericsson Xperia X8: GingerDX v31b ; alfs CM7 v09c
LG Optimus 4x HD: my own version of CM 10.1 , CWM recovery, UNlocked BL

Crying that it's an application bug is like crying over the speed of light: you should deal with reality, not what you wish reality was. - Linus Torvalds
The Following 40 Users Say Thank You to laufersteppenwolf For This Useful Post: [ Click to Expand ]
 
laufersteppenwolf
Old
(Last edited by laufersteppenwolf; 11th May 2014 at 04:00 PM.)
#2  
laufersteppenwolf's Avatar
Forum Moderator / Recognized Developer - OP
Thanks Meter 5,225
Posts: 2,489
Join Date: Jul 2012
Location: Baden-Württemberg

 
DONATE TO ME
Default Environment setup script

Who is bored of setting up an entire build environment for Android? I certainly am, which is why I wrote this "tiny" script

This script sets up a complete build environment, so you can directly start to repo sync a ROM after the script is done. And the best thing is, it is extremely customizable without even having to edit the script itself. All done by appending the appropriate flags to the executing command.
A further big advantage of this script is, that it is compatible with the two most common Linux distros Arch Linux and Ubuntu (also including all distros that are based on these 2, like Xubuntu, Lubuntu,....). This compatibility is achieved by detecting the distro in the beginning of the script and then using the appropriate commands (apt-get or pacman).

The script is located HERE and called "setup.sh"

To run the script, cd to the folder the script is located and enter ". setup.sh" and append all desired flags. If you need help, just append the "-h" or "--help" flag and some help will be shown.

So, you may ask yourself now "That's nice, but what the hell does this script install/set up?" and the answer is quite simple: All you need, and (if desired) even more

The "base package" includes:
  • Ccache
  • Java
  • GIT
  • All needed build tools
  • Python 2
  • The Android SDK

Furthermore, you can also choose the "extended package" by appending the flag "-e" or "--extended", which includes:
  • SSH
  • iostat
  • bmon
  • htop
  • geany
  • The dev-host commandline tool by GermainZ
  • udev-rules (on Arch only)

If this still isn't enough for you, you can also add your own packages. This can be done by either editing the script and entering the packages inside the quotes of the following line:
Code:
extra=""			# Add here some extra packages to install
OR
by appending the flag "-s" or "--special" and then listing the packages within quotes, seperated by spaces.
Example:
Code:
. setup.sh -s "package1 package2 package3"

This script is made to perform all actions on its own, however, it will not do so by default. To have it automated, you need to append either "-a" or "--automated". The script will then install the "base package" with all default packages (such as Oracle's JDK 6).
But you can still also append the other flags, like "-e", "-s", "-j",...


Now, let's talk about Java. This script can install 3 Java versions: Oracle's JDK 6, openJDK 6 and openJDK 7. The default version is Oracle's JDK 6. You can change the version by either appending the "-j" or "--java" flag followed by the desired version (1, 2 or 3), or if the -a flag isn't triggered, the script will ask you about it.


What? You don't want to install/change java at all? No problem! Just append "--no-java" and Java will get completely skipped.
The same thing also happens to the SDK when appending "--no-sdk".



The script has been tested on (X)ubuntu 13.10 and 14.04 by @nilse and me, and on Arch Linux by @SMillerNL and me. However, I have only tested Oracle's JDK 6, no other java versions but according to the wiki pages, it should work just fine

You have suggestions, feedback, improvements? Shoot! Just let me know and I'll do my best to include it

A big thanks goes to my testers @nilse and @SMillerNL who also made some nice suggestions. But also to @GermainZ for his dev-host commandline tool
Furthermore to @eagleeyetom for giving me the idea
Sony Ericsson Xperia X8: GingerDX v31b ; alfs CM7 v09c
LG Optimus 4x HD: my own version of CM 10.1 , CWM recovery, UNlocked BL

Crying that it's an application bug is like crying over the speed of light: you should deal with reality, not what you wish reality was. - Linus Torvalds
The Following 15 Users Say Thank You to laufersteppenwolf For This Useful Post: [ Click to Expand ]
 
gerciolisz
Old
#3  
Senior Member
Thanks Meter 183
Posts: 526
Join Date: Feb 2013
Thanks awesome work it will be helpfull i was looking for such thing yesterday XD you're best @laufersteppenwolf
 
xboxfanj
Old
#4  
xboxfanj's Avatar
Recognized Developer
Thanks Meter 6,449
Posts: 6,967
Join Date: Apr 2011
Location: Saint Louis, Mizzou

 
DONATE TO ME
The anykernel script doesn't work on newer devices with zImage-dtb right?

Doesn't look like it based on the script, but I've had trouble with the M8 DTB so figured I'd ask.


If you need help with anything or just wanna chat, feel free to GTalk me at xboxlover360@gmail.com or PM me

 
laufersteppenwolf
Old
#7  
laufersteppenwolf's Avatar
Forum Moderator / Recognized Developer - OP
Thanks Meter 5,225
Posts: 2,489
Join Date: Jul 2012
Location: Baden-Württemberg

 
DONATE TO ME
Quote:
Originally Posted by xboxfanj View Post
The anykernel script doesn't work on newer devices with zImage-dtb right?

Doesn't look like it based on the script, but I've had trouble with the M8 DTB so figured I'd ask.
To be honest, I have no idea
I have only tested it on the 4x HD myself, but if you use all the same commands as the the ROM build process does (maybe also grab the needed files) it should work. I mean, it does exactly the same thing as when the ROM build packs the boot image, it puts the zImage and ramdisk into one file. Only anykernel does this on the device itself, rather than on your PC.

If you want, we can take a look into it together

Quote:
Originally Posted by Marília de Oliveira View Post
Fits ics?
Sure, should work with all ROMs, just edit some stuff (like rom_version=11 to rom_version=9 when compiling CM) and it should work just fine
Sony Ericsson Xperia X8: GingerDX v31b ; alfs CM7 v09c
LG Optimus 4x HD: my own version of CM 10.1 , CWM recovery, UNlocked BL

Crying that it's an application bug is like crying over the speed of light: you should deal with reality, not what you wish reality was. - Linus Torvalds
 
Marília de Oliveira
Old
#8  
Marília de Oliveira's Avatar
Senior Member
Thanks Meter 353
Posts: 501
Join Date: Nov 2012
Location: City of God / City of Sun *-*

 
DONATE TO ME
Quote:
Originally Posted by laufersteppenwolf View Post
To be honest, I have no idea
I have only tested it on the 4x HD myself, but if you use all the same commands as the the ROM build process does (maybe also grab the needed files) it should work. I mean, it does exactly the same thing as when the ROM build packs the boot image, it puts the zImage and ramdisk into one file. Only anykernel does this on the device itself, rather than on your PC.

If you want, we can take a look into it together



Sure, should work with all ROMs, just edit some stuff (like rom_version=11 to rom_version=9 when compiling CM) and it should work just fine
How do I edit? Can you explain me better .. Thanks
 
sgt. meow
Old
#9  
sgt. meow's Avatar
Recognized Contributor
Thanks Meter 2,787
Posts: 4,339
Join Date: Dec 2011
Location: Dhaka
Thanks a lot @lauferstppenwolf
Really takes the stress out of executing commands during my kernel compiles.
 

https://www.dropbox.com/s/ho7noezbf3ph0l6/CrossMiranda.png
R.I.P. Miranda Nicole
An innocent soul, who deserved to live a lot longer. We all miss you.

R.I.P Alif Shahriar
A true friend, no longer here in this world, but always there in our hearts. We sorely miss you.


Owner and creator of Oxydo kernels for Nexus 7 2012 (Grouper/Tilapia) and Xperia X8 (Shakira)
Maintainer of AOSPAL for Nexus 7 2012 (Grouper).


My blog: http://alltheengsawesumz.blogspot.com/
Circle or chat: https://plus.google.com/+FayadChowdhury
 
gerciolisz
Old
(Last edited by gerciolisz; 25th April 2014 at 10:21 PM.)
#10  
Senior Member
Thanks Meter 183
Posts: 526
Join Date: Feb 2013
Quote:
Originally Posted by Marília de Oliveira View Post
How do I edit? Can you explain me better .. Thanks
open in notepad or gedit or whatever and edit what u want

BTW does -j number of jobs should be for example "-j6" or "-j 6"?

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes