summaryrefslogtreecommitdiff
path: root/apexer/apexer.py
diff options
context:
space:
mode:
authorLingfeng Yang <lfy@google.com>2018-12-25 00:30:19 +0000
committerLingfeng Yang <lfy@google.com>2018-12-25 00:30:19 +0000
commit0fe26b1e6832d7fe6c19e728c21fdc0e9be2ed44 (patch)
tree3cb7f3e324d2e2d1a1daf407bcbbd52aec667796 /apexer/apexer.py
parent7e021e8dcae1098eccf972eb9e71448134fdc08b (diff)
Revert "Use protobuf as schema for JSON APEX manifest"
This reverts commit 7e021e8dcae1098eccf972eb9e71448134fdc08b. Reason for revert: build break Change-Id: I6fbd8176ec7d4124c49d07f07ca9cd21a54caad3
Diffstat (limited to 'apexer/apexer.py')
-rw-r--r--apexer/apexer.py26
1 files changed, 15 insertions, 11 deletions
diff --git a/apexer/apexer.py b/apexer/apexer.py
index db4dd50..c15b6da 100644
--- a/apexer/apexer.py
+++ b/apexer/apexer.py
@@ -24,6 +24,7 @@ Typical usage: apexer input_dir output.apex
import argparse
import hashlib
+import json
import os
import re
import shutil
@@ -31,8 +32,6 @@ import subprocess
import sys
import tempfile
import uuid
-from apex_manifest import ValidateApexManifest
-from apex_manifest import ApexManifestError
if 'APEXER_TOOL_PATH' not in os.environ:
sys.stderr.write("""
@@ -169,17 +168,22 @@ def CreateApex(args, work_dir):
print "Using tools from " + str(tool_path_list)
try:
- with open(args.manifest, "r") as f:
- manifest_raw = f.read()
- manifest_apex = ValidateApexManifest(manifest_raw)
- except ApexManifestError as err:
+ with open(args.manifest) as f:
+ manifest = json.load(f)
+ except ValueError:
print("'" + args.manifest + "' is not a valid manifest file")
- print err.errmessage
return False
except IOError:
print("Cannot read manifest file: '" + args.manifest + "'")
return False
+ if 'name' not in manifest or manifest['name'] is None:
+ print("Invalid manifest: 'name' does not exist")
+ return False
+
+ package_name = manifest['name']
+ version_number = manifest['version']
+
# create an empty ext4 image that is sufficiently big
# Sufficiently big = twice the size of the input directory
# For the case when the input directory is really small, the minimum of the
@@ -203,8 +207,8 @@ def CreateApex(args, work_dir):
if args.payload_type == 'image':
key_name = os.path.basename(os.path.splitext(args.key)[0])
- if manifest_apex.package_name != key_name:
- print("package name '" + manifest_apex.package_name + "' does not match with key name '" + key_name + "'")
+ if package_name != key_name:
+ print("package name '" + package_name + "' does not match with key name '" + key_name + "'")
return False
img_file = os.path.join(content_dir, 'apex_payload.img')
@@ -261,7 +265,7 @@ def CreateApex(args, work_dir):
cmd.extend(['--prop', "apex.key:" + key_name])
# Set up the salt based on manifest content which includes name
# and version
- salt = hashlib.sha256(manifest_raw).hexdigest()
+ salt = hashlib.sha256(json.dumps(manifest)).hexdigest()
cmd.extend(['--salt', salt])
cmd.extend(['--image', img_file])
RunCommand(cmd, args.verbose)
@@ -296,7 +300,7 @@ def CreateApex(args, work_dir):
if args.verbose:
print('Creating AndroidManifest ' + android_manifest_file)
with open(android_manifest_file, 'w+') as f:
- f.write(PrepareAndroidManifest(manifest_apex.package_name, manifest_apex.version_number))
+ f.write(PrepareAndroidManifest(package_name, version_number))
# copy manifest to the content dir so that it is also accessible
# without mounting the image