minitar 1.0.2 → 1.1.1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +326 -0
- data/CODE_OF_CONDUCT.md +167 -0
- data/CONTRIBUTING.md +312 -0
- data/CONTRIBUTORS.md +27 -0
- data/LICENCE.md +42 -0
- data/Manifest.txt +31 -8
- data/README.md +82 -0
- data/Rakefile +74 -20
- data/SECURITY.md +54 -0
- data/lib/minitar/input.rb +242 -189
- data/lib/minitar/output.rb +72 -64
- data/lib/minitar/pax_header.rb +111 -0
- data/lib/minitar/posix_header.rb +276 -239
- data/lib/minitar/reader.rb +226 -231
- data/lib/minitar/version.rb +5 -0
- data/lib/minitar/writer.rb +246 -299
- data/lib/minitar.rb +134 -115
- data/licenses/bsdl.txt +20 -0
- data/licenses/dco.txt +34 -0
- data/licenses/ruby.txt +52 -0
- data/test/fixtures/issue_46.tar.gz +0 -0
- data/test/fixtures/issue_62.tar.gz +0 -0
- data/test/fixtures/tar_input.tgz +0 -0
- data/test/fixtures/test_input_non_strict_octal.tgz +0 -0
- data/test/fixtures/test_input_relative.tgz +0 -0
- data/test/fixtures/test_input_space_octal.tgz +0 -0
- data/test/fixtures/test_minitar.tar.gz +0 -0
- data/test/minitest_helper.rb +12 -1
- data/test/support/minitar_test_helpers/fixtures.rb +38 -0
- data/test/support/minitar_test_helpers/header.rb +130 -0
- data/test/support/minitar_test_helpers/tarball.rb +324 -0
- data/test/support/minitar_test_helpers.rb +36 -0
- data/test/test_filename_boundary_conditions.rb +74 -0
- data/test/test_gnu_tar_compatibility.rb +92 -0
- data/test/test_integration_pack_unpack_cycle.rb +38 -0
- data/test/test_issue_46.rb +5 -23
- data/test/test_issue_62.rb +50 -0
- data/test/test_minitar.rb +168 -39
- data/test/test_path_normalization.rb +170 -0
- data/test/test_pax_header.rb +104 -0
- data/test/test_pax_support.rb +66 -0
- data/test/test_tar_header.rb +289 -75
- data/test/test_tar_input.rb +14 -61
- data/test/test_tar_output.rb +7 -9
- data/test/test_tar_reader.rb +17 -18
- data/test/test_tar_writer.rb +105 -126
- data/test/test_windows_extraction.rb +121 -0
- metadata +108 -95
- data/Code-of-Conduct.md +0 -128
- data/Contributing.md +0 -94
- data/History.md +0 -236
- data/Licence.md +0 -15
- data/README.rdoc +0 -92
- data/docs/bsdl.txt +0 -19
- data/docs/ruby.txt +0 -56
- data/test/support/tar_test_helpers.rb +0 -134
data/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Contribution to Minitar is encouraged: bug reports, feature requests, or code
|
|
4
|
+
contributions. New features should be proposed and discussed in an
|
|
5
|
+
[issue][issues].
|
|
6
|
+
|
|
7
|
+
Before contributing patches, please read the [Licence](./LICENCE.md).
|
|
8
|
+
|
|
9
|
+
Minitar is governed under the [Contributor Covenant Code of Conduct][cccoc].
|
|
10
|
+
|
|
11
|
+
## Code Guidelines
|
|
12
|
+
|
|
13
|
+
I have several guidelines to contributing code through pull requests:
|
|
14
|
+
|
|
15
|
+
- All code changes require tests. In most cases, this will be added or updated
|
|
16
|
+
unit tests. I use [Minitest][minitest].
|
|
17
|
+
|
|
18
|
+
- I use code formatters, static analysis tools, and linting to ensure
|
|
19
|
+
consistent styles and formatting. There should be no warning output from
|
|
20
|
+
test run processes. I use [Standard Ruby][standardrb].
|
|
21
|
+
|
|
22
|
+
- Proposed changes should be on a thoughtfully-named topic branch and
|
|
23
|
+
organized into logical commit chunks as appropriate.
|
|
24
|
+
|
|
25
|
+
- Use [Conventional Commits][conventional] with my
|
|
26
|
+
[conventions](#commit-conventions).
|
|
27
|
+
|
|
28
|
+
- Versions must not be updated in pull requests unless otherwise directed.
|
|
29
|
+
This means that you must not:
|
|
30
|
+
|
|
31
|
+
- Modify `VERSION` in `lib/minitar/version.rb`. When your patch is accepted
|
|
32
|
+
and a release is made, the version will be updated at that point.
|
|
33
|
+
|
|
34
|
+
- Modify `minitar.gemspec`; it is a generated file. (You _may_ use
|
|
35
|
+
`rake gemspec` to regenerate it if your change involves metadata related
|
|
36
|
+
to gem itself).
|
|
37
|
+
|
|
38
|
+
- Modify the `Gemfile`.
|
|
39
|
+
|
|
40
|
+
- Documentation should be added or updated as appropriate for new or updated
|
|
41
|
+
functionality. The documentation is RDoc; Minitar does not use extensions
|
|
42
|
+
that may be present in alternative documentation generators.
|
|
43
|
+
|
|
44
|
+
- All GitHub Actions checks marked as required must pass before a pull request
|
|
45
|
+
may be accepted and merged.
|
|
46
|
+
|
|
47
|
+
- Add your name or GitHub handle to `CONTRIBUTORS.md` and a record in the
|
|
48
|
+
`CHANGELOG.md` as a separate commit from your main change. (Follow the style
|
|
49
|
+
in the `CHANGELOG.md` and provide a link to your PR.)
|
|
50
|
+
|
|
51
|
+
- Include your DCO sign-off in each commit message (see
|
|
52
|
+
[LICENCE](LICENCE.md)).
|
|
53
|
+
|
|
54
|
+
## AI Contribution Policy
|
|
55
|
+
|
|
56
|
+
Minitar is a library that may have access to the underlying file system. It is
|
|
57
|
+
extremely important that contributions of any sort be well understood by the
|
|
58
|
+
submitter and that the developer can attest to the
|
|
59
|
+
[Developer Certificate of Origin][dco] for each pull request (see
|
|
60
|
+
[LICENCE](LICENCE.md)).
|
|
61
|
+
|
|
62
|
+
Any contribution (bug, feature request, or pull request) that uses undeclared
|
|
63
|
+
AI output will be rejected.
|
|
64
|
+
|
|
65
|
+
For an example of how this should be done, see [#151][pr-151] and its
|
|
66
|
+
[associated commits][pr-151-commits].
|
|
67
|
+
|
|
68
|
+
## Commit Conventions
|
|
69
|
+
|
|
70
|
+
Minitar has adopted a variation of the Conventional Commits format for commit
|
|
71
|
+
messages. The following types are permitted:
|
|
72
|
+
|
|
73
|
+
| Type | Purpose |
|
|
74
|
+
| ------- | ----------------------------------------------------- |
|
|
75
|
+
| `feat` | A new feature |
|
|
76
|
+
| `fix` | A bug fix |
|
|
77
|
+
| `chore` | A code change that is neither a bug fix nor a feature |
|
|
78
|
+
| `docs` | Documentation updates |
|
|
79
|
+
| `deps` | Dependency updates, including GitHub Actions. |
|
|
80
|
+
|
|
81
|
+
I encourage the use of [Tim Pope's][tpope-qcm] or [Chris Beam's][cbeams]
|
|
82
|
+
guidelines on the writing of commit messages
|
|
83
|
+
|
|
84
|
+
I require the use of [git][trailers1] [trailers][trailers2] for specific
|
|
85
|
+
additional metadata and strongly encourage it for others. The conditionally
|
|
86
|
+
required metadata trailers are:
|
|
87
|
+
|
|
88
|
+
- `Breaking-Change`: if the change is a breaking change. **Do not** use the
|
|
89
|
+
shorthand form (`feat!(scope)`) or `BREAKING CHANGE`.
|
|
90
|
+
|
|
91
|
+
- `Signed-off-by`: this is required for all developers except me, as outlined
|
|
92
|
+
in the [Licence](./LICENCE.md#developer-certificate-of-origin).
|
|
93
|
+
|
|
94
|
+
- `Fixes` or `Resolves`: If a change fixes one or more open [issues][issues],
|
|
95
|
+
that issue must be included in the `Fixes` or `Resolves` trailer. Multiple
|
|
96
|
+
issues should be listed comma separated in the same trailer:
|
|
97
|
+
`Fixes: #1, #5, #7`, but _may_ appear in separate trailers. While both
|
|
98
|
+
`Fixes` and `Resolves` are synonyms, only _one_ should be used in a given
|
|
99
|
+
commit or pull request.
|
|
100
|
+
|
|
101
|
+
- `Related to`: If a change does not fix an issue, those issue references
|
|
102
|
+
should be included in this trailer.
|
|
103
|
+
|
|
104
|
+
## Testing Minitar
|
|
105
|
+
|
|
106
|
+
Minitar uses Ryan Davis's [Hoe][Hoe] to manage the release process, and it
|
|
107
|
+
adds a number of rake tasks. You will mostly be interested in `rake`, which
|
|
108
|
+
runs the tests the same way that `rake test` will do.
|
|
109
|
+
|
|
110
|
+
To assist with the installation of the development dependencies for Minitar, I
|
|
111
|
+
have provided the simplest possible Gemfile pointing to the (generated)
|
|
112
|
+
`minitar.gemspec` file. This will permit you to do `bundle install` to get the
|
|
113
|
+
development dependencies.
|
|
114
|
+
|
|
115
|
+
You can run tests with code coverage analysis by running `rake coverage`.
|
|
116
|
+
|
|
117
|
+
Minitar includes a number of custom test assertions, constants, and test
|
|
118
|
+
utility methods that are useful for writing tests. These are maintained
|
|
119
|
+
through modules defined in `test/support`.
|
|
120
|
+
|
|
121
|
+
### Fixture Utilities
|
|
122
|
+
|
|
123
|
+
Minitar uses fixture tarballs in various tests, referenced by their base name
|
|
124
|
+
(`test/fixtures/tar_input.tar.gz` becomes `tar_input`, etc.). There are two
|
|
125
|
+
utility methods:
|
|
126
|
+
|
|
127
|
+
- `Fixture(name)`: This returns the `Pathname` object for the full path of the
|
|
128
|
+
named fixture tarball or `nil` if the named fixture does not exist.
|
|
129
|
+
|
|
130
|
+
- `open_fixture(name)`: This retrieves the named fixture and opens it. If the
|
|
131
|
+
fixture ends with `.gz` or `.tgz`, it will be opened with a
|
|
132
|
+
`Zlib::GZipReader`. A block may be provided to ensure that the fixture is
|
|
133
|
+
automatically closed.
|
|
134
|
+
|
|
135
|
+
### Header Assertions and Utilities
|
|
136
|
+
|
|
137
|
+
Tar headers need to be built and compared in an exacting way, even for tests.
|
|
138
|
+
|
|
139
|
+
There are two assertions:
|
|
140
|
+
|
|
141
|
+
- `assert_headers_equal(expected, actual)`: This compares headers by field
|
|
142
|
+
order verifying that each field in `actual` is supposed to match the
|
|
143
|
+
corresponding field in `expected`.
|
|
144
|
+
|
|
145
|
+
`expected` must be a string representation of the expected header and this
|
|
146
|
+
assertion calls `#to_s` on the `actual` value so that both `PosixHeader` and
|
|
147
|
+
`PaxHeader` instances are converted to string representations for
|
|
148
|
+
comparison.
|
|
149
|
+
|
|
150
|
+
- `assert_modes_equal(expected, actual, filename)`: This compares the expected
|
|
151
|
+
octal mode string of `expected` against `actual` for a given `filename`. The
|
|
152
|
+
modes must be integer values. This assertion is skipped on Windows.
|
|
153
|
+
|
|
154
|
+
There are several other helper methods available for working with headers:
|
|
155
|
+
|
|
156
|
+
- `build_tar_file_header(name, prefix, mode, length)`: This builds a header
|
|
157
|
+
for a file `prefix/name` with `mode` and `length` bytes. `name` is limited
|
|
158
|
+
to 100 bytes and `prefix` is limited to 155 bytes.
|
|
159
|
+
|
|
160
|
+
- `build_tar_dir_header(name, prefix, mode)`: This builds a header for a
|
|
161
|
+
directory `prefix/name` with `mode`. `name` is limited to 100 bytes and
|
|
162
|
+
`prefix` is limited to 155 bytes.
|
|
163
|
+
|
|
164
|
+
- `build_tar_symlink_header(name, prefix, mode, target)`: This builds a header
|
|
165
|
+
for a symbolic link of `prefix/name` to `target` where the symbolic link has
|
|
166
|
+
`mode`. `name` is limited to 100 bytes and `prefix` is limited to 155 bytes.
|
|
167
|
+
|
|
168
|
+
- `build_tar_pax_header(name, prefix, bytes)`: This builds a header block for
|
|
169
|
+
a PAX extension at `name/prefix` with `content_size` bytes.
|
|
170
|
+
|
|
171
|
+
- `build_header(type, name, prefix, size, mode, link = "")`: This builds an
|
|
172
|
+
otherwise unspecified header type. If you find yourself using this, it is
|
|
173
|
+
recommended to add a new `build_*_header` helper method.
|
|
174
|
+
|
|
175
|
+
### Tarball Helpers
|
|
176
|
+
|
|
177
|
+
Minitar has several complex assertions and utilities to work with both
|
|
178
|
+
in-memory and on-disk tarballs. These work using two concepts, file hashes
|
|
179
|
+
(`file_hash`) and workspaces (`workspace`).
|
|
180
|
+
|
|
181
|
+
#### File Hashes (`file_hash`)
|
|
182
|
+
|
|
183
|
+
Many of these consume or produce a `file_hash`, which is a hash of
|
|
184
|
+
`{filename => content}` where the tarball will be produced with such that each
|
|
185
|
+
entry in the `file_hash` becomes a file named `filename` with the data
|
|
186
|
+
`content`.
|
|
187
|
+
|
|
188
|
+
As an example, `Minitar::TestHelpers` has a `MIXED_FILENAME_SCENARIOS`
|
|
189
|
+
constant that is a `file_hash`:
|
|
190
|
+
|
|
191
|
+
```ruby
|
|
192
|
+
MIXED_FILENAME_SCENARIOS = {
|
|
193
|
+
"short.txt" => "short content",
|
|
194
|
+
"medium_length_filename_under_100_chars.txt" => "medium content",
|
|
195
|
+
"dir1/medium_filename.js" => "medium nested content",
|
|
196
|
+
"#{"x" * 120}.txt" => "long content",
|
|
197
|
+
"nested/dir/#{"y" * 110}.css" => "long nested content"
|
|
198
|
+
}.freeze
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
This will produce a tarball that looks like:
|
|
202
|
+
|
|
203
|
+
```
|
|
204
|
+
short.txt
|
|
205
|
+
medium_length_filename_under_100_chars.txt
|
|
206
|
+
dir1/medium_filename.js
|
|
207
|
+
x[118 more 'x' characters...]x
|
|
208
|
+
nested/dir/y[108 more y' characters...]y.css
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
Each file will contain the text as the content.
|
|
212
|
+
|
|
213
|
+
If the `content` is `nil`, this will be ignored for in-memory tarballs, but
|
|
214
|
+
will be created as empty directory entries for on-disk tarballs.
|
|
215
|
+
|
|
216
|
+
#### Workspace (`workspace`)
|
|
217
|
+
|
|
218
|
+
A workspace is a temporary directory used for on-disk tests. It is created
|
|
219
|
+
with the `workspace` utility method (see below) and must be passed a block
|
|
220
|
+
where all setup and tests will be run.
|
|
221
|
+
|
|
222
|
+
At most one `workspace` may be used per test method.
|
|
223
|
+
|
|
224
|
+
#### Assertions
|
|
225
|
+
|
|
226
|
+
There are five assertions:
|
|
227
|
+
|
|
228
|
+
- `assert_tar_structure_preserved(original_files, extracted_files)`: This is
|
|
229
|
+
used primarily with string tarballs. Given two `file_hash`es representing
|
|
230
|
+
tarball contents (the original files passed to `create_tar_string` and the
|
|
231
|
+
extracted files returned from `extract_tar_string`), it ensures that all
|
|
232
|
+
files from the original contents are present and that no additional files
|
|
233
|
+
have been added in the process.
|
|
234
|
+
|
|
235
|
+
- `assert_files_extracted_in_workspace`: Can only be run in a `workspace` and
|
|
236
|
+
the test tarball must have been both created and extracted. This ensures
|
|
237
|
+
that all of the files and/or directories expected have been extracted and
|
|
238
|
+
that the contents of files match. File modes are ignored for this assertion.
|
|
239
|
+
|
|
240
|
+
- `refute_file_path_duplication_in_workspace`: Can only be run in a
|
|
241
|
+
`workspace` and the test tarball must have been both created and extracted.
|
|
242
|
+
This is used to prevent regression of [#62][issue-62] with explicit file
|
|
243
|
+
tests. This only needs to be called after unpacking with Minitar methods.
|
|
244
|
+
|
|
245
|
+
- `assert_extracted_files_match_source_files_in_workspace`: Can only be run in
|
|
246
|
+
a `workspace` and the test tarball must have been both created and
|
|
247
|
+
extracted. This ensures that there are no files missing or added in the
|
|
248
|
+
`target` directory that should are not also be in the `source` directory.
|
|
249
|
+
This does no contents comparison.
|
|
250
|
+
|
|
251
|
+
- `assert_file_modes_match_in_workspace`: Can only be run in a `workspace` and
|
|
252
|
+
the test tarball must have been both created and extracted. This ensures
|
|
253
|
+
that all files have the same modes between source and target. This is
|
|
254
|
+
skipped on Windows.
|
|
255
|
+
|
|
256
|
+
#### In-Memory Tarball Utilities
|
|
257
|
+
|
|
258
|
+
- `create_tar_string`: Given a `file_hash`, this creates a string containing
|
|
259
|
+
the output of `Minitar::Output.open` and `Minitar.pack_as_file`.
|
|
260
|
+
|
|
261
|
+
- `extract_tar_string`: Given the string output of `create_tar_string` (or any
|
|
262
|
+
uncompressed tarball string), uses `Minitar::Input.open` to read the files
|
|
263
|
+
into a hash of `{filename => content}`.
|
|
264
|
+
|
|
265
|
+
- `roundtrip_tar_string`: calls `create_tar_string` on a `file_hash` and
|
|
266
|
+
immediately calls `extract_tar_string`, returning a processed `file_hash`.
|
|
267
|
+
|
|
268
|
+
#### On-Disk Workspace Tarball Utilities
|
|
269
|
+
|
|
270
|
+
- `workspace`: Prepares a temporary directory for working with tarballs on
|
|
271
|
+
disk inside the block that must be provided. If given a hash of files, calls
|
|
272
|
+
`prepare_files`. The workspace directory will be removed after the block
|
|
273
|
+
finishes executing.
|
|
274
|
+
|
|
275
|
+
A workspace has a `source` directory, a `target`
|
|
276
|
+
directory`, and the`tarball` which will be created from the prepared files.
|
|
277
|
+
|
|
278
|
+
All other utility methods _must_ be run inside of a `workspace` block.
|
|
279
|
+
|
|
280
|
+
- `prepare_workspace`: creates a file structure in the workspace source
|
|
281
|
+
directory given the `{filename => content}` hash. For on-disk file
|
|
282
|
+
structures, `{directory_name => nil}` can be used to create empty
|
|
283
|
+
directories. Directory names will be created automatically for nested
|
|
284
|
+
filenames.
|
|
285
|
+
|
|
286
|
+
- `gnu_tar_create_in_workspace`, `gnu_tar_extract_in_workspace`, and
|
|
287
|
+
`gnu_tar_list_in_workspace` work with the workspace tarball using GNU tar
|
|
288
|
+
(either `tar` or `gtar`). GNU tar tests will be skipped if GNU tar is not
|
|
289
|
+
available.
|
|
290
|
+
|
|
291
|
+
- `minitar_pack_in_workspace`, `minitar_unpack_in_workspace` use
|
|
292
|
+
`Minitar.pack` and `Minitar.unpack`, respectively, to work with the
|
|
293
|
+
workspace tarball.
|
|
294
|
+
|
|
295
|
+
- `minitar_writer_create_in_workspace` uses `Minitar::Writer` to create the
|
|
296
|
+
workspace tarball.
|
|
297
|
+
|
|
298
|
+
[cbeams]: https://cbea.ms/git-commit/
|
|
299
|
+
[cccoc]: ./CODE_OF_CONDUCT.md
|
|
300
|
+
[conventional]: https://www.conventionalcommits.org/en/v1.0.0/
|
|
301
|
+
[dco]: licences/dco.txt
|
|
302
|
+
[hoe]: https://github.com/seattlerb/hoe
|
|
303
|
+
[issue-62]: https://github.com/halostatue/minitar/issues/62
|
|
304
|
+
[issues]: https://github.com/halostatue/minitar/issues
|
|
305
|
+
[minitest]: https://github.com/seattlerb/minitest
|
|
306
|
+
[pr-151-commits]: https://github.com/halostatue/minitar/pull/151/commits
|
|
307
|
+
[pr-151]: https://github.com/halostatue/minitar/pull/151
|
|
308
|
+
[sign-off]: LICENCE.md#developer-certificate-of-origin
|
|
309
|
+
[standardrb]: https://github.com/standardrb/standard
|
|
310
|
+
[tpope-qcm]: https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
|
|
311
|
+
[trailers1]: https://git-scm.com/docs/git-interpret-trailers
|
|
312
|
+
[trailers2]: https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---trailerlttokengtltvaluegt
|
data/CONTRIBUTORS.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Contributors
|
|
2
|
+
|
|
3
|
+
- Austin Ziegler created minitar, based on work originally written by Mauricio
|
|
4
|
+
Fernández for rpa-base.
|
|
5
|
+
|
|
6
|
+
Thanks to everyone who has contributed to minitar:
|
|
7
|
+
|
|
8
|
+
- Akinori MUSHA (knu)
|
|
9
|
+
- Antoine Toulme
|
|
10
|
+
- Curtis Sampson
|
|
11
|
+
- Daniel J. Berger
|
|
12
|
+
- [@dearblue](https://github.com/dearblue)
|
|
13
|
+
- [@inkstak](https://github.com/inkstak)
|
|
14
|
+
- John Prince
|
|
15
|
+
- Jorie Tappa
|
|
16
|
+
- Kazuyoshi Kato
|
|
17
|
+
- Kevin McDermott
|
|
18
|
+
- Matthew Kent
|
|
19
|
+
- Merten Falk
|
|
20
|
+
- Michal Suchanek
|
|
21
|
+
- Mike Furr
|
|
22
|
+
- [@ooooooo-q](https://github.com/ooooooo-q)
|
|
23
|
+
- Pete Fritchman
|
|
24
|
+
- [@sorah](https://github.com/sorah)
|
|
25
|
+
- Vijay ([@bv-vijay](https://github.com/bv-vijay))
|
|
26
|
+
- Yamamoto Kōhei
|
|
27
|
+
- Zach Dennis
|
data/LICENCE.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Licence
|
|
2
|
+
|
|
3
|
+
<-- SPDX-License-Identifier: Ruby or BSD-2-clause -->
|
|
4
|
+
|
|
5
|
+
- Copyright 2004–2026 Austin Ziegler and other contributors.
|
|
6
|
+
- Portions copyright 2004 Mauricio Julio Fernández Pradier.
|
|
7
|
+
|
|
8
|
+
minitar is free software that may be redistributed and/or modified under the
|
|
9
|
+
terms of Ruby’s licence or the Simplified BSD licence.
|
|
10
|
+
|
|
11
|
+
- SPDX License: [Ruby][ruby-license] OR [BSD-2-Clause][bsd-2-clause]
|
|
12
|
+
|
|
13
|
+
### Simplified BSD Licence
|
|
14
|
+
|
|
15
|
+
See the file [bsdl.txt](docs/bsdl.txt) in the main distribution.
|
|
16
|
+
|
|
17
|
+
### Ruby's Licence
|
|
18
|
+
|
|
19
|
+
See the file [ruby.txt](docs/ruby.txt) in the main distribution.
|
|
20
|
+
|
|
21
|
+
## Developer Certificate of Origin
|
|
22
|
+
|
|
23
|
+
All contributors **must** certify they are willing and able to provide their
|
|
24
|
+
contributions under the terms of this project's licences with the
|
|
25
|
+
certification of the
|
|
26
|
+
[Developer Certificate of Origin (Version 1.1)](licences/dco.txt).
|
|
27
|
+
|
|
28
|
+
Such certification is provided by ensuring that a `Signed-off-by`
|
|
29
|
+
[commit trailer][trailer] is present on every commit:
|
|
30
|
+
|
|
31
|
+
Signed-off-by: FirstName LastName <email@example.org>
|
|
32
|
+
|
|
33
|
+
The `Signed-off-by` trailer can be automatically added by git with the `-s` or
|
|
34
|
+
`--signoff` option on `git commit`:
|
|
35
|
+
|
|
36
|
+
```sh
|
|
37
|
+
git commit --signoff
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
[bsd-2-clause]: https://spdx.org/licenses/BSD-2-Clause.html
|
|
41
|
+
[ruby-license]: https://spdx.org/licenses/Ruby.html
|
|
42
|
+
[trailer]: https://git-scm.com/docs/git-interpret-trailers
|
data/Manifest.txt
CHANGED
|
@@ -1,24 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
CHANGELOG.md
|
|
2
|
+
CODE_OF_CONDUCT.md
|
|
3
|
+
CONTRIBUTING.md
|
|
4
|
+
CONTRIBUTORS.md
|
|
5
|
+
LICENCE.md
|
|
5
6
|
Manifest.txt
|
|
6
|
-
README.
|
|
7
|
+
README.md
|
|
7
8
|
Rakefile
|
|
8
|
-
|
|
9
|
-
docs/ruby.txt
|
|
9
|
+
SECURITY.md
|
|
10
10
|
lib/minitar.rb
|
|
11
11
|
lib/minitar/input.rb
|
|
12
12
|
lib/minitar/output.rb
|
|
13
|
+
lib/minitar/pax_header.rb
|
|
13
14
|
lib/minitar/posix_header.rb
|
|
14
15
|
lib/minitar/reader.rb
|
|
16
|
+
lib/minitar/version.rb
|
|
15
17
|
lib/minitar/writer.rb
|
|
18
|
+
licenses/bsdl.txt
|
|
19
|
+
licenses/dco.txt
|
|
20
|
+
licenses/ruby.txt
|
|
21
|
+
test/fixtures/issue_46.tar.gz
|
|
22
|
+
test/fixtures/issue_62.tar.gz
|
|
23
|
+
test/fixtures/tar_input.tgz
|
|
24
|
+
test/fixtures/test_input_non_strict_octal.tgz
|
|
25
|
+
test/fixtures/test_input_relative.tgz
|
|
26
|
+
test/fixtures/test_input_space_octal.tgz
|
|
27
|
+
test/fixtures/test_minitar.tar.gz
|
|
16
28
|
test/minitest_helper.rb
|
|
17
|
-
test/support/
|
|
29
|
+
test/support/minitar_test_helpers.rb
|
|
30
|
+
test/support/minitar_test_helpers/fixtures.rb
|
|
31
|
+
test/support/minitar_test_helpers/header.rb
|
|
32
|
+
test/support/minitar_test_helpers/tarball.rb
|
|
33
|
+
test/test_filename_boundary_conditions.rb
|
|
34
|
+
test/test_gnu_tar_compatibility.rb
|
|
35
|
+
test/test_integration_pack_unpack_cycle.rb
|
|
18
36
|
test/test_issue_46.rb
|
|
37
|
+
test/test_issue_62.rb
|
|
19
38
|
test/test_minitar.rb
|
|
39
|
+
test/test_path_normalization.rb
|
|
40
|
+
test/test_pax_header.rb
|
|
41
|
+
test/test_pax_support.rb
|
|
20
42
|
test/test_tar_header.rb
|
|
21
43
|
test/test_tar_input.rb
|
|
22
44
|
test/test_tar_output.rb
|
|
23
45
|
test/test_tar_reader.rb
|
|
24
46
|
test/test_tar_writer.rb
|
|
47
|
+
test/test_windows_extraction.rb
|
data/README.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# minitar
|
|
2
|
+
|
|
3
|
+
[![RubyGems Version][shield-gems]][rubygems] ![Coveralls][shield-coveralls]
|
|
4
|
+
[![Build Status][shield-ci]][ci-workflow]
|
|
5
|
+
|
|
6
|
+
- code :: <https://github.com/halostatue/minitar>
|
|
7
|
+
- issues :: <https://github.com/halostatue/minitar/issues>
|
|
8
|
+
- docs :: <https://halostatue.github.io/minitar/>
|
|
9
|
+
- changelog :: <https://github.com/halostatue/minitar/blob/main/CHANGELOG.md>
|
|
10
|
+
|
|
11
|
+
## Description
|
|
12
|
+
|
|
13
|
+
The minitar library is a pure-Ruby library that operates on POSIX tar(1)
|
|
14
|
+
archive files.
|
|
15
|
+
|
|
16
|
+
minitar (previously called Archive::Tar::Minitar) is based heavily on code
|
|
17
|
+
originally written by Mauricio Julio Fernández Pradier for the rpa-base
|
|
18
|
+
project.
|
|
19
|
+
|
|
20
|
+
## Synopsis
|
|
21
|
+
|
|
22
|
+
Using minitar is easy. The simplest case is:
|
|
23
|
+
|
|
24
|
+
```ruby
|
|
25
|
+
require 'minitar'
|
|
26
|
+
|
|
27
|
+
# Packs everything that matches Find.find('tests').
|
|
28
|
+
# test.tar will automatically be closed by Minitar.pack.
|
|
29
|
+
Minitar.pack('tests', File.open('test.tar', 'wb'))
|
|
30
|
+
|
|
31
|
+
# Unpacks 'test.tar' to 'x', creating 'x' if necessary.
|
|
32
|
+
Minitar.unpack('test.tar', 'x')
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
A gzipped tar can be written with:
|
|
36
|
+
|
|
37
|
+
```ruby
|
|
38
|
+
require 'zlib'
|
|
39
|
+
# test.tgz will be closed automatically.
|
|
40
|
+
Minitar.pack('tests', Zlib::GzipWriter.new(File.open('test.tgz', 'wb'))
|
|
41
|
+
|
|
42
|
+
# test.tgz will be closed automatically.
|
|
43
|
+
Minitar.unpack(Zlib::GzipReader.new(File.open('test.tgz', 'rb')), 'x')
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
As the case above shows, one need not write to a file. However, it will
|
|
47
|
+
sometimes require that one dive a little deeper into the API, as in the case
|
|
48
|
+
of StringIO objects. Note that I'm not providing a block with Minitar::Output,
|
|
49
|
+
as Minitar::Output#close automatically closes both the Output object and the
|
|
50
|
+
wrapped data stream object.
|
|
51
|
+
|
|
52
|
+
```ruby
|
|
53
|
+
begin
|
|
54
|
+
sgz = Zlib::GzipWriter.new(StringIO.new(String.new))
|
|
55
|
+
tar = Output.new(sgz)
|
|
56
|
+
Find.find('tests') do |entry|
|
|
57
|
+
Minitar.pack_file(entry, tar)
|
|
58
|
+
end
|
|
59
|
+
ensure
|
|
60
|
+
# Closes both tar and sgz.
|
|
61
|
+
tar.close
|
|
62
|
+
end
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Minitar and Security
|
|
66
|
+
|
|
67
|
+
See [SECURITY](./SECURITY.md)
|
|
68
|
+
|
|
69
|
+
## minitar Semantic Versioning
|
|
70
|
+
|
|
71
|
+
The minitar library uses a [Semantic Versioning][semver] scheme with one
|
|
72
|
+
change:
|
|
73
|
+
|
|
74
|
+
- When PATCH is zero (`0`), it will be omitted from version references.
|
|
75
|
+
|
|
76
|
+
[ci-workflow]: https://github.com/halostatue/minitar/actions/workflows/ci.yml
|
|
77
|
+
[coveralls]: https://coveralls.io/github/halostatue/minitar?branch=main
|
|
78
|
+
[rubygems]: https://rubygems.org/gems/minitar
|
|
79
|
+
[semver]: https://semver.org/
|
|
80
|
+
[shield-ci]: https://img.shields.io/github/actions/workflow/status/halostatue/minitar/ci.yml?style=for-the-badge "Build Status"
|
|
81
|
+
[shield-coveralls]: https://img.shields.io/coverallsCoverage/github/halostatue/minitar?style=for-the-badge
|
|
82
|
+
[shield-gems]: https://img.shields.io/gem/v/minitar?style=for-the-badge "Version"
|
data/Rakefile
CHANGED
|
@@ -1,42 +1,96 @@
|
|
|
1
|
-
#
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "rubygems"
|
|
4
4
|
require "hoe"
|
|
5
5
|
require "rake/clean"
|
|
6
|
+
require "rdoc/task"
|
|
7
|
+
require "minitest"
|
|
8
|
+
require "minitest/test_task"
|
|
6
9
|
|
|
7
|
-
|
|
10
|
+
Hoe.plugin :halostatue
|
|
8
11
|
|
|
9
|
-
Hoe.
|
|
10
|
-
Hoe.
|
|
11
|
-
Hoe.
|
|
12
|
-
Hoe.
|
|
13
|
-
Hoe.
|
|
14
|
-
Hoe.plugin :cov
|
|
12
|
+
Hoe.plugins.delete :debug
|
|
13
|
+
Hoe.plugins.delete :newb
|
|
14
|
+
Hoe.plugins.delete :publish
|
|
15
|
+
Hoe.plugins.delete :signing
|
|
16
|
+
Hoe.plugins.delete :test
|
|
15
17
|
|
|
16
|
-
Hoe.spec "minitar" do
|
|
18
|
+
hoe = Hoe.spec "minitar" do
|
|
17
19
|
developer("Austin Ziegler", "halostatue@gmail.com")
|
|
18
20
|
|
|
19
|
-
self.
|
|
20
|
-
self.readme_file = "README.rdoc"
|
|
21
|
+
self.trusted_release = ENV["rubygems_release_gem"] == "true"
|
|
21
22
|
|
|
22
23
|
require_ruby_version ">= 3.1"
|
|
23
24
|
|
|
24
25
|
self.licenses = ["Ruby", "BSD-2-Clause"]
|
|
25
26
|
|
|
26
|
-
spec_extras[:metadata] = ->(val) {
|
|
27
|
+
spec_extras[:metadata] = ->(val) {
|
|
28
|
+
val["rubygems_mfa_required"] = "true"
|
|
29
|
+
}
|
|
27
30
|
|
|
28
|
-
extra_dev_deps << ["base64", "~> 0.2"]
|
|
29
31
|
extra_dev_deps << ["hoe", "~> 4.0"]
|
|
30
|
-
extra_dev_deps << ["hoe-
|
|
31
|
-
extra_dev_deps << ["
|
|
32
|
-
extra_dev_deps << ["
|
|
33
|
-
extra_dev_deps << ["hoe-rubygems", "~> 1.0"]
|
|
34
|
-
extra_dev_deps << ["minitest", "~> 5.16"]
|
|
32
|
+
extra_dev_deps << ["hoe-halostatue", "~> 3.0"]
|
|
33
|
+
extra_dev_deps << ["irb", "~> 1.0"]
|
|
34
|
+
extra_dev_deps << ["minitest", ">= 5.16", "< 7"]
|
|
35
35
|
extra_dev_deps << ["minitest-autotest", "~> 1.0"]
|
|
36
|
-
extra_dev_deps << ["minitest-focus", "~> 1.
|
|
36
|
+
extra_dev_deps << ["minitest-focus", "~> 1.1"]
|
|
37
37
|
extra_dev_deps << ["rake", ">= 10.0", "< 14"]
|
|
38
|
-
extra_dev_deps << ["rdoc", ">= 0.0"]
|
|
38
|
+
extra_dev_deps << ["rdoc", ">= 0.0", "< 8"]
|
|
39
|
+
extra_dev_deps << ["simplecov", ">= 0.22", "< 2"]
|
|
40
|
+
extra_dev_deps << ["simplecov-lcov", "~> 0.8"]
|
|
39
41
|
extra_dev_deps << ["standard", "~> 1.0"]
|
|
40
42
|
extra_dev_deps << ["standard-minitest", "~> 1.0"]
|
|
41
43
|
extra_dev_deps << ["standard-thread_safety", "~> 1.0"]
|
|
42
44
|
end
|
|
45
|
+
|
|
46
|
+
Minitest::TestTask.create :test
|
|
47
|
+
Minitest::TestTask.create :coverage do |t|
|
|
48
|
+
formatters = <<-RUBY.split($/).join(" ")
|
|
49
|
+
SimpleCov::Formatter::MultiFormatter.new([
|
|
50
|
+
SimpleCov::Formatter::HTMLFormatter,
|
|
51
|
+
SimpleCov::Formatter::LcovFormatter,
|
|
52
|
+
SimpleCov::Formatter::SimpleFormatter
|
|
53
|
+
])
|
|
54
|
+
RUBY
|
|
55
|
+
t.test_prelude = <<-RUBY.split($/).join("; ")
|
|
56
|
+
require "simplecov"
|
|
57
|
+
require "simplecov-lcov"
|
|
58
|
+
|
|
59
|
+
SimpleCov::Formatter::LcovFormatter.config do |config|
|
|
60
|
+
config.report_with_single_file = true
|
|
61
|
+
config.lcov_file_name = "lcov.info"
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
SimpleCov.start "test_frameworks" do
|
|
65
|
+
enable_coverage :branch
|
|
66
|
+
primary_coverage :branch
|
|
67
|
+
formatter #{formatters}
|
|
68
|
+
end
|
|
69
|
+
RUBY
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
task default: :test
|
|
73
|
+
|
|
74
|
+
task :version do
|
|
75
|
+
require "minitar/version"
|
|
76
|
+
puts Minitar::VERSION
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
RDoc::Task.new do
|
|
80
|
+
_1.title = "minitar"
|
|
81
|
+
_1.main = "README.md"
|
|
82
|
+
_1.rdoc_dir = "doc"
|
|
83
|
+
_1.rdoc_files = hoe.spec.require_paths - ["Manifest.txt"] + hoe.spec.extra_rdoc_files
|
|
84
|
+
_1.markup = "markdown"
|
|
85
|
+
end
|
|
86
|
+
task docs: :rerdoc
|
|
87
|
+
|
|
88
|
+
task :console do
|
|
89
|
+
arguments = %w[irb]
|
|
90
|
+
arguments.push(*hoe.spec.require_paths.map { |dir| "-I#{dir}" })
|
|
91
|
+
arguments.push("-r#{hoe.spec.name.gsub("-", File::SEPARATOR)}")
|
|
92
|
+
unless system(*arguments)
|
|
93
|
+
error "Command failed: #{show_command}"
|
|
94
|
+
abort
|
|
95
|
+
end
|
|
96
|
+
end
|