Skip to content
Snippets Groups Projects
Commit b85e7852 authored by Maria Glukhova's avatar Maria Glukhova Committed by Chris Lamb
Browse files

Remove archive name from apktool.yml and rename it. (Closes: #850501)


Signed-off-by: Chris Lamb's avatarChris Lamb <lamby@debian.org>
parent 8bf8d351
No related branches found
No related tags found
No related merge requests found
......@@ -31,6 +31,18 @@ from .utils.archive import Archive
logger = logging.getLogger(__name__)
def filter_apk_metadata(filepath, archive_name):
new_filename = os.path.join(os.path.split(filepath)[0], "APK metadata")
logger.debug("Moving APK metadata from %s to %s", filepath, new_filename)
with open(filepath) as f:
with open(new_filename, "w") as f_out:
for line in f:
if not re.match(r'^apkFileName: %s' % os.path.basename(archive_name), line):
f_out.write(line)
os.remove(filepath)
return new_filename
class ApkContainer(Archive):
@property
def path(self):
......@@ -53,6 +65,10 @@ class ApkContainer(Archive):
for root, _, files in os.walk(self._unpacked):
for f in files:
abspath = os.path.join(root, f)
# apktool.yml is a file created by apktool and containing metadata information.
# Rename it to clarify.
if os.path.basename(abspath) == "apktool.yml":
abspath = filter_apk_metadata(abspath, os.path.basename(self.source.name))
relpath = abspath[len(self._unpacked)+1:]
self._members.append(relpath)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment