|
|
|
@ -11,6 +11,9 @@ import java.util.regex.Pattern;
|
|
|
|
|
|
|
|
|
|
def workdir='build/unzip_boot'
|
|
|
|
|
def defaultRootDir = workdir + "/root"
|
|
|
|
|
String[] bins = [ "sh", "logcat", "logd", "linker", "toolbox", "toybox", "applypatch_static" ]
|
|
|
|
|
String[] libs = [ "libdl.so", "libutils.so", "libc++.so", "libc.so", "libm.so", "libcutils.so", "libselinux.so", "liblog.so", "libpcre.so", "libsysutils.so", "libnl.so", "libbase.so", "libbacktrace.so", "libunwind.so" ]
|
|
|
|
|
boolean gDebug=true
|
|
|
|
|
|
|
|
|
|
model {
|
|
|
|
|
buildTypes {
|
|
|
|
@ -85,8 +88,8 @@ task unpack(type: Delete, dependsOn: unpack_cpio) {
|
|
|
|
|
|
|
|
|
|
task pack_ramdisk_and_gz { Task task ->
|
|
|
|
|
def rootDir = defaultRootDir
|
|
|
|
|
if (null != System.getenv("ANDROID_PRODUCT_OUT")) {
|
|
|
|
|
rootDir = System.getenv("ANDROID_PRODUCT_OUT") + "/root"
|
|
|
|
|
if (null != System.getProperty("ANDROID_PRODUCT_OUT")) {
|
|
|
|
|
rootDir = System.getProperty("ANDROID_PRODUCT_OUT") + "/root"
|
|
|
|
|
}
|
|
|
|
|
doLast {
|
|
|
|
|
if (!rootDir.equals(defaultRootDir)) {
|
|
|
|
@ -109,6 +112,9 @@ pack_ramdisk_and_gz.dependsOn('mkbootfsExecutable')
|
|
|
|
|
|
|
|
|
|
task pack_clear(type: Exec, dependsOn: [pack_ramdisk_and_gz, 'mkbootimgExecutable']) {
|
|
|
|
|
def theCmdLine = getRamdiskConfig(workdir, 'cmdline')
|
|
|
|
|
if (gDebug) {
|
|
|
|
|
theCmdLine = "androidboot.selinux=disabled " + theCmdLine
|
|
|
|
|
}
|
|
|
|
|
def theBaseAddr = getBaseAddress(workdir)
|
|
|
|
|
workingDir '.'
|
|
|
|
|
executable 'build/exe/mkbootimg/mkbootimg'
|
|
|
|
@ -228,10 +234,13 @@ task _setup(type: Copy) {
|
|
|
|
|
into '.'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Run(List<String> inCmd) {
|
|
|
|
|
println("CMD: " + inCmd)
|
|
|
|
|
void Run(List<String> inCmd, String inWorkdir = null) {
|
|
|
|
|
println("CMD:" + inCmd)
|
|
|
|
|
if (inWorkdir == null) {
|
|
|
|
|
inWorkdir = ".";
|
|
|
|
|
}
|
|
|
|
|
ProcessBuilder pb = new ProcessBuilder(inCmd)
|
|
|
|
|
.directory(new File("."))
|
|
|
|
|
.directory(new File(inWorkdir))
|
|
|
|
|
.redirectErrorStream(true);
|
|
|
|
|
Process p = pb.start()
|
|
|
|
|
p.inputStream.eachLine {println it}
|
|
|
|
@ -239,15 +248,33 @@ void Run(List<String> inCmd) {
|
|
|
|
|
assert 0 == p.exitValue()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Run(String inCmd) {
|
|
|
|
|
Run(Arrays.asList(inCmd.split()))
|
|
|
|
|
void Run(String inCmd, String inWorkdir = null) {
|
|
|
|
|
Run(Arrays.asList(inCmd.split()), inWorkdir);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
boolean RunFunc(List<String> inCmd, String inWorkdir = null) {
|
|
|
|
|
println("CMD:" + inCmd)
|
|
|
|
|
if (inWorkdir == null) {
|
|
|
|
|
inWorkdir = ".";
|
|
|
|
|
}
|
|
|
|
|
ProcessBuilder pb = new ProcessBuilder(inCmd)
|
|
|
|
|
.directory(new File(inWorkdir))
|
|
|
|
|
.redirectErrorStream(true);
|
|
|
|
|
Process p = pb.start()
|
|
|
|
|
p.inputStream.eachLine {println it}
|
|
|
|
|
p.waitFor();
|
|
|
|
|
return 0 == p.exitValue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunFunc(String inCmd, String inWorkdir = null) {
|
|
|
|
|
RunFunc(Arrays.asList(inCmd.split()), inWorkdir);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void updateBootImage() {
|
|
|
|
|
String flashTarget = "/dev/block/by-name/" + System.getProperty("img", "boot")
|
|
|
|
|
Run("adb root")
|
|
|
|
|
Run("adb push boot.img.signed /cache/")
|
|
|
|
|
List<String> cmd2 = ["adb", "shell", "dd if=/cache/boot.img.signed of=/dev/block/by-name/boot"];
|
|
|
|
|
List<String> cmd2 = ["adb", "shell", "dd if=/cache/boot.img.signed of=" + flashTarget];
|
|
|
|
|
Run(cmd2)
|
|
|
|
|
cmd2 = ["adb", "shell", "rm -f /cache/boot.img.signed"];
|
|
|
|
|
Run(cmd2)
|
|
|
|
@ -257,23 +284,50 @@ task flash << {
|
|
|
|
|
updateBootImage()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void rebootRecovery() {
|
|
|
|
|
Run("adb reboot recovery")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
task rr << {
|
|
|
|
|
rebootRecovery()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void updateLinks(String inWorkdir) {
|
|
|
|
|
String sysBinDir = inWorkdir + "/root/system/bin";
|
|
|
|
|
String[] toolboxLinks = [ "df", "getevent", "iftop", "ioctl", "ionice", "log", "ls", "lsof", "mount", "nandread", "newfs_msdos", "ps", "prlimit", "renice", "sendevent", "start", "stop", "top", "uptime", "watchprops", "dd", "du" ];
|
|
|
|
|
String[] toyboxLinks = [ "acpi", "basename", "blockdev", "bzcat", "cal", "cat", "chcon", "chgrp", "chmod", "chown", "chroot", "cksum", "clear", "comm", "cmp", "cp", "cpio", "cut", "date", "dirname", "dmesg", "dos2unix", "echo", "env", "expand", "expr", "fallocate", "false", "find", "free", "getenforce", "getprop", "groups", "head", "hostname", "hwclock", "id", "ifconfig", "inotifyd", "insmod", "kill", "load_policy", "ln", "logname", "losetup", "lsmod", "lsusb", "md5sum", "mkdir", "mknod", "mkswap", "mktemp", "modinfo", "more", "mountpoint", "mv", "netstat", "nice", "nl", "nohup", "od", "paste", "patch", "pgrep", "pidof", "pkill", "pmap", "printenv", "printf", "pwd", "readlink", "realpath", "restorecon", "rm", "rmdir", "rmmod", "route", "runcon", "sed", "seq", "setenforce", "setprop", "setsid", "sha1sum", "sleep", "sort", "split", "stat", "strings", "swapoff", "swapon", "sync", "sysctl", "tac", "tail", "tar", "taskset", "tee", "time", "timeout", "touch", "tr", "true", "truncate", "umount", "uname", "uniq", "unix2dos", "usleep", "vmstat", "wc", "which", "whoami", "xargs", "yes" ];
|
|
|
|
|
|
|
|
|
|
for (String item : toolboxLinks) {
|
|
|
|
|
RunFunc("unlink " + item, sysBinDir);
|
|
|
|
|
}
|
|
|
|
|
for (String item : toyboxLinks) {
|
|
|
|
|
RunFunc("unlink " + item, sysBinDir);
|
|
|
|
|
}
|
|
|
|
|
for (String item : toolboxLinks) {
|
|
|
|
|
Run("/bin/ln -s toolbox " + item, sysBinDir);
|
|
|
|
|
}
|
|
|
|
|
for (String item : toyboxLinks) {
|
|
|
|
|
Run("/bin/ln -s toybox " + item, sysBinDir);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
task debug(dependsOn: ['addSystemBin', 'addSystemLib']) {
|
|
|
|
|
description "add debug tools into recovery rootfs"
|
|
|
|
|
println(System.getenv("PATH"))
|
|
|
|
|
doLast {
|
|
|
|
|
updateLinks(workdir);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
task addSystemBin(type: Copy, dependsOn: 'unpack') {
|
|
|
|
|
String[] bins = [ "sh", "logcat", "logd", "linker", "toolbox", "toybox" ]
|
|
|
|
|
from System.getenv("ANDROID_PRODUCT_OUT") + '/system/bin'
|
|
|
|
|
task addSystemBin(type: Copy) {
|
|
|
|
|
from System.getProperty("ANDROID_PRODUCT_OUT") + '/system/bin'
|
|
|
|
|
into workdir + "/root/system/bin"
|
|
|
|
|
include { details ->
|
|
|
|
|
inTargetList(details.file.name, bins)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
task addSystemLib(type: Copy, dependsOn: 'unpack') {
|
|
|
|
|
String[] libs = [ "libdl.so", "libutils.so", "libc++.so", "libc.so", "libm.so", "libcutils.so", "libselinux.so", "liblog.so", "libpcre.so", "libsysutils.so", "libnl.so", "libbase.so", "libbacktrace.so", "libunwind.so" ]
|
|
|
|
|
from System.getenv("ANDROID_PRODUCT_OUT") + '/system/lib'
|
|
|
|
|
task addSystemLib(type: Copy) {
|
|
|
|
|
from System.getProperty("ANDROID_PRODUCT_OUT") + '/system/lib'
|
|
|
|
|
into workdir + "/root/system/lib"
|
|
|
|
|
include { details ->
|
|
|
|
|
inTargetList(details.file.name, libs)
|
|
|
|
|