diff options
author | Jooyung Han <jooyung@google.com> | 2019-11-02 02:47:22 +0900 |
---|---|---|
committer | Jooyung Han <jooyung@google.com> | 2019-11-08 15:06:35 +0900 |
commit | cd4d81e0766ba8fbe568ff6928b433241b567a7e (patch) | |
tree | e7f90ccb7764d00964b84df4d82fa41a7882ca8c /apexer/apex_manifest.py | |
parent | b1b081f2cb8c99d7804f01c3adcb1412d0c49147 (diff) |
apexer: add apex_manifest.pb
apexer adds apex_manifest.pb as well as Q-compatible json and R+ json.
apexd on Q can't understand newly added properties in
apex_manifest.json, which prevents from installed APEX packages built
with new properties.
apexer accepts three of apex_mainfest(.json, _full.json, .pb) from
commandline, and then put them in the apex container and image in it.
Bug: 143654022
Test: m -j
Change-Id: I8752b0c21af747be6fc5c3a04d1cb114d789c77e
Diffstat (limited to 'apexer/apex_manifest.py')
-rw-r--r-- | apexer/apex_manifest.py | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/apexer/apex_manifest.py b/apexer/apex_manifest.py index 290924e..b2f08e5 100644 --- a/apexer/apex_manifest.py +++ b/apexer/apex_manifest.py @@ -14,11 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -import json import apex_manifest_pb2 -from google.protobuf.json_format import Parse -from google.protobuf.json_format import ParseError - +from google.protobuf import message class ApexManifestError(Exception): @@ -27,12 +24,12 @@ class ApexManifestError(Exception): self.errmessage = errmessage -def ValidateApexManifest(manifest_raw): +def ValidateApexManifest(file): try: - manifest_json = json.loads(manifest_raw) - manifest_pb = Parse( - json.dumps(manifest_json), apex_manifest_pb2.ApexManifest()) - except (ParseError, ValueError) as err: + with open(file, "rb") as f: + manifest_pb = apex_manifest_pb2.ApexManifest() + manifest_pb.ParseFromString(f.read()) + except message.DecodeError as err: raise ApexManifestError(err) # Checking required fields if manifest_pb.name == "": |