SquashFS, XZ-Utils, CPIO, U-Boot Tools, OpenSSL, Util-Linux, Coreutils, Diffutils, Bash, and More

The following are packages and tools to expand and/or enhance the functionality of the PR4100/PR2100 factory firmware. Entware is required and make, zlib, bzip2 and gcc must be installed to compile them on the actual hardware. Use at your own risk.

Entware Packages (Required):

opkg install make
opkg install zlib-dev
opkg install bzip2
opkg install gcc

SquashFS (Requires XZ-Utils):

The SquashFS package is a compressed read-only filesystem for Linux, and is used during the image.cfs file creation process. Specifically, the mksquashfs program is intended to replace the ancient 32 bit version included with WD factory firmware GPL source code and the unsquashfs program may be used to extract the contents of the image.cfs file, but only after it’s 2048 byte header has been removed.

curl -L https://sourceforge.net/projects/squashfs/files/squashfs/squashfs4.3/squashfs4.3.tar.gz/download -o squashfs4.3.tar.gz
tar zxvf squashfs4.3.tar.gz
cd squashfs4.3/squashfs-tools
export CC=gcc HOSTCC=gcc ARCH=x86_64
source /opt/bin/gcc_env.sh
sed -i -e "s/^INCLUDEDIR = -I./INCLUDEDIR = -I . -I \/opt\/include/g" Makefile
sed -i -e 's/^INSTALL_DIR = \/usr\/local\/bin/INSTALL_DIR = \/opt\/bin/g' Makefile
sed -i -e "s/^#XZ_SUPPORT = 1/XZ_SUPPORT = 1/g" Makefile
#sed -i -e "s/^XZ_SUPPORT = 1/#XZ_SUPPORT = 1/g" Makefile
make clean
make -j4
make install
cd ../../
rm -rf squashfs4.3

XZ-Utils:

The XZ Utils package is a general-purpose data compression program with a high compression ratio based on the LZMA2 compression algorithm, and is required by the Squashfs Tools package.

curl -L https://tukaani.org/xz/xz-5.2.4.tar.gz -o xz-5.2.4.tar.gz
tar zxvf xz-5.2.4.tar.gz
cd xz-5.2.4
export CC=gcc HOSTCC=gcc ARCH=x86_64
source /opt/bin/gcc_env.sh
./configure --prefix=/opt
make clean
make -j4
make install
cd ../
rm -rf xz-5.2.4

CPIO:

The CPIO package copies files into or out of a cpio or tar archive, used during the uRamdisk file creation process, which also requires the mkimage program from the U-Boot Tools package.

curl -L https://ftp.gnu.org/gnu/cpio/cpio-2.12.tar.gz -o cpio-2.12.tar.gz
tar zxvf cpio-2.12.tar.gz
cd cpio-2.12
export CC=gcc HOSTCC=gcc ARCH=x86_64
source /opt/bin/gcc_env.sh
./configure --prefix=/opt
make clean
make -j4
make install
cd ../
rm -rf cpio-2.12

U-Boot Tools (Requires OpenSSL, M4, Flex, and Bison):

U-Boot uses a special image format when loading the Linux kernel or ramdisk or other images. This image contains information about the time of creation, operating system, compression type, image type, image name and CRC32 checksums, etc. The mkimage tool is used to create such images or to display the information they contain.

The U-Boot Tools package is especially tricky to compile, where it requires precise configurations for specific boards, but in this case a generic board configuration is used to compile the tools to run on x86_64 hardware. Specifically, the mkimage program is intended to replace the ancient 32 bit version included with WD factory firmware GPL source code.

