Commit Graph

44 Commits

Author SHA1 Message Date
Howard Chen
f3e1facf7f Fix incorrect prebuilt-info.txt
The 8351194 has a kernel-build-id=8339614 in the prebuilt-info.txt.
This value is incorrect and should be 8350305. Fix this issue by
get the build id from artifact.

Bug: 198363484
Test: development/gsi/build_with_kernel/repack_kernels.sh aarch64
Change-Id: I4c0fd6273df4a794b7dddb5346d182e7fc91adf4
2022-03-25 13:00:16 +08:00
SzuWei Lin
887386c263 Output system_dlkm_staging_archive.tar.gz to dist folder
Bug: 223726390
Test: TH
Change-Id: Iba067ad36ce2ce1f05035d39fb6eb2730880a436
2022-03-14 10:24:04 +08:00
SzuWei Lin
20a24006ec Output system_dlkm.img to dist folder
Bug: 223726390
Test: TH
Change-Id: I7a03162dfb7770381c8465a279379b3fa5dfed84
2022-03-10 17:34:14 +08:00
Howard Chen
2b79b9da13 Add script to update the 5.15 kernel build chaining
This is for the aos-master-boot branch to support
android13-5.15 development.

Bug: 198363484
Bug: 216409649
Test: \
  ./development/gsi/build_with_kernel/fetch_kernels.sh \
  ./development/gsi/build_with_kernel/repack_kernels.sh \
  ./development/gsi/build_with_kernel/update_kernel_prebuilts_515_arm64.sh

Change-Id: Ieadd5a0f8cc6a3e4b654973b2b8844dee2ec0763
2022-02-22 17:43:33 +08:00
Howard Chen
56bfe956a4 Pack all boot images in a zip for certification
The certification script accepts one single zip file as its input.

Bug: 198363484
Test: \
  make bootimage dist && \
  ./development/gsi/build_with_kernel/pack_boot_for_signing.sh
Change-Id: Ia0289979400ea23196449c34865540309bf1e19b
2022-01-05 10:02:22 +08:00
Inseob Kim
54d873122b Remove gsi_util
It doesn't seem to be used nowadays.

Bug: 210536608
Test: presubmit
Change-Id: Ide57b8fb08f6c08302aa1202a59bd33bdc6b1c53
2021-12-21 15:54:38 +09:00
Howard Chen
8187c23b38 Update kernel prebuilts with local artifacts
Bug: 198363484
Test: \
  development/gsi/build_with_kernel/fetch_kernel.sh && \
  development/gsi/build_with_kernel/repack_kernels.sh && \
  development/gsi/build_with_kernel/update_kernel_prebuilts_510_arm64.sh

Change-Id: I88e167be7aff70ff52abee875997d8e9a5c51e79
2021-12-16 08:34:14 +00:00
Howard Chen
4cd02dc116 Avoid to use make directly
Buildbot does not allow script to call make directly.

Test: ./development/gsi/build_with_kernel/repack_kernels.sh
Bug: 198363484
Change-Id: Ia24cae56af27c6c73327002ebbed2c067c490851
2021-11-12 06:36:17 +00:00
Howard Chen
ca961096fc Deprecate prebuilts/misc/linux-x86/lz4/lz4
Replace prebuilts/misc/linux-x86/lz4/lz4 with external/lz4.

Test: \
  development/gsi/build_with_kernel/fetch_kernel.sh \
  development/gsi/build_with_kernel/repack_kernels.sh
Bug: 205492988

Change-Id: Ic22e6ea7cc68b45761b963ea3c41fd099ea29bc9
2021-11-08 04:03:38 +00:00
Howard Chen
35b6f96567 Change android12-5.10 to android13-5.10
The aosp/master is using android13-5.10 for T.
The fetch_kernel.sh is for testing.

Bug: 198363484
Test: \
  development/gsi/build_with_kernel/fetch_kernel.sh && \
  development/gsi/build_with_kernel/repack_kernels.sh && \
  development/gsi/build_with_kernel/kernel_info_to_dist.sh

