'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
42 lines
1.3 KiB
Python
42 lines
1.3 KiB
Python
# Copyright 2017 - The Android Open Source Project
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
"""Image-related utilities."""
|
|
|
|
import logging
|
|
|
|
from gsi_util.utils.cmd_utils import run_command
|
|
|
|
|
|
def unsparse(output_filename, input_filename):
|
|
logging.debug('Unsparsing %s...', input_filename)
|
|
run_command(['simg2img', input_filename, output_filename])
|
|
|
|
|
|
def mount(mount_point, image_filename):
|
|
logging.debug('Mounting...')
|
|
run_command(
|
|
['mount', '-t', 'ext4', '-o', 'loop', image_filename, mount_point],
|
|
sudo=True)
|
|
|
|
|
|
def unmount(mount_point):
|
|
logging.debug('Unmounting...')
|
|
run_command(['umount', '-l', mount_point], sudo=True, raise_on_error=False)
|
|
|
|
|
|
def copy_file(dest, src):
|
|
run_command(['cp', src, dest], sudo=True)
|
|
# This is a hack to give access permission without root
|
|
run_command(['chmod', '+444', dest], sudo=True)
|