### Example pack file Source: https://github.com/agentd/squashfs-tools-ng/blob/master/bin/gensquashfs/gensquashfs.1 A complete example pack file showing how to create directories, device nodes, regular files, and glob entries. The glob commands collect directory trees, regular files, and symlinks from ./lib into /usr/lib, with explicit modes and uid/gid. ```plaintext # A simple squashfs image dir /dev 0755 0 0 nod /dev/console 0600 0 0 c 5 1 dir /root 0700 0 0 dir /sbin 0755 0 0 # Add a file. Input is relative to pack dir or listing path file /sbin/init 0755 0 0 ../init/sbin/init # Read from ./bin/bash relative to pack dir or listing path # /bin is created implicitly with default attributes. file /bin/bash 0755 0 0 # file name with a space in it and a "special" name file "/opt/my app/\"special\"/data" 0600 0 0 # collect the contents of ./lib and put it under /usr/lib # mode and uid/gid are explictly set. First we collect the directory tree, # then all so files, then all symlinks that don't end in ".so" glob /usr/lib 0755 0 0 -type d ./lib glob /usr/lib 0755 0 0 -type f -name "*.so.*" ./lib glob /usr/lib 0777 0 0 -type l -name "*.so.*" ./lib ``` -------------------------------- ### Build and install optimized squashfs-tools-ng to tmpfs Source: https://github.com/agentd/squashfs-tools-ng/blob/master/doc/benchmark.txt Commands to compile an optimized build of squashfs-tools-ng and install it to a tmpfs directory. The build uses CFLAGS and LDFLAGS with -O3 -Ofast -march=native -mtune=native. Working in tmpfs eliminates I/O performance and caching side effects to measure actual processing time. ```bash $ mkdir /dev/shm/temp $ ln -s /dev/shm/temp out $ ./autogen.sh $ ./configure CFLAGS="-O3 -Ofast -march=native -mtune=native" \ LDFLAGS="-O3 -Ofast" --prefix=$(pwd)/out $ make -j install-strip $ cd out ``` -------------------------------- ### Build from release tarball with autotools Source: https://github.com/agentd/squashfs-tools-ng/blob/master/README.md Standard autotools build steps for an official release tarball: configure, make, and install. ```shell ./configure make make install ``` -------------------------------- ### Build RPM package for OpenSUSE Source: https://github.com/agentd/squashfs-tools-ng/blob/master/packages/README.md Install rpm-build, download sources manually (spectool not available), install build dependencies, and build the RPM package. ```bash zypper install -y rpm-build rpmspec --parse squashfs-tools-ng.spec | grep Source0 | awk '{print $2}' | xargs wget -N -P $(rpm --eval '%{_sourcedir}') rpmspec --parse squashfs-tools-ng.spec | grep BuildRequires | cut -d' ' -f2 | xargs sudo zypper install -y rpmbuild --clean -ba squashfs-tools-ng.spec ``` -------------------------------- ### Generate SquashFS image with specified compressor Source: https://github.com/agentd/squashfs-tools-ng/blob/master/doc/benchmark.txt Used to create a SquashFS image for each supported compressor in the reference decompression benchmark. Replace with the desired compressor name. ```bash $ ./bin/sqfs2tar debian.sqfs | ./bin/tar2sqfs -c test.sqfs ``` -------------------------------- ### Build RPM package for CentOS/Fedora Source: https://github.com/agentd/squashfs-tools-ng/blob/master/packages/README.md Install rpm-build and spectool, set up rpm tree, download sources, install build dependencies, and build the RPM package. ```bash yum install -y rpm-build spectool rpmdev-setuptree spectool -g -R squashfs-tools-ng.spec rpmspec --parse squashfs-tools-ng.spec | grep BuildRequires | cut -d' ' -f2 | xargs sudo yum install -y rpmbuild --clean -ba squashfs-tools-ng.spec ``` -------------------------------- ### Set up Alpine build environment Source: https://github.com/agentd/squashfs-tools-ng/blob/master/packages/README.md Create a user named pkg-builder, add to abuild group, configure sudoers, and install alpine-sdk. Required before building APK packages. ```bash adduser pkg-builder addgroup pkg-builder abuild echo '%abuild ALL=(ALL) NOPASSWD:/sbin/apk, /bin/mkdir -p /etc/apk/keys, /bin/cp -i *.pub /etc/apk/keys/' > /etc/sudoers.d/abuild chmod 0400 /etc/sudoers.d/abuild apk add alpine-sdk ``` -------------------------------- ### Measure unpacking time with sqfs2tar Source: https://github.com/agentd/squashfs-tools-ng/blob/master/doc/benchmark.txt Command used to measure the unpacking time for each compressor. The output is discarded by redirecting to /dev/null. The measurement was repeated 4 times and the worst wall-clock time (real) was used for comparison. ```bash $ time -p ./bin/sqfs2tar test.sqfs > /dev/null ``` -------------------------------- ### Convert Debian image to tarball with sqfs2tar Source: https://github.com/agentd/squashfs-tools-ng/blob/master/doc/benchmark.txt Converts the Debian image (debian.sqfs) to a tarball using sqfs2tar. The output is redirected to test.tar. This tarball is used as input for the subsequent repacking benchmark. ```bash $ ./bin/sqfs2tar debian.sqfs > test.tar ``` -------------------------------- ### Build DEB package for version 1.0.4 Source: https://github.com/agentd/squashfs-tools-ng/blob/master/packages/README.md Install dependencies, download source, set up debian directory, update changelog, install build deps, and build the package. Adds codename to version number. ```bash apt-get install devscripts build-essential wget source /etc/os-release wget https://github.com/AgentD/squashfs-tools-ng/archive/v1.0.4/squashfs-tools-ng-1.0.4.tar.gz -O squashfs-tools-ng_1.0.4+$VERSION_CODENAME.orig.tar.gz tar xfz squashfs-tools-ng_1.0.4+$VERSION_CODENAME.orig.tar.gz cd squashfs-tools-ng-1.0.4 ln -s packages/debian DEBFULLNAME="$USER" DEBEMAIL="$USER@localhost" dch -v 1.0.4+$VERSION_CODENAME-1 -D $VERSION_CODENAME "Build 1.0.4 for $VERSION_CODENAME." mk-build-deps --install --tool='apt-get --no-install-recommends --yes' debian/control rm *.deb debuild debuild -- clean ``` -------------------------------- ### Repack tarball with tar2sqfs and measure time Source: https://github.com/agentd/squashfs-tools-ng/blob/master/doc/benchmark.txt Repacks the tarball into a SquashFS image using tar2sqfs with a specified number of CPUs and compressor. The time -p command measures wall-clock time. The repacking was repeated 4 times and the worst real time was used for comparison. ```bash $ time -p ./bin/tar2sqfs -j -c -f test.sqfs < test.tar ``` -------------------------------- ### Build PKG package Source: https://github.com/agentd/squashfs-tools-ng/blob/master/packages/README.md Install required tools and build the Archlinux package using makepkg. ```bash sudo pacman -S --noconfirm fakeroot binutils namcap makepkg --noconfirm -Cfsir PKGBUILD ``` -------------------------------- ### Build Doxygen reference manual Source: https://github.com/agentd/squashfs-tools-ng/blob/master/README.md Build the reference manual if Doxygen is available. ```shell make doxygen-doc ``` -------------------------------- ### Bootstrap build system from git tree Source: https://github.com/agentd/squashfs-tools-ng/blob/master/README.md Run autogen.sh first when working on the git tree to bootstrap the build system before building. ```shell ./autogen.sh ``` -------------------------------- ### Build Windows binaries with MinGW helper script Source: https://github.com/agentd/squashfs-tools-ng/blob/master/README.md Uses a MinGW cross toolchain to build squashfs-tools-ng and required dependencies for Windows. ```shell ./mkwinbins.sh ``` -------------------------------- ### Check PKG package with namcap Source: https://github.com/agentd/squashfs-tools-ng/blob/master/packages/README.md Run namcap to check the built package and PKGBUILD for issues. ```bash namcap -i squashfs-tools-*.pkg.tar.zst PKGBUILD ``` -------------------------------- ### Create compressed tar with gzip Source: https://github.com/agentd/squashfs-tools-ng/blob/master/bin/sqfs2tar/sqfs2tar.1 Uses the --compressor option to produce a gzip-compressed tar archive. ```bash sqfs2tar --compressor gzip rootfs.sqfs > rootfs.tar.gz ``` -------------------------------- ### Pack file format syntax Source: https://github.com/agentd/squashfs-tools-ng/blob/master/bin/gensquashfs/gensquashfs.1 Defines the newline-separated entries for the gensquashfs pack file. Each line specifies an entry type (file, dir, nod, slink, link, pipe, sock, glob) with required fields; optional location and target fields are used where applicable. ```plaintext # a comment file [] dir nod slink link pipe sock glob [OPTIONS...] ``` -------------------------------- ### Pipe to xz for custom compression flags Source: https://github.com/agentd/squashfs-tools-ng/blob/master/bin/sqfs2tar/sqfs2tar.1 Creates an uncompressed archive and pipes it into xz to apply custom compression flags. ```bash sqfs2tar rootfs.sqfs | xz -9e > rootfs.tar.xz ``` -------------------------------- ### Build packages using Docker Source: https://github.com/agentd/squashfs-tools-ng/blob/master/packages/README.md Use the build script to build packages for a specific vendor and release. Packages are output in the _out directory. ```bash ./build VENDOR RELEASE ``` -------------------------------- ### Build APK package Source: https://github.com/agentd/squashfs-tools-ng/blob/master/packages/README.md Generate a signing key and build the APK package as the pkg-builder user. ```bash abuild-keygen -nai abuild -r ``` -------------------------------- ### Convert tar archive to SquashFS with tar2sqfs Source: https://github.com/agentd/squashfs-tools-ng/blob/master/bin/tar2sqfs/tar2sqfs.1 Use this command to turn an uncompressed tar archive into a SquashFS image. The input archive is read from standard input and the output image is written to the specified file. ```bash tar2sqfs rootfs.sqfs < rootfs.tar.gz ``` -------------------------------- ### Convert SquashFS to tar Source: https://github.com/agentd/squashfs-tools-ng/blob/master/bin/sqfs2tar/sqfs2tar.1 Basic usage: converts a SquashFS image to an uncompressed tar archive written to stdout. ```bash sqfs2tar rootfs.sqfs > rootfs.tar ```