Change-Id: Iad16792312ba3dad8b3352534ecc3e184afc71cb
2021-11-01 09:07:13 +00:00
SzuWei Lin
29cceb796f Add building with kernel helper scripts
This scripts are for building GSI targets with prebuilt kernel
binaries. The kernel binaries are from a kernel build on AndroidCI,
or the build chaining on build server.

download_kernels_prebults.sh
  For local testing the build chaining with kernel prebuilt binaries.
  Downloads the kernel prebuilts binaries from AndroidCI with the
  build ID in the file `bid`.

kernel_info_to_dist.sh
  A postprocessing script to download the kernel prebuilt binaries
  and debugging information from AndroidCI, and output to dist folder.

repack_kernel(_x86_64).sh
  The preprocessing helper scripts for build chaining with kernel
  prebuilt binaries.

Bug: 196916063
Test: na
Change-Id: I081585d20f8d4a4e3cf135a1447775a8562d6fae
2021-09-23 13:17:40 +08:00
SzuWei Lin
70743f3355 Revert "Define some symlinks for workaround solutions"
This reverts commit 18f2cb7506.

Reason for revert: Workaround reason is gone.

Change-Id: I3c8217c6d6063dfd5ff39ba6e263e10bd4c21e40
2021-03-19 07:03:49 +00:00
SzuWei Lin
18f2cb7506 Define some symlinks for workaround solutions
Bug: 181614552
Test: n/a
Change-Id: I6a63df5807ff8f4301f4091d63d9d221c7c81d3b
2021-03-16 17:24:25 +08:00
SzuWei Lin
6008e0ff3a Merge "Add empty.mk" 2021-03-15 10:53:12 +00:00
SzuWei Lin
061d91766a Add empty.mk
Bug: 181614552
Test: n/a
Change-Id: Ib624af5b230d4627476e38e62ba8389e19d357da
2021-03-15 16:57:08 +08:00
Bob Badour
f7cf305656 [LSC] Add LOCAL_LICENSE_KINDS to development
Added SPDX-license-identifier-Apache-2.0 to:
  apps/BluetoothDebug/Android.bp
  apps/BuildWidget/Android.bp
  apps/CustomLocale/Android.bp
  apps/DevelopmentSettings/Android.bp
  apps/Fallback/Android.bp
  apps/GestureBuilder/Android.bp
  apps/NinePatchLab/Android.bp
  apps/OBJViewer/Android.bp
  apps/PushApiAuthenticator/Android.bp
  apps/PushApiTestAppOne/Android.bp
  apps/PushApiTestAppTwo/Android.bp
  apps/SdkSetup/Android.bp
  apps/SettingInjectorSample/Android.bp
  apps/WidgetPreview/Android.bp
  apps/launchperf/Android.bp
  cmds/monkey/Android.mk
  gsi/gsi_util/Android.bp
  gsi/repack_super_image/Android.bp
  host/windows/Android.bp
  python-packages/Android.bp
  samples/AccelerometerPlay/Android.bp
  samples/AdaptiveIconSample/Android.bp
  samples/AliasActivity/Android.bp
  samples/AndroidBeamDemo/Android.bp
  samples/AppNavigation/Android.bp
  samples/AutofillKeyboard/Android.bp
  samples/BackupRestore/Android.bp
  samples/BasicGLSurfaceView/Android.bp
  samples/BluetoothChat/Android.bp
  samples/BrokenKeyDerivation/Android.bp
  samples/BrokenKeyDerivation/tests/Android.bp
  samples/BusinessCard/Android.bp
  samples/Compass/Android.bp
  samples/ContactManager/Android.bp
  samples/CubeLiveWallpaper/Android.bp
  samples/DataWiper/Android.bp
  samples/DeviceAdminWhitelistedAccount/Android.bp
  samples/FixedGridLayout/Android.bp
  samples/HeavyWeight/Android.bp
  samples/HelloActivity/Android.bp
  samples/HelloActivity/tests/Android.bp
  samples/HelloEffects/Android.bp
  samples/Home/Android.bp
  samples/HoneycombGallery/Android.bp
  samples/InlineFillService/Android.bp
  samples/JetBoy/Android.bp
  samples/LceDemo/Android.bp
  samples/LunarLander/Android.bp
  samples/LunarLander/tests/Android.bp
  samples/MultiResolution/Android.bp
  samples/MultiWindow/Android.bp
  samples/MySampleRss/Android.bp
  samples/NotePad/Android.bp
  samples/Obb/Android.bp
  samples/RSSReader/Android.bp
  samples/ReceiveShareDemo/Android.bp
  samples/SampleSyncAdapter/Android.bp
  samples/SimpleJNI/Android.bp
  samples/SimpleJNI/jni/Android.bp
  samples/SipDemo/Android.bp
  samples/SkeletonApp/Android.bp
  samples/SkeletonApp/tests/Android.bp
  samples/Snake/Android.bp
  samples/Snake/tests/Android.bp
  samples/SoftKeyboard/Android.bp
  samples/SpellChecker/HelloSpellChecker/Android.bp
  samples/SpellChecker/SampleSpellCheckerService/Android.bp
  samples/StackWidget/Android.bp
  samples/ThemedNavBarKeyboard/Android.bp
  samples/ToyVpn/Android.bp
  samples/TtsEngine/Android.bp
  samples/USB/AdbTest/Android.bp
  samples/USB/MissileLauncher/Android.bp
  samples/UiAutomator/Android.mk
  samples/Vault/Android.bp
  samples/Vault/tests/Android.bp
  samples/VoiceRecognitionService/Android.bp
  samples/VoicemailProviderDemo/Android.bp
  samples/WeatherListWidget/Android.bp
  samples/WiFiDirectDemo/Android.bp
  samples/WiFiDirectServiceDiscovery/Android.bp
  samples/Wiktionary/Android.bp
  samples/WiktionarySimple/Android.bp
  samples/XmlAdapters/Android.bp
  samples/apkcachetest/Android.bp
  samples/training/NsdChat/Android.bp
  scripts/Android.bp
  testrunner/Android.mk
  testrunner/tests/Android_native.mk
  tools/apkcheck/Android.bp
  tools/bugreport/Android.bp
  tools/etc1tool/Android.bp
  tools/idegen/Android.bp
  tools/mkstubs/Android.bp
  tools/rmtypedefs/Android.bp
  vndk/Android.bp
  vndk/tools/Android.bp
  vndk/tools/elfcheck/Android.bp
  vndk/tools/header-checker/Android.bp
  vndk/tools/header-checker/src/repr/protobuf/proto/Android.bp
  vndk/tools/header-checker/tests/integration/ifunc/Android.bp
  vndk/tools/header-checker/tests/integration/version_script_example/Android.bp
  vndk/tools/image-diff-tool/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD
    SPDX-license-identifier-CPL-1.0 SPDX-license-identifier-MIT
    SPDX-license-identifier-Unicode-DFS SPDX-license-identifier-W3C
    legacy_restricted legacy_unencumbered
