From 4a723261ba46b1e020b90a73847e955a657857b9 Mon Sep 17 00:00:00 2001 From: androidlover5842 Date: Sun, 25 Mar 2018 14:18:11 +0530 Subject: [PATCH] change out dir --- .gitignore | 1 + res/unpack-MTK.pl | 16 ++++++++-------- src/mkTree/MakeTree.java | 39 +++++++++++++++++++------------------- src/util/Clean.java | 4 ++-- src/util/Config.java | 7 +++++++ src/util/GetBuildInfo.java | 7 ++++--- 6 files changed, 41 insertions(+), 33 deletions(-) create mode 100644 src/util/Config.java diff --git a/.gitignore b/.gitignore index cd79c38..0fee13f 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ jar/ build/ .idea/ TwrpBuilder.iml +tmp/ \ No newline at end of file diff --git a/res/unpack-MTK.pl b/res/unpack-MTK.pl index 4136695..47b575e 100755 --- a/res/unpack-MTK.pl +++ b/res/unpack-MTK.pl @@ -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; @@ -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; diff --git a/src/mkTree/MakeTree.java b/src/mkTree/MakeTree.java index 44afaac..ecb2bdc 100644 --- a/src/mkTree/MakeTree.java +++ b/src/mkTree/MakeTree.java @@ -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; @@ -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); @@ -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)); @@ -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" + @@ -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