3 # Copyright (C) 2012 The Android Open Source Project
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
21 from hashlib import sha1
23 from sha import sha as sha1
32 if line.startswith("require"):
33 key, value = line.split()[1].split("=", 1)
34 build_info[key] = value
39 for item in sys.argv[2:]:
40 key, fn = item.split(":", 1)
42 values = build_info.get(key, None)
45 values = values.split("|")
48 digest = sha1(f.read()).hexdigest()
53 f = open(fn + ".sha1")
56 print "*** Error opening \"%s.sha1\"; can't verify %s" % (fn, key)
61 if not line or line.startswith("#"): continue
65 if digest not in versions:
67 print "*** SHA-1 hash of \"%s\" doesn't appear in \"%s.sha1\"" % (fn, fn)
71 if versions[digest] not in values:
73 print "*** \"%s\" is version %s; not any %s allowed by \"%s\"." % (
74 fn, versions[digest], key, sys.argv[1])