view make/make.sh @ 51:93c68f362860

New script to download OLS files (and others), and split up volumes into individual papers, plus teach make.sh to run it.
author Rob Landley <rob@landley.net>
date Fri, 28 Sep 2007 14:47:14 -0500
parents aa424ac2ce30
children 7fa04e9d3e4b
line wrap: on
line source

#!/bin/bash

[ -z "$WEBDIR" ] && WEBDIR=~/www/kdocs
[ -z "$LNXDIR" ] && LNXDIR=~/linux

echo $WEBDIR

echo "Update master index."

$WEBDIR/make/indexsections.py $WEBDIR/master.idx > $WEBDIR/index.html || exit 1

echo "Mirror resources"

cd "$WEBDIR"
make/mirror.py
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

exit 1

echo "Update Linux kernel from kernel.org"

if [ ! -d "$LNXDIR" ]
then
  # Clone repository if we haven't got one yet.
  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 &&
  hg pull -u
fi

[ $? -ne 0 ] && exit 1

echo -n "Grab version number..."

LNXTAG="$(hg tags | head -n 2 | tail -n 1 | awk '{print $1}')"

echo $LNXTAG

echo Copy readme files from Linux kernel

rm -rf $WEBDIR/readme
mkdir $WEBDIR/readme
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/$OUT
done
make help > $WEBDIR/makehelp.txt

echo Convert kconfig to html for all architectures

echo $WEBDIR/menuconfig/
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

echo Install updated Documentation

rm -rf $WEBDIR/Documentation/
cp -a $LNXDIR/hg/Documentation $WEBDIR/Documentation

echo Build htmldocs and xhtml-nochunks

rm -rf $LNXDIR/temp
cd $LNXDIR/hg
mkdir $LNXDIR/temp
make allnoconfig O=$LNXDIR/temp

# I have a dual processor laptop, so overlap work here.  Generate the xml
# first, then have make htmldocs produce split-up versions in the background
# while a script produces nochunks versions in the foreground.
cd $LNXDIR/temp
make -j 2 xmldocs
make -j 2 htmldocs &
cd Documentation/DocBook
for i in *.xml
do
  echo "Converting $i"
  xmlto xhtml-nochunks $i -o xhtml-nochunks 
done
# Wait for background task to finish before retrieving result
while [ $(jobs | wc -l) -ne 0 ]
do
  sleep 1
  # Without this next line, bash never notices a change in the number of jobs.
  # Bug noticed in Ubuntu 7.04
  jobs > /dev/null
done
mv xhtml-nochunks/*.html .
rmdir xhtml-nochunks

echo Install htmldocs and update index

rm -rf $WEBDIR/htmldocs
cp -a $LNXDIR/temp/Documentation/DocBook $WEBDIR/htmldocs
cd $WEBDIR/htmldocs
# Work around a bug in xmlto: it puts an incorrect code page into the converted
# html documents, which produces line noise in the output.
find . -name "*.html" | xargs sed -i -e 's/.*ISO-8859-1.*//'
head -n 2 index.html > index2.html
echo "<ul>" >> index2.html
for i in $(ls -p | sed -n 's@/$@@p')
do
  echo "<li>(<a href=\"$i\">chunks</a>) (<a href=\"${i}.html\">nochunks</a>) " >> index2.html
  sed -nr 's@.*<title>(.*)</title>.*@\1@p' ${i}.xml | head -n 1 >> index2.html
  echo "</li>" >> index2.html
done
echo "</ul>" >> index2.html
mv index2.html index.html
echo "Done with kdocs"