diff options
author | Brian Evans <grknight@gentoo.org> | 2019-11-07 10:05:10 -0500 |
---|---|---|
committer | Brian Evans <grknight@gentoo.org> | 2019-11-07 10:05:10 -0500 |
commit | 6c930dc94691fd01d5d5d5096c8ab92e66a40064 (patch) | |
tree | 78e440e030b8c4cf31f92f14a613e2c727efcde9 /bin | |
parent | bin/gen-eclass-html.sh: Fix BASENAME test (diff) | |
download | devmanual-6c930dc94691fd01d5d5d5096c8ab92e66a40064.tar.gz devmanual-6c930dc94691fd01d5d5d5096c8ab92e66a40064.tar.bz2 devmanual-6c930dc94691fd01d5d5d5096c8ab92e66a40064.zip |
bin/gen-eclass-html.sh: Work for all common compression methods
Signed-off-by: Brian Evans <grknight@gentoo.org>
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/gen-eclass-html.sh | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/bin/gen-eclass-html.sh b/bin/gen-eclass-html.sh index d3b0cf2..8c9c337 100755 --- a/bin/gen-eclass-html.sh +++ b/bin/gen-eclass-html.sh @@ -35,13 +35,28 @@ IFS='' read -r -d '' FOOTER << 'EOF' </html> EOF +guesscompress() { + case "$1" in + *.gz|*.z) echo "gunzip -c" ;; + *.bz2|*.bz) echo "bunzip2 -c" ;; + *.lz) echo "lzip -dc" ;; + *.lzma) echo "unlzma -c" ;; + *.lzo) echo "lzop -dc" ;; + *.xz) echo "xzdec" ;; + *.zst) echo "zstd -dc" ;; + *) echo "cat" ;; + esac +} + # We also need the ebuild man page -for i in $(/usr/bin/qlist eclass-manpages) /usr/share/man/man5/ebuild.5.bz2; do - BASENAME="$(basename $i .5.bz2)" - [[ ${BASENAME} != "${i##*/}" ]] || continue +for i in $(/usr/bin/qlist eclass-manpages) /usr/share/man/man5/ebuild.5*; do + FILEBASE=${i##*/} + BASENAME="${FILEBASE%.5*}" + [[ ${BASENAME} != "${FILEBASE}" ]] || continue DIRNAME="${OUTPUTDIR}/${BASENAME}" TMP="${DIRNAME}/index.html.tmp" FINAL="${DIRNAME}/index.html" + DECOMPRESS=$(guesscompress "${i}") [[ -d ${DIRNAME} ]] || mkdir -p ${DIRNAME} # rebuild the man page each time cat << EOF > ${FINAL} @@ -89,7 +104,7 @@ for i in $(/usr/bin/qlist eclass-manpages) /usr/share/man/man5/ebuild.5.bz2; do <div class="container"> EOF # generate html pages and fix hyperlinks for eclass and ebuild man pages - /bin/bunzip2 -c $i | /usr/bin/man2html -r - | \ + $DECOMPRESS "$i" | /usr/bin/man2html -r - | \ sed -e "/<A HREF=/s:=.*man.*/\(.*eclass\).*html\">:=../\1/index.html>:" \ -e "/<\/BODY>/d" -e "/<\/HTML>/d" \ -e "/<A HREF=/s:=.*man.*/\(.*ebuild\).*html\">:=../\1/\index.html>:" >> ${TMP} |