to:
  Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-CPL-1.0
to:
  samples/SearchableDictionary/Android.bp

Added SPDX-license-identifier-Apache-2.0 legacy_unencumbered
to:
  tools/Android.bp

Added SPDX-license-identifier-BSD SPDX-license-identifier-CPL-1.0
    SPDX-license-identifier-MIT SPDX-license-identifier-Unicode-DFS
    SPDX-license-identifier-W3C
to:
  sdk/Android.bp

Added legacy_restricted
to:
  samples/KeyChainDemo/Android.bp
  tools/line_endings/Android.bp
  vndk/tools/definition-tool/datasets/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all

Exempt-From-Owner-Approval: janitorial work
Change-Id: I9847e00fb4278bc083b4debbc751003c995ea45c
2021-02-12 17:13:45 -08:00
Hsin-Yi Chen
3e8b7f96d8 Support repacking super image with virtual AB
Bug: 155702857
Test: repack_super_image --ota-tools ./otatools.zip \
      --misc-info ./misc_info.txt ./super.img product= \
      system=system.img
Change-Id: I03f33969d3c033a47cf123f94d875a4b56d2d343
2020-05-06 16:48:13 +08:00
Yo Chiang
95a6da9cf3 gsi-pubsign-release.sh: Add copyright notice
Bug: 149803895
Test: manual
Merged-In: I7208b928fd13ede982a06205badeb4800d5cbb85
Change-Id: I7208b928fd13ede982a06205badeb4800d5cbb85
(cherry picked from commit 06cc62e141)
2020-03-09 17:07:45 +08:00
Treehugger Robot
e0505bfec4 Merge changes Ide2ae854,I71ca710e,I90a80a7a,I05e82f06
* changes:
  gsi-pubsign-release.sh follows symbolic link
  gsi-pubsign-release.sh print verbose log
  Fix gsi-pubsign-release.sh rsync command
  Add script for gsi_pubsign build chaining target
