romfs 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- romfs-0.0.1/.editorconfig +24 -0
- romfs-0.0.1/.github/dependabot.yml +12 -0
- romfs-0.0.1/.github/workflows/ci.yml +66 -0
- romfs-0.0.1/.github/workflows/publish.yml +53 -0
- romfs-0.0.1/.gitignore +43 -0
- romfs-0.0.1/LICENSE +202 -0
- romfs-0.0.1/PKG-INFO +151 -0
- romfs-0.0.1/README.md +118 -0
- romfs-0.0.1/aaa.img +0 -0
- romfs-0.0.1/main.py +19 -0
- romfs-0.0.1/pyproject.toml +88 -0
- romfs-0.0.1/src/romfs/__init__.py +30 -0
- romfs-0.0.1/src/romfs/cli.py +145 -0
- romfs-0.0.1/src/romfs/errors.py +34 -0
- romfs-0.0.1/src/romfs/format.py +175 -0
- romfs-0.0.1/src/romfs/nodes.py +63 -0
- romfs-0.0.1/src/romfs/reader.py +225 -0
- romfs-0.0.1/src/romfs/writer.py +207 -0
- romfs-0.0.1/tests/__init__.py +2 -0
- romfs-0.0.1/tests/test_romfs.py +351 -0
- romfs-0.0.1/tests/test_version.py +9 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# Copyright (c) 2026 Junbo Zheng
|
|
3
|
+
|
|
4
|
+
root = true
|
|
5
|
+
|
|
6
|
+
[*]
|
|
7
|
+
charset = utf-8
|
|
8
|
+
end_of_line = lf
|
|
9
|
+
insert_final_newline = true
|
|
10
|
+
trim_trailing_whitespace = true
|
|
11
|
+
indent_style = space
|
|
12
|
+
indent_size = 4
|
|
13
|
+
|
|
14
|
+
[*.{md,markdown}]
|
|
15
|
+
trim_trailing_whitespace = false
|
|
16
|
+
|
|
17
|
+
[Makefile]
|
|
18
|
+
indent_style = tab
|
|
19
|
+
|
|
20
|
+
[*.{yml,yaml}]
|
|
21
|
+
indent_size = 2
|
|
22
|
+
|
|
23
|
+
[*.{json,toml}]
|
|
24
|
+
indent_size = 2
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# Copyright (c) 2026 Junbo Zheng
|
|
3
|
+
|
|
4
|
+
name: CI
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
push:
|
|
8
|
+
branches: [main, master]
|
|
9
|
+
pull_request:
|
|
10
|
+
branches: [main, master]
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
test:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
strategy:
|
|
16
|
+
matrix:
|
|
17
|
+
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v4
|
|
20
|
+
|
|
21
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
22
|
+
uses: actions/setup-python@v5
|
|
23
|
+
with:
|
|
24
|
+
python-version: ${{ matrix.python-version }}
|
|
25
|
+
|
|
26
|
+
- name: Install package + dev deps
|
|
27
|
+
run: |
|
|
28
|
+
python -m pip install --upgrade pip
|
|
29
|
+
pip install -e ".[dev]"
|
|
30
|
+
|
|
31
|
+
- name: Lint (black)
|
|
32
|
+
run: black --check src tests main.py
|
|
33
|
+
|
|
34
|
+
- name: Lint (ruff)
|
|
35
|
+
run: ruff check src tests
|
|
36
|
+
|
|
37
|
+
- name: Type check (mypy)
|
|
38
|
+
run: mypy src
|
|
39
|
+
|
|
40
|
+
- name: Run pytest
|
|
41
|
+
run: pytest -v
|
|
42
|
+
|
|
43
|
+
# Verify the *built* package: since pyproject sets pythonpath = ["src"], local
|
|
44
|
+
# runs and the editable job above both import from src/ and never exercise the
|
|
45
|
+
# wheel. This job builds the wheel, installs it into a clean env, and runs the
|
|
46
|
+
# suite with `-o pythonpath=` so the installed package is imported — catching
|
|
47
|
+
# packaging bugs (a module missing from the wheel, a data file left out).
|
|
48
|
+
package:
|
|
49
|
+
runs-on: ubuntu-latest
|
|
50
|
+
steps:
|
|
51
|
+
- uses: actions/checkout@v4
|
|
52
|
+
|
|
53
|
+
- name: Set up Python
|
|
54
|
+
uses: actions/setup-python@v5
|
|
55
|
+
with:
|
|
56
|
+
python-version: "3.12"
|
|
57
|
+
|
|
58
|
+
- name: Build and install the wheel
|
|
59
|
+
run: |
|
|
60
|
+
python -m pip install --upgrade pip build
|
|
61
|
+
python -m build
|
|
62
|
+
pip install dist/*.whl
|
|
63
|
+
pip install pytest
|
|
64
|
+
|
|
65
|
+
- name: Run pytest against the installed package
|
|
66
|
+
run: pytest -v -o pythonpath=
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# Copyright (c) 2026 Junbo Zheng
|
|
3
|
+
|
|
4
|
+
name: Publish to PyPI
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
release:
|
|
8
|
+
types: [published]
|
|
9
|
+
|
|
10
|
+
permissions:
|
|
11
|
+
contents: read
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
build:
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
steps:
|
|
17
|
+
- name: Checkout code
|
|
18
|
+
uses: actions/checkout@v4
|
|
19
|
+
with:
|
|
20
|
+
fetch-depth: 0
|
|
21
|
+
|
|
22
|
+
- name: Set up Python
|
|
23
|
+
uses: actions/setup-python@v5
|
|
24
|
+
with:
|
|
25
|
+
python-version: "3.12"
|
|
26
|
+
|
|
27
|
+
- name: Install build backend
|
|
28
|
+
run: pip install build
|
|
29
|
+
|
|
30
|
+
- name: Build distribution
|
|
31
|
+
run: python -m build
|
|
32
|
+
|
|
33
|
+
- name: Upload dist artifact
|
|
34
|
+
uses: actions/upload-artifact@v4
|
|
35
|
+
with:
|
|
36
|
+
name: dist
|
|
37
|
+
path: dist/
|
|
38
|
+
|
|
39
|
+
publish:
|
|
40
|
+
needs: build
|
|
41
|
+
runs-on: ubuntu-latest
|
|
42
|
+
environment: pypi
|
|
43
|
+
permissions:
|
|
44
|
+
id-token: write # OIDC token for PyPI Trusted Publishing (no API token)
|
|
45
|
+
steps:
|
|
46
|
+
- name: Download dist artifact
|
|
47
|
+
uses: actions/download-artifact@v4
|
|
48
|
+
with:
|
|
49
|
+
name: dist
|
|
50
|
+
path: dist/
|
|
51
|
+
|
|
52
|
+
- name: Publish to PyPI
|
|
53
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
romfs-0.0.1/.gitignore
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# Copyright (c) 2026 Junbo Zheng
|
|
3
|
+
|
|
4
|
+
# Byte-compiled / DLL files
|
|
5
|
+
__pycache__/
|
|
6
|
+
*.py[cod]
|
|
7
|
+
*$py.class
|
|
8
|
+
|
|
9
|
+
# Virtual envs
|
|
10
|
+
.venv/
|
|
11
|
+
venv/
|
|
12
|
+
env/
|
|
13
|
+
|
|
14
|
+
# Distribution / packaging
|
|
15
|
+
build/
|
|
16
|
+
dist/
|
|
17
|
+
*.egg-info/
|
|
18
|
+
*.egg
|
|
19
|
+
|
|
20
|
+
# Test / coverage / type-check caches
|
|
21
|
+
.pytest_cache/
|
|
22
|
+
.mypy_cache/
|
|
23
|
+
.ruff_cache/
|
|
24
|
+
.coverage
|
|
25
|
+
coverage.xml
|
|
26
|
+
htmlcov/
|
|
27
|
+
|
|
28
|
+
# Editor / IDE
|
|
29
|
+
.vscode/
|
|
30
|
+
.idea/
|
|
31
|
+
*.swp
|
|
32
|
+
*.swo
|
|
33
|
+
*~
|
|
34
|
+
|
|
35
|
+
# OS noise
|
|
36
|
+
.DS_Store
|
|
37
|
+
Thumbs.db
|
|
38
|
+
|
|
39
|
+
# Secrets — never commit
|
|
40
|
+
.env
|
|
41
|
+
credentials.json
|
|
42
|
+
*.pem
|
|
43
|
+
*.key
|
romfs-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
romfs-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: romfs
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Pure-Python reader and writer for Linux romfs (-rom1fs-) filesystem images.
|
|
5
|
+
Project-URL: Homepage, https://github.com/Junbo-Zheng/romfs
|
|
6
|
+
Project-URL: Issues, https://github.com/Junbo-Zheng/romfs/issues
|
|
7
|
+
Author-email: Junbo Zheng <Junbo-Zheng@users.noreply.github.com>
|
|
8
|
+
License: Apache-2.0
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: embedded,filesystem,image,initrd,rom1fs,romfs
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
21
|
+
Classifier: Topic :: System :: Filesystems
|
|
22
|
+
Classifier: Typing :: Typed
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Provides-Extra: dev
|
|
25
|
+
Requires-Dist: black; extra == 'dev'
|
|
26
|
+
Requires-Dist: build; extra == 'dev'
|
|
27
|
+
Requires-Dist: mypy; extra == 'dev'
|
|
28
|
+
Requires-Dist: pytest-cov; extra == 'dev'
|
|
29
|
+
Requires-Dist: pytest>=7.0; extra == 'dev'
|
|
30
|
+
Requires-Dist: ruff; extra == 'dev'
|
|
31
|
+
Requires-Dist: twine; extra == 'dev'
|
|
32
|
+
Description-Content-Type: text/markdown
|
|
33
|
+
|
|
34
|
+
# romfs
|
|
35
|
+
|
|
36
|
+
[](https://pypi.org/project/romfs/)
|
|
37
|
+
[](https://github.com/Junbo-Zheng/romfs/actions/workflows/ci.yml)
|
|
38
|
+
[](https://pypi.org/project/romfs/)
|
|
39
|
+
[](LICENSE)
|
|
40
|
+
|
|
41
|
+
> Pure-Python reader and writer for Linux romfs (`-rom1fs-`) filesystem images.
|
|
42
|
+
> Standard library only, no runtime dependencies.
|
|
43
|
+
|
|
44
|
+
`romfs` lets you build, inspect, and extract the small read-only filesystem
|
|
45
|
+
images the Linux kernel uses for initrds and embedded root filesystems. Images
|
|
46
|
+
produced by the writer are byte-compatible with `mount -t romfs` and
|
|
47
|
+
interchangeable with `genromfs`; the reader parses any such image, including
|
|
48
|
+
real `genromfs` output with `.`/`..` self-links and dedup hardlinks.
|
|
49
|
+
|
|
50
|
+
## Features
|
|
51
|
+
|
|
52
|
+
- **Read** an image into a node tree; list entries and read file contents
|
|
53
|
+
lazily via `mmap` — large images don't blow up memory.
|
|
54
|
+
- **Write** an image from a local directory tree, preserving the structure,
|
|
55
|
+
regular files, and symbolic links.
|
|
56
|
+
- **CLI** with `list`, `extract`, `pack`, and `info` subcommands.
|
|
57
|
+
- **Importable library** API for embedding in other tools.
|
|
58
|
+
- Byte-exact conformance with the kernel romfs format: 16-byte alignment,
|
|
59
|
+
big-endian, superblock + header checksums.
|
|
60
|
+
- Entries sorted by name for a deterministic, diff-friendly layout.
|
|
61
|
+
|
|
62
|
+
> [!NOTE]
|
|
63
|
+
> The writer lays out entries sorted by name, so two versions of the same
|
|
64
|
+
> resource tree produce byte-stable images — keeping binary diffs (delta
|
|
65
|
+
> packages) small.
|
|
66
|
+
|
|
67
|
+
## Installation
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
pip install romfs
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Run from source with no install:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
./main.py <args>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Quick start
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
# Pack a folder tree into a single romfs image
|
|
83
|
+
romfs pack ./rootfs -o rootfs.img -n myvol
|
|
84
|
+
|
|
85
|
+
# List the file tree (type, size, path)
|
|
86
|
+
romfs list rootfs.img
|
|
87
|
+
|
|
88
|
+
# Extract one file to stdout, or everything to a directory
|
|
89
|
+
romfs extract rootfs.img etc/init.d/rcS
|
|
90
|
+
romfs extract rootfs.img -o ./out
|
|
91
|
+
|
|
92
|
+
# Show header info and verify the superblock checksum
|
|
93
|
+
romfs info rootfs.img --verify
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## CLI reference
|
|
97
|
+
|
|
98
|
+
```text
|
|
99
|
+
romfs list <image> list the file tree (path, type, size)
|
|
100
|
+
romfs extract <image> [-o OUTDIR] [PATH] extract all, or one entry to stdout
|
|
101
|
+
romfs pack <srcdir> -o <image> [-n NAME] build an image from a directory tree
|
|
102
|
+
romfs info <image> [--verify] print header info + checksum check
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
`romfs -V` prints the version; `romfs -h` shows help.
|
|
106
|
+
|
|
107
|
+
## Library API
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
from romfs import RomFSReader, RomFSWriter, EntryType
|
|
111
|
+
|
|
112
|
+
# Read an image
|
|
113
|
+
with RomFSReader("rootfs.img") as r:
|
|
114
|
+
print(r.volume_name, r.full_size)
|
|
115
|
+
for path, node in r.walk():
|
|
116
|
+
print(f"{node.type.name:9} {node.size:>8} {path}")
|
|
117
|
+
# File contents are sliced from the mmap on demand
|
|
118
|
+
data = r.read(r.root.children[0])
|
|
119
|
+
|
|
120
|
+
# Build an image from a directory tree
|
|
121
|
+
RomFSWriter.from_directory("./rootfs", volume_name="myvol").write("out.img")
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Supported entry types
|
|
125
|
+
|
|
126
|
+
| Type | Read | Write |
|
|
127
|
+
|-------------------------------------|:----:|:-----:|
|
|
128
|
+
| Regular file | yes | yes |
|
|
129
|
+
| Directory | yes | yes |
|
|
130
|
+
| Symlink | yes | yes |
|
|
131
|
+
| Hardlink / device / socket / fifo | yes | no |
|
|
132
|
+
|
|
133
|
+
> [!NOTE]
|
|
134
|
+
> romfs does not store per-file Unix mode bits in the standard format, so the
|
|
135
|
+
> kernel assigns fixed default modes. Permissions are not preserved on write.
|
|
136
|
+
> Hardlinks and special files are parsed on read but not emitted on write.
|
|
137
|
+
|
|
138
|
+
## Development
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
pip install -e ".[dev]" # pytest, black, ruff, mypy, build, twine
|
|
142
|
+
pytest # runs against src/ directly, no install needed
|
|
143
|
+
black src tests main.py # format
|
|
144
|
+
ruff check src tests # lint
|
|
145
|
+
mypy src # type check
|
|
146
|
+
python -m build # build sdist + wheel into dist/
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
CI runs black + ruff + mypy + pytest across Python 3.10-3.13, plus a packaging
|
|
150
|
+
job that builds the wheel and tests the installed package. Releases publish to
|
|
151
|
+
PyPI automatically on a GitHub Release via Trusted Publishing (OIDC).
|
romfs-0.0.1/README.md
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# romfs
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/romfs/)
|
|
4
|
+
[](https://github.com/Junbo-Zheng/romfs/actions/workflows/ci.yml)
|
|
5
|
+
[](https://pypi.org/project/romfs/)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
|
|
8
|
+
> Pure-Python reader and writer for Linux romfs (`-rom1fs-`) filesystem images.
|
|
9
|
+
> Standard library only, no runtime dependencies.
|
|
10
|
+
|
|
11
|
+
`romfs` lets you build, inspect, and extract the small read-only filesystem
|
|
12
|
+
images the Linux kernel uses for initrds and embedded root filesystems. Images
|
|
13
|
+
produced by the writer are byte-compatible with `mount -t romfs` and
|
|
14
|
+
interchangeable with `genromfs`; the reader parses any such image, including
|
|
15
|
+
real `genromfs` output with `.`/`..` self-links and dedup hardlinks.
|
|
16
|
+
|
|
17
|
+
## Features
|
|
18
|
+
|
|
19
|
+
- **Read** an image into a node tree; list entries and read file contents
|
|
20
|
+
lazily via `mmap` — large images don't blow up memory.
|
|
21
|
+
- **Write** an image from a local directory tree, preserving the structure,
|
|
22
|
+
regular files, and symbolic links.
|
|
23
|
+
- **CLI** with `list`, `extract`, `pack`, and `info` subcommands.
|
|
24
|
+
- **Importable library** API for embedding in other tools.
|
|
25
|
+
- Byte-exact conformance with the kernel romfs format: 16-byte alignment,
|
|
26
|
+
big-endian, superblock + header checksums.
|
|
27
|
+
- Entries sorted by name for a deterministic, diff-friendly layout.
|
|
28
|
+
|
|
29
|
+
> [!NOTE]
|
|
30
|
+
> The writer lays out entries sorted by name, so two versions of the same
|
|
31
|
+
> resource tree produce byte-stable images — keeping binary diffs (delta
|
|
32
|
+
> packages) small.
|
|
33
|
+
|
|
34
|
+
## Installation
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
pip install romfs
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Run from source with no install:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
./main.py <args>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Quick start
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
# Pack a folder tree into a single romfs image
|
|
50
|
+
romfs pack ./rootfs -o rootfs.img -n myvol
|
|
51
|
+
|
|
52
|
+
# List the file tree (type, size, path)
|
|
53
|
+
romfs list rootfs.img
|
|
54
|
+
|
|
55
|
+
# Extract one file to stdout, or everything to a directory
|
|
56
|
+
romfs extract rootfs.img etc/init.d/rcS
|
|
57
|
+
romfs extract rootfs.img -o ./out
|
|
58
|
+
|
|
59
|
+
# Show header info and verify the superblock checksum
|
|
60
|
+
romfs info rootfs.img --verify
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## CLI reference
|
|
64
|
+
|
|
65
|
+
```text
|
|
66
|
+
romfs list <image> list the file tree (path, type, size)
|
|
67
|
+
romfs extract <image> [-o OUTDIR] [PATH] extract all, or one entry to stdout
|
|
68
|
+
romfs pack <srcdir> -o <image> [-n NAME] build an image from a directory tree
|
|
69
|
+
romfs info <image> [--verify] print header info + checksum check
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
`romfs -V` prints the version; `romfs -h` shows help.
|
|
73
|
+
|
|
74
|
+
## Library API
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
from romfs import RomFSReader, RomFSWriter, EntryType
|
|
78
|
+
|
|
79
|
+
# Read an image
|
|
80
|
+
with RomFSReader("rootfs.img") as r:
|
|
81
|
+
print(r.volume_name, r.full_size)
|
|
82
|
+
for path, node in r.walk():
|
|
83
|
+
print(f"{node.type.name:9} {node.size:>8} {path}")
|
|
84
|
+
# File contents are sliced from the mmap on demand
|
|
85
|
+
data = r.read(r.root.children[0])
|
|
86
|
+
|
|
87
|
+
# Build an image from a directory tree
|
|
88
|
+
RomFSWriter.from_directory("./rootfs", volume_name="myvol").write("out.img")
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Supported entry types
|
|
92
|
+
|
|
93
|
+
| Type | Read | Write |
|
|
94
|
+
|-------------------------------------|:----:|:-----:|
|
|
95
|
+
| Regular file | yes | yes |
|
|
96
|
+
| Directory | yes | yes |
|
|
97
|
+
| Symlink | yes | yes |
|
|
98
|
+
| Hardlink / device / socket / fifo | yes | no |
|
|
99
|
+
|
|
100
|
+
> [!NOTE]
|
|
101
|
+
> romfs does not store per-file Unix mode bits in the standard format, so the
|
|
102
|
+
> kernel assigns fixed default modes. Permissions are not preserved on write.
|
|
103
|
+
> Hardlinks and special files are parsed on read but not emitted on write.
|
|
104
|
+
|
|
105
|
+
## Development
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
pip install -e ".[dev]" # pytest, black, ruff, mypy, build, twine
|
|
109
|
+
pytest # runs against src/ directly, no install needed
|
|
110
|
+
black src tests main.py # format
|
|
111
|
+
ruff check src tests # lint
|
|
112
|
+
mypy src # type check
|
|
113
|
+
python -m build # build sdist + wheel into dist/
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
CI runs black + ruff + mypy + pytest across Python 3.10-3.13, plus a packaging
|
|
117
|
+
job that builds the wheel and tests the installed package. Releases publish to
|
|
118
|
+
PyPI automatically on a GitHub Release via Trusted Publishing (OIDC).
|
romfs-0.0.1/aaa.img
ADDED
|
Binary file
|