use of com.taobao.android.object.PatchInfo in project atlas by alibaba.
the class PatchFileBuilder method createHisTPatch.
/**
* 创建指定版本的patch文件
*
* @param targetVersion
*/
private PatchInfo createHisTPatch(String targetVersion, ILogger logger) throws IOException, PatchException {
PatchInfo hisPatchInfo = hisPatchInfos.get(targetVersion);
String patchName = "patch-" + currentBuildPatchInfo.getPatchVersion() + "@" + hisPatchInfo.getPatchVersion();
File destTPathTmpFolder = new File(tPatchTmpFolder, patchName);
destTPathTmpFolder.mkdirs();
File curTPatchUnzipFolder = unzipCurTPatchFolder(patchName);
// 处理awb的更新
List<BundlePatch> bundlePatches = diffPatch(hisPatchInfo, currentBuildPatchInfo);
PatchInfo newPatchInfo = processBundlePatch(hisPatchInfo, bundlePatches, curTPatchUnzipFolder);
// 比对主bundle的信息
PatchBundleInfo curMainBundleInfo = getMainBundleInfo(currentBuildPatchInfo);
PatchBundleInfo hisMainBundleInfo = getMainBundleInfo(hisPatchInfo);
PatchBundleInfo mainBundleInfo = new PatchBundleInfo();
mainBundleInfo.setMainBundle(true);
mainBundleInfo.setNewBundle(false);
if (null != curMainBundleInfo) {
File mainBundleFile = new File(curTPatchUnzipFolder, curMainBundleInfo.getName() + ".so");
FileUtils.copyFileToDirectory(mainBundleFile, destTPathTmpFolder);
mainBundleInfo.setVersion(curMainBundleInfo.getVersion());
mainBundleInfo.setPkgName(curMainBundleInfo.getPkgName());
mainBundleInfo.setBaseVersion(curMainBundleInfo.getBaseVersion());
mainBundleInfo.setName(curMainBundleInfo.getName());
mainBundleInfo.setPkgName(curMainBundleInfo.getPkgName());
mainBundleInfo.setApplicationName(curMainBundleInfo.getApplicationName());
newPatchInfo.getBundles().add(mainBundleInfo);
}
// 生成tpatch文件
for (PatchBundleInfo bundleInfo : newPatchInfo.getBundles()) {
if (bundleInfo.getMainBundle() || bundleInfo.getNewBundle() || noPatchBundles.contains(bundleInfo.getPkgName())) {
File bundleFolder = new File(destTPathTmpFolder, bundleInfo.getName());
File soFile = new File(destTPathTmpFolder, bundleInfo.getName() + ".so");
if (soFile.exists() || bundleInfo.getVersion().equals(ROLLBACK_VERSION)) {
continue;
}
zipBundleSo(bundleFolder, soFile);
FileUtils.deleteDirectory(bundleFolder);
}
}
File tPatchFile = new File(patchsFolder, newPatchInfo.getFileName());
if (tPatchFile.exists())
FileUtils.deleteQuietly(tPatchFile);
zipBundleSo(destTPathTmpFolder, tPatchFile);
if (null != logger) {
logger.info("[TPatchFile]" + tPatchFile.getAbsolutePath());
}
return newPatchInfo;
}
Aggregations