summaryrefslogtreecommitdiffstats
path: root/generate-manpages
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 17:23:08 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 17:23:08 +0000
commitdd76e45c20acc3f352ffe8257208cc617ba33eba (patch)
treec50c016a4182a27fd1ece9ec7ba4abf405f19e5f /generate-manpages
parentInitial commit. (diff)
downloadsquashfs-tools-dd76e45c20acc3f352ffe8257208cc617ba33eba.tar.xz
squashfs-tools-dd76e45c20acc3f352ffe8257208cc617ba33eba.zip
Adding upstream version 1:4.6.1.upstream/1%4.6.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'generate-manpages')
-rwxr-xr-xgenerate-manpages/functions.sh18
-rwxr-xr-xgenerate-manpages/install-manpages.sh82
-rwxr-xr-xgenerate-manpages/mksquashfs-manpage.sh253
-rw-r--r--generate-manpages/mksquashfs.h2m150
-rwxr-xr-xgenerate-manpages/sqfscat-manpage.sh189
-rw-r--r--generate-manpages/sqfscat.h2m29
-rwxr-xr-xgenerate-manpages/sqfstar-manpage.sh241
-rw-r--r--generate-manpages/sqfstar.h2m84
-rwxr-xr-xgenerate-manpages/unsquashfs-manpage.sh189
-rw-r--r--generate-manpages/unsquashfs.h2m89
10 files changed, 1324 insertions, 0 deletions
diff --git a/generate-manpages/functions.sh b/generate-manpages/functions.sh
new file mode 100755
index 0000000..ded09f2
--- /dev/null
+++ b/generate-manpages/functions.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+# Sanity check, check that the non-builtin echo exists and is in PATH
+if ! which echo > /dev/null 2>&1; then
+ echo "$0: This script needs the non-builtin echo, which is not in your PATH." >&2
+ echo "$0: Fix PATH or install before running this script!" >&2
+ exit 1
+fi
+
+ECHO=$(which echo)
+
+print() {
+ ${ECHO} "$@"
+}
+
+error() {
+ ${ECHO} "$@" >&2
+}
diff --git a/generate-manpages/install-manpages.sh b/generate-manpages/install-manpages.sh
new file mode 100755
index 0000000..23ab6a2
--- /dev/null
+++ b/generate-manpages/install-manpages.sh
@@ -0,0 +1,82 @@
+#!/bin/sh
+
+
+if [ $# -lt 3 ]; then
+ echo "$0: Insufficient arguments." >&2
+ echo "$0: <path to git-root/source-root> <path to install manpages> <use prebuilt manpages=y/n>" >&2
+ exit 1;
+fi
+
+if [ ! -f $1/generate-manpages/functions.sh ]; then
+ echo "$0: <arg1> doesn't seem to contain the path to the git-root/source-root" >&2
+ exit 1
+fi
+
+. $1/generate-manpages/functions.sh
+
+if [ -z "$2" ]; then
+ error "$0: Install path for manpages empty. Skipping manpage install"
+ exit 0
+fi
+
+# Sanity check, check that the utilities this script depends on, are in PATH
+for i in gzip; do
+ if ! which $i > /dev/null 2>&1; then
+ error "$0: This script needs $i, which is not in your PATH."
+ error "$0: Fix PATH or install before running this script!"
+ exit 1
+ fi
+done
+cd $1/generate-manpages
+
+# We must have help2man to generate "custom" manpages for the
+# built squashfs-tools, incorporating build choices (the
+# compressors built, default compressors, XATTR support etc).
+#
+# If help2man doesn't exist, or the manpage generation fails, use
+# the pre-built manpages.
+
+if [ $3 = "y" ]; then
+ print "$0: Using pre-built manpages"
+elif which help2man > /dev/null 2>&1; then
+ for i in mksquashfs unsquashfs sqfstar sqfscat; do
+ if ! ./$i-manpage.sh ../squashfs-tools ../squashfs-tools/$i.1; then
+ error "$0: Failed to generate manpage. Falling back to using pre-built manpages"
+ failed="y"
+ break
+ fi
+ done
+
+ [ -z "$failed" ] && source=../squashfs-tools
+else
+ error "$0: ERROR - No help2man in PATH. Cannot generate manpages."
+ failed="y"
+fi
+
+if [ -z "$source" ]; then
+ if [ "$failed" = "y" ]; then
+ error "$0: WARNING: Installing pre-built manpages."
+ error "$0: WARNING: These pages are built with the Makefile defaults, and all"
+ error "$0: WARNING: the compressors configured (except the deprecated lzma). This may not"
+ error "$0: WARNING: match your build configuration."
+ error -e "\n$0: Set USE_PREBUILT_MANPAGES to "y" in Makefile, to avoid these errors/warnings"
+ fi
+ source=../manpages
+fi
+
+if ! mkdir -p $2; then
+ error "$0: Creating manpage install directory failed. Aborting"
+ exit 1
+fi
+
+for i in mksquashfs unsquashfs sqfstar sqfscat; do
+ if ! cp $source/$i.1 $2/$i.1; then
+ error "$0: Copying manpage to install directory failed. Aborting"
+ exit 1
+ fi
+
+ if ! gzip -n -f9 $2/$i.1; then
+ error "$0: Compressing installed manpage failed. Aborting"
+ exit 1
+ fi
+done
diff --git a/generate-manpages/mksquashfs-manpage.sh b/generate-manpages/mksquashfs-manpage.sh
new file mode 100755
index 0000000..09658f5
--- /dev/null
+++ b/generate-manpages/mksquashfs-manpage.sh
@@ -0,0 +1,253 @@
+#!/bin/sh
+
+# This script generates a manpage from the mksquashfs -help and -version
+# output, using help2man. The script does various modfications to the
+# output from -help and -version, before passing it to help2man, to allow
+# it be successfully processed into a manpage by help2man.
+
+if [ ! -f functions.sh ]; then
+ echo "$0: this script should be run in the <git-root/source-root>/generate-manpages directory" >&2
+ exit 1
+fi
+
+. ./functions.sh
+
+if [ $# -lt 2 ]; then
+ error "$0: Insufficient arguments"
+ error "$0: <path to mksquashfs> <output file>"
+ exit 1
+fi
+
+# Sanity check, ensure $1 points to a directory with a runnable Mksquashfs
+if [ ! -x $1/mksquashfs ]; then
+ error "$0: <arg1> doesn't point to a directory with Mksquashfs in it!"
+ error "$0: <arg1> should point to the directory with the Mksquashfs" \
+ "you want to generate a manpage for."
+ exit 1
+fi
+
+# Sanity check, check that the utilities this script depends on, are in PATH
+for i in expand sed help2man; do
+ if ! which $i > /dev/null 2>&1; then
+ error "$0: This script needs $i, which is not in your PATH."
+ error "$0: Fix PATH or install before running this script!"
+ exit 1
+ fi
+done
+
+tmp=$(mktemp -d)
+
+# Run mksquashfs -help, expand TABS to spaces, and output the help text to
+# $tmp/mksquashfs.help. This is to allow it to be modified before
+# passing to help2man.
+
+if ! $1/mksquashfs -help > $tmp/mksquashfs.help2 2>&1; then
+ error "$0: Running Mksquashfs failed. Cross-compiled or incompatible binary?"
+ exit 1
+fi
+
+expand $tmp/mksquashfs.help2 > $tmp/mksquashfs.help
+
+# Run mksquashfs -version, and output the version text to
+# $tmp/mksquashfs.version. This is to allow it to be modified before
+# passing to help2man.
+
+$1/mksquashfs -version > $tmp/mksquashfs.version
+
+# Create a dummy executable in $tmp, which outputs $tmp/mksquashfs.help
+# and $tmp/mksquashfs.version. This gets around the fact help2man wants
+# to pass --help and --version directly to mksquashfs, rather than take the
+# (modified) output from $tmp/mksquashfs.help and $tmp/mksquashfs.version
+
+print "#!/bin/sh
+if [ \$1 = \"--help\" ]; then
+ cat $tmp/mksquashfs.help
+else
+ cat $tmp/mksquashfs.version
+fi" > $tmp/mksquashfs.sh
+
+chmod u+x $tmp/mksquashfs.sh
+
+# help2man gets confused by the version date returned by -version,
+# and includes it in the version string
+
+sed -i "s/ (.*)$//" $tmp/mksquashfs.version
+
+# help2man expects copyright to have an upper-case C ...
+
+sed -i "s/^copyright/Copyright/" $tmp/mksquashfs.version
+
+# help2man doesn't pick up the author from the version. Easiest to add
+# it here.
+
+print >> $tmp/mksquashfs.version
+print "Written by Phillip Lougher <phillip@squashfs.org.uk>" >> $tmp/mksquashfs.version
+
+# help2man expects "Usage: ", and so rename "SYNTAX:" to "Usage: "
+
+sed -i "s/^SYNTAX:/Usage: /" $tmp/mksquashfs.help
+
+# The Usage text expands over two lines, and that confuses help2man.
+# So concatenate the lines if the second isn't empty
+
+sed -i "/^Usage/ {
+N
+/\n$/b
+s/\n/ /
+}" $tmp/mksquashfs.help
+
+# Man pages expect the options to be in the "Options" section. So insert
+# Options section after Usage
+
+sed -i "/^Usage/a *OPTIONS*" $tmp/mksquashfs.help
+
+# help2man expects options to start in the 2nd column
+
+sed -i "s/^-/ -/" $tmp/mksquashfs.help
+sed -i "s/^ *-X/ -X/" $tmp/mksquashfs.help
+
+# help2man expects the options usage to be separated from the
+# option and operands text by at least 2 spaces.
+
+sed -i -e "s/expr> as/expr> as/" -e "s/exp> as/exp> as/" -e "s/file> as/file> as/" -e "s/regex> exclude/regex> exclude/" -e "s/regex> include/regex> include/" $tmp/mksquashfs.help
+
+# Expand certain operands truncated in help text due to lack of space
+
+sed -i -e "s/act@/action@/g" -e "s/expr>/expression>/g" -e "s/exp>/expression>/" -e "s/<f>/<file>/g" $tmp/mksquashfs.help
+
+# Uppercase the options operands (between < and > ) to make it conform
+# more to man page standards
+
+sed -i "s/<[^>]*>/\U&/g" $tmp/mksquashfs.help
+
+# Remove the "<" and ">" around options operands to make it conform
+# more to man page standards
+
+sed -i -e "s/<//g" -e "s/>//g" $tmp/mksquashfs.help
+
+# help2man doesn't deal well with the list of supported compressors.
+# So concatenate them onto one line with commas
+
+sed -i "/^ -comp/ {
+N
+s/\n */. /
+s/:/: /
+
+N
+s/\n *\([^ ]*$\)/\1/
+s/\n *\([^ ]* (default)$\)/\1/
+
+: again
+N
+/\n -noI/b
+
+s/\n *\([^ ]*$\)/, \1/
+s/\n *\([^ ]* (default)$\)/, \1/
+b again
+}" $tmp/mksquashfs.help
+
+# help2man doesn't deal well with the list of lzo1* algorithms.
+# So concatenate them onto one line with commas
+
+sed -i "/^ *lzo1x_1/ {
+s/\n *\([^ ]*$\)/\1/
+s/\n *\([^ ]* (default)$\)/\1/
+
+: again
+N
+/\n *lzo/!b
+
+s/\n *\([^ ]*$\)/, \1/
+s/\n *\([^ ]* (default)$\)/, \1/
+b again
+}" $tmp/mksquashfs.help
+
+# Make the pseudo file definitions into "options" so they're handled
+# properly by help2man
+
+sed -i "s/^\"filename/ -p \"filename/" $tmp/mksquashfs.help
+
+# Make each compressor entry in the compressors available section, a subsection
+# First, have to deal with the deprecated lzma compressor separately, because
+# it doesn't have any options (i.e. text prefixed with -).
+
+sed -i "/^ *lzma/ {
+s/^ *\(lzma.*$\)/\1:/
+n
+s/^ */ /
+} " $tmp/mksquashfs.help
+
+# Now deal with the others
+
+sed -i -e "s/^ *\(gzip.*$\)/\1:/" -e "s/^ *\(lzo$\)/\1:/" \
+ -e "s/^ *\(lzo (default)$\)/\1:/" -e "s/^ *\(lz4.*$\)/\1:/" \
+ -e "s/^ *\(xz.*$\)/\1:/" -e "s/^ *\(zstd.*$\)/\1:/" \
+ $tmp/mksquashfs.help
+
+# Concatenate the options text (normal options, pseudo file definitions and
+# compressor options) on to one line. Add a full stop to the end of the
+# options text
+
+sed -i "/^ -/ {
+:option
+s/^ *-/ -/
+
+/ -.* /!s/.$/& /
+
+:again
+N
+/\n$/b print
+/\n[^ ]/b print
+/\n -/b print
+s/\n */ /
+b again
+
+:print
+s/ \n/.\n/
+s/\([^.]\)\n/\1.\n/
+P
+s/^.*\n//
+/^ *-/b option
+}" $tmp/mksquashfs.help
+
+# Concatenate the SOURCE_DATE_EPOCH text on to one line. Indent the line by
+# two and add a full stop to the end of the line
+
+sed -i " /SOURCE_DATE_EPOCH/ {
+s/SOURCE_DATE_EPOCH/ SOURCE_DATE_EPOCH/
+
+:again
+N
+/\n$/b print
+s/\n */ /
+b again
+
+:print
+s/\([^.]\)\n/\1.\n/
+}" $tmp/mksquashfs.help
+
+# Make Compressors available header into a manpage section
+
+sed -i "s/\(Compressors available and compressor specific options\):/*\1*/" $tmp/mksquashfs.help
+
+# Make pseudo definition format header into a manpage section
+
+sed -i "s/\(Pseudo file definition format\):/*\1*/" $tmp/mksquashfs.help
+
+# Add reference to manpages for other squashfs-tools programs
+sed -i "s/See also:/See also:\nunsquashfs(1), sqfstar(1), sqfscat(1)\n/" $tmp/mksquashfs.help
+
+# Make See also header into a manpage section
+
+sed -i "s/\(See also\):/*\1*/" $tmp/mksquashfs.help
+
+# Make Environment header into a manpage section
+
+sed -i "s/\(Environment\):/*\1*/" $tmp/mksquashfs.help
+
+if ! help2man -Ni mksquashfs.h2m -o $2 $tmp/mksquashfs.sh; then
+ error "$0: help2man returned error. Aborting"
+ exit 1
+fi
+
+rm -rf $tmp
diff --git a/generate-manpages/mksquashfs.h2m b/generate-manpages/mksquashfs.h2m
new file mode 100644
index 0000000..8f9acaa
--- /dev/null
+++ b/generate-manpages/mksquashfs.h2m
@@ -0,0 +1,150 @@
+[Name]
+mksquashfs - tool to create and append to squashfs filesystems
+
+[Description]
+Squashfs is a highly compressed read-only filesystem for Linux.
+It uses either gzip/xz/lzo/lz4/zstd compression to compress both files, inodes
+and directories. Inodes in the system are very small and all blocks are
+packed to minimise data overhead. Block sizes greater than 4K are supported
+up to a maximum of 1Mbytes (default block size 128K).
+
+Squashfs is intended for general read-only filesystem use, for archival
+use (i.e. in cases where a .tar.gz file may be used), and in constrained
+block device/memory systems (e.g. embedded systems) where low overhead is
+needed.
+
+[Examples]
+.TP
+mksquashfs DIRECTORY IMAGE.SQFS
+Create a Squashfs filesystem from the contents of DIRECTORY, writing the output
+to IMAGE.SQSH. Mksquashfs will use the default compressor (normally gzip), and
+block size of 128 Kbytes.
+.TP
+mksquashfs DIRECTORY FILE1 FILE2 IMAGE.SQFS
+Create a Squashfs filesystem containing DIRECTORY and FILE1 and FILE2. If
+multiple sources are specified on the command line they will be combined into
+a single directory.
+.TP
+mksquashfs DIRECTORY IMAGE.SQFS -b 1M -comp zstd
+Use a block size of 1 Mbyte and Zstandard compression to create the filesystem.
+.TP
+mksquashfs DIRECTORY IMAGE.SQFS -e file1 file2
+Exclude file1 and file2 from DIRECTORY when creating filesystem. No wildcard
+matching of files.
+.TP
+mksquashfs DIRECTORY IMAGE.SQFS -wildcards -e "*.gz"
+Exclude anything in DIRECTORY which matches the wildcard pattern "*.gz".
+.TP
+mksquashfs DIRECTORY IMAGE.SQFS -wildcards -e "... *.gz"
+Exclude files which match the wildcard pattern "*.gz" anywhere within DIRECTORY
+and its sub-directories. The initial "..." indicates the wildcard pattern is
+"non-anchored" and will match anywhere.
+.PP
+Note: when passing wildcarded names to Mksquashfs, they should be quoted (as in
+the above examples), to ensure that they are not processed by the shell.
+
+.SS Using pseudo file definitions
+.TP
+mksquashfs DIRECTORY IMAGE.SQFS -p "build_dir d 0644 0 0"
+Create a directory called "build_dir" in the output filesystem.
+.TP
+mksquashfs DIRECTORY IMAGE.SQFS -p "version.txt l /tmp/build/version"
+Create a reference called "version.txt" to a file outside DIRECTORY, which acts
+as if the file "/tmp/build/version" was copied or hard-linked into DIRECTORY
+before calling Mksquashfs.
+.TP
+mksquashfs DIRECTORY IMAGE.SQFS -p "date.txt f 0644 0 0 date"
+Create a file called "date.txt" which holds the output (stdout) from running
+the "date" command.
+.TP
+mksquashfs DIRECTORY IMAGE.SQFS -p "\\"hello world\\" f 0644 0 0 date"
+As above, but, showing that filenames can have spaces, if they are quoted.
+The quotes need to be blackslashed to protect them from the shell.
+.TP
+mksquashfs - IMAGE.SQFS -p "input f 0644 root root dd if=/dev/sda1 bs=1024" -p "/ d 0644 0 0"
+Create a file containing the contents of partition /dev/sda1". Ordinarily
+Mksquashfs given a device, fifo, or named socket will place that special file
+within the Squashfs filesystem, the above allows input from these special files
+to be captured and placed in the Squashfs filesystem. Note there are no other
+sources than the pseudo file, and so the command line source is "-". If there
+are no other sources than pseudo files, the root (/) directory must be defined
+too, as seen in this example.
+.TP
+unsquashfs -pf - IMAGE.SQFS | mksquashfs - NEW.SQFS -pf -
+Transcode IMAGE.SQFS to NEW.SQFS by piping the pseudo file output from
+Unsquashfs to Mksquashfs using stdout and stdin. This can convert from
+earlier Squashfs filesystems or change compression algorithm, block size etc.
+without needing to unpack into an intermediate directory or file.
+.PP
+Note: pseudo file definitions should be quoted (as in the above examples), to
+ensure that they are passed to Mksquashfs as a single argument, and to ensure
+that they are not processed by the shell.
+
+.SS Using extended attribute options
+.TP
+mksquashfs DIRECTORY IMAGE.SQFS -no-xattrs
+Do not store any extended attributes in the Squashfs filesystem. Any extended
+attributes in the source files will be ignored.
+.TP
+mksquashfs DIRECTORY IMAGE.SQFS -xattrs-include "^user."
+Filter the extended attributes in the source files, and only store extended
+attributes in the user namespace in the Squashfs filesystem.
+.TP
+mksquashfs DIRECTORY IMAGE.SQFS -xattrs-exclude "^user."
+Filter the extended attributes in the source files, and don't store any
+extended attributes in the user namespace in the Squashfs filesystem.
+.TP
+mksquashfs DIRECTORY IMAGE.SQFS -xattrs-add "user.comment=hello world"
+Add the extended attribute called "user.comment" with the content "hello world"
+to all files and directories in the Squashfs filesystem.
+.TP
+mksquashfs DIRECTORY IMAGE.SQFS -xattrs-add "user.comment=0thello world\\012"
+Add the extended attribute called "user.comment" to all files and directories,
+but in this case the contents of the extended attribute will be "hello world"
+with a trailing newline character (012 octal).
+.TP
+mksquashfs DIRECTORY IMAGE.SQFS -xattrs-add "user.comment=0saGVsbG8gd29ybGQ="
+Add the extended attribute called "user.comment" to all files and directories,
+where the value is given in base64 encoding, representing "hello world".
+.TP
+mksquashfs DIRECTORY IMAGE.SQFS -action "-xattrs-include(^user.) @ type(f)"
+Filter the extended attributes but only in regular files (type f), and only
+store extended attributes in the user namespace.
+.TP
+mksquashfs DIRECTORY IMAGE.SQFS -p "hello_world x user.comment=0tsalve mundi\\012"
+Add the extended attribute called "user.comment" to the file called
+"hello_world", with the contents of the extended attribute being "salve mundi"
+with a trailing newline character (012 octal).
+
+.SS Using Actions to not compress, change attributes etc.
+.TP
+mksquashfs DIRECTORY IMAGE.SQSH -action "uncompressed @ (name(*.jpg) || name(*.mpg) ) || (name(*.img) && filesize(+1G))"
+Specify that any files matching the wildcards "*.jpg" and "*.mpg" should not be
+compressed. Additionally, it also specifies any files matching the wildcard
+"*.img" and are larger than 1 Gigabyte should be uncompressed too. This shows
+test operators can be combined with logical expressions.
+.TP
+mksquashfs DIRECTORY IMAGE.SQSH -action "chmod(o+r)@! perm(o+r)"
+If any files within DIRECTORY are not readable by "others", then make them
+readable by others in the Squashfs filesystem.
+.TP
+mksquashfs DIRECTORY IMAGE.SQSH -action "uid(phillip)@! perm(o+r)"
+As previous, match on any files which are not readable by "others", but, in
+this case change the owner of the file to "phillip" in the Squashfs filesystem.
+.TP
+mksquashfs DIRECTORY IMAGE.SQSH -action "prune @ type(l) && ! exists"
+Delete any symbolic link within DIRECTORY which points outside of DIRECTORY,
+i.e. will be unresolvable in the Squashfs filesystem.
+.TP
+mksquashfs DIRECTORY IMAGE.SQSH -action "exclude @ depth(3)"
+Create a Squashfs filesystem containing the two top most levels (contents of
+DIRECTORY and immediate sub-directories), and exclude anything at level 3 or
+below.
+.TP
+mksquashfs DIRECTORY IMAGE.SQFS -action "-xattrs-include(^user.) @ type(f)"
+Filter the extended attributes but only in regular files (type f), and only
+store extended attributes in the user namespace.
+.PP
+Note: actions should be quoted (as in the above examples), to ensure that they
+are passed to Mksquashfs as a single argument, and to ensure that they are not
+processed by the shell.
diff --git a/generate-manpages/sqfscat-manpage.sh b/generate-manpages/sqfscat-manpage.sh
new file mode 100755
index 0000000..305c2a9
--- /dev/null
+++ b/generate-manpages/sqfscat-manpage.sh
@@ -0,0 +1,189 @@
+#!/bin/sh
+
+# This script generates a manpage from the sqfscat -help and -version
+# output, using help2man. The script does various modfications to the
+# output from -help and -version, before passing it to help2man, to allow
+# it be successfully processed into a manpage by help2man.
+
+if [ ! -f functions.sh ]; then
+ echo "$0: this script should be run in the <git-root/source-root>/generate-manpages directory" >&2
+ exit 1
+fi
+
+. ./functions.sh
+
+if [ $# -lt 2 ]; then
+ error "$0: Insufficient arguments"
+ error "$0: <path to sqfscat> <output file>"
+ exit 1
+fi
+
+# Sanity check, ensure $1 points to a directory with a runnable Sqfscat
+if [ ! -x $1/sqfscat ]; then
+ error "$0: <arg1> doesn't point to a directory with Sqfscat in it!"
+ error "$0: <arg1> should point to the directory with the Sqfscat" \
+ "you want to generate a manpage for."
+ exit 1
+fi
+
+# Sanity check, check that the utilities this script depends on, are in PATH
+for i in sed help2man; do
+ if ! which $i > /dev/null 2>&1; then
+ error "$0: This script needs $i, which is not in your PATH."
+ error "$0: Fix PATH or install before running this script!"
+ exit 1
+ fi
+done
+
+tmp=$(mktemp -d)
+
+# Run sqfscat -help, and output the help text to
+# $tmp/sqfscat.help. This is to allow it to be modified before
+# passing to help2man.
+
+if ! $1/sqfscat -help > $tmp/sqfscat.help; then
+ error "$0: Running Sqfscat failed. Cross-compiled or incompatible binary?"
+ exit 1
+fi
+
+# Run sqfscat -version, and output the version text to
+# $tmp/sqfscat.version. This is to allow it to be modified before
+# passing to help2man.
+
+$1/sqfscat -version > $tmp/sqfscat.version
+
+# Create a dummy executable in $tmp, which outputs $tmp/sqfscat.help
+# and $tmp/sqfscat.version. This gets around the fact help2man wants
+# to pass --help and --version directly to sqfscat, rather than take the
+# (modified) output from $tmp/sqfscat.help and $tmp/sqfscat.version
+
+print "#!/bin/sh
+if [ \$1 = \"--help\" ]; then
+ cat $tmp/sqfscat.help
+else
+ cat $tmp/sqfscat.version
+fi" > $tmp/sqfscat.sh
+
+chmod u+x $tmp/sqfscat.sh
+
+# help2man gets confused by the version date returned by -version,
+# and includes it in the version string
+
+sed -i "s/ (.*)$//" $tmp/sqfscat.version
+
+# help2man expects copyright to have an upper-case C ...
+
+sed -i "s/^copyright/Copyright/" $tmp/sqfscat.version
+
+# help2man doesn't pick up the author from the version. Easiest to add
+# it here.
+
+print >> $tmp/sqfscat.version
+print "Written by Phillip Lougher <phillip@squashfs.org.uk>" >> $tmp/sqfscat.version
+
+# help2man expects "Usage: ", and so rename "SYNTAX:" to "Usage: "
+
+sed -i "s/^SYNTAX:/Usage: /" $tmp/sqfscat.help
+
+# Man pages expect the options to be in the "Options" section. So insert
+# Options section after Usage
+
+sed -i "/^Usage/a *OPTIONS*" $tmp/sqfscat.help
+
+# help2man expects options to start in the 2nd column
+
+sed -i "s/^\t-/ -/" $tmp/sqfscat.help
+
+# Split combined short-form/long-form options into separate short-form,
+# and long form, i.e.
+# -da[ta-queue] <size> becomes
+# -da <size>, -data-queue <size>
+
+sed -i "s/\([^ ][^ \[]*\)\[\([a-z-]*\)\] \(<[a-z-]*>\)/\1 \3, \1\2 \3/" $tmp/sqfscat.help
+sed -i "s/\([^ ][^ \[]*\)\[\([a-z-]*\)\]/\1, \1\2/" $tmp/sqfscat.help
+
+# help2man expects the options usage to be separated from the
+# option and operands text by at least 2 spaces.
+
+sed -i "s/\t/ /g" $tmp/sqfscat.help
+
+# Uppercase the options operands (between < and > ) to make it conform
+# more to man page standards
+
+sed -i "s/<[^>]*>/\U&/g" $tmp/sqfscat.help
+
+# Remove the "<" and ">" around options operands to make it conform
+# more to man page standards
+
+sed -i -e "s/<//g" -e "s/>//g" $tmp/sqfscat.help
+
+# help2man doesn't deal well with the list of supported compressors.
+# So concatenate them onto one line with commas
+
+sed -i "/^Decompressors available:/ {
+n
+s/^ //
+
+: again
+N
+/\n$/b
+
+s/\n */, /
+b again
+}" $tmp/sqfscat.help
+
+# Concatenate the options text on to one line. Add a full stop to the end of the
+# options text
+
+sed -i "/^ -/ {
+:again
+N
+/\n$/b print
+/\n -/b print
+s/\n */ /
+b again
+
+:print
+s/\([^.]\)\n/\1.\n/
+P
+s/^.*\n//
+/^ -/b again
+}" $tmp/sqfscat.help
+
+# Concatenate the exit status text on to one line.
+
+sed -i "/^ [012]/ {
+:again
+N
+/\n$/b print
+/\n [012]/b print
+s/\n */ /
+b again
+
+:print
+P
+s/^.*\n//
+/^ [012]/b again
+}" $tmp/sqfscat.help
+
+# Make Decompressors available header into a manpage section
+
+sed -i "s/\(Decompressors available\):/*\1*/" $tmp/sqfscat.help
+
+# Make Exit status header into a manpage section
+
+sed -i "s/\(Exit status\):/*\1*/" $tmp/sqfscat.help
+
+# Add reference to manpages for other squashfs-tools programs
+sed -i "s/See also:/See also:\nmksquashfs(1), unsquashfs(1), sqfstar(1)\n/" $tmp/sqfscat.help
+
+# Make See also header into a manpage section
+
+sed -i "s/\(See also\):/*\1*/" $tmp/sqfscat.help
+
+if ! help2man -Ni sqfscat.h2m -o $2 $tmp/sqfscat.sh; then
+ error "$0: help2man returned error. Aborting"
+ exit 1
+fi
+
+rm -rf $tmp
diff --git a/generate-manpages/sqfscat.h2m b/generate-manpages/sqfscat.h2m
new file mode 100644
index 0000000..b6a8acc
--- /dev/null
+++ b/generate-manpages/sqfscat.h2m
@@ -0,0 +1,29 @@
+[Name]
+sqfscat - tool to cat files from a squashfs filesystem to stdout
+
+[Description]
+Squashfs is a highly compressed read-only filesystem for Linux.
+It uses either gzip/xz/lzo/lz4/zstd compression to compress both files, inodes
+and directories. Inodes in the system are very small and all blocks are
+packed to minimise data overhead. Block sizes greater than 4K are supported
+up to a maximum of 1Mbytes (default block size 128K).
+
+Squashfs is intended for general read-only filesystem use, for archival
+use (i.e. in cases where a .tar.gz file may be used), and in constrained
+block device/memory systems (e.g. embedded systems) where low overhead is
+needed.
+
+[Examples]
+.TP
+sqfscat IMAGE.SQFS hello
+Output the contents of "hello" to stdout.
+.TP
+sqfscat IMAGE.SQFS hello world
+Output the contents of "hello" and then "world" to stdout.
+.TP
+sqfscat IMAGE.SQFS "*.[ch]"
+Output the contents of all the files in the root directory that match the
+wildcard *.[ch], to stdout, e.g. hello.c, hello.h, world.c, world.h.
+.PP
+Note: when passing wildcarded names to Sqfscat, they should be quoted (as in
+the above examples), to ensure that they are not processed by the shell.
diff --git a/generate-manpages/sqfstar-manpage.sh b/generate-manpages/sqfstar-manpage.sh
new file mode 100755
index 0000000..c37f695
--- /dev/null
+++ b/generate-manpages/sqfstar-manpage.sh
@@ -0,0 +1,241 @@
+#!/bin/sh
+
+# This script generates a manpage from the sqfstar -help and -version
+# output, using help2man. The script does various modfications to the
+# output from -help and -version, before passing it to help2man, to allow
+# it be successfully processed into a manpage by help2man.
+
+if [ ! -f functions.sh ]; then
+ echo "$0: this script should be run in the <git-root/source-root>/generate-manpages directory" >&2
+ exit 1
+fi
+
+. ./functions.sh
+
+if [ $# -lt 2 ]; then
+ error "$0: Insufficient arguments"
+ error "$0: <path to sqfstar> <output file>"
+ exit 1
+fi
+
+# Sanity check, ensure $1 points to a directory with a runnable Sqfstar
+if [ ! -x $1/sqfstar ]; then
+ error "$0: <arg1> doesn't point to a directory with Sqfstar in it!"
+ error "$0: <arg1> should point to the directory with the Sqfstar" \
+ "you want to generate a manpage for."
+ exit 1
+fi
+
+# Sanity check, check that the utilities this script depends on, are in PATH
+for i in expand sed help2man; do
+ if ! which $i > /dev/null 2>&1; then
+ error "$0: This script needs $i, which is not in your PATH."
+ error "$0: Fix PATH or install before running this script!"
+ exit 1
+ fi
+done
+
+tmp=$(mktemp -d)
+
+# Run sqfstar -help, expand TABS to spaces, and output the help text to
+# $tmp/sqfstar.help. This is to allow it to be modified before
+# passing to help2man.
+
+if ! $1/sqfstar -help > $tmp/sqfstar.help2; then
+ error "$0: Running Sqfstar failed. Cross-compiled or incompatible binary?"
+ exit 1
+fi
+
+expand $tmp/sqfstar.help2 > $tmp/sqfstar.help
+
+
+# Run sqfstar -version, and output the version text to
+# $tmp/sqfstar.version. This is to allow it to be modified before
+# passing to help2man.
+
+$1/sqfstar -version > $tmp/sqfstar.version
+
+# Create a dummy executable in $tmp, which outputs $tmp/sqfstar.help
+# and $tmp/sqfstar.version. This gets around the fact help2man wants
+# to pass --help and --version directly to sqfstar, rather than take the
+# (modified) output from $tmp/sqfstar.help and $tmp/sqfstar.version
+
+print "#!/bin/sh
+if [ \$1 = \"--help\" ]; then
+ cat $tmp/sqfstar.help
+else
+ cat $tmp/sqfstar.version
+fi" > $tmp/sqfstar.sh
+
+chmod u+x $tmp/sqfstar.sh
+
+# help2man gets confused by the version date returned by -version,
+# and includes it in the version string
+
+sed -i "s/ (.*)$//" $tmp/sqfstar.version
+
+# help2man expects copyright to have an upper-case C ...
+
+sed -i "s/^copyright/Copyright/" $tmp/sqfstar.version
+
+# help2man doesn't pick up the author from the version. Easiest to add
+# it here.
+
+print >> $tmp/sqfstar.version
+print "Written by Phillip Lougher <phillip@squashfs.org.uk>" >> $tmp/sqfstar.version
+
+# Man pages expect the options to be in the "Options" section. So insert
+# Options section after first line
+
+sed -i "1a *OPTIONS*" $tmp/sqfstar.help
+
+# Delete the first line, as this is being replaced by a section included
+# from sqfstar.h2m
+
+sed -i "1d" $tmp/sqfstar.help
+
+# help2man expects options to start in the 2nd column
+
+sed -i "s/^-/ -/" $tmp/sqfstar.help
+sed -i "s/^ *-X/ -X/" $tmp/sqfstar.help
+
+# help2man expects the options usage to be separated from the
+# option and operands text by at least 2 spaces.
+
+sed -i -e "s/regex> exclude/regex> exclude/" -e "s/regex> include/regex> include/" $tmp/sqfstar.help
+
+# Uppercase the options operands (between < and > ) to make it conform
+# more to man page standards
+
+sed -i "s/<[^>]*>/\U&/g" $tmp/sqfstar.help
+
+# Remove the "<" and ">" around options operands to make it conform
+# more to man page standards
+
+sed -i -e "s/<//g" -e "s/>//g" $tmp/sqfstar.help
+
+# help2man doesn't deal well with the list of supported compressors.
+# So concatenate them onto one line with commas
+
+sed -i "/^ -comp/ {
+N
+s/\n */. /
+s/:/: /
+
+N
+s/\n *\([^ ]*$\)/\1/
+s/\n *\([^ ]* (default)$\)/\1/
+
+: again
+N
+/\n -noI/b
+
+s/\n *\([^ ]*$\)/, \1/
+s/\n *\([^ ]* (default)$\)/, \1/
+b again
+}" $tmp/sqfstar.help
+
+# help2man doesn't deal well with the list of lzo1* algorithms.
+# So concatenate them onto one line with commas
+
+sed -i "/^ *lzo1x_1/ {
+s/\n *\([^ ]*$\)/\1/
+s/\n *\([^ ]* (default)$\)/\1/
+
+: again
+N
+/\n *lzo/!b
+
+s/\n *\([^ ]*$\)/, \1/
+s/\n *\([^ ]* (default)$\)/, \1/
+b again
+}" $tmp/sqfstar.help
+
+# Make the pseudo file definitions into "options" so they're handled
+# properly by help2man
+
+sed -i "s/^\"filename/ -p \"filename/" $tmp/sqfstar.help
+
+# Make each compressor entry in the compressors available section, a subsection
+# First, have to deal with the deprecated lzma compressor separately, because
+# it doesn't have any options (i.e. text prefixed with -).
+
+sed -i "/^ *lzma/ {
+s/^ *\(lzma.*$\)/\1:/
+n
+s/^ */ /
+} " $tmp/sqfstar.help
+
+# Now deal with the others
+
+sed -i -e "s/^ *\(gzip.*$\)/\1:/" -e "s/^ *\(lzo$\)/\1:/" \
+ -e "s/^ *\(lzo (default)$\)/\1:/" -e "s/^ *\(lz4.*$\)/\1:/" \
+ -e "s/^ *\(xz.*$\)/\1:/" -e "s/^ *\(zstd.*$\)/\1:/" \
+ $tmp/sqfstar.help
+
+# Concatenate the options text (normal options and compressor options) on to one
+# line. Add a full stop to the end of the options text
+
+sed -i "/^ -/ {
+:option
+s/^ *-/ -/
+
+/ -.* /!s/.$/& /
+
+:again
+N
+/\n$/b print
+/\n[^ ]/b print
+/\n -/b print
+s/\n */ /
+b again
+
+:print
+s/ \n/.\n/
+s/\([^.]\)\n/\1.\n/
+P
+s/^.*\n//
+/^ *-/b option
+}" $tmp/sqfstar.help
+
+# Concatenate the SOURCE_DATE_EPOCH text on to one line. Indent the line by
+# two and add a full stop to the end of the line
+
+sed -i " /SOURCE_DATE_EPOCH/ {
+s/SOURCE_DATE_EPOCH/ SOURCE_DATE_EPOCH/
+
+:again
+N
+/\n$/b print
+s/\n */ /
+b again
+
+:print
+s/\([^.]\)\n/\1.\n/
+}" $tmp/sqfstar.help
+
+# Make Compressors available header into a manpage section
+
+sed -i "s/\(Compressors available and compressor specific options\):/*\1*/" $tmp/sqfstar.help
+
+# Make pseudo definition format header into a manpage section
+
+sed -i "s/\(Pseudo file definition format\):/*\1*/" $tmp/sqfstar.help
+
+# Add reference to manpages for other squashfs-tools programs
+sed -i "s/See also:/See also:\nmksquashfs(1), unsquashfs(1), sqfscat(1)\n/" $tmp/sqfstar.help
+
+# Make See also header into a manpage section
+
+sed -i "s/\(See also\):/*\1*/" $tmp/sqfstar.help
+
+# Make Environment header into a manpage section
+
+sed -i "s/\(Environment\):/*\1*/" $tmp/sqfstar.help
+
+if ! help2man -Ni sqfstar.h2m -o $2 $tmp/sqfstar.sh; then
+ error "$0: help2man returned error. Aborting"
+ exit 1
+fi
+
+rm -rf $tmp
diff --git a/generate-manpages/sqfstar.h2m b/generate-manpages/sqfstar.h2m
new file mode 100644
index 0000000..b1d1c3e
--- /dev/null
+++ b/generate-manpages/sqfstar.h2m
@@ -0,0 +1,84 @@
+[Name]
+sqfstar - tool to create a squashfs filesystem from a tar archive
+
+[Synopsis]
+ cat xxx.tar | sqfstar [OPTIONS] FILESYSTEM [exclude files]
+ zcat xxx.tgz | sqfstar [OPTIONS] FILESYSTEM [exclude files]
+ xzcat xxx.tar.xz | sqfstar [OPTIONS] FILESYSTEM [exclude files]
+ zstdcat xxx.tar.zst | sqfstar [OPTIONS] FILESYSTEM [exclude files]
+
+[Description]
+Squashfs is a highly compressed read-only filesystem for Linux.
+It uses either gzip/xz/lzo/lz4/zstd compression to compress both files, inodes
+and directories. Inodes in the system are very small and all blocks are
+packed to minimise data overhead. Block sizes greater than 4K are supported
+up to a maximum of 1Mbytes (default block size 128K).
+
+Squashfs is intended for general read-only filesystem use, for archival
+use (i.e. in cases where a .tar.gz file may be used), and in constrained
+block device/memory systems (e.g. embedded systems) where low overhead is
+needed.
+
+[Examples]
+.TP
+sqfstar IMAGE.SQFS < archive.tar
+Create a Squashfs filesystem from the uncompressed tar file "archive.tar".
+Sqfstar will use the default compressor (normally gzip), and block size of 128
+Kbytes.
+.TP
+zcat archive.tgz | sqfstar IMAGE.SQFS
+Create a Squashfs filesystem from the compressed tar file "archive.tgz". Sqfstar
+will use the default compressor (normally gzip), and block size of 128 Kbytes.
+.TP
+sqfstar -b 1M -comp zstd IMAGE.SQFS < archive.tar
+Use a block size of 1 Mbyte and Zstandard compression to create the filesystem.
+.TP
+sqfstar -root-uid 0 -root-gid 0 IMAGE.SQFS < archive.tar
+Tar files do not supply a definition for the root directory, and the default is
+to make the directory owned/group owned by the user running Sqfstar. The above
+command sets the ownership/group ownership to root.
+.TP
+sqfstar -root-mode 0755 IMAGE.SQFS < archive.tar
+The default permissions for the root directory is 0777 (rwxrwxrwx). The above
+command sets the permissions to 0755 (rwxr-xr-x).
+.TP
+sqfstar IMAGE.SQFS file1 file2 < archive.tar
+Exclude file1 and file2 from the tar file when creating filesystem.
+.TP
+sqfstar IMAGE.SQFS "*.gz" < archive.tar
+Exclude any files in the top level directory which matches the wildcard pattern
+"*.gz".
+.TP
+sqfstar IMAGE.SQFS "... *.gz" < archive.tar
+Exclude any file which matches the wildcard pattern "*.gz" anywhere within the
+tar file. The initial "..." indicates the wildcard pattern is "non-anchored"
+and will match anywhere.
+.PP
+Note: when passing wildcarded names to Sqfstar, they should be quoted (as in
+the above examples), to ensure that they are not processed by the shell.
+
+.SS Using pseudo file definitions
+.TP
+sqfstar -p "build_dir d 0644 0 0" IMAGE.SQFS < archive.tar
+Create a directory called "build_dir" in the output filesystem.
+.TP
+sqfstar -p "version.txt l /tmp/build/version" IMAGE.SQFS < archive.tar
+Create a reference called "version.txt" to a file not in the tar archive,
+which acts as if that file was in the tar archive.
+.TP
+sqfstar -p "date.txt f 0644 0 0 date" IMAGE.SQFS < archive.tar
+Create a file called "date.txt" which holds the output (stdout) from running
+the "date" command.
+.TP
+sqfstar -p "\\"hello world\\" f 0644 0 0 date" IMAGE.SQFS < archive.tar
+As above, but, showing that filenames can have spaces, if they are quoted.
+The quotes need to be blackslashed to protect them from the shell.
+.TP
+sqfstar -p "input f 0644 root root dd if=/dev/sda1 bs=1024" IMAGE.SQFS < archive.tar
+Create a file containing the contents of partition /dev/sda1". The above allows
+input from these special files to be captured and placed in the Squashfs
+filesystem.
+.PP
+Note: pseudo file definitions should be quoted (as in the above examples), to
+ensure that they are passed to Mksquashfs as a single argument, and to ensure
+that they are not processed by the shell.
diff --git a/generate-manpages/unsquashfs-manpage.sh b/generate-manpages/unsquashfs-manpage.sh
new file mode 100755
index 0000000..ea8609b
--- /dev/null
+++ b/generate-manpages/unsquashfs-manpage.sh
@@ -0,0 +1,189 @@
+#!/bin/sh
+
+# This script generates a manpage from the unsquashfs -help and -version
+# output, using help2man. The script does various modfications to the
+# output from -help and -version, before passing it to help2man, to allow
+# it be successfully processed into a manpage by help2man.
+
+if [ ! -f functions.sh ]; then
+ echo "$0: this script should be run in the <git-root/source-root>/generate-manpages directory" >&2
+ exit 1
+fi
+
+. ./functions.sh
+
+if [ $# -lt 2 ]; then
+ error "$0: Insufficient arguments"
+ error "$0: <path to unsquashfs> <output file>"
+ exit 1
+fi
+
+# Sanity check, ensure $1 points to a directory with a runnable Unsquashfs
+if [ ! -x $1/unsquashfs ]; then
+ error "$0: <arg1> doesn't point to a directory with Unsquashfs in it!"
+ error "$0: <arg1> should point to the directory with the Unsquashfs" \
+ "you want to generate a manpage for."
+ exit 1
+fi
+
+# Sanity check, check that the utilities this script depends on, are in PATH
+for i in sed help2man; do
+ if ! which $i > /dev/null 2>&1; then
+ error "$0: This script needs $i, which is not in your PATH."
+ error "$0: Fix PATH or install before running this script!"
+ exit 1
+ fi
+done
+
+tmp=$(mktemp -d)
+
+# Run unsquashfs -help, and output the help text to
+# $tmp/unsquashfs.help. This is to allow it to be modified before
+# passing to help2man.
+
+if ! $1/unsquashfs -help > $tmp/unsquashfs.help; then
+ error "$0: Running Unsquashfs failed. Cross-compiled or incompatible binary?"
+ exit 1
+fi
+
+# Run unsquashfs -version, and output the version text to
+# $tmp/unsquashfs.version. This is to allow it to be modified before
+# passing to help2man.
+
+$1/unsquashfs -version > $tmp/unsquashfs.version
+
+# Create a dummy executable in $tmp, which outputs $tmp/unsquashfs.help
+# and $tmp/unsquashfs.version. This gets around the fact help2man wants
+# to pass --help and --version directly to unsquashfs, rather than take the
+# (modified) output from $tmp/unsquashfs.help and $tmp/unsquashfs.version
+
+print "#!/bin/sh
+if [ \$1 = \"--help\" ]; then
+ cat $tmp/unsquashfs.help
+else
+ cat $tmp/unsquashfs.version
+fi" > $tmp/unsquashfs.sh
+
+chmod u+x $tmp/unsquashfs.sh
+
+# help2man gets confused by the version date returned by -version,
+# and includes it in the version string
+
+sed -i "s/ (.*)$//" $tmp/unsquashfs.version
+
+# help2man expects copyright to have an upper-case C ...
+
+sed -i "s/^copyright/Copyright/" $tmp/unsquashfs.version
+
+# help2man doesn't pick up the author from the version. Easiest to add
+# it here.
+
+print >> $tmp/unsquashfs.version
+print "Written by Phillip Lougher <phillip@squashfs.org.uk>" >> $tmp/unsquashfs.version
+
+# help2man expects "Usage: ", and so rename "SYNTAX:" to "Usage: "
+
+sed -i "s/^SYNTAX:/Usage: /" $tmp/unsquashfs.help
+
+# Man pages expect the options to be in the "Options" section. So insert
+# Options section after Usage
+
+sed -i "/^Usage/a *OPTIONS*" $tmp/unsquashfs.help
+
+# help2man expects options to start in the 2nd column
+
+sed -i "s/^\t-/ -/" $tmp/unsquashfs.help
+
+# Split combined short-form/long-form options into separate short-form,
+# and long form, i.e.
+# -da[ta-queue] <size> becomes
+# -da <size>, -data-queue <size>
+
+sed -i "s/\([^ ][^ \[]*\)\[\([a-z-]*\)\] \(<[a-z-]*>\)/\1 \3, \1\2 \3/" $tmp/unsquashfs.help
+sed -i "s/\([^ ][^ \[]*\)\[\([a-z-]*\)\]/\1, \1\2/" $tmp/unsquashfs.help
+
+# help2man expects the options usage to be separated from the
+# option and operands text by at least 2 spaces.
+
+sed -i "s/\t/ /g" $tmp/unsquashfs.help
+
+# Uppercase the options operands (between < and > ) to make it conform
+# more to man page standards
+
+sed -i "s/<[^>]*>/\U&/g" $tmp/unsquashfs.help
+
+# Remove the "<" and ">" around options operands to make it conform
+# more to man page standards
+
+sed -i -e "s/<//g" -e "s/>//g" $tmp/unsquashfs.help
+
+# help2man doesn't deal well with the list of supported compressors.
+# So concatenate them onto one line with commas
+
+sed -i "/^Decompressors available:/ {
+n
+s/^ //
+
+: again
+N
+/\n$/b
+
+s/\n */, /
+b again
+}" $tmp/unsquashfs.help
+
+# Concatenate the options text on to one line. Add a full stop to the end of
+# the options text
+
+sed -i "/^ -/ {
+:again
+N
+/\n$/b print
+/\n -/b print
+s/\n */ /
+b again
+
+:print
+s/\([^.]\)\n/\1.\n/
+P
+s/^.*\n//
+/^ -/b again
+}" $tmp/unsquashfs.help
+
+# Concatenate the exit status text on to one line.
+
+sed -i "/^ [012]/ {
+:again
+N
+/\n$/b print
+/\n [012]/b print
+s/\n */ /
+b again
+
+:print
+P
+s/^.*\n//
+/^ [012]/b again
+}" $tmp/unsquashfs.help
+
+# Make Decompressors available header into a manpage section
+
+sed -i "s/\(Decompressors available\):/*\1*/" $tmp/unsquashfs.help
+
+# Make Exit status header into a manpage section
+
+sed -i "s/\(Exit status\):/*\1*/" $tmp/unsquashfs.help
+
+# Add reference to manpages for other squashfs-tools programs
+sed -i "s/See also:/See also:\nmksquashfs(1), sqfstar(1), sqfscat(1)\n/" $tmp/unsquashfs.help
+
+# Make See also header into a manpage section
+
+sed -i "s/\(See also\):/*\1*/" $tmp/unsquashfs.help
+
+if ! help2man -Ni unsquashfs.h2m -o $2 $tmp/unsquashfs.sh; then
+ error "$0: help2man returned error. Aborting"
+ exit 1
+fi
+
+rm -rf $tmp
diff --git a/generate-manpages/unsquashfs.h2m b/generate-manpages/unsquashfs.h2m
new file mode 100644
index 0000000..edbf165
--- /dev/null
+++ b/generate-manpages/unsquashfs.h2m
@@ -0,0 +1,89 @@
+[Name]
+unsquashfs - tool to uncompress, extract and list squashfs filesystems
+
+[Description]
+Squashfs is a highly compressed read-only filesystem for Linux.
+It uses either gzip/xz/lzo/lz4/zstd compression to compress both files, inodes
+and directories. Inodes in the system are very small and all blocks are
+packed to minimise data overhead. Block sizes greater than 4K are supported
+up to a maximum of 1Mbytes (default block size 128K).
+
+Squashfs is intended for general read-only filesystem use, for archival
+use (i.e. in cases where a .tar.gz file may be used), and in constrained
+block device/memory systems (e.g. embedded systems) where low overhead is
+needed.
+
+[Examples]
+.TP
+unsquashfs IMAGE.SQFS
+Extract IMAGE.SQFS to "squashfs-root" in the current working directory.
+.TP
+unsquashfs -d output IMAGE.SQFS
+Extract IMAGE.SQFS to "output" in the current working directory.
+.TP
+unsquashfs -d . IMAGE.SQFS
+Extract IMAGE.SQFS to current working directory.
+.TP
+unsquashfs -linfo IMAGE.SQFS
+Output a listing of IMAGE.SQFS with file attributes to stdout, while extracting
+the filesystem to "squashfs-root".
+.TP
+unsquashfs -lls IMAGE.SQFS
+Output a listing of IMAGE.SQFS with file attributes to stdout, but do not
+extract the filesystem. The listing will be prefixed with "squashfs-root".
+.TP
+unsquashfs -d "" -lls IMAGE.SQFS
+Output a listing of IMAGE.SQFS with file attributes to stdout, but do not
+extract the filesystem. The listing will not be prefixed with "squashfs-root".
+.TP
+unsquashfs IMAGE.SQFS fs/squashfs
+Extract only the "fs/squashfs" directory.
+.TP
+unsquashfs IMAGE.SQFS "[Tt]est/example*"
+Extract all files beginning with "example" inside top level directories
+called "Test" or "test".
+.TP
+unsquashfs -excludes IMAGE.SQFS "test/*data*.gz"
+This will extract everything except for files that match *data*.gz in the
+test directory. The -excludes option tells Unsquashfs to exclude the files
+on the command line rather than extract them.
+.TP
+unsquashfs -excludes IMAGE.SQFS "... *.gz"
+This will extract everything except for files that match *.gz anywhere
+in the image. The "..." means this is a non-anchored exclude which
+matches anywhere.
+.TP
+unsquashfs -ex "test/*data*.gz" \; IMAGE.SQFS test
+This uses both extract and exclude options, to tell Unsquashfs to only
+extract the "test" directory, and to exclude any files within it that
+match *data*.gz.
+.TP
+unsquashfs -ex "... *.gz" IMAGE.SQFS test
+This uses both extract and exclude options, to tell Unsquashfs to only
+extract the "test" directory, and to exclude files which match "*.gz"
+anywhere within "test" directory or sub-directories.
+.TP
+unsquashfs -dest output -max-depth 2 IMAGE.SQFS
+Extract only the top two levels of IMAGE.SQFS to "output" directory.
+.TP
+unsquashfs -max-depth 2 IMAGE.SQFS "test/*.gz"
+Only extract the gzipped files in the test directory.
+.TP
+unsquashfs -llc -max-depth 2 IMAGE.SQFS "test/*.gz"
+Output a listing of the gzipped files in the test directory to stdout,
+but do not extract them.
+.TP
+unsquashfs -no-xattrs IMAGE.SQFS
+Do not extract any extended attributes. Any extended attributes in the
+filesystem will be ignored.
+.TP
+unsquashfs -xattrs-include "^user." IMAGE.SQFS
+Filter the extended attributes and only extract extended attributes in the
+user namespace from the Squashfs filesystem.
+.TP
+unsquashfs -xattrs-exclude "^user." IMAGE.SQFS
+Filter the extended attributes and do not extract any extended attributes in
+the user namespace from the Squashfs filesystem.
+.PP
+Note: when passing wildcarded names to Unsquashfs, they should be quoted (as in
+the above examples), to ensure that they are not processed by the shell.