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

fix(-A): detect more compression formats #934

Merged
merged 2 commits into from
Sep 29, 2024
Merged

Conversation

190n
Copy link
Contributor

@190n 190n commented Sep 16, 2024

109ce67 added support for uncompressed package tarballs, but the compression format was limited to xz or zstd. I added detection for all the compression formats mentioned in the default makepkg.conf:

COMPRESSGZ=(gzip -c -f -n)
COMPRESSBZ2=(bzip2 -c -f)
COMPRESSXZ=(xz -c -z -)
COMPRESSZST=(zstd -c -T0 -)
COMPRESSLRZ=(lrzip -q)
COMPRESSLZO=(lzop -q)
COMPRESSZ=(compress -c -f)
COMPRESSLZ4=(lz4 -q)
COMPRESSLZ=(lzip -c -f)

In particular this restores LZ4 support which broke for me when I recently upgraded to aura 4.0.

@fosskers
Copy link
Owner

Hi, thanks for this. I will do a full review in 5 days.

Comment on lines +267 to +280
[
".pkg.tar.gz",
".pkg.tar.bz2",
".pkg.tar.xz",
".pkg.tar.zst",
".pkg.tar.lrz",
".pkg.tar.lzo",
".pkg.tar.Z",
".pkg.tar.lz4",
".pkg.tar.lz",
".pkg.tar",
]
.iter()
.any(|ext| p.ends_with(ext))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is used in a number of places and in some cases may be called thousands of times. I'd like to avoid the allocation of an Iter and the O(n) lookup if possible, but for that we'd need a HashSet or something, yet can't allocate one statically.

Another approach would be to just have a large chain of || calls, with the most likely candidates first. Any thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked on Godbolt and all the iterator stuff seems to be inlined. Here's the code generated with any() and here's the code with a || chain. The order is a little different but the basic operations are the same.

I can move .pkg.tar, .pkg.tar.zst, and .pkg.tar.xz to the top, though. That does affect the order in which comparisons are made in the assembly so it'll be a bit faster to return early on those cases.

@fosskers fosskers merged commit 55dc97d into fosskers:master Sep 29, 2024
1 check passed
@fosskers
Copy link
Owner

I took care of it. Thanks again for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants