[Android Software/Hacking General [Developers Only]] Beakhole:
Ok. Now I've been trying to make a test script and I have a few questions: Below is the script I've started to make. Did I do it right if I want to extract the file from the zip and set the perms to 0755?

#!/sbin/sh
# ROM Patcher: Recovery Flashable Zip
# osm0sis @ xda-developers

OUTFD=/proc/self/fd/$2;
ZIP="$3";
DIR=`dirname "$ZIP"`;

ui_print() {
until [ ! "$1" ]; do
echo -e "ui_print $1nui_print" > $OUTFD;
shift;
done;
}
show_progress() { echo "progress $1 $2" > $OUTFD; }
set_progress() { echo "set_progress $1" > $OUTFD; }

#sleep <seconds> exists in shell

is_substring() {
case "$2" in
*$1*) echo 1;;
*) echo 0;;
esac;
}
#less_than_int(x, y) {} is unneeded since a if [ $x -lt $y ] comparison may be done directly
#greater than int(x, y) {} is unneeded since a if [ $x -gt $y ] comparison may be done directly

#format(fs_type, partition_type, device, fs_size, mountpoint) {} is unneeded since specific format/wipe commands may be run directly
#mount <partition> exists in shell
unmount() { umount $1; }
is_mounted() {
case `mount` in
*$1*) echo 1;;
*) echo 0;;
esac;
}

write_raw_image() { dd if=$1 of=$2; }
#write_firmware_image() {} is a manufacturer command to apply further OEM update zips with hboot/uboot functions, so can't be duplicated

package_extract_file() { unzip -o "$ZIP" "$1" -p > "$2"; }
package_extract_dir() { unzip -o "$ZIP" "$1/*" -d /; }

delete() { rm -f $*; }
delete_recursive() { rm -rf $*; }

symlink() {
links=$(echo $* | awk '{ print substr($0, index($0,$2)) }');
ln -s $1 $links;
}

set_perm() {
files=$(echo $* | awk '{ print substr($0, index($0,$4)) }');
for i in $files; do
chown $1.$2 $i; chown $1:$2 $i;
chmod $3 $i;
done;
}
set_perm_recursive() {
dirs=$(echo $* | awk '{ print substr($0, index($0,$5)) }');
for i in $dirs; do
chown -R $1.$2 $i; chown -R $1:$2 $i;
find "$i" -type d -exec chmod $3 {} +;
find "$i" -type f -exec chmod $4 {} +;
done;
}

ch_con() {
LD_LIBRARY_PATH=/system/lib /system/toolbox chcon u:object_r:$1:s0 $2;
LD_LIBRARY_PATH=/system/lib /system/bin/toolbox chcon u:object_r:$1:s0 $2;
chcon u:object_r:$1:s0 $2;
}
ch_con_recursive() {
dirs=$(echo $* | awk '{ print substr($0, index($0,$3)) }');
for i in $dirs; do
find "$i" -type d -exec LD_LIBRARY_PATH=/system/lib /system/toolbox chcon u:object_r:$1:s0 {} +;
find "$i" -type d -exec LD_LIBRARY_PATH=/system/lib /system/bin/toolbox chcon u:object_r:$1:s0 {} +;
find "$i" -type d -exec chcon u:object_r:$1:s0 '{}' +;
find "$i" -type f -exec LD_LIBRARY_PATH=/system/lib /system/toolbox chcon u:object_r:$2:s0 {} +;
find "$i" -type f -exec LD_LIBRARY_PATH=/system/lib /system/bin/toolbox chcon u:object_r:$2:s0 {} +;
find "$i" -type f -exec chcon u:object_r:$2:s0 '{}' +;
done;
}
restore_con() {
LD_LIBRARY_PATH=/system/lib /system/toolbox restorecon -R $*;
LD_LIBRARY_PATH=/system/lib /system/bin/toolbox restorecon -R $*;
restorecon -R $*;
}

file_getprop() { grep "^$2" "$1" | cut -d= -f2; }
getprop() { test -e /sbin/getprop && /sbin/getprop $1 || file_getprop /default.prop $1; }

sha1_check() {
sum=$(sha1sum $1 | awk '{ print $1 }');
if [ ! "$2" -o $(is_substring $sum "$*") == 1 ]; then
echo $sum;
fi;
}

#apply_patch(srcfile, tgtfile, tgtsha1, tgtsize, sha1_1, patch_1, ...) {} not possible without external bspatch binaries
#apply_patch_check(file, [sha1_1, ...]) {} not possible without external bspatch binaries
#apply_patch_space(bytes) {} not possible without external bspatch binaries

#run_program(program) {} is unneeded since programs may be run directly

abort() { ui_print "$*"; exit 1; }
assert() {
until [ ! "$1" ]; do
$1;
test $? == 1 && abort "assert failed($1)";
shift;
done;
}

backup_files() {
until [ ! "$1" ]; do
test ! -e "$1.bak" && cp -pf "$1" "$1.bak";
shift;
done;
}
restore_files() {
until [ ! "$1" ]; do
mv -f "${1}.bak" "$1";
shift;
done;
}

ui_print " TEST ";
mount /system;
package_extract_dir system;
set_perm 0 0 0755 /system/etc/init.d/ZZZ-Kernel-Gestures;
unmount /system;