Building squashfs-tools from the source package

Submitted by olaf on 2016-04-03

To learn more about how my router works, I downloaded a firmware image and unpacked it into bootloader, kernel and rootfs. The root filesystem is compressed with Squashfs. To look into it, I tried unsquashfs. Unfortunately, the stock Ubuntu squashfs-tools package doesn’t support LZMA compressed filesystems.

A quick web search revealed How to use ‘unsquashfs’ with lzma?, but usually I prefer using the package system wherever possible.

So I installed the source package

apt-get source squashfs-tools
cd squashfs-tools-4.2+20130409

and then uncommented in the Makefile the line

LZMA_XZ_SUPPORT = 1

but left alone

#LZMA_SUPPORT = 1

because Ubuntu’s version (lzma-dev, 9.22) is too far away from 4.65 used by the developers. Now run

dpkg-buildpackage -uc -tc

which results in a few error messages

dpkg-checkbuilddeps: Unmet build dependencies: libattr1-dev liblzma-dev liblzo2-dev
dpkg-buildpackage: warning: build dependencies/conflicts unsatisfied; aborting

Installing the missing dependencies

apt-get install libattr1-dev liblzma-dev liblzo2-dev

and rerunning the build

dpkg-buildpackage -uc -tc

gave a few more errors, because of my Makefile modifications

dpkg-source: info: local changes detected, the modified files are:
squashfs-tools-4.2+20130409/Makefile
dpkg-source: info: you can integrate the local changes with dpkg-source –commit
dpkg-source: error: aborting due to unexpected upstream changes, see /tmp/squashfs-tools_4.2+20130409-2.diff.qIUs6W
dpkg-buildpackage: error: dpkg-source -b squashfs-tools-4.2+20130409 gave error exit status 2

Again Stackexchange came to the rescue

Avoid the Debian bureaucracy by just building the binary: dpkg-buildpackage -b

And finally

dpkg-buildpackage -b -uc -tc

delivered the desired result. As a last step, I had to install the newly built package before I could return to my router studies.

Post a comment

All comments are held for moderation; Markdown and basic HTML formatting accepted. If you want to stay anonymous, leave name, e-mail and website empty.