Skip to content

Commit

Permalink
change out dir
Browse files Browse the repository at this point in the history
  • Loading branch information
androidlover5842 committed Mar 25, 2018
1 parent 1da3adc commit 4a72326
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 33 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ jar/
build/
.idea/
TwrpBuilder.iml
tmp/
16 changes: 8 additions & 8 deletions res/unpack-MTK.pl
Original file line number Diff line number Diff line change
Expand Up @@ -147,35 +147,35 @@ sub unpack_boot {
}

# create file containing extra arguments for further repacking
system("mkdir out");
open (PAGEFILE, ">out/$inputFilename-pagesize")
system("mkdir tmp");
open (PAGEFILE, ">tmp/$inputFilename-pagesize")
or die();
printf PAGEFILE ("%d",$pageSize) or die;
close (PAGEFILE);

open (RAMDISKOFF, ">out/$inputFilename-ramdisk_offset")
open (RAMDISKOFF, ">tmp/$inputFilename-ramdisk_offset")
or die();
printf RAMDISKOFF ("%.8x",$ram1Offset) or die;
close (RAMDISKOFF);

open (TAGSOFFSET, ">out/$inputFilename-tags_offset")
open (TAGSOFFSET, ">tmp/$inputFilename-tags_offset")
or die();
printf TAGSOFFSET ("%.8x",$tagsOffset) or die;
close (TAGSOFFSET);

open (kernelbase, ">out/$inputFilename-base")
open (kernelbase, ">tmp/$inputFilename-base")
or die();
printf kernelbase ("%.8x",$baseAddr) or die;
close (kernelbase);

open (CMDLINE, ">out/$inputFilename-cmdline")
open (CMDLINE, ">tmp/$inputFilename-cmdline")
or die();
printf CMDLINE ("%s",$cmdLine) or die;
close (CMDLINE);

