[Guide] Making Mod Pack for a ROM - Miscellaneous Android Development

its about making patch modpack for my rom and
making update script full...
So,Let's start...
________________________________________
________________________________________
How to make modpack or patch...
Frist make sure that what you want to add on your
rom..like i want to add my modded
systemui,framwork_res,some importent app,some
brinery like su,mkbootimg,some wallpaper,new
ringtone,boot logo,boot animation and some app
with data...
ok now i explain you somethings which are very
very important...
frist in a modpack this folders are added..like>>>
1.Meta_inf
2.data
3.sdcard
4.system...etc etc...
you will also see more folder or file but now i will
tell you about this folders ^^^...
1.Meta_inf...
i think everybody know this folder...i give a short
example...
in this folder you will found update script and
update brinary...
[Q]what is update script?
[Ans.] updater-script - it is just a text file which
contains all the commands which tells the
clockworkmod what to do with the given
zip file. the updater-script is written in the edify
scripting language.
[Q]what is update brinary?
[ans] update-binary - it is a binary which is
requiered by the clockworkmod to translate the
human readable format of the updater-
script to machine readable format for execution
of the updater-script in our device.
now i think you would understand what is update
script and brinary...
ok now 2.Data folder...in data folder you can add
some app with data...fir this what you need?!!
Frist install your app on your mobile and mod
it...like i want to add Xposed installer with
frimwere updated in my modpack...so frist i
installed the app and open it..then click on install/
update...then reboot my device...now my modding
was complete...now its time to add it with data...
.
so i made a folder on sdcard like (modpack for my
rom) then open it and made another folder name
(data) then in data folder i made two folders like
(app) and (data)
then i opened root explorer and went to root
derectory...then go to data...then go to app folder
and choosed my app thats mean xposed...then
copied it to sdcard/modpack/data/app and again
go to root derectory/data...this time i go to data
folder and find my apps data.then copy it to
sdcard/modpack/data/data...thats all...
This is an example...now you can add you app
with data like i had added...but i recommend you
that dont add more then 4 apps with data...
ok now 3.sdcard...
by this folder you can add anythings to your
sdcard...like i want to add some themes of mi
home luncher and all kernel,profile of viper 4
fx...frist made (sdcard)folder on your sdcard/
modpack...now copy all things from your sdcard
which you want to add..like i copied viper4fx
folder from my sdcard and paste it to sdcard/
modpack/sdcard...you can add themes in this way
too...just copied the themes with the whole
derctory in your sdcard/modpack/sdcard
folder...like i copied miui folder to my sdcard/
modpack/sdcard folder...beacuse all themes of
miui are in miui folder...
now comes 4.System folder.. so make a folder
(system) on your sdcard/modpack...then open
system folder and made some folder like
app,etc,lib,bin,xbin etc if you want to add
somethings on your roms system folder..i think
every body know this folder...if you want to add
your modded app,just sing it and drop it to...
Now full completed...you can see some extra
folders and files...if you want to add these to then
comment here i will told you how add these
folder...or you can pm me too
________________________________________
now its time to make update script for your
modpack..
...........
frist copy a meta_inf to your sdcard/modpack and
open update script...delect all things...
you can edit this line as your wish>>>
ui_print(“xolo – next level”);
now see what is ui print?
ui_print – This command prints the prints the
word inside the quotations
Example – ui_print(“xolo – next level”); prints
xolo next level in your cwm recovery
______________________
then you need to mount system partition...and
also another pertition like data,etc (if you want
to add anythings to this folderd)...but no need to
mount sdcard...For mount system-
mount(“ext4″, “EMMC”, “/
dev/block/mmcblk0p5″, “/system”);
if you want to mount data folder then write data
insted of system like-
mount(“ext4″, “EMMC”, “/
dev/block/mmcblk0p5″, “/data”);
okey...done mounting...
Now see what is mount?
mount – This command mounts the partition, if
you want to add files to system partition you
have to mount system partition, data for data
partition
To mount system - mount(“ext4″, “EMMC”, “/
dev/block/mmcblk0p5″, “/system”);
Here mmcblk0p5 is the name of system
partition for mtk 6589 chipsets (this name
varies from device to device)
To mount data - mount(“ext4″, “EMMC”, “/dev/
block/mmcblk0p7″, “/data”); (partition name
varies from device to device)
_____________________
Now formating...what is format>
format - This command formats the partition
specified
It is highly recommended to include this
command to format system and data if you are
making updater-script for ROM
To Format system - format(“ext4″, “EMMC”, “/
dev/block/mmcblk0p5″, “0″);(partition name
varies from device to device)
To Format data - format(“ext4″, “EMMC”, “/
dev/block/mmcblk0p7″, “0″);(partition name
varies from device to device)
NB.dont use it in your modpacks script its for
custom rom....
_______________________
Now you done mounting and its time to install all
things in all folder thats mean extracting...like
sustem folder will extract in your system
pertition...data folder will be in data pertition
and sdcard folder in your sdcard...for extract
system files use this command>>>
package_extract_file(”system“,”/system”)
for data>>> just delect system and add data like.
package_extract_file(”data“,”/data”)
for sdcard do same...
Now what is this>>>
package_extract_dir(” “, “/”) – This command
extracts all the files from the folder mentioned
inside first quotation to the partition or
directory
inside second quotation
For system - package_extract_dir(“system”, “/
system”);
(this copies all files from system folder in zip to
system partition in phone)
For data - package_extract_dir(“data”, “/
data”);
____________________
Ok now symlink...
symlink("mksh", "/system/bin/sh");
the above command creates a symlink.
okay, now let's see about symlinks,
symlink is nothing but shortcuts, for example if
a file is requiered in two different places instead
of copy pasting the file
in two different locations, the file is copied to
one of the two locations and in the other
location a shortcut to the file(symlink)
is created. the source and the symlink can have
different names (actually this is the prime use
of symlinks).
to explain in a noob friendly manner,
take the above symlink, it creates a shortcut
(symlink) for the command "mksh" and places
it in the path of the operating system.
the shortcut(symlink) directs to the file "/
system/bin/sh" , so whenever the os gets a
request to execute the "mksh" command, the
actual
binary that gets excuted will be "/system/bin/
sh" .
creating symlinks saves a lot of space because
instead of copying the whole file and placing it
in requiered places we are just
creating shortcuts which directs to the source
file which can be placed anywhere in the file
system (generally placed in the path of the os)
i think you understood...if you not then dont
use...its just use then when you want to add
somethings on system/bin folder and its for
advance user..
______________________
ok now seting permission..its not need if you
wont want anything in system/bin...but if add
then you must need add permission for this gile
and seting petmission are really too much easy
and so funny just see what is it and how to
set>>>
set_perm_recursive - This command sets
permission for folders
here android uses unix permission system
in unix
4 – read
2 – write
1 – execute
so
rwx is 4+2+1 = 7
rw is 4+2 = 6
rx is 4+1 = 5
Example - set_perm_recursive(0, 0, 0755,
0644, “/system”);
In this 0 is a user id for owner that refers to
root. It means that permission owner for
system folder. and 0 is root user means it
unrestricted access to system. it is given in
order to run programs to run properly
second 0 also refers to root. but here it refers
to group id 0
we are only seeing about folders because
“set_perm_recursive” is a command that sets
permission to folders
next 0755 it means rwxr-xr-x permission has
been given to system folder and rw-r-r is set
for all folders inside system folder
hope you understan...
___________________
Now another things...and its use in seting
permissions to but its defferent just see>>>
set_perm – This command sets permission for
a specific file
Example - set_perm(1000, 1000, 0640, “/
system/etc/bluetooth/auto_pairing.conf”);
here the 1000 refers to user id system and
0640 is rw-r—–
and this command sets the permission rw-r—–
for the file auto_pairing.conf
this is use for one files auto_praing.conf
__________________
Now you need to unmount these folder which you
mounted...see it>>>
unmount – This command unmounts the
partition
Example - unmount(“/system”); – unmounts
system...you need to unmount another folder
too..like for unmount data>>>
unmount(“/data”);
___________________
ok guys all done...i hope you understood all that i
have told...if you not then ignore it...and now try
to make a script for your modpack...
____________________
now give you a short example of my modpack and
update script...
...................
in my modpack i have these folders>>>
1.meta_inf,
2.data,
3.sdcard,
4.system,
.....now have a look in my script >>>
ui_print("====================
===============");
ui_print("Installing cayno x v2 modpack for all
cayno x users");
ui_print(" ");
ui_print(" By: MD.Shafikul main dev of cayno x ");
ui_print("====================
===============");
ui_print("");
ui_print("mounting system");
show_progress(0.500000, 0);
mount("ext4", "EMMC", "/dev/block/mmcblk0p5", "/
system");
ui_print("mounting data");
mount("ext4", "EMMC", "/dev/block/mmcblk0p5", "/
data");
show_progress(0.200000, 0);
ui_print("[ ] Installing all files");
package_extract_dir("system", "/system");
show_progress(0.200000, 0);
package_extract_dir("data", "/data");
ui_print("installing themes ");
package_extract_dir("sdcard", "/sdcard");
set_perm(0, 1000, 0755, "/system/xbin/busybox");
symlink("/system/xbin/busybox", "/system/bin/
busybox");
ui_print("letast busybox installed");
run_program("/system/xbin/busybox", "--install", "-
s", "/system/xbin");
ui_print("installing abrouted!");
show_progress(0.500000, 0);
set_perm(0, 0, 06755, "/system/xbin/su");
symlink("/system/xbin/su", "/system/bin/su");
set_perm_recursive(0, 0, 0777, 0777, "/system/etc/
init.d");
ui_print("init.d activated!");
ui_print("jocking man... ");
show_progress(0.200000, 0);
unmount("/system");
ui_print("[*] unmount system succeced! ");
unmount("/data");
ui_print("[*] unmount dataoo succeced! ");
unmount("/sdcard");
ui_print("");
ui_print(" Thanks for downloading cayno x ");
ui_print(" Auto rebooting ");
sleep(2);
ui_print(" Please wait... ");
sleep(2);
run_program("/sbin/sleep", "5");
run_program("/sbin/reboot");
^^^^^thats all that i wrote
_______________________________________
NB.(must read)>>>1.General rule in updater-script
– all commands
should end with semi colon ; otherwise it
will show error and if cwm or twrp shows status
7 error the error is in updater-script
2.if you dont understand then ignore beacuse its
can bootlooped...
3.if felt in installing zip then pm me pr comment
here or give me your script i will try my best to
correct it...
4.if the post help you,then give me some
respect...please..
5.dont forget to click on like botton its can
inspared me to write more post...
6.if you copy these post then give me credit,if
you not then i will understood that you are a
busted...
7.and never stop customization
Credit goes to my friend Md. Shafiqul for writting this..
HIT A THANKS IF I HAVE HELPED YOU

Related

[Resolved] [GUIDE][CWM][GPS]["GPS off-and-on" bug] without root

Hello
I use dungphp's Pyramid HTC WWE 1.35.401.1 - Real 3D [V2.2][RAF 1.9GB] ROM and was not able to change gps.conf with ES Explorer (missing root).
I will share what i've done to solve this problem for me:
1. Downloading Fix Flash player with video streaming from here
2. extracting the ZIP file
3. delete folders: sd-ext and system
4. create folders: system/etc and etc
5. create your own gps.conf.
Mine is:
NTP_SERVER=europe.pool.ntp.org
XTRA_SERVER_1=http://xtra1.gpsonextra.net/xtra.bin
XTRA_SERVER_2=http://xtra2.gpsonextra.net/xtra.bin
XTRA_SERVER_3=http://xtra3.gpsonextra.net/xtra.bin
SUPL_HOST=supl.google.com
SUPL_PORT=7276
GPS1_CLEANUP_ENABLED=0
Click to expand...
Click to collapse
6. copy gps.conf to the folders: etc and system/etc
7. edit the file: META-INF\com\google\android\updater-script
Should look like this:
ui_print("------------------------------------------------");
ui_print(" UPDATE anythings to the builds ");
ui_print(" From DUNGPHP ");
ui_print("------------------------------------------------");
show_progress(0.500000, 0);
mount("MTD", "system", "/system");
mount("MTD", "etc", "/etc");
delete("/system/etc/gps.conf");
delete("/etc/gps.conf");
package_extract_dir("system","/system");
package_extract_dir("etc","/etc");
set_perm(1000, 1000, 0644, "/system/etc/gps.conf");
set_perm(1000, 1000, 0644, "/etc/gps.conf");
show_progress(0.000000, 0);
unmount("/system");
unmount("/etc");
ui_print("All done !");
Click to expand...
Click to collapse
8. Pack the folders META-INF, etc and system to a zip file (Fix_gps_conf.zip)
9. Copy this zip-file to your sd-card
10. Shut down your device and start CWM
11. Choose Install zip file from SD card and choose your zip
12. When done, reboot

[Q] set_perm_recursive to set_perm question

I've been searching for a guide to help me understand the syntax set_perm and set_perm_recursive, but can not find anything from googling these terms and explanations of how to use them and what values to use for a particular permission...
What I'm trying to do is create a flashable zip with apks ( some stored in the /system/app & some in the /data/app ), and with the updater-script file I've cut it down to the necessity syntaxs but having problems with the above syntax... I see that I can set permissions to all files within the /system/app folder ( using set_perm_recursive(0, 0, 0755, 0644, "/system/app"); syntax ), however I don't want/need to set all the file permissions in /system/app folder that have already been set from the initial rom flash, so using set_perm(x, x, x, "/path"); syntax instead I want to set each file I flash into the /system/app folder ( from the flashable zip ) individually to the exact same permissions as set_perm_recursive I pasted above... So, can I just remove the _recursive & 0644, parts of the syntax so that it looks like this set_perm(0, 0, 0755, "/system/app/xxx.apk"); for each individual file permission?
Much appreciate the response and hope you all understand what I'm trying to achieve, cuz I was kinda confused a little when writing this!
Cheers all
trueno2k said:
I've been searching for a guide to help me understand the syntax set_perm and set_perm_recursive, but can not find anything from googling these terms and explanations of how to use them and what values to use for a particular permission...
What I'm trying to do is create a flashable zip with apks ( some stored in the /system/app & some in the /data/app ), and with the updater-script file I've cut it down to the necessity syntaxs but having problems with the above syntax... I see that I can set permissions to all files within the /system/app folder ( using set_perm_recursive(0, 0, 0755, 0644, "/system/app"); syntax ), however I don't want/need to set all the file permissions in /system/app folder that have already been set from the initial rom flash, so using set_perm(x, x, x, "/path"); syntax instead I want to set each file I flash into the /system/app folder ( from the flashable zip ) individually to the exact same permissions as set_perm_recursive I pasted above... So, can I just remove the _recursive & 0644, parts of the syntax so that it looks like this set_perm(0, 0, 0755, "/system/app/xxx.apk"); for each individual file permission?
Much appreciate the response and hope you all understand what I'm trying to achieve, cuz I was kinda confused a little when writing this!
Cheers all
Click to expand...
Click to collapse
Don't know if you're still requiring this, but you can take a look at this:
Function Name: set_perm
Function Syntax: set_perm(uid, gid, mode, file1, file2, ..., fileN)
Parameter Details:
uid = user id
gid = group id
mode = permission mode
fileX = file to set permission on
These 4 attributes are necessary, hope it helps!
more insight
Function Name: set_perm_recursive
Function Syntax: set_perm_recursive(uid, gid, dirmode, filemode, dir1, dir2, ...dirN)
Parameter Details:
uid = user id
gid = group id
dirmode = permission to set to directories contained within the specified directory
filemode = permission to set to files contained within the specified directory
dirX = directory to set permission on
Action: Set permissions of a directory or set of directories and all files and folders within them. At least one directory must be specified (The first 5 parameters are required)
hope it helps and know that sure as hell it did help me, cheers

[Tutorial] Edify Scripts,Making Flashable Zips

This is a WIP.
Edify Scripting Commands
I came across the problem of creating flash-able ZIP files and Edify scripting and in the interests of sharing and helping this great community I would like to share what I have found and hopefully learn more through discussion, I certainly am no expert and am always willing to learn.
So I would like to try and put together a guide to Edify scripting commands and what their function is. I hope we can all collaborate to make this a helpful source of information to all budding devs...we all have to start somewhere right!?
***Please, if there are any mistakes in this post or if you can help by adding further info please post below, thanks***
If any of you have ever flashed a zip,ROM you most probably see things written on the recovery screen like wiping data,wiping cache or CM10 by so and so.You ever wonder how these things are written??
Well the answer is in Edify script.So all those of you who wanna learn how to do all that have to learn the commands used in Edify scripting.
Interested???
Ok lets begin...
Print text in the recovery during flashing process:
Code:
ui_print("Your text here");
Code:
ui_print(" ");
This simply prints a line of text in the recovery, it has no actual effect on the flashing process, if you want a blank line just leave a blank space as the second example.
Controlling the progress bar:
I believe I understand this correctly, if not please do post below with further clarification.
Code:
show_progress(0.000000, 0);
or
Code:
set_progress(0.000000);
You have two choices when controlling the progress bar, the first example allows you to define fractions of the progress bar and how long they will take to fill. The second example just allows you to specify that the bar fills to a certain fraction at whatever point during the flashing process.
The command is defined as:
set_progress(progress bar fraction, duration in seconds to fill defined fraction);
Click to expand...
Click to collapse
For example the following code lines interspersed with your other commands would fill a fifth of the progress bar every five seconds:
Code:
show_progress(0.200000, 5);
ui_print(" ");
show_progress(0.200000, 5);
ui_print(" ");
show_progress(0.200000, 5);
ui_print(" ");
show_progress(0.200000, 5);
ui_print(" ");
show_progress(0.200000, 5);
This process will only complete if the script takes long enough to flash, therefore you need to be aware of what you are actually flashing and how long it will take when defining these values.
If you wish to just define a fraction without fill without a time scale you can use the following command:
Code:
set_progress(0.000000);
It is also best practice to include this element in your scripts as it will reassure people that their handset hasn't frozen during a flash.
Mounting/Unmounting a partition:
This has to be dealt with care as without mounting the required partition you can't do any modification.
To mount a partition you need to use the following syntax:
mount("filesystem-type", "partition-type", "device-specific-location", "mount-point");
filesystem-type: "ext3" or "yaffs2" (edison is ext4)
partition-type: "EMMC" or "MTD" (edison is EMMC)
location: Device specific address(eg. system is /dev/block/mmcblk1p21 )
mount-point: the partition you want to mount (eg./system etc)
Click to expand...
Click to collapse
Example command would be:
Code:
mount("ext3", "EMMC", "/dev/block/mmcblk1p21", "/system");
To unmount a partition you need to input the following command:
Code:
unmount("/system");
Obviously replace the mount partition with whatever partition you are working in.
Format a partition:
To format a partition you need to use the following syntax:
format("filesystem-type", "partition-type", "device-specific-location", "0");
Click to expand...
Click to collapse
Example:
format("ext3", "EMMC", "/dev/block/mmcblk1p21", "0");
Some scripts include the "0" and some do not, not sure exactly on the function difference when included or not, again clarification would be great.
Flashing the contents of your ZIP file:
To flash an entire directory i.e. to copy the contents of the entire directory from your zip into the respective folders in ROM:
Code:
package_extract_dir("system", "/system");
To flash a single file:
Code:
package_extract_file("youtube.apk", "/data");
These commands are structured as follows:
Entire directory:
package_extract_dir ("zipfileSource", "destination-partition");
Click to expand...
Click to collapse
Single File:
package_extract_file ("file", "device-specific-mountpoint");
Click to expand...
Click to collapse
Deleting folders & files:
You can delete multiple folders or files using just one command, as follows:
To delete files:
Code:
delete("file-path-1", "file-path-2", "file-path-3);
To delete folders/directories:
Code:
delete_recursive("directory-path-1", "directory-path-2", "directory-path-3");
Setting Permissions
Here are the basics for setting permissions.
If you want to research the reasons behind this, there is some useful information on Linux permissions here: chmod wiki,
Set permissions of a file or set of files:
set_perm(uid, gid, mode, "filepath1", "filepath2")
uid - user id
gid - group id
mode - permission mode
filepath... - file to set permission on
Click to expand...
Click to collapse
Example:
Code:
set_perm(0, 0, 06755, "/system/xbin/su");
Set permissions of a directory or set of directories and all files and folders within them:
set_perm_recursive(uid, gid, dirmode, filemode, "dirpath1", "dirpath2")
uid - user id
gid - group id
dirmode - permission to set to directories contained within the specified directory
filemode - permission to set to files contained within the specified directory
dirpath... - directory to set permission on
Click to expand...
Click to collapse
Example:
Code:
set_perm_recursive(0, 0, 0755, 0644, "/system");
Permissions syntax explained...so I can understand it lol (if I do then anyone can!):
The following are the pre-defined Android UID's & GID's. Taken from the following link: Android UIDs and GIDs
AID_ROOT 0 /* traditional unix root user */
AID_SYSTEM 1000 /* system server */
AID_RADIO 1001 /* telephony subsystem, RIL */
AID_BLUETOOTH 1002 /* bluetooth subsystem */
AID_GRAPHICS 1003 /* graphics devices */
AID_INPUT 1004 /* input devices */
AID_AUDIO 1005 /* audio devices */
AID_CAMERA 1006 /* camera devices */
AID_LOG 1007 /* log devices */
AID_COMPASS 1008 /* compass device */
AID_MOUNT 1009 /* mountd socket */
AID_WIFI 1010 /* wifi subsystem */
AID_ADB 1011 /* android debug bridge (adbd) */
AID_INSTALL 1012 /* group for installing packages */
AID_MEDIA 1013 /* mediaserver process */
AID_DHCP 1014 /* dhcp client */
AID_SHELL 2000 /* adb and debug shell user */
AID_CACHE 2001 /* cache access */
AID_DIAG 2002 /* access to diagnostic resources */
/* The 3000 series are intended for use as supplemental group id's only. */
/* They indicate special Android capabilities that the kernel is aware of. */
AID_NET_BT_ADMIN 3001 /* bluetooth: create any socket */
AID_NET_BT 3002 /* bluetooth: create sco, rfcomm or l2cap sockets */
AID_INET 3003 /* can create AF_INET and AF_INET6 sockets */
AID_NET_RAW 3004 /* can create raw INET sockets */
AID_MISC 9998 /* access to misc storage */
AID_NOBODY 9999
AID_APP 10000 /* first app user */
"root", AID_ROOT
"system", AID_SYSTEM
"radio", AID_RADIO
"bluetooth", AID_BLUETOOTH
"graphics", AID_GRAPHICS
"input", AID_INPUT
"audio", AID_AUDIO
"camera", AID_CAMERA
"log", AID_LOG
"compass", AID_COMPASS
"mount", AID_MOUNT
"wifi", AID_WIFI
"dhcp", AID_DHCP
"adb", AID_ADB
"install", AID_INSTALL
"media", AID_MEDIA
"shell", AID_SHELL
"cache", AID_CACHE
"diag", AID_DIAG
"net_bt_admin", AID_NET_BT_ADMIN
"net_bt", AID_NET_BT
"inet", AID_INET
"net_raw", AID_NET_RAW
"misc", AID_MISC
"nobody", AID_NOBODY
Click to expand...
Click to collapse
You will need to also understand the way file permissions are represented:
Example = drwxrwxrwx
-Use Root Explorer to find the UID, GID, and permissions for a file. Permissions are the string that looks like some variation on 'rwxr-xr--' next to each file. Long press and choose "change owner" to get the UID and GID. You just want the number next to "owner" and "group", respectively.
-If you're replacing a file, look up these settings for the existing copy and use them. If you're adding a file, just find a file that does the same functions and copy what it has (for example, installing an app to /system/app? Just look at these settings for any other app in that directory).
-MODE is technically a 4-bit string, but the first character can be omitted. There doesn't seem to be any android file permissions with the first character set. For good practice, I think it's safe to assume you can always use a leading 0 unless you know otherwise for something specific. Or, just use a 3-digit MODE, which says to leave those settings as they are (disabled by default). (I.e. 0644=644).
The next 9 characters define the file permissions. These permissions are
given in groups of 3 each.
The first 3 characters are the permissions for the owner of the file or directory.
Example = -rwx------
The next 3 are permissions for the group that the file is owned by.
Example = ----rwx---
The final 3 characters define the access permissions for everyone not part of the group.
Example = -------rwx
There are 3 possible attributes that make up file access permissions.
r - Read permission. Whether the file may be read. In the case of a
directory* this would mean the ability to list the contents of the
directory.
w - Write permission. Whether the file may be written to or modified. For
a directory* this defines whether you can make any changes to the contents
of the directory. If write permission is not set then you will not be able
to delete* rename or create a file.
x - Execute permission. Whether the file may be executed. In the case of a
directory* this attribute decides whether you have permission to enter*
run a search through that directory or execute some program from that
directory
You set these permissions using the following binary based numerical system:
Code:
0: --- No Permissions (the user(s) cannot do anything)
1: --x Execute Only (the user(s) can only execute the file)
2: -w- Write Only (the user(s) can only write to the file)
3: -wx Write and Execute Permissions
4: r-- Read Only
5: r-x Read and Execute Permissions
6: rw- Read and Write Permissions
7: rwx Read, Write and Execute Permissions
Click to expand...
Click to collapse
Default Linux permissions:
For Files:
"Read" means to be able to open and view the file
"Write" means to overwrite or modify the file
"eXecute" means to run the file as a binary
For Directories:
"Read" means to be able to view the contents of the directory
"Write" means to be able to create new files/directories within the directory
"eXecute" means to be able to "Change Directory" (cd) into the directory
Most of the time you set "Read" and "eXecute" together on directories (kind of useless when set by themselves)
Interestingly through further research it seems this system is based on the Octal Binary system...I may be wrong...
Further Commands:
In progress...
So, this is by no means an exhaustive list and I would appreciate it that if I have made any mistakes people make me aware in this thread and I can update this tutorial.
I would also like to add further commands and their uses, if people can provide more I will add them too.
I hope this helps people out! Many thanks!
Credits: wilskywalker for his guide from which I got the ideas and the knowledge.
How to create the flashable zip:
You will need the following:
Android SDK, ADB & Fastboot set up for your handset.
Notepad++
7Zip
Setting up your zip directories:
you will need to create the following folder structure (these are case sensitive):
/META-INF/com/google/android
Click to expand...
Click to collapse
All flash-able zips include this file structure, the final folder 'android' will contain two files:
update-binary
updater-script
Click to expand...
Click to collapse
update-binary: I have been unable to find much information on the update-binary file other than they seem to be chip set specific (if anyone can shed further light on these I will include it here). For the sake of compatibility I have attached the update binary from the latest CyanogenMod Nightlies for the Atrix 2 at the bottom of this thread - You can of course download the latest nightly and extract the update-binary file yourself as the attached one will obviously begin to date.
For anybody having problems flashing it is worth ensuring you have an up to date version of the update-binary (obviously the one attached to this thread will gradually become out of date).
updater-script: This we can create ourselves, to ensure it works properly we will use Notepad++.
Open Notepad++ and start a new file, with the following settings:
Format: Unix
Encoding: ANSI
Default Language: Normal Text
Click to expand...
Click to collapse
Save this file as:
File name: updater-script
File type: All types (*.*)
Click to expand...
Click to collapse
You can now begin writing your edify script in this file.
I'm explaining a simple example script for your better understanding.
Code:
assert(getprop("ro.product.board") == "edison");
ui_print(" ");
ui_print("confirming device edison");
ui_print(" ");
ui_print("success");
ui_print(" ");
show_progress(0.200000, 5);
ui_print("Mounting your system...");
mount("ext3", "EMMC", "/dev/block/mmcblk1p21", "/system");
ui_print(" ");
show_progress(0.200000, 5);
ui_print("updating system files");
package_extract_dir("system", "/system");
ui_print(" ");
show_progress(0.200000, 5);
ui_print("unmounting system");
unmount("/system");
ui_print(" ");
show_progress(0.200000, 5);
ui_print("by your name");
show_progress(0.200000, 5);
ui_print(" ");
***EMPTY LINE***
assert(getprop("ro.product.board") == "edison");
Click to expand...
Click to collapse
This is checking you are flashing the correct handset, this is not a requirement, but is best practice. Just insert another device name in the place of "edison" if you so wish, or remove the command all together.
mount("ext3", "EMMC", "/dev/block/mmcblk1p21", "/system");
Click to expand...
Click to collapse
This is the specific mount point for the edison system partition, if you wish to flash a different partition, data for instance you can get the mount points for your device by entering the following code over ADB:
Code:
adb shell "mount > /sdcard/PHONENAME_mountinfo.txt"
This will place a text file on your sdcard with the mount points for your specific device (remember to swap 'PHONENAME' with your device name e.g. 'edison').
Additionaly here are the mount points for data and cache for A2
Cache:
mount("ext3", "EMMC", "/dev/block/mmcblk1p22", "/cache");
Click to expand...
Click to collapse
Data:
mount("ext3", "EMMC", "/dev/block/mmcblk1p25", "/data");
Click to expand...
Click to collapse
package_extract_dir("system", "/system");
Click to expand...
Click to collapse
This command extracts the files you wish to flash from the zip and flashes them to the phone, it is formatted as follows ("package-path", "/destination-path"). So for this example you are telling it to flash everything from the 'system' folder in your zip to the /system partition of your handset. You can obviously change these values for different partitions.
unmount("/system");
Click to expand...
Click to collapse
This simply unmounts whatever partition you previously mounted.
ui_print(" ");
Click to expand...
Click to collapse
Shows text in the recovery whilst the flash is ongoing, you can put whatever you please between the double quotes, you must leave a space if you wish to have a blank line.
show_progress(0.200000, 5);
Click to expand...
Click to collapse
Controls what the progress bar in the background is displaying, it is formatted as follows (fragment, seconds).
***EMPTY LINE***
Click to expand...
Click to collapse
This is not actually text, you simply need to leave a blank line at the end of your script before you save it for it to work.
FYI, this means in fact your script could look like this and still work:
Code:
ui_print(" ");
show_progress(1.000000, 30);
mount("ext3", "EMMC", "/dev/block/mmcblk1p21", "/system");
package_extract_dir("system", "/system");
unmount("/system");
ui_print(" ");
***EMPTY LINE***
But that just isn't that pretty, or as deceptively complicated lol!
Make sure you save your edify script.
Files to flash:
You now need to create a further folder, this needs to be named based on where within the system you are flashing, for the sake of this example we are flashing to the system partition, so create this folder path(of course the structure depends on what are files you need to flash and their location):
/system/app
Click to expand...
Click to collapse
Place whatever files you wish to flash within this file e.g:
/system/app/nameofapp.apk
Click to expand...
Click to collapse
Creating your .zip file:
Select both of your top directories and their contents 'META-INF' and 'system' and package them into a .zip file with 7zip using the following settings:
Archive: name_of_your_file
Archive Format: zip
Compression level: Store
Update mode: Add and replace files
Click to expand...
Click to collapse
And there you have it, your very own flash-able .zip file.
How to sign your update.zip:
You don't actually need to sign your zip file for it to work as most custom recoveries now support unsigned zips, for aspiring developers and the more cautious among us though the how to will be updated later.
For now you can use the META-INF folder from the attached zip as is just modify the updater-script according to your requirments.
How to create your own private signing key & certificate:
You will need the following download:
Open SSL
If you want to create your own private keys for signing, here's what you need to do.
As before extract the OpenSSL files to a folder in the root of your c:\ drive, preferably named 'openssl' for ease of cmd line navigation. Then input the following:
Code:
cd\openssl\
openssl genrsa -out key.pem 1024
openssl req -new -key key.pem -out request.pem
openssl x509 -req -days 9999 -in request.pem -signkey key.pem -out certificate.pem
openssl pkcs8 -topk8 -outform DER -in key.pem -inform PEM -out key.pk8 -nocrypt
You can then replace 'key.pk8' & 'certificate.pem' with your own files.
I have attached an example flashable .zip file that includes a updater-script and the update-binary.Use that as a base or example to set your zip up.
I really hope this has helped folks out, if so please consider hitting the 'Thanks' button!
Happy flashing!
May the -Mass times Acceleration-be with you...
Thanks a TON!! You must've read my mind because I planned on trying to figure this out this weekend.lol BTW, what program are you using to write these scripts?
Brought to you by time and relative dimensions in space.
1BadWolf said:
Thanks a TON!! You must've read my mind because I planned on trying to figure this out this weekend.lol BTW, what program are you using to write these scripts?
Brought to you by time and relative dimensions in space.
Click to expand...
Click to collapse
Lol.
Notepad++ is the unanimous choice.
Also always leave one blank line at the bottom or the script won't work.
May the -Mass times Acceleration-be with you...
deveshmanish said:
Notepad++ is the unanimous choice.
Also always leave one blank line at the bottom or the script won't work.
May the -Mass times Acceleration-be with you...
Click to expand...
Click to collapse
I thought so but wanted to be sure. Thanks again.
Brought to you by time and relative dimensions in space.
Thanks for putting this together..
At first it seems a little complex for an aspiring modder, but still a great reference for the novice as well as the experienced modders..
Maybe offer some example scripts..? Feel free to use some from any of my zips.. Also, that goes for people trying to make their own - look at what others have done as examples.
Also might be worth noting the default permissions for system are 0644 - meaning if you are only installing things that need those perms (like an .apk, .jar or .so, etc), then you don't need to specify permissions in the updater-script.
EDIT: another text editor worth trying is Sublime Text 2 (thanks to cogeary for the tip) - need to eventually pay for the license (or find another way around it) or you will get pop-ups.
It's for both Windows and Linux (I use it in Ubuntu constantly, and mostly Notepad++ in Windows).
Sent from my MB865 using xda app-developers app
alteredlikeness said:
Thanks for putting this together..
At first it seems a little complex for an aspiring modder, but still a great reference for the novice as well as the experienced modders..
Maybe offer some example scripts..? Feel free to use some from any of my zips.. Also, that goes for people trying to make their own - look at what others have done as examples.
Also might be worth noting the default permissions for system are 0644 - meaning if you are only installing things that need those perms (like an .apk, .jar or .so, etc), then you don't need to specify permissions in the updater-script.
Sent from my MB865 using xda app-developers app
Click to expand...
Click to collapse
I'm definitely going to try and make this simpler.BTW great idea of putting sample zips together for reference.Thanks.
And yeah some stuff needs to be added even the path for data and cache partitions.And also I'm thinking of adding a slight explanation of busybox.The folder structure of a zip and what files it contains those are also on the to-do list.
Will get back to this once I'm done playing with MIUIv5.Enjoying it so far.
May the -Mass times Acceleration- be with You...
OP updated with guide to create the flashable zip.
Nice Tut Sir Its Very Helpful...
Yeah... I love this thread and use it often too excellent job op!
Interesting tutorial. What got me interested in this thread is. I want to convert a recovery.img to a flashable recovery zip so I can easily switch recoveries without odin. I have seen apps that can create flash zip automatically, but none of them support of adding recovery.img. Thanks.

[TUT] Create your own updater-script!

To create updater-script or to edit updater-script you need Notepad++ (don’t use notepad). Download it from here and install in your pc
updater-script is located in Meta-inf/com/google/android/updater-script
To create your own updater-script
Open notepad++ and from file menu select new and create the commands and create your own updater-script with this tutorial
After typing the commands save it as all types(*.*) and name it as updater-script and click save and put it in folder Meta-inf/com/google/android/updater-script
In this tutorial i will explain you all commands used in updater-script so that you can edit or create updater-script
ui_print – This command prints the prints the word inside the quotations
Example – ui_print(“galaxy s advance”); prints galaxy s advance in your cwm recovery
mount – This command mounts the partition, if you want to add files to system partition you have to mount system partition, data for data partition
To mount system - mount(“ext4″, “EMMC”, “/dev/block/mmcblk0p3″, “/system”);
Here mmcblk0p3 is the name of system partition for galaxy s advance(this name varies from device to device)
format - This command formats the partition specified
It is highly recommended to include this command to format system and data if you are making updater-script for ROM
To Format system - format(“ext4″, “EMMC”, “/dev/block/mmcblk0p3″, “0″);(partition name varies from device to device)
package_extract_dir(” “, “/”) – This command extracts all the files from the folder mentioned inside first quotation to the partition or directory inside second quotation
For system - package_extract_dir(“system”, “/system”);
(this copies all files from system folder in zip to system partition in phone)
For data - package_extract_dir(“data”, “/data”);
package_extract_file(” “,”/”) - This command extract the single file inside between first quotation from zip to the partition or directory inside second quotation
symlink – This command creates links to its executable files
Here is an example
for super su binaries - symlink(“/system/xbin/su”, “/system/bin/su”);
set_perm_recursive - This command sets permission for folders
here android uses unix permission system
in unix
4 – read
2 – write
1 – execute
so
rwx is 4+2+1 = 7
rw is 4+2 = 6
rx is 4+1 = 5
Example - set_perm_recursive(0, 0, 0755, 0644, “/system”);
In this 0 is a user id for owner that refers to root. It means that permission owner for system folder. and 0 is root user means it unrestricted access to system. it is given in order to run programs to run properly
second 0 also refers to root. but here it refers to group id 0
we are only seeing about folders because “set_perm_recursive” is a command that sets permission to folders
next 0755 it means rwxr-xr-x permission has been given to system folder and rw-r-r is set for all folders inside system folder
set_perm – This command sets permission for a specific file
Example - set_perm(1000, 1000, 0640, “/system/etc/bluetooth/auto_pairing.conf”);
here the 1000 refers to user id system and 0640 is rw-r—–
and this command sets the permission rw-r—– for the file auto_pairing.conf
unmount – This command unmounts the partition
Example - unmount(“/system”); – unmounts system
General rule in updater-script – all commands should end with semi colon ; otherwise it will show error and if cwm or twrp shows status 7 error the error is in updater-script
try fixing it by going through this thread
Great!!!!! I was looking for something like this, thanks
Enviado desde mi GT-I9070 mediante Tapatalk
Thanks. it took lot of time for me to understand this, after looking through suid, Unix and going through Linux permissions I understood
So I made a tut for in simple way that everyone could understand
Sent from my GT-I9070 using xda app-developers app
Thanx A lot
@PradeepMurugan Usefull Post for all. Keep it up bro.
abhinav2hd said:
@PradeepMurugan Usefull Post for all. Keep it up bro.
Click to expand...
Click to collapse
Thanks I will update this thread by adding information how to create updater-script for flashable zips soon and make thread some what beautiful soon
Sent from my GT-I9070 using Tapatalk
Thanks mate
keep up the good work

permission backup system - TWRP

Hello,
I have a script in TWRP
I trying to take backup of the android system all in: "/system"
into a sdcard "/external_sd/backupOSUmidigiPower"
Code:
ui_print("Start");
run_program("/sbin/busybox", "mount", "/dev/block/mmcblk0p31", "/system");
run_program("/sbin/busybox", "mkdir", "-p", "/external_sd/backupOSUmidigiPower");
run_program("/sbin/busybox", "cp", "-rp", "/system", "/external_sd/backupOSUmidigiPower/");
ui_print("Finish");
That Works very fine and take backup into sd card
But then i trying to take restore backup back to "/system"
but my question is:
1. "Why is my permission gone, see photo"
2. How can i copy all files/folder with permissions
linux cp commands:
Code:
cp
copy with recursion (-r) and (-p) preserve mode,ownership,timestamps
sudo cp -rp <sourceDir> <destDir>
And still got chmod 777 permission on all files/folders
I got bootloop before i think file permission is chmod 777
Can you help me out
Thanks for your time
I experienced that cp command always changes ownership of copied files / directories to root:root regardless of their initial ownership.
jwoegerbauer said:
I experienced that cp command always changes ownership of copied files / directories to root:root regardless of their initial ownership.
Click to expand...
Click to collapse
How can i move files and keep permission?
Moving and Copying are different things.
Don't confuse file's / directory's permissions and file's / directory's ownership: these are different things.

Categories

Resources