2020-03-02 05:52:16 +00:00
Yo Chiang
5b8373d7b9 gsi-pubsign-release.sh follows symbolic link
Use `find -L` and `cp --dereference` to follow symlinks.

Bug: 149803895
Test: manual
Merged-In: Ide2ae854dd61e595ca2676634f660241343e6dba
Change-Id: Ide2ae854dd61e595ca2676634f660241343e6dba
(cherry picked from commit abdcbb3f83)
2020-03-02 02:47:22 +00:00
Yo Chiang
f2c04ff675 gsi-pubsign-release.sh print verbose log
Bug: 149803895
Test: ./gsi-pubsign-release.sh aosp_arm64 aosp_arm64_pubsign \
        aosp_arm64-artifact_path aosp_arm64_pubsign-artifact_path
Merged-In: I71ca710e3d2d7305112e118e8d19c3b07d6f028c
Change-Id: I71ca710e3d2d7305112e118e8d19c3b07d6f028c
(cherry picked from commit fe9bb151c0)
2020-03-02 02:47:14 +00:00
Yo Chiang
7d0189a6ec Fix gsi-pubsign-release.sh rsync command
Add trailing / to rsync source directory, this prevents rsync from
creating an additional level of directory under the destination.

For example, if `tree src` outputs:
  src
  └── file

then:
$ rsync src dest   # creates dest/src/file
$ rsync src/ dest  # creates dest/file

Bug: 149803895
Test: ./gsi-pubsign-release.sh aosp_arm64 aosp_arm64_pubsign \
        aosp_arm64-artifact_path aosp_arm64_pubsign-artifact_path

Merged-In: I90a80a7afdf6f71db592599c6a645554cf830309
Change-Id: I90a80a7afdf6f71db592599c6a645554cf830309
(cherry picked from commit 8b15a8ba3c)
2020-03-02 02:45:45 +00:00
Yo Chiang
12d2ae00ea Add script for gsi_pubsign build chaining target
Bug: 149803895
Test: ./gsi-pubsign-release.sh aosp_arm64 aosp_arm64_pubsign \
        aosp_arm64-artifact_path aosp_arm64_pubsign-artifact_path

Merged-In: I05e82f0605eec33c0da9b5a5d5cbf3506af3706c
Change-Id: I05e82f0605eec33c0da9b5a5d5cbf3506af3706c
(cherry picked from commit 45c81a65e7)
2020-03-02 10:38:54 +08:00
Hsin-Yi Chen
a39f294116 Remove embedded launcher from repack_super_image
The launcher has dependency on libc++.so which isn't available on the
test server. This commit disables embedded_launcher so that the script
is interpreted by the python3 installed on the OS.

