diff --git a/.gitignore b/.gitignore index a44478e..a427b9b 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,7 @@ squashfs.test # Memory and CPU pprof profiles mem.out cpu.out + +# IDEs +.idea/ +.vscode/ diff --git a/README.md b/README.md index 20d13d1..3bd1c41 100644 --- a/README.md +++ b/README.md @@ -2,22 +2,25 @@ [![PkgGoDev](https://pkg.go.dev/badge/github.com/CalebQ42/squashfs)](https://pkg.go.dev/github.com/CalebQ42/squashfs) [![Go Report Card](https://goreportcard.com/badge/github.com/CalebQ42/squashfs)](https://goreportcard.com/report/github.com/CalebQ42/squashfs) -A PURE Go library to read squashfs. There is currently no plans to add archive creation support as it will almost always be better to just call `mksquashfs`. I could see some possible use cases, but probably won't spend time on it unless it's requested (open a discussion if you want this feature). +A PURE Go library to read squashfs. There are currently no plans to add archive creation support as it will almost always be better to just call `mksquashfs`. +I could see some possible use cases, but probably won't spend time on it unless it's requested (open a discussion if you want this feature). The library has two parts with this `github.com/CalebQ42/squashfs` being easy to use as it implements `io/fs` interfaces and doesn't expose unnecessary information. 95% this is the library you want. If you need lower level access to the information, use `github.com/CalebQ42/squashfs/low` where far more information is exposed. Currently has support for reading squashfs files and extracting files and folders. -Special thanks to for some VERY important information in an easy to understand format. -Thanks also to [distri's squashfs library](https://github.com/distr1/distri/tree/master/internal/squashfs) as I referenced it to figure some things out (and double check others). +Special thanks to for some VERY important information in an easy-to-understand format. +Thanks also to [distri's squashfs library](https://github.com/distr1/distri/tree/master/internal/squashfs) as I referenced it to figure some things out (and double-check others). ## Build tags -As of `v1.1.0` this library has two optional build tags: `no_gpl` and `no_obsolete`. `no_gpl` disables the ability to read archives with lzo compression due to the library's gpl license. `no_obsolete` removes "obsolete" compression types for a reduced compilation size; currently this only disable lzma compression since it's superseded by xz. +This library has two optional build tags: +- `no_gpl` disables the ability to read archives with lzo compression due to the library's gpl license (this has been removed in `v1.2.0`). +- `no_obsolete` removes "obsolete" compression types for a reduced compilation size; currently this only disables lzma compression since it's superseded by xz. ## FUSE -As of `v1.0`, FUSE capabilities has been moved to [a separate library](https://github.com/CalebQ42/squashfuse). +As of `v1.0`, FUSE capabilities have been moved to [a separate library](https://github.com/CalebQ42/squashfuse). ## Limitations @@ -28,7 +31,7 @@ As of `v1.0`, FUSE capabilities has been moved to [a separate library](https://g ## Issues -* Noticably slower then `unsquashfs` for extraction, especially on larger images. +* Noticeably slower then `unsquashfs` for extraction, especially on larger images. * This seems to be related to above along with the general optimization of `unsquashfs` and it's compression libraries. * Times seem to be largely dependent on file tree size and compression type. * My main testing image (~100MB) using Zstd takes ~2x longer. diff --git a/go.mod b/go.mod index 6cad08b..d2acb7f 100644 --- a/go.mod +++ b/go.mod @@ -3,9 +3,9 @@ module github.com/CalebQ42/squashfs go 1.24.0 require ( + github.com/anchore/go-lzo v0.1.0 github.com/klauspost/compress v1.18.0 github.com/mikelolasagasti/xz v1.0.1 github.com/pierrec/lz4/v4 v4.1.22 - github.com/rasky/go-lzo v0.0.0-20200203143853-96a758eda86e github.com/ulikunitz/xz v0.5.12 ) diff --git a/go.sum b/go.sum index 9ede4f7..1c7476f 100644 --- a/go.sum +++ b/go.sum @@ -1,10 +1,10 @@ +github.com/anchore/go-lzo v0.1.0 h1:NgAacnzqPeGH49Ky19QKLBZEuFRqtTG9cdaucc3Vncs= +github.com/anchore/go-lzo v0.1.0/go.mod h1:3kLx0bve2oN1iDwgM1U5zGku1Tfbdb0No5qp1eL1fIk= github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo= github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ= github.com/mikelolasagasti/xz v1.0.1 h1:Q2F2jX0RYJUG3+WsM+FJknv+6eVjsjXNDV0KJXZzkD0= github.com/mikelolasagasti/xz v1.0.1/go.mod h1:muAirjiOUxPRXwm9HdDtB3uoRPrGnL85XHtokL9Hcgc= github.com/pierrec/lz4/v4 v4.1.22 h1:cKFw6uJDK+/gfw5BcDL0JL5aBsAFdsIT18eRtLj7VIU= github.com/pierrec/lz4/v4 v4.1.22/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= -github.com/rasky/go-lzo v0.0.0-20200203143853-96a758eda86e h1:dCWirM5F3wMY+cmRda/B1BiPsFtmzXqV9b0hLWtVBMs= -github.com/rasky/go-lzo v0.0.0-20200203143853-96a758eda86e/go.mod h1:9leZcVcItj6m9/CfHY5Em/iBrCz7js8LcRQGTKEEv2M= github.com/ulikunitz/xz v0.5.12 h1:37Nm15o69RwBkXM0J6A5OlE67RZTfzUxTj8fB3dfcsc= github.com/ulikunitz/xz v0.5.12/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= diff --git a/internal/decompress/lzo.go b/internal/decompress/lzo.go index 9f54e9e..e1fe241 100644 --- a/internal/decompress/lzo.go +++ b/internal/decompress/lzo.go @@ -1,11 +1,7 @@ -//go:build !no_gpl - package decompress import ( - "bytes" - - "github.com/rasky/go-lzo" + "github.com/anchore/go-lzo" ) type Lzo struct{} @@ -15,5 +11,7 @@ func NewLzo() (Lzo, error) { } func (l Lzo) Decompress(data []byte) ([]byte, error) { - return lzo.Decompress1X(bytes.NewReader(data), len(data), 0) + var dest []byte + _, err := lzo.Decompress(data, dest) + return dest, err } diff --git a/internal/decompress/lzo_disabled.go b/internal/decompress/lzo_disabled.go deleted file mode 100644 index 181b5cb..0000000 --- a/internal/decompress/lzo_disabled.go +++ /dev/null @@ -1,15 +0,0 @@ -//go:build no_gpl - -package decompress - -import "errors" - -type Lzo struct{} - -func NewLzo() (Lzo, error) { - return Lzo{}, errors.New("lzo compression is disable in this build with no_gpl") -} - -func (l Lzo) Decompress(data []byte) ([]byte, error) { - return nil, errors.New("lzo compression is disable in this build with no_gpl") -}