Merge "Convert check_radio_versions to python3"
This commit is contained in:
commit
afa0bd4717
3 changed files with 28 additions and 13 deletions
|
@ -19,8 +19,11 @@ board_info_txt := $(TARGET_BOARD_INFO_FILE)
|
||||||
ifndef board_info_txt
|
ifndef board_info_txt
|
||||||
board_info_txt := $(wildcard $(TARGET_DEVICE_DIR)/board-info.txt)
|
board_info_txt := $(wildcard $(TARGET_DEVICE_DIR)/board-info.txt)
|
||||||
endif
|
endif
|
||||||
$(INSTALLED_ANDROID_INFO_TXT_TARGET): $(board_info_txt) build/make/tools/check_radio_versions.py
|
CHECK_RADIO_VERSIONS := $(HOST_OUT_EXECUTABLES)/check_radio_versions$(HOST_EXECUTABLE_SUFFIX)
|
||||||
$(hide) build/make/tools/check_radio_versions.py $< $(BOARD_INFO_CHECK)
|
$(INSTALLED_ANDROID_INFO_TXT_TARGET): $(board_info_txt) $(CHECK_RADIO_VERSIONS)
|
||||||
|
$(hide) $(CHECK_RADIO_VERSIONS) \
|
||||||
|
--board_info_txt $(board_info_txt) \
|
||||||
|
--board_info_check $(BOARD_INFO_CHECK)
|
||||||
$(call pretty,"Generated: ($@)")
|
$(call pretty,"Generated: ($@)")
|
||||||
ifdef board_info_txt
|
ifdef board_info_txt
|
||||||
$(hide) grep -v '#' $< > $@
|
$(hide) grep -v '#' $< > $@
|
||||||
|
|
|
@ -54,3 +54,8 @@ cc_binary_host {
|
||||||
name: "build-runfiles",
|
name: "build-runfiles",
|
||||||
srcs: ["build-runfiles.cc"],
|
srcs: ["build-runfiles.cc"],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
python_binary_host {
|
||||||
|
name: "check_radio_versions",
|
||||||
|
srcs: ["check_radio_versions.py"],
|
||||||
|
}
|
||||||
|
|
|
@ -22,11 +22,18 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from sha import sha as sha1
|
from sha import sha as sha1
|
||||||
|
|
||||||
if len(sys.argv) < 2:
|
import argparse
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument("--board_info_txt", nargs="?", required=True)
|
||||||
|
parser.add_argument("--board_info_check", nargs="*", required=True)
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
if not args.board_info_txt:
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
build_info = {}
|
build_info = {}
|
||||||
f = open(sys.argv[1])
|
f = open(args.board_info_txt)
|
||||||
for line in f:
|
for line in f:
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
if line.startswith("require"):
|
if line.startswith("require"):
|
||||||
|
@ -36,7 +43,7 @@ f.close()
|
||||||
|
|
||||||
bad = False
|
bad = False
|
||||||
|
|
||||||
for item in sys.argv[2:]:
|
for item in args.board_info_check:
|
||||||
key, fn = item.split(":", 1)
|
key, fn = item.split(":", 1)
|
||||||
|
|
||||||
values = build_info.get(key, None)
|
values = build_info.get(key, None)
|
||||||
|
@ -52,8 +59,8 @@ for item in sys.argv[2:]:
|
||||||
try:
|
try:
|
||||||
f = open(fn + ".sha1")
|
f = open(fn + ".sha1")
|
||||||
except IOError:
|
except IOError:
|
||||||
if not bad: print
|
if not bad: print()
|
||||||
print "*** Error opening \"%s.sha1\"; can't verify %s" % (fn, key)
|
print("*** Error opening \"%s.sha1\"; can't verify %s" % (fn, key))
|
||||||
bad = True
|
bad = True
|
||||||
continue
|
continue
|
||||||
for line in f:
|
for line in f:
|
||||||
|
@ -63,17 +70,17 @@ for item in sys.argv[2:]:
|
||||||
versions[h] = v
|
versions[h] = v
|
||||||
|
|
||||||
if digest not in versions:
|
if digest not in versions:
|
||||||
if not bad: print
|
if not bad: print()
|
||||||
print "*** SHA-1 hash of \"%s\" doesn't appear in \"%s.sha1\"" % (fn, fn)
|
print("*** SHA-1 hash of \"%s\" doesn't appear in \"%s.sha1\"" % (fn, fn))
|
||||||
bad = True
|
bad = True
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if versions[digest] not in values:
|
if versions[digest] not in values:
|
||||||
if not bad: print
|
if not bad: print()
|
||||||
print "*** \"%s\" is version %s; not any %s allowed by \"%s\"." % (
|
print("*** \"%s\" is version %s; not any %s allowed by \"%s\"." % (
|
||||||
fn, versions[digest], key, sys.argv[1])
|
fn, versions[digest], key, args.board_info_txt))
|
||||||
bad = True
|
bad = True
|
||||||
|
|
||||||
if bad:
|
if bad:
|
||||||
print
|
print()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
Loading…
Reference in a new issue