if ($extract =~ /kernel/) {
my $kernel = substr($bootimg, $pageSize, $kernelSize);
open (KERNELFILE, ">out/$inputFilename-zImage")
open (KERNELFILE, ">tmp/$inputFilename-zImage")
or die_msg("couldn't create file '$inputFilename-zImage'!");
binmode (KERNELFILE);
print KERNELFILE $kernel or die;
Expand All @@ -199,7 +199,7 @@ sub unpack_boot {
die_msg("the specified boot image does not appear to contain a valid gzip file!");
}

open (RAMDISKFILE, ">out/$inputFilename-ramdisk.gz")
open (RAMDISKFILE, ">tmp/$inputFilename-ramdisk.gz")
or die_msg("couldn't create file '$inputFilename-ramdisk.gz'!");
binmode (RAMDISKFILE);
print RAMDISKFILE $ram1 or die;
Expand Down
39 changes: 19 additions & 20 deletions src/mkTree/MakeTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@

import java.io.File;

import util.Clean;
import util.FWriter;
import util.GetBuildInfo;
import util.ShellExecuter;
import util.*;

public class MakeTree {
private long l=0;
Expand All @@ -15,8 +12,10 @@ public class MakeTree {
private String fstabIdata=ShellExecuter.CopyRight();
public static boolean otg;
private GetBuildInfo info;
private Config config;
private String out;
public MakeTree(boolean mtk,String type){

out=config.outDir;
if(mtk)
{
extractKernel(true);
Expand Down Expand Up @@ -73,20 +72,20 @@ private void extractKernel(boolean mtk) {
else
{
ShellExecuter.mkdir("out");
ShellExecuter.command("./umkbootimg -i recovery.img -o out/ ");
ShellExecuter.command("./umkbootimg -i recovery.img -o "+out);
}
}

private void mkKernel(boolean mtk) {
System.out.println("Making kernel.mk");
if(new File("out/recovery.img-zImage").exists())
if(new File(out+"recovery.img-zImage").exists())
{
ShellExecuter.cp("out/recovery.img-zImage", info.getPathS()+"kernel");
ShellExecuter.cp(out+"recovery.img-zImage", info.getPathS()+"kernel");
}
if(new File("out/recovery.img-dt").length()!=l)
if(new File(out+"recovery.img-dt").length()!=l)
{

ShellExecuter.cp("out/recovery.img-dt", info.getPathS()+"dt.img");
ShellExecuter.cp(out+"recovery.img-dt", info.getPathS()+"dt.img");
new FWriter("kernel.mk",getKernelData(true));
}else {
new FWriter("kernel.mk",getKernelData(false));
Expand All @@ -96,11 +95,11 @@ private void mkKernel(boolean mtk) {

private String getKernelData(boolean dt) {
String idata;
String pagesize=ShellExecuter.commandnoapp("cat out/recovery.img-pagesize");
String cmdline=ShellExecuter.commandnoapp("cat out/recovery.img-cmdline");
String ramdiskofsset=ShellExecuter.commandnoapp("cat out/recovery.img-ramdisk_offset");
String tagsoffset=ShellExecuter.commandnoapp("cat out/recovery.img-tags_offset");
String kernelbase=ShellExecuter.commandnoapp("cat out/recovery.img-base");
String pagesize=ShellExecuter.commandnoapp("cat "+out+"recovery.img-pagesize");
String cmdline=ShellExecuter.commandnoapp("cat "+out+"recovery.img-cmdline");
String ramdiskofsset=ShellExecuter.commandnoapp("cat "+out+"recovery.img-ramdisk_offset");
String tagsoffset=ShellExecuter.commandnoapp("cat "+out+"recovery.img-tags_offset");
String kernelbase=ShellExecuter.commandnoapp("cat "+out+"recovery.img-base");
idata=ShellExecuter.CopyRight();
idata+="# Kernel\n" +
"TARGET_PREBUILT_KERNEL := "+info.getPathS()+"kernel\n" +
Expand Down Expand Up @@ -135,12 +134,12 @@ public void extractFstab() {
if(compressionType.equals("lzma"))
{
System.out.println("Found lzma comression in ramdisk");
ShellExecuter.command("mv out/recovery.img-ramdisk.gz out/recovery.img-ramdisk.lzma && lzma -d out/recovery.img-ramdisk.lzma && cd out && cpio -i <recovery.img-ramdisk");
ShellExecuter.command("mv "+out+"recovery.img-ramdisk.gz "+out+"recovery.img-ramdisk.lzma && lzma -d "+out+"recovery.img-ramdisk.lzma && cd out && cpio -i <recovery.img-ramdisk");
lzma=true;
}else if(compressionType.equals("gzip"))
{
System.out.println("Found gzip comression in ramdisk");
ShellExecuter.command("gzip -d out/recovery.img-ramdisk.gz && cd out && cpio -i <recovery.img-ramdisk");
ShellExecuter.command("gzip -d "+out+"recovery.img-ramdisk.gz && cd out && cpio -i <recovery.img-ramdisk");
}
else if(compressionType.equals("lz4"))
{
Expand Down Expand Up @@ -169,9 +168,9 @@ public void MkFstab() {


private void FstablastMessage() {
if(new File("out/etc").exists()) {
Fstab("out/etc/recovery.fstab");
ShellExecuter.command("mkdir "+info.getPathS()+"stock && mv out/etc/* "+info.getPathS()+"stock/");
if(new File(out+"etc").exists()) {
Fstab(out+"etc/recovery.fstab");
ShellExecuter.command("mkdir "+info.getPathS()+"stock && mv "+out+"etc/* "+info.getPathS()+"stock/");
}
System.out.println("Build fingerPrint: "+info.getFingerPrint());
System.out.println("tree ready for "+ info.getCodename());
Expand Down
4 changes: 2 additions & 2 deletions src/util/Clean.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ public Clean(){
ShellExecuter.commandnoapp("rm umkbootimg");
}

if (new File("out").exists())
if (new File(Config.outDir).exists())
{
ShellExecuter.commandnoapp("rm -rf out");
ShellExecuter.commandnoapp("rm -rf "+Config.outDir);
}

if(new File("unpack-MTK.pl").exists())
Expand Down
7 changes: 7 additions & 0 deletions src/util/Config.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package util;

import java.io.File;

public class Config {
public static String outDir="tmp"+ File.separator;
}
7 changes: 4 additions & 3 deletions src/util/GetBuildInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@
public class GetBuildInfo {

private static String model,product,brand,codename,platform,api,size,fingerprint;

private static Config config;
private static String out=config.outDir;
public static String propFile() {
String prop=null;
if(new File("build.prop").exists())
{
prop="build.prop";
}
else
if(new File("out/default.prop").exists())
if(new File(out+"default.prop").exists())
{
prop="out/default.prop";
prop=out+"default.prop";
}
else {
prop="null";
Expand Down

0 comments on commit 4a72326

Please sign in to comment.