Mercurial > hg > kdocs
view make/functions.sh @ 83:13a980b307f8
Largeish rewrite of make.sh, breaking things out into functions. This has the
advantage of letting subsets of this functionality easily be called by new
wrapper scripts (instead of turning make.sh into a nest of --options), but
doesn't leave us with 8 gazillion tiny little scripts that share no common
code. (Probably buggy, this is just the first good stopping point.)
author | Rob Landley <rob@landley.net> |
---|---|
date | Wed, 07 Nov 2007 01:43:39 -0600 |
parents | |
children | ca7e38053195 |
line wrap: on
line source
#!/bin/bash # This file defines functions used by make.sh # Safety check: Only define these functions if WEBDIR and LNXDIR defined. if [ -z "$WEBDIR" ] || [ -z "$LNXDIR" ] then echo set WEBDIR and LNXDIR exit 1 fi # Update Documentation directory function update_documentation_dir() { rm -rf $WEBDIR/Documentation/ cp -a $LNXDIR/hg/Documentation $WEBDIR/Documentation # Make the change directory local to this function ( cd $WEBDIR for i in make/patches/*.patch do echo $i patch -p1 -i $i || exit 1 done make/docdiridx.py ) } # Clone or update mercurial Linux kernel repository from kernel.org function get_hg() { # Make the chdir local to this function ( if [ ! -d "$LNXDIR" ] then echo "Clone Linux kernel repository from kernel.org" mkdir -p "$LNXDIR"/hg && cd "$LNXDIR"/hg && hg clone http://kernel.org/hg/linux-2.6 hg else # Update kernel mercurial repository. cd "$LNXDIR"/hg && echo "Update Linux kernel from kernel.org" && hg pull -u fi [ $? -ne 0 ] && exit 1 echo "Linux version: $(hg tags | head -n 2 | tail -n 1 | awk '{print $1}')" ) } function make_htmldocs() { # Make the chdir local ( cd "$LNXDIR"/temp && make -j 2 htmldocs ) } function make_htmlnochunks() { # Make the chdir local ( cd "$LNXDIR"/temp && # Probably redundant, but just in case... make -j 2 xmldocs && cd Documentation/DocBook && for i in *.xml do echo "Converting $i" xmlto xhtml-nochunks $i -o xhtml-nochunks done ) } function install_htmldocs() { ( rm -f $WEBDIR/htmldocs cd "$LNXDIR"/Documentation/DocBook && # Install nochunks versions mv xhtml-nochunks "$WEBDIR"/htmldocs && head -n 2 index.html > "$WEBDIR"/htmldocs/index.html && echo "<ul>" >> "$WEBDIR"/htmldocs/index.html [ $? -ne 0 ] && exit 1 # Install broken-up versions and index.html for i in $(ls -p | sed -n 's@/$@@p') do mv $i "$WEBDIR"/htmldocs && echo "<li>(<a href=\"$i\">chunks</a>) (<a href=\"${i}.html\">nochunks</a>) " \ >> "$WEBDIR"/htmldocs/index.html && sed -nr 's@.*<title>(.*)</title>.*@\1@p' ${i}.xml | head -n 1 >> \ "$WEBDIR"/htmldocs/index.html && echo "</li>" >> "$WEBDIR"/htmldocs/index.html [ $? -ne 0 ] && exit 1 done cd "$WEBDIR"/htmldocs && echo "</ul>" >> index.html && # Work around a bug in xmlto: it puts an incorrect code page into the # converted html documents, which produces line noise in the output. sed -i -e 's/.*ISO-8859-1.*//' $(find . -name "*.html") ) } function update_master() { "$WEBDIR"/make/indexsections.py $WEBDIR/master.idx > $WEBDIR/index.html } function htmlize_menuconfig() { ( cd "$LNXDIR"/hg && LNXTAG="$(hg tags | head -n 2 | tail -n 1 | awk '{print $1}')" rm -rf "$WEBDIR"/menuconfig/ mkdir -p "$WEBDIR"/menuconfig && echo "<html><title>Menuconfig docs for Linux $LNXTAG</title><body><ul>" > \ "$WEBDIR"/menuconfig/index.html && for i in $(find arch -maxdepth 2 -name Kconfig | sort) do echo Converting "$i" && ARCH=$(echo $i | sed -r 's@.*/(.*)/.*@\1@') && echo "<li><a href=${ARCH}.html>${ARCH}</a></li>" >> \ "$WEBDIR"/menuconfig/index.html && "$WEBDIR"/make/menuconfig2html.py $i "$WEBDIR"/menuconfig "$LNXTAG" > \ "$WEBDIR"/menuconfig/$ARCH.html done ) && echo "</ul></body></html>" >> "$WEBDIR"/menuconfig/index.html } function mirror_files() { ( cd "$WEBDIR" && make/mirror.py [ $? -ne 0 ] && exit 1 cat mirror/ols2002.pdf.gz | gunzip > mirror/ols2002.pdf && if [ -z "$(find mirror/ols2001 -name "*.pdf")" ] then mkdir -p mirror/ols2001 && cd mirror/ols2001 && wget -r -l 1 -nd http://lwn.net/2001/features/OLS/pdf/pdf/ && cd ../.. [ $? -ne 0 ] && exit 1 fi if [ -z "$(find ols/2007 -name "*.pdf")" ] then echo "Split ols files" mkdir -p ols/{1999,2000,2001,2002,2003,2004,2005,2006,2007} && cp mirror/ols2001/*.pdf ols/2001 && make/splitols.py mirror ols [ $? -ne 0 ] && exit 1 fi ) } function find_readmes() { ( rm -rf "$WEBDIR"/readme mkdir "$WEBDIR"/readme && cd "$LNXDIR"/hg && make help > "$WEBDIR"/makehelp.txt && for i in $(find . -name "*[Rr][Ee][Aa][Dd][Mm][Ee]*" | grep -v "Documentation/") do OUT=$(echo $i | sed -e 's@\./@@' -e 's@/@-@g') cp $i "$WEBDIR"/readme/"$(echo $i | sed -e 's@\./@@' -e 's@/@-@g')" done ) } function findrfc() { ( cd "$LNXDIR" || exit 1 echo -n "Search for RFC references" x=0 # Iterate through *.c and *.h in the Linux source code. for i in `find "$LNXDIR"/hg -name "*.[hc]"` do # Progress indicator x=$[$x+1] if [ $x -gt 250 ] then echo -n . >&2 x=0 fi # Grep each source file for mention of an RFC, filtering out the more # obvious false positives. for j in $(grep -io "rfc *[1-9][0-9]*" $i | grep -v " " | grep -v "@rfc822\.org" | sed -r 's/[Rr][Ff][Cc] *([0-9]*)/rfc\1/g') do echo $i:$j done done ) > "$WEBDIR">temp-linuxrfc.txt # Process the temporary directory into an html file. echo Converting to html... ( cd "$WEBDIR" || exit 1 echo "<html><head><title>RFCs used by the Linux kernel</title></head>" echo "<ul>" for i in $(sed 's/.*://' temp-linuxrfc.txt | sort -u | sort -t c -k 2,2 -n) do echo '<li><h2><a href="http://tools.ietf.org/html/'$i'">'$i'</a></h2><p>' for j in $(sed -rn 's@\'"$LNXDIR"/hg'(.*):'$i'$@\1@p' temp-linuxrfc.txt) do echo '<a href="http://kernel.org/hg/linux-2.6/file/tip/'$j'">'$j'</a>' done echo "</p></li>" done echo "</ul></html>" ) > "$WEBDIR"/rfc-linux.html # Remove the temporary file rm temp-linuxrfc.txt } # Set up for out of tree build of Linux. function setuplinuxtemp() { if [ ! -d "$WEBDIR"/Documentation ] then "$WEBDIR"/make/do-Documentation.sh || exit 1 fi rm -rf "$LNXDIR"/temp && mkdir "$LNXDIR"/temp && ( cd "$LNXDIR"/hg && make allnoconfig O=$LNXDIR/temp && # Adjust to use the patched Documentation directory ln -s "$WEBDIR"/Documentation "$LNXDIR"/temp && # We'll need this later. make -j 2 xmldocs ) }