curl -L http://ftp.denx.de/pub/u-boot/u-boot-2018.09.tar.bz2 -o u-boot-2018.09.tar.bz2
bzip2 -d < u-boot-2018.09.tar.bz2 | tar xf -
mv u-boot-2018.09 u-boot
#git clone http://git.denx.de/u-boot.git
cd u-boot
export CC=gcc HOSTCC=gcc ARCH=x86_64
source /opt/bin/gcc_env.sh
make distclean
make -j4 qemu-x86_defconfig HOSTCC=gcc tools-only
# make install
cp ./tools/mkimage /opt/bin
cd ../
rm -rf u-boot

OpenSSL:

The OpenSSL package is a robust, commercial-grade, and full-featured toolkit for the Transport Layer Security (TLS) and Secure Sockets Layer (SSL) protocols. It is also a general-purpose cryptography library.

This is an upgrade to the OpenSSL package included with the PR4100 factory firmware, and is required by the U-Boot Tools package.

curl -L https://www.openssl.org/source/openssl-1.1.1.tar.gz -o openssl-1.1.1.tar.gz
tar zxvf openssl-1.1.1.tar.gz
cd openssl-1.1.1
export CC=gcc HOSTCC=gcc ARCH=x86_64
source /opt/bin/gcc_env.sh
./config --prefix=/opt
make clean
make -j4
make install
cd ../
rm -rf openssl-1.1.1

M4:

The GNU M4 package is an implementation of the traditional Unix macro processor, and is required by the U-Boot Tools package.

curl -L http://ftp.gnu.org/gnu/m4/m4-1.4.18.tar.gz -o m4-1.4.18.tar.gz
tar zxvf m4-1.4.18.tar.gz
cd m4-1.4.18
export CC=gcc HOSTCC=gcc ARCH=x86_64
source /opt/bin/gcc_env.sh
./configure --prefix=/opt
make clean
make -j4
make install
cd ../
rm -rf m4-1.4.18

Flex:

The Flex package is a fast lexical analyzer generator for generating scanners: programs which recognize lexical patterns in text, and is required by the U-Boot Tools package.

curl -L https://github.com/westes/flex/releases/download/v2.6.4/flex-2.6.4.tar.gz -o flex-2.6.4.tar.gz
tar zxvf flex-2.6.4.tar.gz
cd flex-2.6.4
export CC=gcc HOSTCC=gcc ARCH=x86_64
source /opt/bin/gcc_env.sh
./configure --prefix=/opt
make clean
make -j4
make install
cd ../
rm -rf flex-2.6.4

Bison:

The Bison package is a general-purpose parser generator that converts an annotated context-free grammar into a deterministic LR or generalized LR (GLR) parser employing LALR(1) parser tables, and is required by the U-Boot Tools package.

curl -L http://ftp.gnu.org/gnu/bison/bison-3.1.tar.gz -o bison-3.1.tar.gz
tar zxvf bison-3.1.tar.gz
cd bison-3.1
export CC=gcc HOSTCC=gcc ARCH=x86_64
source /opt/bin/gcc_env.sh
./configure --prefix=/opt
make clean
make -j4
make install
cd ../
rm -rf bison-3.1

Util-Linux:

The util-linux package is a standard collection of Linux utilities (blkid, fdisk, kill, lsblk, mount, umount, etc…) distributed by the Linux Kernel Organization.

curl -L https://mirrors.edge.kernel.org/pub/linux/utils/util-linux/v2.32/util-linux-2.32.1.tar.gz -o util-linux-2.32.1.tar.gz
tar zxvf util-linux-2.32.1.tar.gz
cd util-linux-2.32.1
export CC=gcc HOSTCC=gcc ARCH=x86_64
source /opt/bin/gcc_env.sh
./configure --prefix=/opt --includedir=/opt/include --disable-eject
make clean
make -j4
make install
cd ../
rm -rf util-linux-2.32.1

Coreutils (GNU):

The coreutils package contains utilities (cat, chmod, dd, ls, mkdir, rm, etc…) for manipulating basic system characteristics.

