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
Related
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
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
I am trying to get my android updater-script to selectively change permissions based on filename. I want all files under a certain subdirectory following the naming pattern "A.xy" set to 0755 and all other files set to 0644
So I first set all of them to 0644, then tried to selectively set the rest to 0755 by piping commands using xargs and exec. However, neither of the following commands worked but neither of them gave an error. Does anyone have a better way of doing this, or have an idea why neither of these worked?
run_program("/sbin/busybox", "find", " /data/app", "-name", "A.xy", "-type", "f", "-print0", "|", "/sbin/busybox", "xargs", "-0", "chmod", "0644");
run_program("/sbin/busybox find /data/app -name A.xy -type f -exec chmod 0644 {} \;");
It seems like update-binary doesn't allow piping? It doesn't give an error though.
Any idea how I can set all files of one type to be one permission, and all files of another type to be a different permission?
Thread closed.
Please see the continuation of this topic here: http://forum.xda-developers.com/android/help/edify-question-how-to-pipe-t3509804
Thanks!
I am trying to get my android updater-script to selectively change permissions based on filename. I want all files under a certain subdirectory following the naming pattern "A.xy" set to 0755 and all other files set to 0644
So I first set all of them to 0644, then tried to selectively set the rest to 0755 by piping commands using xargs and exec. However, neither of the following commands worked but neither of them gave an error. Does anyone have a better way of doing this, or have an idea why neither of these worked?
run_program("/sbin/busybox", "find", " /data/app", "-name", "A.xy", "-type", "f", "-print0", "|", "/sbin/busybox", "xargs", "-0", "chmod", "0644");
run_program("/sbin/busybox find /data/app -name A.xy -type f -exec chmod 0644 {} \;");
It seems like update-binary doesn't allow piping? It doesn't give an error though.
Any idea how I can set all files of one type to be one permission, and all files of another type to be a different permission?
Thread closed.
Please see the continuation of this topic here: http://forum.xda-developers.com/android/help/edify-question-how-to-pipe-t3509804
Thanks!
I am trying to get my android updater-script to selectively change permissions based on filename. I want all files under a certain subdirectory following the naming pattern "A.xy" set to 0755 and all other files set to 0644
So I first set all of them to 0644, then tried to selectively set the rest to 0755 by piping commands using xargs and exec. However, neither of the following commands worked but neither of them gave an error. Does anyone have a better way of doing this, or have an idea why neither of these worked?
run_program("/sbin/busybox", "find", " /data/app", "-name", "A.xy", "-type", "f", "-print0", "|", "/sbin/busybox", "xargs", "-0", "chmod", "0644");
run_program("/sbin/busybox find /data/app -name A.xy -type f -exec chmod 0644 {} \;");
It seems like update-binary doesn't allow piping? It doesn't give an error though.
Any idea how I can set all files of one type to be one permission, and all files of another type to be a different permission?
Thread closed.
Please see the continuation of this topic here: http://forum.xda-developers.com/android/help/edify-question-how-to-pipe-t3509804
Thanks!