libarchive icon indicating copy to clipboard operation
libarchive copied to clipboard

Support multi-volume archives with bsdtar CLI

Open polyzen opened this issue 9 years ago • 8 comments
trafficstars

https://github.com/libarchive/libarchive/issues/569#issuecomment-228560974

polyzen avatar Sep 12 '16 17:09 polyzen

Can you suggest what this CLI might look like?

kientzle avatar Sep 23 '16 03:09 kientzle

Preferably the same way it currently looks. bsdtar xf $archive.rar

This is how mpv handles it: https://github.com/mpv-player/mpv/pull/2458/files#diff-2bfc98a5d1644cf7803ce3dbc4279eceR160

polyzen avatar Sep 23 '16 08:09 polyzen

Hmmm.. First, I'll note that we cannot copy code from mpv due to GPL issues.

But the idea is certainly interesting. If I understand correctly, it works like this:

If the filename matches one of a list of known patterns, then: * Look for other files that match the pattern. * Collect all of the resulting files as input to libarchive

So if I type bsdtar xf archive.rar, and the files archive.r02, archive.r03 are sitting on disk, then bsdtar would automatically use them. Similarly, if I type bsdtar xf archive.001.rar, it would look for and use archive.002.rar but not archive.r02. This would all happen before bsdtar asked libarchive to open the archive, so would happen before any format checks.

Is that basically what you're suggesting?

kientzle avatar Sep 23 '16 14:09 kientzle

I see here the headers has details on if the archive is part of a multivolume set and more details that may be of use.

Archive flags vint 0x0001 Volume. Archive is a part of multivolume set. End of archive flags vint 0x0001 Archive is volume and it is not last volume in the set

Will take another look to see if it actually points to the following part(s) of the archive.

polyzen avatar Sep 24 '16 03:09 polyzen

fwiw, it can be done "manually" by simply cat archive.r* | bsdtar xf -, or of course cat archive.r* > archive2.rar && bsdtar xf archive2.rar. i think this works for both rar4 and rar5. unfortunately this is not efficient for listing or extracting subsets of large archives. if your filesystem supports reflink (btrfs, xfs) then you could do it faster with copy_file_range but i don't know of any utilities that will do cat with copy_file_range.

Hello71 avatar Sep 17 '21 14:09 Hello71

bsdtar can do so much but the lack of support for multi-volumes is the only reason why I use unarchiver.

rieje avatar Dec 17 '21 00:12 rieje

This works only for rar5. (Edit: wrong; that was for v3.4.3; now also rar4 works)

bgermann avatar Nov 14 '22 21:11 bgermann

Is there any progress for this? I found a tool that uses libarchive for this. But it would be nice if bsdtar could support that.

https://gitlab.com/bgermann/unrar-free

misery avatar Jul 18 '23 08:07 misery