③.根目录以及分区的定义(在Android源代码的root.c文件中定义)
④.具体实例:
1.
assert(getprop("ro.product.device")== "swift" || getprop("ro.build.product") =="swift" || getprop("ro.product.board") =="swift");
2.
package_extract_file("system/bin/backuptool.sh","/tmp/backuptool.sh");
3.
set_perm(0, 0, 0777,"/tmp/backuptool.sh");
4.
run_program("/tmp/backuptool.sh","backup");
5.
show_progress(0.500000,0);
6.
format("yaffs2","MTD", "system");
7.
mount("yaffs2","MTD", "system", "/system");
8.
package_extract_dir("recovery","/system");
9.
package_extract_dir("system","/system");
10.
symlink("busybox","/system/xbin/[", "/system/xbin/[[",
11.
"/system/xbin/arp", "/system/xbin/ash","/system/xbin/awk",
12.
"/system/xbin/basename", "/system/xbin/bbconfig","/system/xbin/brctl",
13.
"/system/xbin/bunzip2","/system/xbin/bzcat", "/system/xbin/bzip2",
14.
"/system/xbin/cal", "/system/xbin/cat","/system/xbin/catv",
15.
"/system/xbin/chgrp","/system/xbin/chmod", "/system/xbin/chown",
16.
"/system/xbin/chroot","/system/xbin/cksum", "/system/xbin/clear",
17.
"/system/xbin/cmp", "/system/xbin/cp","/system/xbin/cpio",
18.
"/system/xbin/cut", "/system/xbin/date","/system/xbin/dc",
19.
"/system/xbin/dd", "/system/xbin/depmod","/system/xbin/devmem",
20.
"/system/xbin/df", "/system/xbin/diff","/system/xbin/dirname",
21.
"/system/xbin/dmesg","/system/xbin/dnsd", "/system/xbin/dos2unix",
22.
"/system/xbin/du", "/system/xbin/echo","/system/xbin/ed",
23.
"/system/xbin/egrep", "/system/xbin/env","/system/xbin/expr",
24.
"/system/xbin/false","/system/xbin/fdisk", "/system/xbin/fgrep",
25.
"/system/xbin/find", "/system/xbin/fold","/system/xbin/free",
26.
"/system/xbin/freeramdisk", "/system/xbin/fuser","/system/xbin/getopt",
27.
"/system/xbin/grep","/system/xbin/gunzip", "/system/xbin/gzip",
28.
"/system/xbin/head","/system/xbin/hexdump", "/system/xbin/id",
29.
"/system/xbin/ifconfig","/system/xbin/insmod", "/system/xbin/install",
30.
"/system/xbin/ip", "/system/xbin/kill","/system/xbin/killall",
31.
"/system/xbin/killall5","/system/xbin/length", "/system/xbin/less",
32.
"/system/xbin/ln","/system/xbin/losetup", "/system/xbin/ls",
33.
"/system/xbin/lsmod", "/system/xbin/lspci","/system/xbin/lsusb",
34.
"/system/xbin/lzop","/system/xbin/lzopcat", "/system/xbin/md5sum",
35.
"/system/xbin/mkdir","/system/xbin/mke2fs", "/system/xbin/mkfifo",
36.
"/system/xbin/mkfs.ext2","/system/xbin/mknod", "/system/xbin/mkswap",
37.
"/system/xbin/mktemp","/system/xbin/modprobe", "/system/xbin/more",
38.
"/system/xbin/mount","/system/xbin/mountpoint", "/system/xbin/mv",
39.
"/system/xbin/netstat","/system/xbin/nice", "/system/xbin/nohup",
40.
"/system/xbin/nslookup","/system/xbin/ntpd", "/system/xbin/od",
41.
"/system/xbin/patch","/system/xbin/pgrep", "/system/xbin/pidof",
42.
"/system/xbin/ping","/system/xbin/pkill", "/system/xbin/printenv",
43.
"/system/xbin/printf", "/system/xbin/ps","/system/xbin/pwd",
44.
"/system/xbin/rdev","/system/xbin/readlink", "/system/xbin/realpath",
45.
"/system/xbin/renice","/system/xbin/reset", "/system/xbin/rm",
46.
"/system/xbin/rmdir","/system/xbin/rmmod", "/system/xbin/route",
47.
"/system/xbin/run-parts","/system/xbin/sed", "/system/xbin/seq",
48.
"/system/xbin/setsid", "/system/xbin/sh","/system/xbin/sha1sum",
49.
"/system/xbin/sha256sum","/system/xbin/sha512sum",
50.
"/system/xbin/sleep", "/system/xbin/sort","/system/xbin/split",
51.
"/system/xbin/stat","/system/xbin/strings", "/system/xbin/stty",
52.
"/system/xbin/swapoff","/system/xbin/swapon", "/system/xbin/sync",
53.
"/system/xbin/sysctl","/system/xbin/tac", "/system/xbin/tail",
54.
"/system/xbin/tar", "/system/xbin/tee","/system/xbin/telnet",
55.
"/system/xbin/test", "/system/xbin/tftp","/system/xbin/time",
56.
"/system/xbin/top", "/system/xbin/touch","/system/xbin/tr",
57.
"/system/xbin/traceroute", "/system/xbin/true","/system/xbin/tty",
58.
"/system/xbin/tune2fs","/system/xbin/umount", "/system/xbin/uname",
59.
"/system/xbin/uniq","/system/xbin/unix2dos", "/system/xbin/unlzop",
60.
"/system/xbin/unzip","/system/xbin/uptime", "/system/xbin/usleep",
61.
"/system/xbin/uudecode","/system/xbin/uuencode", "/system/xbin/vi",
62.
"/system/xbin/watch", "/system/xbin/wc","/system/xbin/wget",
63.
"/system/xbin/which","/system/xbin/whoami", "/system/xbin/xargs",
64.
"/system/xbin/yes",
65.
"/system/xbin/zcat");
66.
symlink("iwmulticall","/system/xbin/iwconfig", "/system/xbin/iwgetid",
67.
"/system/xbin/iwlist","/system/xbin/iwpriv",
68.
"/system/xbin/iwspy");
69.
symlink("toolbox","/system/bin/cat", "/system/bin/cmp",
70.
"/system/bin/date", "/system/bin/dd","/system/bin/dmesg",
71.
"/system/bin/getevent","/system/bin/getprop", "/system/bin/hd",
72.
"/system/bin/id", "/system/bin/ifconfig","/system/bin/iftop",
73.
"/system/bin/insmod","/system/bin/ioctl", "/system/bin/ionice",
74.
"/system/bin/kill", "/system/bin/log","/system/bin/lsmod",
75.
"/system/bin/mkdir","/system/bin/nandread", "/system/bin/netstat",
76.
"/system/bin/newfs_msdos","/system/bin/notify", "/system/bin/printenv",
77.
"/system/bin/ps","/system/bin/reboot", "/system/bin/renice",
78.
"/system/bin/rmdir", "/system/bin/rmmod","/system/bin/route",
79.
"/system/bin/schedtop","/system/bin/sendevent",
80.
"/system/bin/setconsole","/system/bin/setprop", "/system/bin/sleep",
81.
"/system/bin/smd", "/system/bin/start","/system/bin/stop",
82.
"/system/bin/sync", "/system/bin/top","/system/bin/uptime",
83.
"/system/bin/vmstat","/system/bin/watchprops",
84.
"/system/bin/wipe");
85.
set_perm_recursive(0,0, 0755, 0644, "/system");
86.
set_perm_recursive(0,2000, 0755, 0755, "/system/bin");
87.
set_perm(0, 3003,02750, "/system/bin/netcfg");
88.
set_perm(0, 3004,02755, "/system/bin/ping");
89.
set_perm(0, 2000,06750, "/system/bin/run-as");
90.
set_perm_recursive(1002,1002, 0755, 0440, "/system/etc/bluetooth");
91.
set_perm(0, 0, 0755,"/system/etc/bluetooth");
92.
set_perm(1000, 1000,0640, "/system/etc/bluetooth/auto_pairing.conf");
93.
set_perm(3002, 3002,0444, "/system/etc/bluetooth/blacklist.conf");
94.
set_perm(1002, 1002,0440, "/system/etc/dbus.conf");
95.
set_perm(1014, 2000,0550, "/system/etc/dhcpcd/dhcpcd-run-hooks");
96.
set_perm_recursive(0,2000, 0755, 0750, "/system/etc/init.d");
97.
set_perm(0, 0, 0755,"/system/etc/init.d");
98.
set_perm(0, 2000, 0550,"/system/etc/init.goldfish.sh");
99.
set_perm(0, 0, 0544,"/system/etc/install-recovery.sh");
100.
set_perm_recursive(0,0, 0755, 0555, "/system/etc/ppp");
101.
set_perm_recursive(0,2000, 0755, 0755, "/system/xbin");
102.
set_perm(0, 0, 06755,"/system/xbin/hcitool");
103.
set_perm(0, 0, 06755,"/system/xbin/librank");
104.
set_perm(0, 0, 06755,"/system/xbin/procmem");
105.
set_perm(0, 0, 06755,"/system/xbin/procrank");
106.
set_perm(0, 0, 06755,"/system/xbin/su");
107.
set_perm(0, 0, 06755,"/system/xbin/tcpdump");
108.
show_progress(0.200000,0);
109.
show_progress(0.200000,10);
110.
package_extract_file("system/bin/backuptool.sh","/tmp/backuptool.sh");
111.
set_perm(0, 0, 0777,"/tmp/backuptool.sh");
112.
run_program("/tmp/backuptool.sh","restore");
113.
package_extract_file("system/bin/modelid_cfg.sh","/tmp/modelid_cfg.sh");
114.
set_perm(0, 0, 0777, "/tmp/modelid_cfg.sh");
115.
run_program("/tmp/modelid_cfg.sh");
116.
package_extract_file("system/bin/verify_cache_partition_size.sh","/tmp/verify_cache_partition_size.sh");
117.
set_perm(0, 0, 0777,"/tmp/verify_cache_partition_size.sh");
118.
run_program("/tmp/verify_cache_partition_size.sh");
119.
show_progress(0.200000,10);
120.
assert(package_extract_file("boot.img","/tmp/boot.img"),
121.
write_raw_image("/tmp/boot.img", "boot"),
122.
delete("/tmp/boot.img"));
123.
show_progress(0.100000,0);
124.
unmount("/system");
125.