=== modified file 'linaro_image_tools/media_create/__init__.py'
@@ -18,7 +18,10 @@
# along with Linaro Image Tools. If not, see <http://www.gnu.org/licenses/>.
import argparse
+import subprocess
+import os
+from linaro_image_tools import cmd_runner
from linaro_image_tools.media_create.boards import board_configs
from linaro_image_tools.media_create.android_boards import android_board_configs
from linaro_image_tools.__version__ import __version__
@@ -46,9 +49,26 @@
setattr(namespace, 'is_live', True)
+def get_version():
+ qemu_path = '/usr/bin/qemu-arm-static'
+ p = cmd_runner.run(["head", "-n", "1"],
+ stdin=subprocess.PIPE, stdout=subprocess.PIPE)
+ if os.path.exists(qemu_path):
+ try:
+ # qemu-arm-static has no --version option so it fails,
+ # but still prints its version plus usage
+ cmd_runner.run(["/usr/bin/qemu-arm-static", "--version"],
+ stdout=p.stdin).communicate()
+ p.communicate()
+ except:
+ qemu_version = p.stdout.read()
+ else:
+ qemu_version = "Cannot find %s." % qemu_path
+ return "%s\n: %s" % (__version__, qemu_version)
+
def get_args_parser():
"""Get the ArgumentParser for the arguments given on the command line."""
- parser = argparse.ArgumentParser(version='%(prog)s ' + __version__)
+ parser = argparse.ArgumentParser(version='%(prog)s ' + get_version())
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument(
'--mmc', dest='device', help='The storage device to use.')
@@ -129,7 +149,7 @@
def get_android_args_parser():
"""Get the ArgumentParser for the arguments given on the command line."""
- parser = argparse.ArgumentParser(version='%(prog)s ' + __version__)
+ parser = argparse.ArgumentParser(version='%(prog)s ' + get_version())
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument(
'--mmc', dest='device', help='The storage device to use.')