curl -L https://ftp.gnu.org/gnu/coreutils/coreutils-8.30.tar.xz -o coreutils-8.30.tar.xz
/opt/bin/tar xvf coreutils-8.30.tar.xz
cd coreutils-8.30
export CC=gcc HOSTCC=gcc ARCH=x86_64 FORCE_UNSAFE_CONFIGURE=1
source /opt/bin/gcc_env.sh
./configure --prefix=/opt
make clean
make -j4
make install
cd ../
rm -rf coreutils-8.30

Binutils (GNU):

The binutils package is a set of programming tools for creating and managing binary programs, object files, libraries, profile data, and source code.

curl -L https://ftp.gnu.org/gnu/binutils/binutils-2.31.tar.gz -o binutils-2.31.tar.gz
tar zxvf binutils-2.31.tar.gz
cd binutils-2.31
export CC=gcc HOSTCC=gcc ARCH=x86_64
source /opt/bin/gcc_env.sh
./configure --prefix=/opt
make clean
make -j4
make install
cd ../
rm -rf binutils-2.31

Diffutils (GNU):

The diffutils package is a collection of several programs related to finding differences between files.

curl -L https://ftp.gnu.org/gnu/diffutils/diffutils-3.6.tar.xz -o diffutils-3.6.tar.xz
/opt/bin/tar xvf diffutils-3.6.tar.xz
cd diffutils-3.6
export CC=gcc HOSTCC=gcc ARCH=x86_64 FORCE_UNSAFE_CONFIGURE=1
source /opt/bin/gcc_env.sh
./configure --prefix=/opt
make clean
make -j4
make install
cd ../
rm -rf diffutils-3.6

Bash (GNU):

Bash (Bourne-again shell) is a command processor that typically runs in a text window where the user types commands that cause actions. Commands can also read and executed from a file called a shell script. Like all Unix shells, it supports filename globbing (wildcard matching), piping, here documents, command substitution, variables, and control structures for condition-testing and iteration. The keywords, syntax and other basic features of the language are all copied from sh. Other features are copied from csh and ksh.

curl -L https://ftp.gnu.org/gnu/bash/bash-4.4.18.tar.gz -o bash-4.4.18.tar.gz
tar zxvf bash-4.4.18.tar.gz
cd bash-4.4.18
export CC=gcc HOSTCC=gcc ARCH=x86_64
source /opt/bin/gcc_env.sh
./configure --prefix=/opt
make clean
make -j4
make install
cd ../
rm -rf bash-4.4.18

Tar (GNU):

The tar package contains an archiver program used to create and manipulate files that are actually collections of many other files.

curl -L https://ftp.gnu.org/gnu/tar/tar-1.30.tar.gz -o tar-1.30.tar.gz
tar zxvf tar-1.30.tar.gz
cd tar-1.30
export CC=gcc HOSTCC=gcc ARCH=x86_64 FORCE_UNSAFE_CONFIGURE=1
source /opt/bin/gcc_env.sh
./configure --prefix=/opt
make clean
make -j4
make install
cd ../
rm -rf tar-1.30

Make (GNU):

The make package contains a tool which controls the generation of executables and other files of a program from the program’s source files. Make gets its knowledge of how to build a program from a file called the makefile, which lists each of the non-source files and how to compute it from other files.

curl -L https://ftp.gnu.org/gnu/make/make-4.2.tar.gz -o make-4.2.tar.gz
tar zxvf make-4.2.tar.gz
cd make-4.2
export CC=gcc HOSTCC=gcc ARCH=x86_64
source /opt/bin/gcc_env.sh
./configure --prefix=/opt
make clean
make -j4
make install
cd ../
rm -rf make-4.2

Nice share!
Is openssl 1.1.1 really required or would 1.0.2n also do? The mksapkg tool uses openssl to sign packages and it relies on the MD5 default hash. The default hash changed in 1.1.x to SHA256, causing the naive mksapkg to add wrong signatures.

The cpio and m4 packages are available through entware, but I guess you needed the header files.