Giter VIP home page Giter VIP logo

squashfs's Introduction

golang library for reading squashfs filesystems.

This is a golang library that provides access to squashfs filesystems.

It uses the the libsquashfs C library from squashfs-tools-ng.

It will build against 1.0.0, but the Read operations require a fix for squashfs-tools-ng/#58.

There is really good doc of squashfs format at doc/format.adoc

Build setup

Most of this is handled by setup program. But if you want to do it on your own, the following is a summary of what setup will do.

I'm assuming you have 'git'. Get that with apt or yum.

  • get squashfs-tools-ng

     $ git clone https://github.com/AgentD/squashfs-tools-ng.git
    
  • get go-squashfs

     $ git clone https://github.com/anuvu/squashfs go-squashfs
    
  • Get build deps

    • Ubuntu

       $ sudo apt-get install --no-install-recommends  --assume-yes \
           autoconf automake make autogen autoconf libtool binutils \
           git squashfs-tools
      
       $ sudo apt-get install --no-install-recommends --assume-yes \
          libzstd-dev zlib1g-dev liblz4-dev libc6-dev liblzma-dev
      
    • Centos 7

       # we need epel for libzstd
       $ sudo yum install --assumeyes https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
      
       $ sudo yum install --assumeyes \
           git make autogen automake autoconf \
           libtool binutils squashfs-tools
      
       $ sudo yum install --assumeyes \
          libzstd-devel libzstd-static \
          zlib-devel zlib-static \
          lz4-devel lz4-static \
          glibc-devel glibc-static \
          xz xz-devel
      
  • Get golang. You can/should figure this out yourself, but here is one way:

     $ ver=1.14.4
     $ majmin=${ver%.*}
     $ curl https://dl.google.com/go/go${ver}.linux-amd64.tar.gz > go.tar.gz
    
     # this creates /usr/lib/go-1.14
     $ sudo tar -C /usr/lib -xvf go.tar.gz --show-transformed-names --transform "s/^go/go-$majmin/"
     $ sudo ln -sf ../lib/go-$majmin/bin/go /usr/bin/go
    
  • install into mylocal="$HOME/lib"

     $ mylocal="$HOME/mylocal"
     $ export LD_LIBRARY_PATH=$mylocal/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
     $ export PKG_CONFIG_PATH=$mylocal/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}
    
  • build and install squashfs-tools-ng

     $ cd squashfs-tools-ng
     $ ./autogen.sh
     $ ./configure --prefix=$mylocal
     $ make
     $ make install
    
  • build go-squashfs

     $ cd go-squashfs
     $ make
    

squashfs's People

Contributors

tych0 avatar ariel-miculas avatar

Stargazers

Vitaly Lipatov avatar alaska avatar Anton Danilov avatar  avatar Dan Ryan avatar Mathew R Gordon avatar solo-fish avatar tianzichen avatar Dave Walker avatar Nickolay avatar

Watchers

Scott Moser avatar Neustradamus avatar Ravi Chamarthy avatar James Cloos avatar Sri Goli avatar  avatar

squashfs's Issues

\x in name (systemd slice files) cause issues.

@raharper found this issue and provided examlpe squashfs

example.squashfs.zip

output output of unsquashfs, but squashtool fails.

$ unsquashfs -lls /tmp/example.squashfs
Parallel unsquashfs: Using 8 processors
2 inodes (2 blocks) to write

drwxr-xr-x 1002/1002                96 2021-01-13 15:17 squashfs-root
-rw-r--r-- 1002/1002               434 2021-01-13 15:17 squashfs-root/system-systemd-cryptsetup.slice
-rw-r--r-- 1002/1002               434 2021-01-13 15:17 squashfs-root/system-systemd\x2dcryptsetup.slice


$ squashtool list /tmp/example.squashfs
 drwxr-xr-x  1 1002 1002           96 Jan  13 15:17 /
 -rw-r--r--  1 1002 1002          434 Jan  13 15:17 /system-systemd-cryptsetup.slice
2021/01/13 15:36:22 walk / failed: file does not exist

good for us, squashtool-ng's rdsquashfs seems to be fine:

$ /usr/bin/rdsquashfs --list=/ /tmp/example.squashfs
-rw-r--r-- 1002/1002 434 system-systemd-cryptsetup.slice
-rw-r--r-- 1002/1002 434 system-systemd\x2dcryptsetup.slice

Ability to open SquashFS file with an offset

For some situations like appending a SquashFS to some other form of file, it is useful to be able to read from that SquashFS with an offset, this function could be named something along the lines of OpenSquashfsWithOffset()

Types errors during building for arm64 and i586

Hi, buddies.
I got errors during using your project on arm64 and i586 :
vendor/github.com/anuvu/squashfs/squash.go:185:33: cannot use f.ModTime().Unix() (value of type int64) as int32 value in struct literal
[i586] vendor/github.com/anuvu/squashfs/squash.go:238:12: cannot use uint64(nlinks) (value of type uint64) as uint32 value in struct literal
[i586] vendor/github.com/anuvu/squashfs/squash.go:244:12: cannot use int64(blksize) (value of type int64) as int32 value in struct literal
[i586] vendor/github.com/anuvu/squashfs/squash.go:341:40: cannot use _Ctype_ulong(f.Pos) (value of type _Ctype_ulong) as _Ctype_ulonglong value in variable declaration
[i586] vendor/github.com/anuvu/squashfs/squash.go:598:3: cannot use _Ctype_ulong(sqfs.super.block_size) (value of type _Ctype_ulong) as _Ctype_uint value in argument to (_Cfunc_sqfs_compressor_config_init)
[i586] vendor/github.com/anuvu/squashfs/squash.go:630:83: cannot use _Ctype_ulong(sqfs.super.block_size) (value of type _Ctype_ulong) as _Ctype_uint value in variable declaration

Can you help me with it, please?

For understanding, i need to build Stacker and have buildings require on you there.

Is there a backport of libsquashfs1 back to focal? building stacker / umoci for Ubuntu focal

side note: Granted, this is a problem with Ubuntu not having a backported lib from jammy / hirsuite and my use of an outdated Ubuntu install. However, if anyone has any idea, please do share it.

~/Projects/squashfs$ make
go build ./...
go: downloading github.com/urfave/cli/v2 v2.2.0
go: downloading golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae
go: downloading github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d
# pkg-config --cflags  -- libsquashfs1
pkg-config: exec: "pkg-config": executable file not found in $PATH

####
~/Projects/squashfs$ make
go build ./...
# pkg-config --cflags  -- libsquashfs1
Package libsquashfs1 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libsquashfs1.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libsquashfs1' found
pkg-config: exit status 1
make: *** [Makefile:17: .build] Error 2

Is there a backport of libsquashfs1 back to focal? I am trying to build umoci in order to build stacker for my Ubuntu Focal.
https://packages.ubuntu.com/search?keywords=squash

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.