| 1 |
#!/bin/bash |
| 2 |
BASE=$(dirname $(readlink -f $0)) |
| 3 |
INFILE="$BASE/../SystemTap_Tapset_Reference/tapsets.xml" |
| 4 |
OUTFILE="$BASE/en-US/Tapset_Reference_Guide.xml" |
| 5 |
TMPFILE=`mktemp` || exit 1 |
| 6 |
TMPFILE2=`mktemp` || exit 1 |
| 7 |
|
| 8 |
do_help() |
| 9 |
{ |
| 10 |
echo "publicanize.sh: usage: |
| 11 |
-?/--help this message |
| 12 |
-i/--input=file input file name |
| 13 |
-o/--output=file output file name |
| 14 |
" >&2 |
| 15 |
} |
| 16 |
|
| 17 |
|
| 18 |
#process optional arguments -i -o |
| 19 |
while [ "$#" -ne 0 ] |
| 20 |
do |
| 21 |
arg=`printf %s $1 | awk -F= '{print $1}'` |
| 22 |
val=`printf %s $1 | awk -F= '{print $2}'` |
| 23 |
shift |
| 24 |
if test -z "$val"; then |
| 25 |
local possibleval=$1 |
| 26 |
printf %s $1 "$possibleval" | grep ^- >/dev/null 2>&1 |
| 27 |
if test "$?" != "0"; then |
| 28 |
val=$possibleval |
| 29 |
if [ "$#" -ge 1 ]; then |
| 30 |
shift |
| 31 |
fi |
| 32 |
fi |
| 33 |
fi |
| 34 |
|
| 35 |
case "$arg" in |
| 36 |
-i|--input) |
| 37 |
INFILE=$val |
| 38 |
;; |
| 39 |
-o|--output) |
| 40 |
OUTFILE=$val |
| 41 |
;; |
| 42 |
-\?|--help) |
| 43 |
do_help |
| 44 |
exit 0 |
| 45 |
;; |
| 46 |
*) |
| 47 |
echo "Unknown option \"$arg\". See opcontrol --help" >&2 |
| 48 |
exit 1 |
| 49 |
;; |
| 50 |
esac |
| 51 |
done |
| 52 |
|
| 53 |
|
| 54 |
#copy the generated tapsets.xml |
| 55 |
cp $INFILE $TMPFILE || exit 1 |
| 56 |
|
| 57 |
#remove all excess whitespace |
| 58 |
sed -i -e 's/^\s*//g' $TMPFILE |
| 59 |
|
| 60 |
#remove marked Intro (starthere to endhere) |
| 61 |
sed -i -e '/starthere/,/endhere/d' $TMPFILE |
| 62 |
|
| 63 |
#re-convert programlisting tags |
| 64 |
sed -i -e 's/<programlisting>/<programlisting>/g' $TMPFILE |
| 65 |
sed -i -e 's/<\/programlisting>/<\/programlisting>/g' $TMPFILE |
| 66 |
|
| 67 |
#replace header |
| 68 |
|
| 69 |
cat $TMPFILE | |
| 70 |
perl -p -e 'undef $/;s|<bookinfo>\n<title>SystemTap Tapset Reference Manual</title>|<xi:include href="Book_Info.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />\n<xi:include href="Preface.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />|msg' | |
| 71 |
#perl -p -e 'undef $/;s|<authorgroup>\n<author>\n<othername>SystemTap</othername>\n<contrib>Hackers</contrib>\n</author>\n</authorgroup>||msg' | |
| 72 |
#perl -p -e 'undef $/;s|<copyright>\n<year>2008-2009</year>\n<holder>Red Hat, Inc. and others</holder>\n</copyright>||msg' | |
| 73 |
#perl -p -e 'undef $/;s|<legalnotice>\n<para>\nThis documentation is free software\; you can redistribute\nit and/or modify it under the terms of the GNU General Public\nLicense version 2 as published by the Free Software Foundation.\n</para>||msg' | |
| 74 |
#perl -p -e 'undef $/;s|<para>\nThis program is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied\nwarranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\nSee the GNU General Public License for more details.\n</para>||msg' | |
| 75 |
#perl -p -e 'undef $/;s|<para>\nYou should have received a copy of the GNU General Public\nLicense along with this program; if not, write to the Free\nSoftware Foundation, Inc., 51 Franklin Street, Fifth Floor,\nBoston, MA 02110-1301 USA.\n</para>||msg' | |
| 76 |
#perl -p -e 'undef $/;s|<para>\nFor more details see the file COPYING in the source\ndistribution of Linux.\n</para>\n</legalnotice>\n</bookinfo>||msg' | |
| 77 |
#perl -p -e 'undef $/;s|<toc></toc>||msg' | |
| 78 |
perl -p -e 'undef $/;s|\n\n\n\n\n\n\n\n\n\n\n\n\n\n||msg' | |
| 79 |
perl -p -e 'undef $/;s|\n\n\n\n\n\n\n\n\n\n\n||msg' | |
| 80 |
perl -p -e 'undef $/;s|<programlisting>\n|<programlisting>\n<emphasis>function <\/emphasis>|msg' | |
| 81 |
perl -p -e 'undef $/;s|<para>\n</para>||msg' | |
| 82 |
perl -p -e 'undef $/;s|<para>\n\n</para>||msg' | |
| 83 |
perl -p -e 'undef $/;s|<para>\n<programlisting>|<programlisting>|msg' | |
| 84 |
perl -p -e 'undef $/;s|</programlisting>\n</para>|</programlisting>|msg' > $TMPFILE2 |
| 85 |
|
| 86 |
#replace Intro with my own |
| 87 |
perl -p -i -e 's|<!--markerforxi-->|<xi:include href="Introduction.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />\n<xi:include href="Tapset_Dev_Guide.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />|g' $TMPFILE2 |
| 88 |
|
| 89 |
#for tapset name format section |
| 90 |
#perl -p -i -e 'undef $/;s|<screen>\nname:return \(parameters\)\ndefinition\n</screen>|<screen>\n<replaceable>function/probe</replaceable> tapset_name:return \(parameters\)\n</screen>|msg' $TMPFILE2 |
| 91 |
#perl -p -i -e 's|<para>In this guide, tapset definitions appear in the following format:</para>|<para>In this guide, the synopsis of each tapset appears in the following format:</para>|g' $TMPFILE2 |
| 92 |
#perl -p -i -e 's|<!-- markerforxi pls dont remove -->|<xi:include href="tapsetnameformat-lastpara.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />\n<xi:include href="refentry-example.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />|g' $TMPFILE2 |
| 93 |
|
| 94 |
# statements change synopsis tags, as they are still currently unfixed in publican-redhat |
| 95 |
sed -i -e 's/refsynopsisdiv>/refsect1>/g' $TMPFILE2 |
| 96 |
sed -i -e 's/refsect1>/refsection>/g' $TMPFILE2 |
| 97 |
sed -i -e 's/synopsis>/programlisting>\n/g' $TMPFILE2 |
| 98 |
|
| 99 |
# re-convert tags |
| 100 |
|
| 101 |
sed -i -e 's/<emphasis>/<emphasis>/g' $TMPFILE2 |
| 102 |
sed -i -e 's/<\/emphasis>/<\/emphasis>/g' $TMPFILE2 |
| 103 |
|
| 104 |
sed -i -e 's/<remark>/<remark>/g' $TMPFILE2 |
| 105 |
sed -i -e 's/<\/remark>/<\/remark>/g' $TMPFILE2 |
| 106 |
|
| 107 |
sed -i -e 's/<command>/<command>/g' $TMPFILE2 |
| 108 |
sed -i -e 's/<\/command>/<\/command>/g' $TMPFILE2 |
| 109 |
|
| 110 |
#useful marker script; moves content between starthere and endhere to file target |
| 111 |
#sed -n '/starthere/,/endhere/ s/.*/&/w target' $TMPFILE2 |
| 112 |
|
| 113 |
mv $TMPFILE2 $OUTFILE |