Skip to content

Instantly share code, notes, and snippets.

@a3li
Created May 28, 2015 12:29
Show Gist options
  • Save a3li/5d84fbfaedb6dd39e197 to your computer and use it in GitHub Desktop.
Save a3li/5d84fbfaedb6dd39e197 to your computer and use it in GitHub Desktop.
#!/bin/bash
# pre1) OOB: The host needs to emerge eclass-manpages on a daily basis.
OUTPUTDIR="/var/www/devmanual.gentoo.org/htdocs/eclass-reference"
# 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)"
DIRNAME="${OUTPUTDIR}/${BASENAME}"
TMP="${DIRNAME}/index.html.tmp"
FINAL="${DIRNAME}/index.html"
[[ -d ${DIRNAME} ]] || mkdir -p ${DIRNAME}
# rebuild the man page each time
cat << EOF > ${FINAL}
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-GB" xml:lang="en-GB">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Gentoo Development Guide: $BASENAME</title>
<link rel="stylesheet" href="../../devmanual.css" type="text/css" />
</head>
<body>
<div class="main">
<h1>Gentoo Development Guide</h1>
<div class="navtop" style="text-align: center;">
<table style="border-top: 1px dashed #330066; margin-left: auto; margin-right: auto; width: 100%;">
<col width="33%" />
<col width="34%" />
<col width="33%" />
<tr>
<td style="text-align: center; border-right: 1px dashed #330066;"></td>
<td style="text-align: center;">↑ <a href="../index.html">Eclass
Reference</a> ↑</td>
<td style="text-align: center; border-left: 1px dashed #330066;"></td>
</tr>
</table>
</div>
<div class="document">
EOF
# generate html pages and fix hyperlinks for eclass and ebuild man pages
/bin/bunzip2 -c $i | /usr/bin/man2html -r - | \
sed -e "/<A HREF=/s:=.*man.*/\(.*eclass\).*html\">:=../\1/index.html>:" \
-e "/<A HREF=/s:=.*man.*/\(.*ebuild\).*html\">:=../\1/\index.html>:" >> ${TMP}
# The first 4 lines are cruft for devmanual
tail -n $(($(wc -l ${TMP} | awk '{print $1}') - 4)) ${TMP} >> ${FINAL}
rm -f ${TMP}
done
# Remove old dirs (eclasses that were dropped from the tree)
find $OUTPUTDIR -mindepth 1 -maxdepth 1 -mtime +1 -exec rm -R {} \;
# build the index, rebuilding it each time
cat << EOF > $OUTPUTDIR/index.html
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-GB" xml:lang="en-GB">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Gentoo Development Guide: Eclass Reference</title>
<link rel="stylesheet" href="../devmanual.css" type="text/css" />
</head>
<body>
<div class="main">
<h1>Gentoo Development Guide</h1>
<div class="navtop" style="text-align: center;">
<table style="border-top: 1px dashed #330066; margin-left: auto; margin-right: auto; width: 100%;">
<col width="33%" />
<col width="34%" />
<col width="33%" />
<tr>
<td style="text-align: center; border-right: 1px dashed #330066;">← <a href="../function-reference/sandbox-functions/index.html">Sandbox Functions Reference</a></td>
<td style="text-align: center;">↑ <a href="../index.html">Master
Index</a> ↑</td>
<td style="text-align: center; border-left: 1px dashed #330066;"><a
href="../../tools-reference/index.html">Tools Reference</a> →</td>
</tr>
</table>
</div>
<div class="document">
<h1>Eclass Reference</h1>
<p>
This section provides a reference for some of the more commonly used eclasses.
Note that most eclasses have an accompanying manual page. These man pages can be
installed by emerging <code class="docutils literal"><span class="pre">app-portage/eclass-manpages</span></code>.
</p>
<div class="section"><h2><a name="contents" id="contents">Contents</a></h2>
<ul>
EOF
for i in $(find $OUTPUTDIR/ -maxdepth 1 -mindepth 1 -type d | sort); do
echo "<li><a class="reference" href="$(basename $i)/index.html">$(basename $i) Reference</a></li>" >> ${OUTPUTDIR}/index.html
done
cat << EOF >> ${OUTPUTDIR}/index.html
</ul></div>
</div>
<div class="navbottom" style="text-align: center;">
<table style="border-top: 1px dashed #330066; margin-left: auto; margin-right: auto; width: 100%;">
<col width="33%" />
<col width="34%" />
<col width="33%" />
<tr>
<td style="text-align: center; border-right: 1px dashed #330066;">← <a href="../function-reference/sandbox-functions/index.html">Sandbox Functions Reference</a></td>
<td style="text-align: center;">↑ <a href="../index.html">Master
Index</a> ↑</td>
<td style="text-align: center; border-left: 1px dashed #330066;"><a
href="../../tools-reference/index.html">Tools Reference</a> →</td>
</tr>
</table>
</div>
</div>
<div class="footer">
<p><a href="http://validator.w3.org/check/referer"><img src="/icons/icon_mini-xhtml.png" alt="Valid XHTML 1.0" /></a><a href="http://jigsaw.w3.org/css-validator/check/referer"><img src="/icons/icon_mini-css.png" alt="Valid CSS" /></a><a href="http://www.gentoo.org/"><img src="/icons/icon_mini-gentoo.png" alt="Powered by Gentoo" /></a><a href="http://creativecommons.org/licenses/by-sa/2.0/"><img src="/icons/icon_mini-creativecommons.png" alt="Creative Commons License" /></a><img src="/icons/icon_mini-xml.png" alt="XML Powered!" /><br /><br />
The text of this document is distributed under the <a href="http://creativecommons.org/licenses/by-sa/2.0/">Creative Commons Attribution-ShareAlike 2.0 License</a>.
</p>
</div>
</body>
</html>
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment