cmd_utils.run_command() will try to find the executable file
in the local bin/ folder firstly.
The patch also add some missing dependency files and make sure
gsi_util could run alone.
Bug: 75992357
Test: ./run_test.py
Test: './build.py setup_env',
then './gsi_util.bin check_compat --system adb --vendor adb' in
another terminal without lunch
Change-Id: I923eb68b4a6829c8ed5e5d8278e97fd4f5860efc
Each Mounter outputs an error log if it cannot prepare a file,
but it could be not really an error sometimes. For example,
some files in sepolicy_checker are optional, and could got
the log:
Fail to prepare file: vendor/etc/selinux/vendor_sepolicy.cil
The patch changes these logs to be 'INFO' level.
This patch also changes run_command() to output logs with 'ERROR'
level when log_stdout or log_stderr is True.
Also, the patch changes it to only output stack dump in debug mode.
Bug: 74507280
Bug: 70588453
Test: ./run_test.py
Test: './gsi_util.py dump --system system.img'
and the system.img doesn't exist.
Test: './gsi_util.py check_compat --vendor adb --system adb'
and vendor/etc/selinux/vendor_sepolicy.cil isn't in the device.
Change-Id: Ibdcb6df459f88ace9159f1a979f280452454a84f
From Pi, the manifest.xml had been moved from system folder,
so remove this file from system-as-root detection.
Bug: 73799919
Test: gsi_util dump --system some-aosp_arm64_ab-on-pi.img
Change-Id: I77e024d1200c46eb3bcdf6a853e1e02ae1493f52
Some checkers could read information from odm image. e.g.
sepolicy_checker could also check the compatibility between
system image and odm image. The patch revises the common image source
argument parser and CompositeMounter to support the odm image.
Bug: 72720671
Test: gsi_util pull --odm $OUT/system.img /odm/system/build.prop
Change-Id: I586decaf96640679c7a8e7ec52086d55510fbdeb
The sepolicy checker merges SEPolicy files from /system and
/vendor, /odm as the init process does when the device boots a GSI.
When the merge failed in init, the device will refuse to boot
Android OS and will jump to fastboot mode directly. It needs serial log
for diagnosis.
The action of SEPolicy merge can be done on host side, to do a trial
merge, prior to flash a GSI. The newly added sepolicy_checker is
designed for this.
Bug: 72069105
Test: m gsi_util
Test: gsi_util list_checks, output is 'vintf', 'sepolicy'
Test: gsi_util --debug check_compat --system $OUT/system.img --vendor adb sepolicy
Change-Id: I842067e447b96e2ba124f03f51831cd289f47dc1
This change includes several refactoring:
1. Adds more function/class comments.
2. Renames the fields in namedtuples 'CheckListItem' and 'CheckResultItem'.
3. Fixes the vintf check issue. It should do two checks:
system -> vendor and vendor -> system, instead of one direction.
4. Fixes import statements, should only import module or package name.
5. Use python3-style print() function instead of print statement.
6. Fix the missing 'import errno' in image_mounter.
7. Checks *.py under 'checker' folder can pass 'pylint'.
Disables the check for a given line if it cannot pass.
e.g., pylint: disable=too-few-public-methods
8. Changes 'summary' result from a string 'pass' to '#pass/#total'.
Bug: 70253825
Test: m gsi_util
Test: gsi_util --debug check_compat --system $OUT/system.img --vendor adb
Test: gsi_util --debug check_compat --system $OUT/system.img --vendor $OUT/vendor.img
Test: gsi_util check_compat --only-summary --system $OUT/system --vendor $OUT/vendor
Test: gsi_util --debug check_compat --system adb --vendor adb vintf
Change-Id: Ia08d1fbeee62f62667876b54778489c89e4228a1
The original solution to access the content in an image file is
'mount' which needs root permision. Replaces 'mount' with 'debugfs',
which does not need root permission and will be useful on server
side usage.
Bug: 72027809
Test: ./gsi_util.py pull --system system.img /system/build.prop
Change-Id: I7d6d7b75527cd144d55465353531597afa3baedb
The patch unifies the code of arguments '--vendor' and '--system',
and to be an argument group 'image sources'.
Bug: 64817940
Test: gsi_util.py for each commands and check the output
Change-Id: I591ef4b922f931b7ceaacc362979156ef830a54e
The 'gsi_util hello' is used for a demo initially.
It should be removed as it's not a practical command.
Bug: None
Test: `gsi_util --help`, checks hello command is gone
Change-Id: I8578db27c1ddbc16bba0a1357207ba77bf13390d
There are some command in build.py:
'setup_env' command can build the dependency files and copy these
files to the script.
'build' command also zip the dependency files to a zip file which
could be released independently.
The patch includes a list REQUIRED_ITEMS, which maintains the
source and destination of the dependency files. INCLUDE_FILES
maintains the files to be included to zip file additionally.
Uses 'list_deps' to list all dependency files.
Bug: 70253683
Test: setup_env and build command and check the files
Change-Id: I0b36da4457fdd04f9995cf30aadb26a2e32c1dd8
'check_compat' command can check the compatibility between
system and vendor image, which can be any source supported by
mounters, ex. image file, folder or adb.
Uses following command for the detail:
$ ./gsu_util.py check_compat --help
The patch also includes a 'checker' framework. There is only
one checker 'VintfChecker' at this time. VintfChecker uses a
host tool, 'checkvintf', to check the compatibility.
Bug: 70253825
Test: check_compat with different mounters
Change-Id: I459b4cbd38465c0058087b4c68bca66e491c940e
'dump' command can dump information from given image, which could
be a image file, folder or device by adb.
Use $./gsi_util.py dump --help for the detail.
The patch also includes a "dump" framework, to implement some
dumpers to dump information. This patch also includes PropDumper to
dump information from property files, and XmlDumper to dump
information from XML files.
There is an initial dump info list in dump_info_list.py.
Use subcommand 'list_dump' could output the list.
Usually using Dumper is enough to dump information. dump.py is an
example to use Dumper.
Bug: 70253764
Test: dump from different mounter
Change-Id: I7c05f8f24d44d3c7429f2c428963f64191f49a53
'pull' command can pull a file from an image file, folder or adb.
The patch includes a "mounter" framework to implement different
source of the system/vendor image. And also includes several
"mounter" implementations.
CompositeMounter integrates all possible mounter implementations.
Usually just using CompositeMounter is enough. With
CompositeMounter, you could access files in different target
with an unique interface, such files in an image file, a folder or
a device with an unique interface. pull.py is an basic example to
use CompositeMounter.
Here are some example to use 'pull' command:
$ ./gsi_util.py pull --system adb:AB0123456789 /system/manifest.xml
$ ./gsi_util.py pull --vendor adb /vendor/compatibility_matrix.xml
$ ./gsi_util.py pull --system system.img /system/build.prop
$ ./gsi_util.py pull --system my/out/folder/system /system/build.prop
As current implementation, accessing files in a the image file requires
root permission. gsi_util will need user to input the password for sudo.
For the detail usage, reference:
$ ./gsi_util.py pull --help
Bug: 71029338
Test: pull /system/build.prop from different targets
Change-Id: Iaeb6352c14ebc24860ed79fc30edd314e225aef9
The first function is UnopenedTemporaryFile, which is similar to
tempfile.TemporaryFile, except an unopened file path is returned
instead of an opened file-like object (fd).
Bug: 70253882
Test: make gsi_util
Test: ./run_test.py
Change-Id: I11de6976a31d8612cb873212b31c3f13a79b1b3e
Adding a run_command function to execute a host command.
Also support reading the stdout and/or stderr of the result if desired,
which might be useful for further parsing and flow decision.
A typical usage will be passing a command sequence:
cmd_utils.run_command(['echo', '123'])
It also supports running a 'shell' command, by passing a single string:
cmd_utils.run_command('echo 123', shell=True)
To get the stdout and/or stderr data, just add 'read_stdout=True' and/or
'read_stderr=True':
cmd_utils.run_command('echo 123', shell=True,
read_stdout=True, read_stderr=True),
which returns a namedtuple:
('CommandResult', 'returncode stdoutdata, stderrdata').
Note that other keyword arguments will be passed to subprocess.Popen().
e.g., the following command will change current directory to
'my_working_dir' prior to execute the command:
cmd_utils.run_command('echo 123', shell=True, cwd=my_working_dir)
More usage examples can be found in cmd_utils_unittest.py.
Also adds a run_test.py to search then run ./*tests/*_unittest.py files.
Bug: 70477387
Test: make gsi_util
Test: ./run_test.py
Change-Id: Id3aae935f941818fe7415798937fd07dbbe6ba33
With this CL, new command can be easily added:
1. Add a new file: gsi/gsi_util/gsi_util/commands/hello.py
And implements a function to register parsers into gsi_util's main parser.
def setup_command_args(subparsers)
2. In gsi/gsi_util/gsi_util.py, add the new command into GsiUtil():
_COMMANDS = ['hello']
Bug: 70588453
Test: make gsi_util
Test: gsi_util --help
Test: gsi_util hello --foo
Test: gsi_util --debug hello --bar
Change-Id: I54fa6d1dea5afed724d9ac4a99f88bf78da82732