shutil.rmtree(OUT_DIR)
-def Apply_Container_Delta(a_apk, b_apk, new_apk, a_folder, g_output_dir):
-
- # CONTROL NAMES, AND PRINTS AND ERROR CASES... SHOULD NOT PROCEED.
- print 'ApplyContainerDelta - ', b_apk, a_folder, g_output_dir
- shutil.copy2(g_output_dir + '/' + b_apk, g_output_dir + '/temp')
- temp_apk = '../' + g_output_dir + '/' + b_apk
- Patch = 'Patch_' + b_apk
- ensure_dir_exists(Patch)
- shutil.copy2(g_output_dir + '/' + b_apk, Patch + '/' + b_apk)
-
- # Size issue on Device side?? shd check this
- subprocess.call(['unzip', '-q', Patch + '/' + b_apk, '-d', Patch])
- with open(g_output_dir + '/PATCH.txt', 'r') as f_new:
- lines = set(f_new.read().splitlines())
- for line in lines:
- #print('Action ==> %s' % line)
- #Action, Path, Patch = line.split('|')
- Items = line.split('|')
- Action = Items[0]
- Path = Items[1]
- ActualPath = a_folder + '/' + Path
- PatchPath = Patch + '/' + Path
- SrcPath = g_output_dir + '/' + path_leaf(Path)
- #print('Action ==> %s Path ==> %s ' % (Action, Path))
- if line[0] == 'c':
- patchName = g_output_dir + '/' + Items[2]
- #print('Apply Patch: ActualPath %s SrcPath %s PatchLoc %s ' % (PatchPath, ActualPath, patchName))
- subprocess.call([DIFFPATCH_UTIL, ActualPath, ActualPath, patchName])
- WorkingDir = os.getcwd()
- os.chdir(WorkingDir + "/" + "temp_a")
- subprocess.call(['cp', '--parents', Path, '../' + Patch])
- os.chdir(WorkingDir)
- elif line[0] == 's':
- WorkingDir = os.getcwd()
- os.chdir(WorkingDir + "/" + "temp_a")
- subprocess.call(['cp', '--parents', Path, '../' + Patch])
- os.chdir(WorkingDir)
- else:
- print('Apply_Container_Delta - Unknown Error')
- #print('Touch all files and set common attributes for DIFF generation')
- WorkingDir = os.getcwd()
- os.chdir(WorkingDir + "/" + Patch)
-
- CONTAINER_DATE = '200011111111.11'
- CONTAINER_MODE = '0755'
- subprocess.call(['find', '.', '-type', 'l', '-exec', 'rm', '-rf', '{}', ';'])
- subprocess.call(['find', '.', '-exec', 'touch', '-t', CONTAINER_DATE, '{}', ';'])
- subprocess.call(['chmod', '-R', CONTAINER_MODE, '../' + Patch])
-
- print 'Update Intermediate Archive'
- #subprocess.call(['zip','-ryX', b_apk, '*'])
- subprocess.call(['zip', '-ryX', b_apk] + glob.glob('*'))
- os.chdir(WorkingDir)
- #print('Apply Path completed - Now create diff for this and place in patch folder')
- #print os.getcwd()
- print('Patch Applied, Create Final Diff - %s %s' % (g_output_dir + '/' + b_apk, new_apk))
- patchName = ('New' + '_%s' + DIFF_SUFFIX) % (b_apk)
- patchLoc = '%s/%s' % (g_output_dir, patchName)
-
- subprocess.call([DIFF_UTIL, Patch + '/' + b_apk, new_apk, patchLoc])
-
- # Only on HOST... for testing
- if TEST_MODE == 'TRUE':
- UpgradedName = '%s_Upgraded' % (b_apk)
- subprocess.call([DIFFPATCH_UTIL, Patch + '/' + b_apk, UpgradedName, patchLoc])
-
- # This is file only with NEWS and empty diffs and same files.
- if TEST_MODE == 'FALSE':
- os.remove(g_output_dir + '/' + b_apk)
- os.rename(g_output_dir + '/temp', g_output_dir + '/' + b_apk)
- shutil.rmtree(Patch)
-
-
def IsSymlink(info):
return (info.external_attr >> 16) == 0120777