Android OS Forum banner
1 - 1 of 1 Posts

·
Premium Member
Joined
·
223 Posts
In RZR 2.1.3, I will be introducing a new feature: plugins! These are simply tarballs containing shell scripts and anything else you can think of. What they can do is limited only by your imagination.

Format:

metadata - if you would like to tell the user anything, this is where to put it. In a file called info is where you will be able to put your name, contact info, description, etc
pre.d - put shell scripts that will execute first here. They are executed alphabetically, scripts will begin with 00, 01, 02, etc. I will paste the layout and script for my Droid RZR install plugin (It's super-simple)
post.d - same thing but executed after pre.d

You can have as many separate shell scripts as you want or just one giant one, its up to you. You can bundle other programs or shells if you wanted to. When a plugin runs, its contents are extracted to /tmp. this is where you will reference your files. When the plugin execution is over, everything it did in /tmp will be erased (it's nice to clean up after yourself, right?)

That's pretty much all there is to it. This is the ROM.TAR format introduced many moons ago by DroidMod, and forgotten about by most everyone but me. I have just repackaged it as plugins and tweaked it.

To get RZR to show plugins, they will be in a directory on the sdcard called /sdcard/RZR/plugins. If this directory does not exist or there are no TGZ/TAR files in there, the Plugins option will NOT appear on the extras menu of RZR.

If you use a gzipped-compressed tarball (perhaps if your plugin contains tons of crap), then call it SOMETHING.tgz. RZR will auto decompress it upon load and will then live as a decompressed tar for the rest of its time on the sdcard.

API functions to control what shows up on the screen from shell scripts:

(ui_commands.sh):

ui_print - will print to the screen
Code:
ui_print "This is some text."
ptotal - this is the number that represents a full progress bar, used by pipleline (you'll see this next)
pcur - this is the number that represents current progress bar status, used by pipeline

pipeline - this is a function that controls progress bars from tar or anything else you can think up to use it, as long as you have someway to measure it. The following example uses pipeline to show a progress bar for a simple tar extraction. PROGRESS is just a variable to control whether or not to show progreess bars, you set this based on whatever you want.
Code:
<br />
pipeline() {<br />
	if [ "$PROGRESS" == "1" ]; then<br />
		[ "$PROGRESS" == "1" ] && echo "* show_indeterminate_progress"<br />
		awk "NR==1 {print \"* ptotal $1\"} {print \"* pcur \" NR}"<br />
		[ "$PROGRESS" == "1" ] && echo "* reset_progress"<br />
	else<br />
		cat<br />
	fi<br />
}<br />
<br />
PTOTAL=`tar tvf /tmp/somefile.tar | wc -l`<br />
tar xvf /tmp/somefile.tar -C destination | pipeline $PTOTAL<br />
ui_show_indeterminate_progress - will show the indeterminate progress bar until either reset or updated by pipeline
Code:
ui_show_indeterminate_progress
ui_reset_progress - resets all progress, removes progress bar from screen
Code:
ui_reset_progress
menu - this will show menus to the user and get input from them. It's best just to look at an example from the Droid RZR installer:
Code:
<br />
menu -h "RZR installation " -h "Would you like to try to make this permanent?" -h "" \<br />
  -i "Yes!" \<br />
  -i "No"<br />
  read ANSWER<br />
<br />
<br />
if [ -z $ANSWER ] || [ $ANSWER = "" ]; then #must have just gone back<br />
  proceed=0<br />
fi<br />
<br />
if [ $ANSWER == 0 ]; then<br />
  proceed=1<br />
fi<br />
if [ $ANSWER == 1 ]; then<br />
  proceed=0<br />
fi<br />
<br />
if [ $proceed == 0 ] || [ -z "$proceed" ]; then<br />
  exit 0<br />
fi<br />
There are more little functions but those are the major ones, feel free to look at ui_commands.sh in / while RZR is running.

Now on to the Droid RZR install layout/script:

layout:
Code:
<br />
./pre.d/<br />
./pre.d/00_go.sh<br />
script code:
Code:
<br />
#!/sbin/sh<br />
source /ui_commands.sh<br />
<br />
#function to take output from tar and make it into a progress bar<br />
pipeline() {<br />
  ui_show_indeterminate_progress<br />
  awk "NR==1 {print \"* ptotal $1\"} {print \"* pcur \" NR}"<br />
}<br />
<br />
<br />
<br />
menu -h "RZR installation " -h "Would you like to try to make this permanent?" -h "" \<br />
  -i "Yes!" \<br />
  -i "No"<br />
  read ANSWER<br />
<br />
<br />
if [ -z $ANSWER ] || [ $ANSWER = "" ]; then #must have just gone back<br />
  proceed=0<br />
fi<br />
<br />
if [ $ANSWER == 0 ]; then<br />
  proceed=1<br />
fi<br />
if [ $ANSWER == 1 ]; then<br />
  proceed=0<br />
fi<br />
<br />
if [ $proceed == 0 ] || [ -z "$proceed" ]; then<br />
  exit 0<br />
fi<br />
<br />
ui_print "Dumping current recovery to /sdcard/orig-recovery.img..."<br />
ui_show_indeterminate_progress<br />
mount /sdcard<br />
dump_image recovery /sdcard/orig-recovery.img<br />
ui_print "Done!"<br />
ui_reset_progress<br />
<br />
ui_print "Unpacking original recovery img to /tmp/recovery-unpacked..."<br />
ui_show_indeterminate_progress<br />
mkdir /tmp/recovery-unpacked<br />
cp /sdcard/orig-recovery.img /tmp/recovery-unpacked/recovery.img<br />
cd /tmp/recovery-unpacked<br />
<br />
unpack_bootimg -i recovery.img<br />
mkdir ramdisk<br />
cd ramdisk<br />
gzip -dc ../recovery.img-ramdisk.gz | cpio -i<br />
<br />
ui_print "Replacing current recovery files with RZR"<br />
cp -a /sbin/* sbin<br />
cp /recovery.version .<br />
cp /ui_commands.sh .<br />
echo > block_update<br />
rm -rf res<br />
cp -a /res .<br />
<br />
cd /tmp/recovery-unpacked<br />
<br />
CMD_LINE=`cat recovery.img-cmdline`<br />
BASE_ADDR=`cat recovery.img-base`<br />
PAGE_SIZE=`cat recovery.img-pagesize`<br />
KERNEL="recovery.img-zImage"<br />
<br />
ui_print "Creating new ramdisk"<br />
mkbootfs ./ramdisk | gzip > ramdisk-new.gz<br />
<br />
ui_print "Creating new recovery.img"<br />
<br />
mkbootimg --kernel $KERNEL --cmdline "$CMDLINE" --ramdisk ramdisk-new.gz --pagesize $PAGE_SIZE --base $BASE_ADDR -o recovery-new.img<br />
<br />
ui_print "Flashing new recovery image..."<br />
flash_image recovery recovery-new.img<br />
<br />
ui_print "Done! let's hope it boots..."<br />
ui_print "Please reboot your recovery."<br />
exit 0<br />
If you want to use those functions I mentioned, you have to source /ui_commands.sh


This is a metadata/info file from one of my old ROM's:
Code:
<br />
author=raidzero<br />
name=RZ Baseline v0.3<br />
description=FRG83, rooted, deodxed, busyboxed, theme - 18 colors<br />
url=http://www.droidforums.net<br />
[email protected]<br />
clobber_system=false #do not wipe system prior to running post.d scripts<br />
clobber_data=false #do not wipe data prior to running post.d scripts<br />
min_rev=001 #used to tell the system what revision you have. you can use scripts to check if they are out of date with this<br />
 
1 - 1 of 1 Posts
This is an older thread, you may not receive a response, and could be reviving an old thread. Please consider creating a new thread.
Top