|
|
|
@ -4,17 +4,13 @@ apply plugin: 'java'
|
|
|
|
|
import java.io.FileInputStream;
|
|
|
|
|
import java.io.FileOutputStream;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.lang.RuntimeException;
|
|
|
|
|
import java.util.zip.GZIPInputStream;
|
|
|
|
|
import java.util.zip.GZIPOutputStream;
|
|
|
|
|
import java.util.regex.Matcher;
|
|
|
|
|
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 {
|
|
|
|
|
release
|
|
|
|
@ -50,6 +46,26 @@ model {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
// global
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
def workdir='build/unzip_boot'
|
|
|
|
|
def defaultRootDir = workdir + "/root"
|
|
|
|
|
String[] bins = [ "sh", "logcat", "logd", "linker", "toolbox", "toybox", "applypatch" ]
|
|
|
|
|
String[] libs = [ "libdl.so", "libutils.so", "libc++.so", "libc.so", "libm.so", "libz.so", "libstdc++.so", "libcutils.so", "libselinux.so", "liblog.so", "libpcre.so", "libsysutils.so", "libnl.so", "libbase.so", "libbacktrace.so", "libunwind.so" ]
|
|
|
|
|
boolean gDebug=true
|
|
|
|
|
String activeImg = null;
|
|
|
|
|
if (new File("boot.img").exists()) {
|
|
|
|
|
activeImg = "boot.img";
|
|
|
|
|
} else if (new File("recovery.img").exists()) {
|
|
|
|
|
activeImg = "recovery.img";
|
|
|
|
|
}
|
|
|
|
|
println("Active image target: " + activeImg);
|
|
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
// tasks
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
task unpack_bootimg(type: Exec, dependsOn: 'abootimgExecutable') {
|
|
|
|
|
doFirst {
|
|
|
|
|
def rootdir = new File(workdir)
|
|
|
|
@ -60,7 +76,7 @@ task unpack_bootimg(type: Exec, dependsOn: 'abootimgExecutable') {
|
|
|
|
|
}
|
|
|
|
|
workingDir '.'
|
|
|
|
|
executable 'build/exe/abootimg/abootimg'
|
|
|
|
|
args = ['-x', 'boot.img', workdir+'/bootimg.cfg', workdir+'/kernel', workdir+'/ramdisk.img.gz']
|
|
|
|
|
args = ['-x', activeImg, workdir+'/bootimg.cfg', workdir+'/kernel', workdir+'/ramdisk.img.gz']
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
task unpack_ramdisk_gz << {
|
|
|
|
@ -82,6 +98,7 @@ task unpack_cpio(type: Exec, dependsOn: unpack_ramdisk_gz) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
task unpack(type: Delete, dependsOn: unpack_cpio) {
|
|
|
|
|
description "extract boot.img or recovery.img"
|
|
|
|
|
delete workdir + "/ramdisk.img.gz"
|
|
|
|
|
delete workdir + "/ramdisk.img"
|
|
|
|
|
}
|
|
|
|
@ -123,10 +140,7 @@ task pack_clear(type: Exec, dependsOn: [pack_ramdisk_and_gz, 'mkbootimgExecutabl
|
|
|
|
|
'--ramdisk', workdir + "/ramdisk.img.gz",
|
|
|
|
|
'--cmdline', theCmdLine,
|
|
|
|
|
'--base', theBaseAddr,
|
|
|
|
|
'--output', 'boot.img.clear']
|
|
|
|
|
}
|
|
|
|
|
if (!new File(workdir + "/bootimg.cfg").exists()) {
|
|
|
|
|
pack_clear.enabled = false;
|
|
|
|
|
'--output', activeImg + '.clear']
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void unGnuzipFile(String compressedFile, String decompressedFile) throws IOException {
|
|
|
|
@ -226,7 +240,7 @@ task pack(type: JavaExec, dependsOn: [pack_clear, 'boot_signer:jar']) {
|
|
|
|
|
main = 'com.android.verity.BootSignature'
|
|
|
|
|
classpath = files("boot_signer/build/libs/boot_signer.jar")
|
|
|
|
|
maxHeapSize '512m'
|
|
|
|
|
args '/boot','boot.img.clear', 'security/verity.pk8', 'security/verity.x509.pem', 'boot.img.signed'
|
|
|
|
|
args '/boot', activeImg + '.clear', 'security/verity.pk8', 'security/verity.x509.pem', activeImg + '.signed'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
task _setup(type: Copy) {
|
|
|
|
@ -271,12 +285,20 @@ void RunFunc(String inCmd, String inWorkdir = null) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void updateBootImage() {
|
|
|
|
|
String flashTarget = "/dev/block/by-name/" + System.getProperty("img", "boot")
|
|
|
|
|
String flashTarget = null;
|
|
|
|
|
switch (activeImg) {
|
|
|
|
|
case "boot.img":
|
|
|
|
|
flashTarget = "/dev/block/by-name/boot";
|
|
|
|
|
break;
|
|
|
|
|
case "recovery.img":
|
|
|
|
|
flashTarget = "/dev/block/by-name/recovery";
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
Run("adb root")
|
|
|
|
|
Run("adb push boot.img.signed /cache/")
|
|
|
|
|
List<String> cmd2 = ["adb", "shell", "dd if=/cache/boot.img.signed of=" + flashTarget];
|
|
|
|
|
Run("adb push " + activeImg + ".signed /cache/")
|
|
|
|
|
List<String> cmd2 = ["adb", "shell", "dd if=/cache/" + activeImg + ".signed of=" + flashTarget];
|
|
|
|
|
Run(cmd2)
|
|
|
|
|
cmd2 = ["adb", "shell", "rm -f /cache/boot.img.signed"];
|
|
|
|
|
cmd2 = ["adb", "shell", "rm -f /cache/" + activeImg + ".signed"];
|
|
|
|
|
Run(cmd2)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -312,7 +334,7 @@ void updateLinks(String inWorkdir) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
task debug(dependsOn: ['addSystemBin', 'addSystemLib']) {
|
|
|
|
|
description "add debug tools into recovery rootfs"
|
|
|
|
|
description "add debug tools into recovery rootfs from ANDROID_PRODUCT_OUT"
|
|
|
|
|
doLast {
|
|
|
|
|
updateLinks(workdir);
|
|
|
|
|
}
|
|
|
|
@ -342,3 +364,18 @@ boolean inTargetList(String file, String[] inArray) {
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
// post configs
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
if (null == activeImg) {
|
|
|
|
|
pack.enabled = false
|
|
|
|
|
unpack.enabled = false
|
|
|
|
|
unpack_cpio.enabled = false
|
|
|
|
|
unpack_bootimg.enabled = false
|
|
|
|
|
unpack_ramdisk_gz.enabled = false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!new File(workdir + "/bootimg.cfg").exists()) {
|
|
|
|
|
pack_clear.enabled = false;
|
|
|
|
|
}
|
|
|
|
|