diff options
| author | 2022-03-28 09:44:33 +0000 | |
|---|---|---|
| committer | 2022-03-28 09:44:33 +0000 | |
| commit | 1df464a90b0f58a9d2baceec656c48ec7f6453e9 (patch) | |
| tree | b4def10988ce8df06bf8b6acc804eaef203fb027 | |
| parent | b3a3a2893be440da609db17ef0a93ebf0fcc30bd (diff) | |
Revert "Add a tool to list contents of .img file"
Revert submission 2041990-microdroid-contents
Reason for revert: b/227144320 (broken build)
Reverted Changes:
Ie2f471d39:Add the golden list of microdroid contents
I7c4fca184:Add a tool to list contents of .img file
Change-Id: If2b5d6cb1325cb17ef2bdc4f13ded003ab2dd6d7
| -rw-r--r-- | scripts/Android.bp | 8 | ||||
| -rw-r--r-- | scripts/list_image.py | 103 |
2 files changed, 0 insertions, 111 deletions
diff --git a/scripts/Android.bp b/scripts/Android.bp index a694b953b..4c847a121 100644 --- a/scripts/Android.bp +++ b/scripts/Android.bp @@ -188,11 +188,3 @@ python_binary_host { "get_clang_version.py", ], } - -python_binary_host { - name: "list_image", - main: "list_image.py", - srcs: [ - "list_image.py", - ], -} diff --git a/scripts/list_image.py b/scripts/list_image.py deleted file mode 100644 index 7f76537f4..000000000 --- a/scripts/list_image.py +++ /dev/null @@ -1,103 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (C) 2022 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. -"""list_image is a tool that prints out content of an .img file. - -To print content of an image to stdout: - list_image foo.img -""" -from __future__ import print_function - -import argparse -import os -import sys -import subprocess - -class ImageEntry(object): - - def __init__(self, name, base_dir, is_directory=False): - self._name = name - self._base_dir = base_dir - self._is_directory = is_directory - - @property - def name(self): - return self._name - - @property - def full_path(self): - return os.path.join(self._base_dir, self._name) - - @property - def is_directory(self): - return self._is_directory - - -class Image(object): - - def __init__(self, debugfs_path, img_path): - self._debugfs = debugfs_path - self._img_path = img_path - - def list(self, path): - print(path) - process = subprocess.Popen([self._debugfs, '-R', 'ls -l -p %s' % path, self._img_path], - stdout=subprocess.PIPE, stderr=subprocess.PIPE, - universal_newlines=True) - stdout, _ = process.communicate() - res = str(stdout) - entries = [] - for line in res.split('\n'): - if not line: - continue - parts = line.split('/') - if len(parts) != 8: - continue - name = parts[5] - if not name: - continue - bits = parts[2] - is_directory = bits[1] == '4' - entries.append(ImageEntry(name, path, is_directory)) - - for e in sorted(entries, key=lambda e: e.name): - yield e - if e.is_directory and e.name != '.' and e.name != '..': - yield from self.list(path + e.name + '/') - - -def main(argv): - parser = argparse.ArgumentParser() - - debugfs_default = None - if 'ANDROID_HOST_OUT' in os.environ: - debugfs_default = '%s/bin/debugfs_static' % os.environ['ANDROID_HOST_OUT'] - parser.add_argument('--debugfs_path', help='The path to debugfs binary', default=debugfs_default) - parser.add_argument('img_path', type=str, help='.img file') - args = parser.parse_args(argv) - - if not args.debugfs_path: - print('ANDROID_HOST_OUT environment variable is not defined, --debugfs_path must be set', - file=sys.stderr) - sys.exit(1) - - for e in Image(args.debugfs_path, args.img_path).list('./'): - if e.is_directory: - continue - print(e.full_path) - - -if __name__ == '__main__': - main(sys.argv[1:]) |