Test: repack_super_image outside of build environment
Bug: 148839595
Change-Id: Ic49cac9c6f5c67bde58ac3272213b3bebc54a73e
2020-02-28 15:25:49 +08:00
Hsin-Yi Chen
20ddc6d248 Add repack_super_image
Bug: 148839595
Test: make dist gsi_utils
Test: repack_super_image \
      --ota-tools $ANDROID_PRODUCT_OUT/otatools.zip \
      --misc-info ./misc_info.txt \
      ./super.img product= \
      system=$ANDROID_PRODUCT_OUT/system.img
Change-Id: I29ff8c6f0e117d3b42cc975929bd0a0823136bc9
2020-02-26 14:10:37 +08:00
Bowgo Tsai
7cca5c35f3 Add OWNERS file for development/gsi
Bug: None
Test: None
Change-Id: I0508163b0e61dbd11c5730ab83b028d2651cba5a
2018-09-18 11:31:19 +08:00
SzuWei Lin
a3424fde0b gsi_util: try to use executable in local bin/ folder
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
2018-03-22 15:26:04 +08:00
SzuWei Lin
bdcbc69cb0 gsi_util: output verbose logs in debug mode only
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
2018-03-19 15:12:29 +08:00
SzuWei Lin
e643431019 gsi_util: add more dump infos
Inlcudes:

- system_fingerprint (instead of system_build_id),
- system_vndk_ver
- vendor_vndk_ver
- vendor_security_patch_level
- vendor_oem_unlock_supported
- vendor_adb_secure

Bug: 70253764
Test: './gsi_util.py dump --system adb --vendor adb' on a device
Change-Id: I7362729908cb75ac5a210ce9abbb233872e51b86
2018-03-15 16:45:11 +08:00
SzuWei Lin
d7fdfa181e Fix system-as-root detection on Pi
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
2018-02-23 17:18:32 +08:00
SzuWei Lin
e6a22f3ca5 Support mounting the odm image
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
2018-02-01 15:09:40 +08:00
Bowgo Tsai
3128bff672 gsi_util: adds sepolicy_checker
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
2018-01-31 20:07:28 +08:00
Bowgo Tsai
97a65926d2 gsi_util: refactors Checker and VintfChecker
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
2018-01-31 18:47:27 +08:00
SzuWei Lin
c1496d986e Remove root permission requirement
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
2018-01-29 18:58:59 +08:00
SzuWei Lin
a07883696e Revise code of gsi_util help
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
2018-01-29 14:31:17 +08:00
Bowgo Tsai
b43a5c9f48 gsi_util: removing 'gsi_util hello'
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
2018-01-18 17:19:52 +08:00
SzuWei Lin
50e7f6c301 gsi_util: add build.py to build and pack gsi_util
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
2018-01-15 17:36:12 +08:00
SzuWei Lin
a30d9ef26b gsi_util: adding check_compat subcommand
'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
2018-01-15 17:35:58 +08:00
SzuWei Lin
18d5e919fe gsi_util: adding dump subcommand
'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
2018-01-15 16:01:14 +08:00
SzuWei Lin
e3658bd0c1 gsi_util: adding pull subcommand
'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
2018-01-12 11:48:50 +08:00
Bowgo Tsai
b510ae3a33 gsi_util: adding flash_gsi subcommand
This change implements the flash_gsi subcommand:
  1. Erase userdata/cache partition
  2. Erase metadata partition (optional)
  3. Flash generic system image
  4. Disable Android Verified Boot (optional)
  5. Reboot the device

Bug: 70253882
Test: make gsi_util
Test: gsi_util flash_gsi
Test: gsi_util --debug flash_gsi --image system.img
Change-Id: I552c04aaf227c6fca2e5c3caab26d713e2f6f5d0
2018-01-03 12:44:10 +08:00
Bowgo Tsai
ac3ee581a8 gsi_util: adding file-related utilities (file_utils)
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
2018-01-03 12:40:20 +08:00
Bowgo Tsai
a1f4058845 gsi_util: adding cmd_utils
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
2017-12-29 17:11:27 +08:00
Bowgo Tsai
73fec9375d gsi_util: adding subcommand framework
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
2017-12-28 17:11:40 +08:00