From ba75f8f6af589ed2f3794c1ae78e77c667ea63e8 Mon Sep 17 00:00:00 2001 From: cfig Date: Sat, 16 Apr 2016 00:26:40 +0800 Subject: [PATCH] fix previous workarounds, fix travis-ci --- .travis.yml | 18 ++++++++++++++++++ README.md | 4 ++++ build.gradle | 39 +++++++++++++++++++++++++++++++-------- 3 files changed, 53 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index dff5f3a..435095e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1 +1,19 @@ language: java + +before_install: + - sudo apt-get -qq update + - sudo apt-get install -y libblkid-dev + +compiler: + - gcc + - clang +install: +- if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi +addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - gcc-4.8 + - g++-4.8 + - clang diff --git a/README.md b/README.md index c073c55..85b6677 100644 --- a/README.md +++ b/README.md @@ -2,3 +2,7 @@ edit boot.img for Nexus Devices [![Build Status](https://travis-ci.org/cfig/Nexus_boot_image_editor.svg?branch=master)](https://travis-ci.org/cfig/Nexus_boot_image_editor) + + +## [usage] +TBD diff --git a/build.gradle b/build.gradle index 893b2d5..60d8366 100644 --- a/build.gradle +++ b/build.gradle @@ -7,6 +7,8 @@ import java.io.IOException; import java.util.zip.GZIPInputStream; import java.util.zip.GZIPOutputStream; +def workdir='build/unzip_boot' + task wrapper(type: Wrapper) { gradleVersion = '2.12' } @@ -46,7 +48,6 @@ model { } } -def workdir='build/unzip_boot' task unpack_bootimg(type: Exec, dependsOn: 'abootimgExecutable') { doFirst { new File(workdir + '/root').mkdirs() @@ -87,16 +88,16 @@ task pack_ramdisk_and_gz { Task task -> } pack_ramdisk_and_gz.dependsOn('mkbootfsExecutable') -task pack_clear(type: Exec, dependsOn: [pack_ramdisk_and_gz, 'mkbootimgExecutable']) { +task pack_clear(type: Exec, dependsOn: [pack_ramdisk_and_gz, 'mkbootimgExecutable']) << { commandLine 'build/exe/mkbootimg/mkbootimg', '--kernel', workdir + "/kernel", '--ramdisk', workdir + "/ramdisk.img.gz", - '--cmdline', "cmdlineeeee", - '--base', '0x01000000', + '--cmdline', getRamdiskConfig(workdir, 'cmdline'), + '--base', getBaseAddress(workdir), '--output', 'boot.img.clear' } -public void unGnuzipFile(String compressedFile, String decompressedFile) throws IOException { +void unGnuzipFile(String compressedFile, String decompressedFile) throws IOException { byte[] buffer = new byte[1024]; try { FileInputStream fileIn = new FileInputStream(compressedFile); @@ -114,7 +115,7 @@ public void unGnuzipFile(String compressedFile, String decompressedFile) throws } } -public void gnuZipFile(String compressedFile, InputStream fis) throws IOException { +void gnuZipFile(String compressedFile, InputStream fis) throws IOException { byte[] buffer = new byte[1024]; try { FileOutputStream fos = new FileOutputStream(compressedFile); @@ -132,7 +133,7 @@ public void gnuZipFile(String compressedFile, InputStream fis) throws IOExceptio } } -public void gnuZipFile(String compressedFile, String decompressedFile) throws IOException { +void gnuZipFile(String compressedFile, String decompressedFile) throws IOException { byte[] buffer = new byte[1024]; try { FileOutputStream fos = new FileOutputStream(compressedFile); @@ -152,10 +153,32 @@ public void gnuZipFile(String compressedFile, String decompressedFile) throws IO } } +String getBaseAddress(String inWorkdir) { + Long ret = Long.parseLong(getRamdiskConfig(inWorkdir, "kerneladdr").substring(2), 16) - 0x8000L; + return Long.toHexString(ret); +} + +String getRamdiskConfig(String inWorkdir, String inKey) { + String ret; + try { + Properties prop = new Properties(); + InputStream fis = new FileInputStream(inWorkdir+ "/bootimg.cfg") + prop.load(fis); + ret = prop.getProperty(inKey); + if (fis != null) { + fis.close(); + } + } catch (IOException e) { + e.printStackTrace(); + throw e; + } + return ret; +} + task pack(type: JavaExec, dependsOn: pack_clear) { 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' } - +pack.dependsOn('boot_signer:jar')