Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Partial extract by pattern #243

Open
VHSgunzo opened this issue Nov 12, 2024 · 4 comments
Open

[Feature Request] Partial extract by pattern #243

VHSgunzo opened this issue Nov 12, 2024 · 4 comments
Labels
enhancement New feature or request fixready

Comments

@VHSgunzo
Copy link

Thanks for the great project!
Is it possible to add a partial extract by pattern, as it is done in unsquashfs?

For example:

unsquashfs squashfs-image '*.desktop'

or:

unsquashfs squashfs-image 'path/in/squashfs/image/*.png'
@mhx
Copy link
Owner

mhx commented Nov 13, 2024

Something like this would certainly be possible to add.

Rather than implementing yet another file selection logic (a quick look at the manpage suggests that it's also possible to exclude paths, use regexes, ...), I'd probably use the same logic that is currently used to filter files in mkdwarfs. For convenience, I'd probably also add simple globbing.

It's going to take a while before I'll get around to implementing any of this, though.

@mhx mhx added the enhancement New feature or request label Nov 13, 2024
@VHSgunzo
Copy link
Author

Thanks again! That would be great. I'll be waiting for the news.

@mhx
Copy link
Owner

mhx commented Nov 16, 2024

I thought I'd let ChatGPT come up with the glob implementation, but after iterating on its malfunctioning and over-complicated "solution" for way too long, I just implemented it myself... :)

Rather than implementing yet another file selection logic (a quick look at the manpage suggests that it's also possible to exclude paths, use regexes, ...), I'd probably use the same logic that is currently used to filter files in mkdwarfs. For convenience, I'd probably also add simple globbing.

I actually went a different route: I changed the code that implements filters in mkdwarfs to also use the new (much more capable) globbing code. This allows for much more flexible filters in addition to supporting partial extraction using one or more patterns. Win-win.

$ dwarfsextract -i data.dwarfs -o tmp2 '**/*.sh' '*.py' '{foo,bar}/**/[i-k]'
I 20:52:30.837724 extraction finished without errors
$ find tmp2
tmp2
tmp2/foo
tmp2/foo/1
tmp2/foo/1/2
tmp2/foo/1/2/3
tmp2/foo/1/2/3/4
tmp2/foo/1/2/3/4/5
tmp2/foo/1/2/3/4/5/6
tmp2/foo/1/2/3/4/5/6/7
tmp2/foo/1/2/3/4/5/6/7/8
tmp2/foo/1/2/3/4/5/6/7/8/9
tmp2/foo/1/2/3/4/5/6/7/8/9/i
tmp2/foo/1/2/3/4/5/6/7/8/9/j
tmp2/foo/1/2/3/4/5/6/7/8/9/k
tmp2/foo/1/2/3/copy.sh
tmp2/foo/1/2/xxx.sh
tmp2/foo/1/fmt.sh
tmp2/foo/bla.sh
tmp2/bench.sh
tmp2/format.sh
tmp2/perl-exec.sh
tmp2/test.py

This should make it into the next release. If you want to play with it, you can try using the artifacts produced by the CI pipeline.

@mhx mhx added the fixready label Nov 16, 2024
@VHSgunzo
Copy link
Author

Thank you for adding this feature, it works better than I even expected ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request fixready
Projects
None yet
Development

No branches or pull requests

2 participants