%global _empty_manifest_terminate_build 0 Name: python-PySquashfsImage Version: 0.8.0 Release: 1 Summary: Squashfs image parser License: GNU Library or Lesser General Public License (LGPL) URL: https://github.com/matteomattei/PySquashfsImage Source0: https://mirrors.nju.edu.cn/pypi/web/packages/7f/0d/5f1a6b44c13029d7e6d7fc4f76709f69476e91c194e76c4ae1de34656558/PySquashfsImage-0.8.0.linux-x86_64.tar.gz BuildArch: noarch %description PySquashfsImage is a lightweight library for reading squashfs image files in Python. It provides a way to read squashfs images header and to retrieve encapsulated binaries. It is compatible with Python 2.6, 2.7 and Python 3.1+. ## Installation ``` pip install PySquashfsImage ``` If you are using Python <= 3.2 and need LZMA decompression, install [backports.lzma](https://pypi.org/project/backports.lzma/). For LZ4 decompression, install [lz4](https://pypi.org/project/lz4/) (Python 3.7+). For Zstandard decompression install [zstandard](https://pypi.org/project/zstandard/) (Python 3.7+). ## Use as a library ### List all elements in the image: ```python from PySquashfsImage import SquashFsImage image = SquashFsImage('/path/to/my/image.img') for item in image.root.find_all(): print(item.name) image.close() ``` ### Print all files and folder with human readable path: ```python from PySquashfsImage import SquashFsImage image = SquashFsImage('/path/to/my/image.img') for path in image.root.find_all_paths(): print(path) image.close() ``` ### Print only files: ```python from PySquashfsImage import SquashFsImage image = SquashFsImage('/path/to/my/image.img') for item in image.root.find_all(): if not item.is_dir: print(item.path) image.close() ``` ### Save the content of a file: ```python from PySquashfsImage import SquashFsImage image = SquashFsImage('/path/to/my/image.img') for item in image.root.find_all(): if item.name == 'myfilename': with open('/tmp/' + item.name, 'wb') as f: print('Saving original ' + item.path + ' in /tmp/' + item.name) f.write(item.read_bytes()) image.close() ``` ## Use as a command ``` $ pysquashfsimage -h usage: pysquashfsimage [-h] [-V] file paths [paths ...] positional arguments: file squashfs filesystem paths directories or files to print information about options: -h, --help show this help message and exit -V, --version show program's version number and exit ``` For each path, if it is a directory it will print the mode and name of each contained file, with sizes and symlinks. If a path is a file, print its content. Example command: ``` $ pysquashfsimage myimage.img /bin /etc/passwd ``` %package -n python3-PySquashfsImage Summary: Squashfs image parser Provides: python-PySquashfsImage BuildRequires: python3-devel BuildRequires: python3-setuptools BuildRequires: python3-pip %description -n python3-PySquashfsImage PySquashfsImage is a lightweight library for reading squashfs image files in Python. It provides a way to read squashfs images header and to retrieve encapsulated binaries. It is compatible with Python 2.6, 2.7 and Python 3.1+. ## Installation ``` pip install PySquashfsImage ``` If you are using Python <= 3.2 and need LZMA decompression, install [backports.lzma](https://pypi.org/project/backports.lzma/). For LZ4 decompression, install [lz4](https://pypi.org/project/lz4/) (Python 3.7+). For Zstandard decompression install [zstandard](https://pypi.org/project/zstandard/) (Python 3.7+). ## Use as a library ### List all elements in the image: ```python from PySquashfsImage import SquashFsImage image = SquashFsImage('/path/to/my/image.img') for item in image.root.find_all(): print(item.name) image.close() ``` ### Print all files and folder with human readable path: ```python from PySquashfsImage import SquashFsImage image = SquashFsImage('/path/to/my/image.img') for path in image.root.find_all_paths(): print(path) image.close() ``` ### Print only files: ```python from PySquashfsImage import SquashFsImage image = SquashFsImage('/path/to/my/image.img') for item in image.root.find_all(): if not item.is_dir: print(item.path) image.close() ``` ### Save the content of a file: ```python from PySquashfsImage import SquashFsImage image = SquashFsImage('/path/to/my/image.img') for item in image.root.find_all(): if item.name == 'myfilename': with open('/tmp/' + item.name, 'wb') as f: print('Saving original ' + item.path + ' in /tmp/' + item.name) f.write(item.read_bytes()) image.close() ``` ## Use as a command ``` $ pysquashfsimage -h usage: pysquashfsimage [-h] [-V] file paths [paths ...] positional arguments: file squashfs filesystem paths directories or files to print information about options: -h, --help show this help message and exit -V, --version show program's version number and exit ``` For each path, if it is a directory it will print the mode and name of each contained file, with sizes and symlinks. If a path is a file, print its content. Example command: ``` $ pysquashfsimage myimage.img /bin /etc/passwd ``` %package help Summary: Development documents and examples for PySquashfsImage Provides: python3-PySquashfsImage-doc %description help PySquashfsImage is a lightweight library for reading squashfs image files in Python. It provides a way to read squashfs images header and to retrieve encapsulated binaries. It is compatible with Python 2.6, 2.7 and Python 3.1+. ## Installation ``` pip install PySquashfsImage ``` If you are using Python <= 3.2 and need LZMA decompression, install [backports.lzma](https://pypi.org/project/backports.lzma/). For LZ4 decompression, install [lz4](https://pypi.org/project/lz4/) (Python 3.7+). For Zstandard decompression install [zstandard](https://pypi.org/project/zstandard/) (Python 3.7+). ## Use as a library ### List all elements in the image: ```python from PySquashfsImage import SquashFsImage image = SquashFsImage('/path/to/my/image.img') for item in image.root.find_all(): print(item.name) image.close() ``` ### Print all files and folder with human readable path: ```python from PySquashfsImage import SquashFsImage image = SquashFsImage('/path/to/my/image.img') for path in image.root.find_all_paths(): print(path) image.close() ``` ### Print only files: ```python from PySquashfsImage import SquashFsImage image = SquashFsImage('/path/to/my/image.img') for item in image.root.find_all(): if not item.is_dir: print(item.path) image.close() ``` ### Save the content of a file: ```python from PySquashfsImage import SquashFsImage image = SquashFsImage('/path/to/my/image.img') for item in image.root.find_all(): if item.name == 'myfilename': with open('/tmp/' + item.name, 'wb') as f: print('Saving original ' + item.path + ' in /tmp/' + item.name) f.write(item.read_bytes()) image.close() ``` ## Use as a command ``` $ pysquashfsimage -h usage: pysquashfsimage [-h] [-V] file paths [paths ...] positional arguments: file squashfs filesystem paths directories or files to print information about options: -h, --help show this help message and exit -V, --version show program's version number and exit ``` For each path, if it is a directory it will print the mode and name of each contained file, with sizes and symlinks. If a path is a file, print its content. Example command: ``` $ pysquashfsimage myimage.img /bin /etc/passwd ``` %prep %autosetup -n PySquashfsImage-0.8.0 %build %py3_build %install %py3_install install -d -m755 %{buildroot}/%{_pkgdocdir} if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi pushd %{buildroot} if [ -d usr/lib ]; then find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/lib64 ]; then find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/bin ]; then find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/sbin ]; then find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst fi touch doclist.lst if [ -d usr/share/man ]; then find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst fi popd mv %{buildroot}/filelist.lst . mv %{buildroot}/doclist.lst . %files -n python3-PySquashfsImage -f filelist.lst %dir %{python3_sitelib}/* %files help -f doclist.lst %{_docdir}/* %changelog * Wed May 10 2023 Python_Bot - 0.8.0-1 - Package Spec generated