diff options
-rw-r--r-- | Makefile | 6 | ||||
-rw-r--r-- | debian/README.debian | 10 | ||||
-rw-r--r-- | debian/changelog | 97 | ||||
-rw-r--r-- | debian/control | 4 | ||||
-rwxr-xr-x | debian/cron.weekly | 12 | ||||
-rw-r--r-- | debian/menu | 13 | ||||
-rwxr-xr-x | debian/postinst | 24 | ||||
-rwxr-xr-x | debian/preinst | 9 | ||||
-rwxr-xr-x | debian/prerm | 15 | ||||
-rwxr-xr-x | debian/rules | 46 | ||||
-rwxr-xr-x | debian/rules.debhelper | 106 | ||||
-rwxr-xr-x | dh_dhelp | 149 | ||||
-rwxr-xr-x | dhelp | 35 | ||||
-rwxr-xr-x | dhelp_fsstnd | 69 | ||||
-rw-r--r-- | dhelp_parse.c | 66 | ||||
-rw-r--r-- | doc/dhelp.html | 56 | ||||
-rw-r--r-- | doc/sgml2dhelp.pl | 2 | ||||
-rwxr-xr-x | dsearch | 37 | ||||
-rw-r--r-- | fsstnd/Makefile | 10 | ||||
-rw-r--r-- | fsstnd/dhelp_parse.c | 808 | ||||
-rw-r--r-- | man/dh_dhelp.1 | 35 | ||||
-rw-r--r-- | man/dhelp_parse.8 | 34 |
22 files changed, 1492 insertions, 151 deletions
@@ -1,8 +1,10 @@ +DBLIB = $(shell if [ -f /usr/lib/libdb1.a ]; then echo -ldb1; else echo -ldb; fi) + all: dhelp_parse.o - gcc dhelp_parse.o -o dhelp_parse -ldb + gcc dhelp_parse.o -o dhelp_parse $(DBLIB) clean: rm -rf dhelp_parse dhelp_parse.o *~ core dhelp_parse.o: dhelp_parse.c - gcc -g -O -c -Wall -o dhelp_parse.o dhelp_parse.c + gcc -g -O2 -c -Wall -o dhelp_parse.o dhelp_parse.c diff --git a/debian/README.debian b/debian/README.debian index c7de04c..d6e0b3a 100644 --- a/debian/README.debian +++ b/debian/README.debian @@ -2,9 +2,17 @@ dhelp ===== +This program supports the new /usr/share/doc directory (FHS). +To browse the old /usr/doc directory (FSSTND) build the index +with the following command: + + dhelp_parse_fsstnd -r + +The index is created in /usr/doc/HTML/. + If your native language is not English, Danish, German, Spanish, Italian or French it would be nice, if you could send me a translation of -/usr/doc/dhelp/.dhelp, /usr/lib/cgi-bin/dsearch (%MESG) and +/usr/doc/share/dhelp/.dhelp, /usr/lib/cgi-bin/dsearch (%MESG) and dhelp_parse.c (function html_w_tail) for your language. Thank you :). Marco Budde (budde@debian.org) diff --git a/debian/changelog b/debian/changelog index c2ca768..f0a7c23 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,100 @@ +dhelp (0.3.23) unstable frozen; urgency=low + + * dsearch: security fix for glimpse's temp files (#60853) + + -- Marco Budde <budde@debian.org> Thu, 23 Mar 2000 21:42:05 +0100 + +dhelp (0.3.22) unstable frozen; urgency=low + + * dsearch: DoS security check (#60849) + + -- Marco Budde <budde@debian.org> Tue, 21 Mar 2000 21:24:09 +0100 + +dhelp (0.3.21) unstable frozen; urgency=low + + * dsearch: dhelp console support fixed (#55545, #20891) + + -- Marco Budde <budde@debian.org> Mon, 20 Mar 2000 22:24:48 +0100 + +dhelp (0.3.20) unstable frozen; urgency=low + + * installation scripts changed + * parser bug "can't open ..." fixed + + -- Marco Budde <budde@debian.org> Sat, 29 Jan 2000 17:30:33 +0100 + +dhelp (0.3.19) unstable frozen; urgency=low + + * alpha patch (bug report #44082) added + * AOLserver support in dhelp (bug report #54527) + * dsearch: sorting bug solved, new look + * dsearch: supports /usr/doc *and* /usr/share/doc + -- please test this new feature -- + + -- Marco Budde <budde@debian.org> Sat, 15 Jan 2000 18:34:29 +0100 + +dhelp (0.3.18) unstable frozen; urgency=low + + * dh_dhelp + * upload to frozen + + -- Marco Budde <budde@debian.org> Tue, 4 Jan 2000 20:21:50 +0100 + +dhelp (0.3.17) unstable; urgency=low + + * most changes of 0.3.16 removed + * /usr/doc/HTML is a link to /usr/share/doc/HTML + * old packages can be found at /usr/doc/HTML2 + + -- Marco Budde <budde@debian.org> Mon, 3 Jan 2000 20:22:22 +0100 + +dhelp (0.3.16) unstable; urgency=low + + * dh_dhelp: support for policy 3.1.0.0 + * fsstnd/dhelp_parse.c: hacked to follow symlinks + (policy 3.1.0.0) + * README in /usr/doc/HTML and /usr/share/doc/HTML added + (bug #49793: dhelp deletes this directories) + * documentation updated + + -- Marco Budde <budde@debian.org> Fri, 31 Dec 1999 13:48:09 +0100 + +dhelp (0.3.15) unstable; urgency=low + + * dh_dhelp: + supports -p/-P options + + supports dh_installdeb + * dh_dhelp man page (new) + * policy 3.1.0.0 (package itself) + + -- Marco Budde <budde@debian.org> Mon, 8 Nov 1999 14:54:21 +0100 + +dhelp (0.3.14) unstable; urgency=low + + * new dhelp_parse_fsstnd to support FSSTND. + + -- Marco Budde <budde@debian.org> Mon, 20 Sep 1999 18:43:09 +0200 + +dhelp (0.3.13) unstable; urgency=low + + * dhelp: support for gnome-help-browser + * dhelp_parse.c: #include <db.h> for "old" systems + * debian/cron.weekly: policy 3.0.0.0 + * dsearch: policy 3.0.0.0 + * man pages: policy 3.0.0.0 + + -- Marco Budde <budde@debian.org> Tue, 20 Jul 1999 20:36:38 +0200 + +dhelp (0.3.12) unstable; urgency=low + + * Makefile: link with db1 + * dhelp_parse.c: #include <db/db.h> + * Policy 3.0.x: /usr/share/doc + * new debian/menu (bug #41140) + * dhelp_parse.c: new look + * dhelp: support for gzilla & amaya added + + -- Marco Budde <budde@debian.org> Tue, 13 Jul 1999 15:20:09 +0200 + dhelp (0.3.11) unstable frozen; urgency=low * dhelp: perl -T problem solved (bug #31211) diff --git a/debian/control b/debian/control index 8d7a244..d8b77da 100644 --- a/debian/control +++ b/debian/control @@ -1,8 +1,8 @@ Source: dhelp Section: doc Priority: optional -Maintainer: Marco Budde <Budde@tu-harburg.de> -Standards-Version: 2.4.0.1 +Maintainer: Marco Budde <budde@debian.org> +Standards-Version: 3.1.0.0 Package: dhelp Depends: ${shlibs:Depends} diff --git a/debian/cron.weekly b/debian/cron.weekly index a6b4408..c053c62 100755 --- a/debian/cron.weekly +++ b/debian/cron.weekly @@ -5,13 +5,19 @@ if [ -f /usr/bin/glimpseindex ]; then if [ ! -d /var/lib/dhelp ]; then mkdir -p /var/lib/dhelp - echo "*html.gz gzip -d -c" > /var/lib/dhelp/.glimpse_filters chown www-data.www-data /var/lib/dhelp fi + + echo "*html.gz gzip -d -c" > /var/lib/dhelp/.glimpse_filters cd / - su www-data -c "find /usr/doc/ -name '*.html*' | \ - glimpseindex -F -X -H /var/lib/dhelp" > /dev/null + su www-data -c \ + "find /usr/doc/ -name '*.html*' 2> /dev/null > /var/lib/dhelp/.glimpse_dhelp; \ + find /usr/share/doc/ -name '*.html*' 2> /dev/null >> /var/lib/dhelp/.glimpse_dhelp; \ + cat /var/lib/dhelp/.glimpse_dhelp | \ + glimpseindex -F -X -H /var/lib/dhelp" > /dev/null + + rm -f /var/lib/dhelp/.glimpse_dhelp chmod 644 /var/lib/dhelp/.glimpse* fi diff --git a/debian/menu b/debian/menu index 62c1ba1..85f9105 100644 --- a/debian/menu +++ b/debian/menu @@ -1,2 +1,13 @@ -text Apps/Tools dhelp none "Debian Online Help" /usr/bin/dhelp +?package(dhelp):needs="X11" section="Help" \ +title="Debian Online Help" command=/usr/bin/dhelp + +?package(dhelp):needs="text" section="Help" \ +title="Debian Online Help" command=/usr/bin/dhelp + +?package(dhelp):needs="X11" section="Help" \ +title="Debian Online Help (old)" command=/usr/bin/dhelp_fsstnd + +?package(dhelp):needs="text" section="Help" \ +title="Debian Online Help (old)" command=/usr/bin/dhelp_fsstnd + diff --git a/debian/postinst b/debian/postinst index a409b84..1305cfc 100755 --- a/debian/postinst +++ b/debian/postinst @@ -1,17 +1,22 @@ #!/bin/sh -e -if [ ! -d /var/lib/dhelp ]; then - mkdir -p /var/lib/dhelp - chown www-data.www-data /var/lib/dhelp -fi +# policy 3.1.0.0: fsstnd -> fhs + +if [ "$1" = "configure" ]; then + if [ -d /usr/doc -a ! -e /usr/doc/dhelp \ + -a -d /usr/share/doc/dhelp ]; then + ln -sf ../share/doc/dhelp /usr/doc/dhelp + fi -if [ -f /var/lib/dhelp/dbase ]; then - rm -f /var/lib/dhelp/dbase + if [ -d /usr/doc -a ! -e /usr/doc/HTML ]; then + ln -sf ../share/doc/HTML /usr/doc/HTML + fi fi if [ -x /usr/sbin/dhelp_parse ]; then echo -n "Building HTML tree ..." /usr/sbin/dhelp_parse -r + /usr/sbin/dhelp_parse_fsstnd -r echo " done" fi @@ -20,5 +25,8 @@ if [ -x /etc/cron.weekly/dhelp -a -x /usr/bin/glimpseindex ]; then /etc/cron.weekly/dhelp 2>/dev/null >/dev/null & fi -echo "run dhelp to read documentation or browse " -echo "http://localhost/doc/HTML/index.html" +#DEBHELPER# + +echo "Run dhelp to read documentation or browse " +echo "http://localhost/doc/HTML/index.html." + diff --git a/debian/preinst b/debian/preinst new file mode 100755 index 0000000..a0fd04d --- /dev/null +++ b/debian/preinst @@ -0,0 +1,9 @@ +#!/bin/sh -e + +mkdir -p /var/lib/dhelp +chown www-data.www-data /var/lib/dhelp + + + + + diff --git a/debian/prerm b/debian/prerm index 90cb90c..2541851 100755 --- a/debian/prerm +++ b/debian/prerm @@ -1,4 +1,17 @@ #!/bin/sh -e +#DEBHELPER# + rm -rf /var/lib/dhelp -rm -rf /usr/doc/HTML +rm -rf /usr/doc/HTML /usr/share/doc/HTML + +if [ \( "$1" = "upgrade" -o "$1" = "remove" \) \ + -a -L /usr/doc/dhelp ]; then + rm -f /usr/doc/dhelp +fi + + +if [ \( "$1" = "upgrade" -o "$1" = "remove" \) \ + -a -L /usr/doc/HTML ]; then + rm -f /usr/doc/HTML +fi diff --git a/debian/rules b/debian/rules index e155db2..984a6b6 100755 --- a/debian/rules +++ b/debian/rules @@ -1,5 +1,4 @@ #!/usr/bin/make -f -# Sample debian.rules file - Copyright 1994,1995 by Ian Jackson. # # Invoke each target with `./debian/rules <target>'. All targets should be # invoked with the package root as the current directory. @@ -14,17 +13,12 @@ DIRECTORIES = \ $(R)/DEBIAN \ $(R)/usr \ $(R)/usr/bin \ - $(R)/usr/doc/$(P) \ - $(R)/usr/lib \ + $(R)/usr/share/doc/$(P) \ $(R)/usr/lib/cgi-bin \ - $(R)/usr/man \ - $(R)/usr/man/man1 \ - $(R)/usr/man/man8 \ - $(R)/usr/man/de_DE \ - $(R)/usr/man/de_DE/man1 \ + $(R)/usr/share/man/man1 \ + $(R)/usr/share/man/man8 \ + $(R)/usr/share/man/de/man1 \ $(R)/usr/sbin \ - $(R)/var \ - $(R)/var/lib \ $(R)/var/lib/dhelp $(DIRECTORIES): @@ -46,6 +40,8 @@ clean: clean-dir $(checkdir) [ ! -f Makefile ] || make clean rm -f debian/files* debian/substvars core debian/*~ *~ doc/*~ build + make -C fsstnd clean + rm -f debian/post*.debhelper debian/pre*.debhelper # Makes a binary package. binary-indep: $(DIRECTORIES) checkroot build @@ -57,19 +53,35 @@ binary-arch: $(DIRECTORIES) checkroot build make cp dhelp_parse $(R)/usr/sbin - cp dhelp dh_dhelp $(R)/usr/bin - cp doc/* debian/THANKS $(R)/usr/doc/$(P) - cp debian/dhelp $(R)/usr/doc/$(P)/.dhelp + cp dhelp dhelp_fsstnd dh_dhelp $(R)/usr/bin + cp doc/* debian/THANKS $(R)/usr/share/doc/$(P) + cp debian/dhelp $(R)/usr/share/doc/$(P)/.dhelp + cp debian/{changelog,README.debian,copyright} $(R)/usr/share/doc/$(P) + gzip -9 $(R)/usr/share/doc/$(P)/{changelog,README.debian,copyright} cp dsearch $(R)/usr/lib/cgi-bin - cp man/dhelp.1 $(R)/usr/man/man1/ - cp man/dhelp_parse.8 $(R)/usr/man/man8/ - cp man/de/dhelp.1 $(R)/usr/man/de_DE/man1/ + cp man/{dhelp.1,dh_dhelp.1} $(R)/usr/share/man/man1/ + cp man/dhelp_parse.8 $(R)/usr/share/man/man8/ + cp man/de/dhelp.1 $(R)/usr/share/man/de/man1/ + gzip $(R)/usr/share/man/man1/* $(R)/usr/share/man/man8/* + gzip $(R)/usr/share/man/de/man1/* + + +# old fsstnd support + make -C fsstnd + cp fsstnd/dhelp_parse_fsstnd $(R)/usr/sbin + + dh_shlibdeps + dh_strip + dh_installcron + dh_installmenu + dh_installdeb + dh_md5sums - debstd -c dpkg-gencontrol chown -R root.root debian/tmp chown www-data.www-data $(R)/var/lib/dhelp chmod -R g-ws debian/tmp + dpkg --build debian/tmp .. define checkdir diff --git a/debian/rules.debhelper b/debian/rules.debhelper new file mode 100755 index 0000000..557817a --- /dev/null +++ b/debian/rules.debhelper @@ -0,0 +1,106 @@ +#!/usr/bin/make -f +# Sample debian.rules file - Copyright 1994,1995 by Ian Jackson. +# +# Invoke each target with `./debian/rules <target>'. All targets should be +# invoked with the package root as the current directory. + +# The name of the package +P = dhelp + +R = debian/tmp + +DIRECTORIES = \ + $(R) \ + $(R)/DEBIAN \ + $(R)/usr \ + $(R)/usr/bin \ + $(R)/usr/share/doc/$(P) \ + $(R)/usr/lib \ + $(R)/usr/lib/cgi-bin \ + $(R)/usr/share/man \ + $(R)/usr/share/man/man1 \ + $(R)/usr/share/man/man8 \ + $(R)/usr/share/man/de_DE \ + $(R)/usr/share/man/de_DE/man1 \ + $(R)/usr/sbin \ + $(R)/var \ + $(R)/var/lib \ + $(R)/var/lib/dhelp + +$(DIRECTORIES): + install -d -g root -o root -m 755 $@ + chmod g-s $@ + +# Builds the binary package. +build: + $(checkdir) + touch build + +# Clean $(DIRECTORIES) +clean-dir: + $(checkdir) + rm -rf $(R) + +# Undoes the effect of `make -f rules build'. +clean: clean-dir + $(checkdir) + [ ! -f Makefile ] || make clean + rm -f debian/files* debian/substvars core debian/*~ *~ doc/*~ build + rm -f debian/*.debhelper + +# Makes a binary package. +binary-indep: $(DIRECTORIES) checkroot build + $(checkdir) + + +binary-arch: $(DIRECTORIES) checkroot build + $(checkdir) + + make +# dh_installdirs + dh_installchangelogs + dh_installmenu + dh_installcron + + dh_installdocs doc + cp debian/dhelp $(R)/usr/share/doc/$(P)/.dhelp + + cp man/dhelp.1 $(R)/usr/share/man/man1/ + cp man/dhelp_parse.8 $(R)/usr/share/man/man8/ + cp man/de/dhelp.1 $(R)/usr/share/man/de_DE/man1/ + + cp dhelp_parse $(R)/usr/sbin + cp dhelp dh_dhelp $(R)/usr/bin + cp dsearch $(R)/usr/lib/cgi-bin + + dh_strip + dh_compress -X.jpg + dh_fixperms + chown www-data.www-data $(R)/var/lib/dhelp + + dh_shlibdeps + dh_gencontrol + dh_installdeb + dh_md5sums + dh_builddeb + + + +define checkdir + test -f debian/rules +endef + +# Below here is fairly generic really + +binary: binary-indep binary-arch + +source diff: + @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false + +checkroot: + $(checkdir) + test root = "`whoami`" + +.PHONY: binary binary-arch binary-indep clean checkroot + + @@ -1,28 +1,38 @@ #!/usr/bin/perl -# Copyright 1998 by Marco Budde (Budde@tu-harburg.de) +# Copyright 1998-99 by Marco Budde (Budde@tu-harburg.de) # GNU GPL license -print "------- dhelp processing -------\n"; - -###################################################### -# copy debian/dhelp to debian/tmp/usr/doc/$package # -###################################################### -if (-f 'debian/dhelp') -{ - open (IN, '< debian/changelog'); - $package = <IN>; - $package =~ /(.+?)\s.+/; +############################################################ +# copy debian/dhelp to debian/tmp/usr/share/doc/$package # +############################################################ - if (-d "debian/tmp/usr/doc/$1") +sub copy +{ + if ($package eq $package_ch) { - system ("cp debian/dhelp debian/tmp/usr/doc/$1/.dhelp"); - print "- Installing dhelp file\n"; + if (-f 'debian/dhelp') + { + if (-d "$dir/usr/share/doc/$package") + { + system ("cp debian/dhelp $dir/usr/share/doc/$package/.dhelp"); + print "- Installing dhelp file\n"; + } + } + } + else + { + if (-f 'debian/dhelp.$package') + { + if (-d "$dir/usr/share/doc/$package") + { + system ("cp debian/dhelp $dir/usr/share/doc/$package/.dhelp"); + print "- Installing dhelp file\n"; + } + } } - - close (IN); } @@ -30,54 +40,91 @@ if (-f 'debian/dhelp') # create postinst/prerm scripts # ################################### -@find = split (/\n/, `find debian/tmp/usr/doc -noleaf -name .dhelp -print`); +sub scripts +{ + @find = split (/\n/, `find $dir/usr/share/doc -noleaf -name .dhelp -print`); + + $POSTINST_EX = -f '$dir/DEBIAN/postinst'; + $PRERM_EX = -f '$dir/DEBIAN/prerm'; -#print "@find "; + open (POSTINST, ">> debian/postinst.debhelper"); + open (PRERM, ">> debian/prerm.debhelper"); -if (not -d 'debian/tmp/DEBIAN') -{ - mkdir ('debian/tmp/DEBIAN', 0755); -} + ### fhs ### -$POSTINST_EX = -f 'debian/tmp/DEBIAN/postinst'; -$PRERM_EX = -f 'debian/tmp/DEBIAN/prerm'; + print POSTINST "\n# dhelp processing (automatically added by dh_dhelp)\n"; + print POSTINST "if [ -x /usr/sbin/dhelp_parse ]; then\n"; + print POSTINST " /usr/sbin/dhelp_parse -a"; -open (POSTINST, ">> debian/tmp/DEBIAN/postinst"); -open (PRERM, ">> debian/tmp/DEBIAN/prerm"); + print PRERM "\n# dhelp processing (automatically added by dh_dhelp)\n"; + print PRERM "if [ -x /usr/sbin/dhelp_parse ]; then\n"; + print PRERM " /usr/sbin/dhelp_parse -d"; -if (not $POSTINST_EX) -{ - print POSTINST "#!/bin/sh -e\n"; - chmod (0755, 'debian/tmp/DEBIAN/postinst'); -} + foreach $entry (@find) + { + $entry =~ /$dir(.+).dhelp$/; + print POSTINST " $1"; + print PRERM " $1"; + print "- Adding $1 (fhs) to postinst/prerm script\n"; + } -if (not $PRERM_EX) -{ - print PRERM "#!/bin/sh -e\n"; - chmod (0755, 'debian/tmp/DEBIAN/prerm'); + print POSTINST "\nfi\n\n"; + print PRERM "\nfi\n\n"; + + ### fsstnd (Debian 2.1) ### + +# print POSTINST "\n# dhelp processing (automatically added by dh_dhelp)\n"; +# print POSTINST "if [ -x /usr/sbin/dhelp_parse_fsstnd ]; then\n"; +# print POSTINST " /usr/sbin/dhelp_parse_fsstnd -a"; + +# print PRERM "\n# dhelp processing (automatically added by dh_dhelp)\n"; +# print PRERM "if [ -x /usr/sbin/dhelp_parse_fsstnd ]; then\n"; +# print PRERM " /usr/sbin/dhelp_parse_fsstnd -d"; + +# foreach $entry (@find) +# { +# $entry =~ /$dir\/usr\/share\/doc(.+).dhelp$/; +# print POSTINST " /usr/doc$1"; +# print PRERM " /usr/doc$1"; +# print "- Adding /usr/doc$1 (fsstnd) to postinst/prerm script\n"; +# } + +# print POSTINST "\nfi\n\n"; +# print PRERM "\nfi\n\n"; + + close POSTINST; + close PRERM; } -print POSTINST "\n# dhelp processing\n"; -print POSTINST "if [ -x /usr/sbin/dhelp_parse ]; then\n"; -print POSTINST " /usr/sbin/dhelp_parse -a"; -print PRERM "\n# dhelp processing\n"; -print PRERM "if [ -x /usr/sbin/dhelp_parse ]; then\n"; -print PRERM " /usr/sbin/dhelp_parse -d"; +################################### +# main # +################################### + +print "------- dhelp processing -------\n"; + +$dir = "debian/tmp"; # defaults +open (IN, '< debian/changelog'); +$package_ch = <IN>; +$package_ch =~ /(.+?)\s.+/; +$package_ch = $1; +$package = $package_ch; +close (IN); -foreach $entry (@find) +foreach (@ARGV) # parse command line { - $entry =~ /debian\/tmp(.+).dhelp$/; - print POSTINST " $1"; - print PRERM " $1"; - print "- Adding $1 to postinst/prerm script\n"; + if (/^-P(.+)$/) # build dir + { + $dir = $1; + } + elsif (/^-p(.+)$/) # package name + { + $package = $1; + } } -print POSTINST "\nfi\n\n"; -print PRERM "\nfi\n\n"; - -close POSTINST; -close PRERM; +© +&scripts; print "------------------------------------\n"; @@ -15,8 +15,17 @@ else BROWSER=$BROWSER2 elif [ -x /usr/bin/X11/netscape ]; then BROWSER=netscape + elif [ -x /usr/bin/X11/gzilla ]; then + BROWSER=gzilla + elif [ -x /usr/bin/gnome-help-browser ]; then + BROWSER=gnome-help-browser + elif [ -x /usr/bin/amaya ]; then + BROWSER=amaya elif [ -x /usr/bin/X11/arena ]; then - BROWSER=arena + BROWSER=arena + elif [ -x /usr/bin/mozilla ]; then + BROWSER=mozilla + else echo "dhelp: no X11 WWW browser found" echo ' Install a browser or use $BROWSER.' @@ -28,10 +37,16 @@ fi # use http? if [ -f /var/run/apache.pid ]; then - HTTP="apache"; + HTTP="Apache"; + DOCUMENT="http://localhost/doc/HTML/index.html"; +elif [ -f /var/run/apache-ssl.pid ]; then + HTTP="Apache SSL"; + DOCUMENT="http://localhost/doc/HTML/index.html"; +elif [ -f /var/run/aolserver/aolserver.pid ]; then + HTTP="AOLserver"; DOCUMENT="http://localhost/doc/HTML/index.html"; else - DOCUMENT="/usr/doc/HTML/index.html"; + DOCUMENT="/usr/share/doc/HTML/index.html"; HTTP="FALSE"; fi @@ -40,26 +55,24 @@ fi echo -n "Starting ${BROWSER}"; -if [ ${HTTP} = "FALSE" ]; then +if [ "$HTTP" = "FALSE" ]; then echo " (using local filesystem) ..."; else echo " (using HTTP ${HTTP}) ..."; fi if [ "$1" = "" ]; then - if [ -f /usr/doc/HTML/index.html ]; then + if [ -f /usr/share/doc/HTML/index.html ]; then $BROWSER ${DOCUMENT}; else echo "dhelp: please run \"dhelp_parse -r\"" fi else - if [ -f /tmp/$$.html ]; then - rm -f /tmp/$$.html - fi + TMPFILE=`tempfile -p dhelp -s .html` /usr/lib/cgi-bin/dsearch $1 | \ - sed 's/\/doc/\/usr\/doc/g' > /tmp/$$.html - $BROWSER /tmp/$$.html - rm -f /tmp/$$.html + sed 's/\/doc/\/usr\/share\/doc/g' > ${TMPFILE} + $BROWSER ${TMPFILE} + rm -f ${TMPFILE} fi diff --git a/dhelp_fsstnd b/dhelp_fsstnd new file mode 100755 index 0000000..55db737 --- /dev/null +++ b/dhelp_fsstnd @@ -0,0 +1,69 @@ +#!/bin/sh + +# which browser will we use? + +if [ "$DISPLAY" = "" ]; then + if [ -x /usr/bin/lynx ]; then + BROWSER=lynx + else + echo "dhelp: lynx not found" + exit + fi +else + BROWSER2=`which $BROWSER` + if [ $? -eq 0 ]; then + BROWSER=$BROWSER2 + elif [ -x /usr/bin/X11/netscape ]; then + BROWSER=netscape + elif [ -x /usr/bin/X11/gzilla ]; then + BROWSER=gzilla + elif [ -x /usr/bin/gnome-help-browser ]; then + BROWSER=gnome-help-browser + elif [ -x /usr/bin/amaya ]; then + BROWSER=amaya + elif [ -x /usr/bin/X11/arena ]; then + BROWSER=arena + else + echo "dhelp: no X11 WWW browser found" + echo ' Install a browser or use $BROWSER.' + exit + fi +fi + + +# use http? + +if [ -f /var/run/apache.pid ]; then + HTTP="Apache"; + DOCUMENT="http://localhost/doc/HTML2/index.html"; +elif [ -f /var/run/apache-ssl.pid ]; then + HTTP="Apache SSL"; + DOCUMENT="http://localhost/doc/HTML2/index.html"; +elif [ -f /var/run/aolserver/aolserver.pid ]; then + HTTP="AOLserver"; + DOCUMENT="http://localhost/doc/HTML/index.html"; +else + DOCUMENT="/usr/doc/HTML2/index.html"; + HTTP="FALSE"; +fi + + +# start browser or search engine + +echo -n "Starting ${BROWSER}"; + +if [ "$HTTP" = "FALSE" ]; then + echo " (using local filesystem) ..."; +else + echo " (using HTTP ${HTTP}) ..."; +fi + +if [ -f /usr/doc/HTML2/index.html ]; then + $BROWSER ${DOCUMENT}; +else + echo "dhelp: please run \"dhelp_parse_fsstnd -r\"" +fi + + + + diff --git a/dhelp_parse.c b/dhelp_parse.c index 4d559c2..6b1498a 100644 --- a/dhelp_parse.c +++ b/dhelp_parse.c @@ -11,15 +11,21 @@ #include <string.h> #include <stdlib.h> #include <unistd.h> -#include <db.h> #include <dirent.h> #include <sys/types.h> #include <fcntl.h> #include <sys/stat.h> #include <sys/param.h> -#define DOCDIR "/usr/doc" -#define INDEXROOT "/usr/doc/HTML" +#if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1 + #include <db1/db.h> +#else + #include <db.h> +#endif + + +#define DOCDIR "/usr/share/doc" +#define INDEXROOT "/usr/share/doc/HTML" #define DBNAME "/var/lib/dhelp/dbase" #define DBTITLE_NAME "/var/lib/dhelp/titles" @@ -148,7 +154,12 @@ DB *db_title_open (int flags) { HASHINFO hash; - hash.bsize = 256; + #ifdef __alpha__ /* chris@beezer.med.miami.edu */ + hash.bsize = 512; + #else + hash.bsize = 256; + #endif + hash.ffactor = 8; hash.nelem = 1; hash.cachesize = 5000; @@ -324,7 +335,7 @@ void html_w_head (FILE *out, DB *tdb) strcat (zw, "dhelp/debian.jpg"); fprintf (out, "<IMG SRC=\"%s\" ALT=\"Debian GNU/Linux\"> \n", zw); fprintf (out, "<H1>%s</H1>\n<P>\n", zw2); - fprintf (out, "<TABLE>\n"); + fprintf (out, "<DL>\n"); html_error (out); } @@ -356,7 +367,7 @@ void html_w_tail (FILE *out) if (i > lang) i = 0; - fprintf (out, "</TABLE>\n"); + fprintf (out, "</DL>\n"); fprintf (out, "<P>\n<CENTER>\n" "<FORM ACTION=\"/cgi-bin/dsearch\">\n" "<INPUT TYPE=\"text\" NAME=\"search\">\n" @@ -379,8 +390,10 @@ void html_w_item (tItem *item, FILE *out) clearerr (out); path_relative (zw); - fprintf (out, "<TR VALIGN=top><TD><IMG SRC=\"%sdhelp/text.gif\">" - "<TD><A HREF=\"%s%s\">%s</A><TD>%s\n", + fprintf (out, "<DT><IMG SRC=\"%sdhelp/text.gif\">" + " <A HREF=\"%s%s\"><FONT FACE=\"Helvetica, Arial\">" + "<B>%s</B></FONT></A><P></DT>\n" + " <DD>%s</DD>\n\n", zw, zw, item->file, item->name, item->descrip); html_error (out); @@ -474,8 +487,11 @@ int html_w_dir_links (char *dirname, DB *tdb) if (S_ISDIR (buf.st_mode)) { path_relative (relpath); - fprintf (out, "<TR VALIGN=top><TD><IMG SRC=\"%sdhelp/folder.gif\">\n" - " <TD><A HREF=\"%s/index.html\">%s/</A>\n", + fprintf (out, "<DT><IMG SRC=\"%sdhelp/folder.gif\">" + " <A HREF=\"%s/index.html\">" + "<FONT FACE=\"Helvetica, Arial\"><B>%s/</B></FONT>" + "</A></DT>\n" + " <DD></DD>\n\n", relpath, dir_entry->d_name, dir_entry->d_name); if (html_w_dir_links (zw, tdb)) { @@ -498,22 +514,32 @@ void html_write (void) { tItem item; DB *db, *tdb; - int i; + int i; + FILE *out; if ((db = db_open (O_RDONLY)) == NULL) { fprintf (stderr, "dhelp_parse: can't open %s\n\n", DBNAME); - exit (1); + exit (0); } - if ((tdb = db_title_open (O_RDONLY)) == NULL) + if ((tdb = db_title_open (O_RDWR|O_CREAT)) == NULL) { fprintf (stderr, "dhelp_parse: can't open %s\n\n", DBTITLE_NAME); - exit (1); + exit (0); } rm_r (INDEXROOT); mkdir (INDEXROOT, 0755); chdir (INDEXROOT); /* usr/doc/HTML */ + + if ((out = fopen ("README", "w")) != NULL) + { + fprintf (out, "\nDon't put files in this directory!\n" + "dhelp will delete *all* files in this directory " + "when creating a new index.\n\n" + "Marco Budde (budde@debian.org)\n\n"); + fclose (out); + } db_read (db, &item); do @@ -661,12 +687,13 @@ int dhelp_del (char *name) char *file_ptr; char resolv_docdir[MAXPATHLEN]; + if ((in = fopen (name, "r")) == NULL) { fprintf (stderr, "dhelp_parse: can't open %s\n\n", name); return (1); } - if ((db = db_open (O_RDWR)) == NULL) + if ((db = db_open (O_RDWR|O_CREAT)) == NULL) { fprintf (stderr, "dhelp_parse: can't open %s\n\n", DBNAME); return (1); @@ -750,6 +777,8 @@ int main (int argc, char *argv[]) dhelp_add_rec (resolv_name); } else + { + mkdir ("/var/lib/dhelp/", 0755); for (i=2; i < argc; i++) { if (!strncmp (argv[i], DOCDIR, strlen (DOCDIR))) @@ -766,6 +795,12 @@ int main (int argc, char *argv[]) default: help (); } } + else if (!strncmp (argv[i], "/usr/doc", 8)) + { + fprintf (stderr, "dhelp_parse: Warning - documents in /usr/doc " + "are no longer supported!\n\n"); + return (0); /* do not break the installation of old packages */ + } else { fprintf (stderr, "dhelp_parse: You can add only directories " @@ -773,6 +808,7 @@ int main (int argc, char *argv[]) return (1); } } + } html_write (); diff --git a/doc/dhelp.html b/doc/dhelp.html index 3578a83..098ba07 100644 --- a/doc/dhelp.html +++ b/doc/dhelp.html @@ -23,7 +23,7 @@ If you haven't installed a WWW server use the dhelp command: <H2>The .dhelp file</H2> Programs supporting dhelp have to install a <tt>.dhelp</tt> file -in every directory under <tt>/usr/doc</tt>. For every HTML file that +in every directory under <tt>/usr/share/doc</tt>. For every HTML file that should appear in the dhelp index the <tt>.dhelp</tt> file have to contain the following section:<P> @@ -46,8 +46,8 @@ the following section:<P> <DT><TT><filename></TT> <DD>The filename of the HTML file with a path relative to the <tt>.dhelp</tt> file. If your document is called - <tt>/usr/doc/dhelp/test.html</tt> and the <tt>.dhelp</tt> - is installed in <tt>/usr/doc/dhelp</tt> you must use + <tt>/usr/share/doc/dhelp/test.html</tt> and the <tt>.dhelp</tt> + is installed in <tt>/usr/share/doc/dhelp</tt> you must use <tt>test.html</tt>. <DT><PRE> <description> @@ -85,10 +85,7 @@ foo foo foo </PRE> You can have several <item> sections in one <tt>.dhelp</tt> -file. At the moment the dhelp standard is supported by the -following Debian packages: <tt>doc-linux-de</tt>, <tt>doc-linux-ja</tt>, -<tt>doc-linux-sv</tt>, <tt>doc-linux-zh</tt>, <tt>fidogate</tt>, -<tt>hwb</tt>, <tt>l3</tt>, and <tt>selfhtml</tt>. +file. <H2>Add a .dhelp file to the index</H2> @@ -96,14 +93,14 @@ following Debian packages: <tt>doc-linux-de</tt>, <tt>doc-linux-ja</tt>, To add a <tt>.dhelp</tt> file to the document index you have to call <tt>dhelp_parse</tt>:<P> -<BLOCKQUOTE># dhelp_parse -a /usr/doc/directory</BLOCKQUOTE> +<BLOCKQUOTE># dhelp_parse -a /usr/share/doc/directory</BLOCKQUOTE> I would suggest to add the following to your package <tt>postinst</tt> script:<P> <BLOCKQUOTE><PRE> if [ -f /usr/sbin/dhelp_parse ]; then - /usr/sbin/dhelp_parse -a /usr/doc/directory + /usr/sbin/dhelp_parse -a /usr/share/doc/directory fi </PRE></BLOCKQUOTE><P> @@ -111,14 +108,41 @@ In <tt>prerm</tt> you should use:<P> <BLOCKQUOTE><PRE> if [ -f /usr/sbin/dhelp_parse ]; then - /usr/sbin/dhelp_parse -d /usr/doc/directory + /usr/sbin/dhelp_parse -d /usr/share/doc/directory fi </PRE></BLOCKQUOTE><P> -Or you can use the new script <tt>dh_dhelp</tt>. This script installs -the <tt>debian/dhelp</tt> file in <tt>/usr/doc/package</tt> and +<!-- +If your package conforms to the latest policy, the <tt>postinst</tt> +script should look like this:<P> + +<BLOCKQUOTE><PRE> +if [ -f /usr/sbin/dhelp_parse ]; then + /usr/sbin/dhelp_parse -a /usr/share/doc/directory +fi + +if [ -f /usr/sbin/dhelp_parse_fsstnd ]; then + /usr/sbin/dhelp_parse_fsstnd -a /usr/doc/directory +fi +</PRE></BLOCKQUOTE><P> + +In <tt>prerm</tt> you should use:<P> + +<BLOCKQUOTE><PRE> +if [ -f /usr/sbin/dhelp_parse ]; then + /usr/sbin/dhelp_parse -d /usr/share/doc/directory +fi + +if [ -f /usr/sbin/dhelp_parse_fsstnd ]; then + /usr/sbin/dhelp_parse_fsstnd -d /usr/doc/directory +fi +</PRE></BLOCKQUOTE><P> +--> + +Or you can use the script <tt>dh_dhelp</tt>. This script installs +the <tt>debian/dhelp</tt> file in <tt>/usr/share/doc/package</tt> and creates the <tt>postinst</tt> and <tt>prerm</tt> scripts of all -<tt>.dhelp</tt> files found in <tt>/usr/doc</tt>. +<tt>.dhelp</tt> files found in <tt>/usr/share/doc</tt>. <H2>Scripts for .dhelp file</H2> @@ -154,12 +178,12 @@ a <tt>.dwww-index</tt> file with the script <H2>What can I do for dhelp?</H2> -If you like dhelp please ask maintainer of Debian packages including +If you like dhelp please ask maintainers of Debian packages including HTML documentation to add dhelp support.<P> If you have any comments or problems please feel free to send -me a email: <A HREF="mailto:mbudde@hqsys.antar.com"> -mbudde@hqsys.antar.com</A> +me an email: <A HREF="mailto:mbudde@sms.antar.com"> +mbudde@sms.antar.com</A> </BODY> </HTML>
\ No newline at end of file diff --git a/doc/sgml2dhelp.pl b/doc/sgml2dhelp.pl index bfaa645..035108d 100644 --- a/doc/sgml2dhelp.pl +++ b/doc/sgml2dhelp.pl @@ -100,7 +100,7 @@ closedir (DIRHANDLE); open (DHELP, "> .dhelp"); open (INDEX, "> index.html"); -print INDEX "<HTML>\n<BODY BGCOLOR=FFFFFF>\n<DL>\n"; +print INDEX "<HTML>\n<BODY BGCOLOR=#FFFFFF>\n<DL>\n"; open (DWWW, "> .dwww-index"); &dwww_pwd; @@ -1,6 +1,6 @@ #!/usr/bin/perl -T -# Copyright 1997-98 by Marco Budde (Budde@tu-harburg.de) +# Copyright 1997-2000 by Marco Budde (Budde@tu-harburg.de) # GNU GPL license $ENV{'PATH'} = '/bin'; @@ -15,7 +15,7 @@ sub url_decode my $input = shift; $input =~ s/\+/ /g; $input =~ s/%([0-9A-Fa-f]{2})/pack("C", hex($1))/eg; - if ($input =~ /^([-\@\w.öäüÖÄÜß]+)$/) # anti hacker test + if ($input =~ /^([-\@\w.öäüÖÄÜß]{3,})$/) # anti hacker test { return $1; } @@ -63,7 +63,7 @@ sub language 'hits', 'Hits', 'error', 'Error', 'error_glimpse', 'Please install the glimpse package on this server!', - 'error_char', 'Your search string includes illegal characters!' ); + 'error_char', 'Your search string includes illegal characters or is shorter than three characters!' ); if ($ENV {'HTTP_ACCEPT_LANGUAGE'} eq "de") { @@ -73,7 +73,7 @@ sub language 'error', 'Fehler', 'error_glimpse', 'Bitte installieren sie das glimpse Paket auf diesem Server!', - 'error_char', 'Ihre Suchanfrage enthält unzulässige Buchstaben!' ); + 'error_char', 'Ihre Suchanfrage enthält unzulässige Buchstaben oder enthält weniger als drei Buchstaben!' ); } if ($ENV {'HTTP_ACCEPT_LANGUAGE'} eq "it") @@ -143,8 +143,8 @@ sub error_message $MESG{$_[0]}<P> <HR> <ADDRESS> - <A HREF="mailto:$ENV{'SERVER_ADMIN'}\@$ENV{'HTTP_HOST'}"> - $ENV{'SERVER_ADMIN'}\@$ENV{'HTTP_HOST'}</A> + <A HREF="mailto:$ENV{'SERVER_ADMIN'}"> + $ENV{'SERVER_ADMIN'}</A> </ADDRESS> </BODY> @@ -173,7 +173,7 @@ sub glimpse_installed sub sort_vgl { - $results{$b}[1] > $results{$a}[1]; + $results{$b}[1] <=> $results{$a}[1]; } @@ -183,8 +183,13 @@ sub sort_vgl sub search { + if (not mkdir "/tmp/dsearch.$$",0700) + { + exit 1; + } @results = split (/\n/, - `/usr/bin/glimpse -i -U -c -H /var/lib/dhelp "$FORM{'search'}"`); + `/usr/bin/glimpse -L 100000:1000 -i -U -c -H /var/lib/dhelp -T /tmp/dsearch.$$ "$FORM{'search'}"`); + rmdir "/tmp/dsearch.$$"; foreach $line (@results) { @@ -193,6 +198,7 @@ sub search $a = $1; $b = $2; $c = $3; + $a =~ s/\/usr\/share//; $a =~ s/\/usr//; $b =~ s/\\:/:/g; $results{$a} = [$b, $c]; @@ -211,16 +217,20 @@ sub search <IMG SRC="/doc/dhelp/debian.jpg" ALT="Debian GNU/Linux"> <H1>$MESG{'headline'} $FORM{'search'}</H1> -<TABLE> -<TR><TH>$MESG{'title'} - <TH>$MESG{'hits'} +<TABLE CELLPADDING=5 BGCOLOR=#EEEEEE BORDER=0> +<TR BGCOLOR=#EEC000> + <TD><FONT COLOR=#FFFFFF SIZE=+1 FACE="Helvetica,Arial"><B> + <CENTER>$MESG{'title'}</CENTER></B></FONT> + <TD><FONT COLOR=#FFFFFF SIZE=+1 FACE="Helvetica,Arial"><B> + <CENTER>$MESG{'hits'}</CENTER></B></FONT> ENDE foreach $key (sort sort_vgl keys %results) { - printf ("<TR><TD><A HREF=\"%s\">%s</A>\n", $key, $results{$key}[0]); + printf ("<TR><TD><DL><DT><A HREF=\"%s\">%s</A><DD><I>%s</I></DL>\n", + $key, $results{$key}[0], $key); printf (" <TD>%s\n", $results{$key}[1]); } printf ("</TABLE>\n"); @@ -237,7 +247,8 @@ ENDE if (defined $ARGV[0]) { - $FORM{'search'} = $ARGV[0]; + $ARGV[0] =~ /(.*)/; + $FORM{'search'} = $1; } else { diff --git a/fsstnd/Makefile b/fsstnd/Makefile new file mode 100644 index 0000000..0c0b98e --- /dev/null +++ b/fsstnd/Makefile @@ -0,0 +1,10 @@ +DBLIB = $(shell if [ -f /usr/lib/libdb1.a ]; then echo -ldb1; else echo -ldb; fi) + +all: dhelp_parse.o + gcc dhelp_parse.o -o dhelp_parse_fsstnd $(DBLIB) + +clean: + rm -rf dhelp_parse_fsstnd dhelp_parse.o *~ core + +dhelp_parse.o: dhelp_parse.c + gcc -g -O2 -c -Wall -o dhelp_parse.o dhelp_parse.c diff --git a/fsstnd/dhelp_parse.c b/fsstnd/dhelp_parse.c new file mode 100644 index 0000000..8bb57e0 --- /dev/null +++ b/fsstnd/dhelp_parse.c @@ -0,0 +1,808 @@ +/* ******************************************************************** + *** dhelp *** + *** Debian online help system *** + ******************************************************************** + *** Copyright (c) 1997-99 by Marco Budde (Budde@tu-harburg.de) *** + *** GNU GPL license *** + ******************************************************************** */ + + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <unistd.h> +#include <dirent.h> +#include <sys/types.h> +#include <fcntl.h> +#include <sys/stat.h> +#include <sys/param.h> + +#if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1 + #include <db1/db.h> +#else + #include <db.h> +#endif + + +#define DOCDIR "/usr/doc" +#define INDEXROOT "/usr/doc/HTML2" +#define DBNAME "/var/lib/dhelp/dbase_fsstnd" +#define DBTITLE_NAME "/var/lib/dhelp/titles_fsstnd" + + +typedef struct +{ + char dir[100]; /* section name */ + char dtitle[100]; /* description of a section */ + char name[50]; /* linkname */ + char file[100]; /* name of a HTML file */ + char descrip[1000]; /* description of item */ +} tItem; + + +/* ************************************ + * Eingabe: String * + * Ausgabe: Anzahl von / im String * + ************************************ */ + +int strcnt (const char *s) +{ + int i=0; + + for ( ; *s!='\0'; s++) + if (*s == '/') + i++; + return i; +} + + +/* ******************************* + * strdel: Ersetzt \n durch \0 * + ******************************* */ + +void strdel (char *s) +{ + for ( ; *s!='\n'; s++); + *s = '\0'; +} + + +/* ************************************ + * strpart: liefert Teilpfad aus in * + ************************************ */ + +void strpart (const char *in, char *out) +{ + for ( ; (*in!='\0')&&(*in!='/'); in++, out++) + *out = *in; + if (*in == '/') + *out++ = *in++; + *out++='\0'; /* richtig ? */ +} + + +/* ------------------------------------------------------------- */ + +char *path_index_cwd (char *buf) +{ + char cwd[MAXPATHLEN]; + char *cwd_ptr; + char resolv_name[MAXPATHLEN]; + + realpath (INDEXROOT, resolv_name); + cwd_ptr = getcwd (cwd, sizeof (cwd)) + strlen (resolv_name); + if (strlen (cwd_ptr) > 0) + cwd_ptr++; + strcpy (buf, cwd_ptr); + + return (buf); +} + + +char *path_relative (char *buf) +{ + char cwd[MAXPATHLEN]; + int i; + + path_index_cwd (cwd); + buf[0] = '\0'; + if (strlen (cwd) != 0) + for (i = 1; i < (strcnt (cwd) + 3); i++) + strcat (buf, "../"); + else + strcpy (buf, "../"); + return (buf); +} + + +void rm_r (char *dirname) +{ + DIR *dir; + struct dirent *dir_entry; + struct stat buf; + char zw[MAXPATHLEN]; + + if ((dir = opendir (dirname)) == NULL) + return; + + while ((dir_entry = readdir (dir)) != NULL) + { + if (strcmp (dir_entry->d_name, ".") != 0 + && (strcmp (dir_entry->d_name, "..") != 0)) + { + strcpy (zw, dirname); + strcat (zw, "/"); + strcat (zw, dir_entry->d_name); + stat (zw, &buf); + if (S_ISDIR (buf.st_mode)) + { + rm_r (zw); /* Unterverzeichnisse loeschen */ + rmdir (zw); + } + else + remove (zw); + } + } + + closedir (dir); +} + +/* --------------------------------------------------------------- */ + + +DB *db_title_open (int flags) +{ + HASHINFO hash; + + #ifdef __alpha__ + hash.bsize = 512; + #else + hash.bsize = 256; + #endif + hash.ffactor = 8; + hash.nelem = 1; + hash.cachesize = 5000; + hash.hash = NULL; + hash.lorder = 0; + + return (dbopen (DBTITLE_NAME, flags, 0644, DB_HASH, &hash)); +} + +int db_title_write (DB *db, tItem *item) +{ + DBT key, data; + + key.data = item->dir; + key.size = strlen (item->dir) + 1; + data.data = item->dtitle; + data.size = strlen (item->dtitle) + 1; + + return ((db->put)(db, &key, &data, 0)); +} + +int db_title_read (DB *db, char *dir, char *title, int size) +{ + DBT key, data; + int i; + + key.data = dir; + key.size = strlen (dir) + 1; + + i = ((db->get)(db, &key, &data, 0)); + + switch (i) + { + case 0 : strncpy (title, data.data, size); + break; + case 1 : strcpy (title, ""); + } + + return (i); +} + + +/* ---------------------------------------------------------------- */ + +typedef struct +{ + char file[100]; + char dir[100]; + char name[50]; +} tkey_data; + +int db_compare (const DBT *key1, const DBT *key2) +{ + /* Ueberprueft, ob key1 groesser, kleiner oder gleich key2 ist */ + + /* muss wahrscheinlich geaendert werden! fidogate/ entfernen vor + Vergleich */ + + tkey_data *data1, *data2; + int i; + + data1 = key1->data; + data2 = key2->data; + + i = strcmp (data1->dir, data2->dir); /* sortieren nach dir */ + if (i == 0) + return (strcmp (data1->name, data2->name)); /* sortieren nach name */ + else + return (i); +} + +DB* db_open (int flags) +{ + /* Oeffnet die Datenbank */ + + BTREEINFO btree; + + btree.flags = 0; + btree.cachesize = 10000; + btree.minkeypage = 0; + btree.psize = 0; + btree.compare = (int (*)(const DBT *, const DBT *))(db_compare); + /* aendern!!! */ + btree.prefix = NULL; + btree.lorder = 0; + + return (dbopen (DBNAME, flags, 0644, DB_BTREE, &btree)); +} + +int db_write (DB *db, tItem *item) +{ + /* speichert einen dhelp Eintrag (item) in die Datenbank */ + + DBT key, data; + tkey_data key_data; + + strcpy (key_data.file, item->file); + strcpy (key_data.dir, item->dir); + strcpy (key_data.name, item->name); + + key.data = &key_data; + key.size = sizeof (key_data); + data.data = item->descrip; /* ohne & richtig? */ + data.size = sizeof (item->descrip); + return ((db->put)(db, &key, &data, 0)); +} + + +int db_read (DB *db, tItem *item) +{ + /* holt einen dhelp Eintrag aus der Datenbank */ + + DBT key, data; + tkey_data *key_data; + int i; + + i = (db->seq)(db, &key, &data, R_NEXT); + + if (i == 0) + { + key_data = key.data; + strcpy (item->file, key_data->file); + strcpy (item->dir, key_data->dir); + strcpy (item->name, key_data->name); + strcpy (item->descrip, data.data); + } + + return (i); +} + +int db_del (DB *db, tItem *item) +{ + DBT key; + tkey_data key_data; + + strcpy (key_data.file, item->file); + strcpy (key_data.dir, item->dir); + strcpy (key_data.name, item->name); + + key.data = &key_data; + key.size = sizeof (key_data); + + return ((db->del)(db, &key, 0)); +} + +/* --------------------------------------------------------------- */ + +void html_error (FILE *out) +{ + if (ferror (out) != 0) + { + fprintf (stderr, "dhelp_parse: can't write index.html\n"); + exit (1); + } +} + + +void html_w_head (FILE *out, DB *tdb) +{ + char zw[MAXPATHLEN], zw2[100]; + char cwd[MAXPATHLEN]; + + clearerr (out); + + path_index_cwd (cwd); + db_title_read (tdb, cwd, zw2, sizeof (zw)); + fprintf (out, "<HTML>\n\n<HEAD>\n<TITLE>%s</TITLE>\n" + "<LINK REV=made HREF=\"mailto:Budde@tu-harburg.de\">\n" + "</HEAD>\n\n", zw2); + fprintf (out, "<BODY BGCOLOR=#FFFFFF>\n"); + + path_relative (zw); + strcat (zw, "dhelp/debian.jpg"); + fprintf (out, "<IMG SRC=\"%s\" ALT=\"Debian GNU/Linux\"> \n", zw); + fprintf (out, "<H1>%s</H1>\n<P>\n", zw2); + fprintf (out, "<DL>\n"); + + html_error (out); +} + + +void html_w_tail (FILE *out) +{ + char cwd[MAXPATHLEN]; + int lang = 5; + char *language[] = { "", "de/", "da/", "it/", "es/", "fr/" }; + char *search[] = { "Search", "Suche", "Søg", "Ricerca", "Buscar", + "Rechercher" }; + char *info[] = { "info documents", "info Dokumente", "info dokumenter", + "documenti info", "documentos info", "Pages info" }; + char *man[] = { "man pages", "Handbücher", "manual", "pagine di manuale", + "páginas de manual", "Pages de manuel" }; + char *other[] = { "other documents", "andere Dokumente", "andre dokumenter", + "altri documenti", "Otros documentos", + "Autres documents" }; + int i; + + clearerr (out); + + path_index_cwd (cwd); /* get language */ + strcat (cwd, "/"); + for (i=0; i <= lang; i++) + if (!strncmp (cwd, language[i], 3)) + break; + if (i > lang) + i = 0; + + fprintf (out, "</DL>\n"); + fprintf (out, "<P>\n<CENTER>\n" + "<FORM ACTION=\"/cgi-bin/dsearch\">\n" + "<INPUT TYPE=\"text\" NAME=\"search\">\n" + "<INPUT TYPE=\"submit\" VALUE=\"%s\">\n" + "</FORM><BR>\n" + "[ <A HREF=\"/cgi-bin/info2www\">%s</A> | \n" + "<A HREF=\"/cgi-bin/man2html\">%s</A> | \n" + "<A HREF=\"/doc/\">%s</A> ]\n</CENTER>\n", + search[i], info[i], man[i], other[i]); + fprintf (out, "</BODY></HTML>\n"); + + html_error (out); +} + + +void html_w_item (tItem *item, FILE *out) +{ + char zw[MAXPATHLEN]; + + clearerr (out); + + path_relative (zw); + fprintf (out, "<DT><IMG SRC=\"%sdhelp/text.gif\">" + " <A HREF=\"%s%s\"><FONT FACE=\"Helvetica, Arial\">" + "<B>%s</B></FONT></A><P></DT>\n" + " <DD>%s</DD>\n\n", + zw, zw, item->file, item->name, item->descrip); + + html_error (out); +} + + +int html_w_item_links (DB *db, DB *tdb, tItem *item) +{ + char cwd[MAXPATHLEN]; + char dir[MAXPATHLEN], *dir_ptr; + FILE *out; + + path_index_cwd (cwd); + dir_ptr = item->dir; /* richtig ? */ + while (strcmp (cwd, item->dir)) + { + strpart (dir_ptr, dir); + dir_ptr += strlen (dir); + mkdir (dir, 0755); + chdir (dir); + path_index_cwd (cwd); + } + + if ((out = fopen ("index.html", "w")) == NULL) + { + fprintf (stderr, "dhelp_parse: can't open index.html\n\n"); + exit (1); + } + + html_w_head (out, tdb); + do + { + strcpy (dir, item->dir); + html_w_item (item, out); + if ((db_read (db, item)) != 0) + { + fclose (out); + return (1); + } + } + while (!strcmp (dir, item->dir)); + fclose (out); + + return (0); +} + + +int html_w_dir_links (char *dirname, DB *tdb) +{ + DIR *dir; + FILE *out; + struct dirent *dir_entry; + struct stat buf; + char zw[MAXPATHLEN]; + char relpath[MAXPATHLEN]; + + strcpy (zw, dirname); + strcat (zw, "/index.html"); + + chdir (dirname); /* ??? */ + + if ((out = fopen (zw, "r")) == NULL) /* existiert index.html bereits? */ + { + if ((out = fopen (zw, "w")) == NULL) + { + fprintf (stderr, "dhelp_parse: can't open %s\n", zw); + return (1); + } + html_w_head (out, tdb); + } + else + { + fclose (out); + if ((out = fopen (zw, "a")) == NULL) + { + fprintf (stderr, "dhelp_parse: can't open %s\n", zw); + return (1); + } + } + dir = opendir (dirname); + + while ((dir_entry = readdir (dir)) != NULL) + { + if (strcmp (dir_entry->d_name, ".") != 0 + && strcmp (dir_entry->d_name, "..") != 0) + { + strcpy (zw, dirname); + strcat (zw, "/"); + strcat (zw, dir_entry->d_name); + stat (zw, &buf); + if (S_ISDIR (buf.st_mode)) + { + path_relative (relpath); + fprintf (out, "<DT><IMG SRC=\"%sdhelp/folder.gif\">" + " <A HREF=\"%s/index.html\">" + "<FONT FACE=\"Helvetica, Arial\"><B>%s/</B></FONT>" + "</A></DT>\n" + " <DD></DD>\n\n", + relpath, dir_entry->d_name, dir_entry->d_name); + if (html_w_dir_links (zw, tdb)) + { + fclose (out); + return (1); + } + chdir (".."); /* ??? */ + } + } + } + html_w_tail (out); + + fclose (out); + closedir (dir); + return (0); +} + + +void html_write (void) +{ + tItem item; + DB *db, *tdb; + int i; + FILE *out; + + if ((db = db_open (O_RDONLY)) == NULL) + { + fprintf (stderr, "dhelp_parse: can't open %s\n\n", DBNAME); + exit (0); + } + if ((tdb = db_title_open (O_RDONLY)) == NULL) + { + fprintf (stderr, "dhelp_parse: can't open %s\n\n", DBTITLE_NAME); + exit (0); + } + + rm_r (INDEXROOT); + mkdir (INDEXROOT, 0755); + chdir (INDEXROOT); /* usr/doc/HTML */ + + if ((out = fopen ("README", "w")) != NULL) + { + fprintf (out, "\nDon't put files in this directory!\n" + "dhelp will delete *all* files in this directory " + "when creating a new index.\n\n" + "Marco Budde (budde@debian.org)\n\n"); + fclose (out); + } + + db_read (db, &item); + do + { + i = html_w_item_links (db, tdb, &item); + chdir (INDEXROOT); + } + while (i == 0); + + if (html_w_dir_links (INDEXROOT, tdb)) + { + fprintf (stderr, "dhelp_parse: can't write index\n"); + exit (1); + } + + db->close (db); /* ??? */ + tdb->close (tdb); /* ??? */ +} + + +/* --------------------------------------------------------------- */ + + + +int get_item (FILE *fd, char *filename, tItem *item) +{ + char zw[200]; + int cnt = 0; + + item->descrip[0]='\0'; + item->dtitle[0]='\0'; + item->file[0]='\0'; + + /* <item> == Start suchen */ + do + if ((fgets (zw, sizeof(zw), fd)) == NULL) + return 1; + while (strncmp ("<item>", zw, 6) != 0); + + /* Daten eines <item> parsen */ + do + { + if ((fgets (zw, sizeof(zw), fd)) == NULL) + return 1; + if (strncmp ("<directory>", zw, 11) == 0) + { + strncpy (item->dir, zw+11, sizeof (item->dir)); + item->dir[sizeof(item->dir)-1] = '\0'; + strdel (item->dir); + } + if (strncmp ("<dirtitle>", zw, 10) == 0) + { + strncpy (item->dtitle, zw+10, sizeof (item->dtitle)); + item->dtitle[sizeof(item->dtitle)-1] = '\0'; + strdel (item->dtitle); + } + if (strncmp ("<linkname>", zw, 10) == 0) + { + strncpy (item->name, zw+10, sizeof (item->name)); + item->name[sizeof(item->name)-1] = '\0'; + strdel (item->name); + } + if (strncmp ("<filename>", zw, 10) == 0) + { + strcpy (item->file, filename); /* Verzeichnisname */ + strncat (item->file, zw+10, sizeof (item->file) - strlen (filename)); + item->file[sizeof(item->file)-1] = '\0'; + strdel (item->file); + } + if (strncmp ("<description>", zw, 13) == 0) + { + fgets (zw, sizeof(zw), fd); + while (strncmp ("</description>", zw, 14) != 0) + { + cnt = cnt + strlen (zw); + if (cnt < sizeof (item->descrip)) + { + strcat (item->descrip, zw); + item->descrip[sizeof(item->descrip)-1] = '\0'; + } + if ((fgets (zw, sizeof(zw), fd)) == NULL) + return 1; + } + } + } + while (strncmp ("</item>", zw, 7) != 0); + + return 0; +} + + +int dhelp_add (char *name) +{ + FILE *in; + tItem item; + DB *db, *db_title; + char *file_ptr; + char resolv_docdir[MAXPATHLEN]; + + if ((in = fopen (name, "r")) == NULL) + { + fprintf (stderr, "dhelp_parse: can't open %s\n\n", name); + return (1); + } + if ((db = db_open (O_RDWR|O_CREAT)) == NULL) + { + fprintf (stderr, "dhelp_parse: can't open %s\n\n", DBNAME); + return (1); + } + if ((db_title = db_title_open (O_RDWR|O_CREAT)) == NULL) + { + fprintf (stderr, "dhelp_parse: can't open %s\n\n", DBTITLE_NAME); + return (1); + } + + /* relativen Pfad zum Dokument erzeugen */ + + realpath (DOCDIR, resolv_docdir); + file_ptr = name; + file_ptr += strlen (resolv_docdir); + file_ptr++; + file_ptr [strlen(file_ptr)-6] = '\0'; + + while (!(get_item (in, file_ptr, &item))) + { + if (item.file[0] != '\0') + db_write (db, &item); + if (item.dtitle[0] != '\0') + db_title_write (db_title, &item); + } + + fclose (in); + db->close (db); + db_title->close (db_title); + + return (0); +} + + +int dhelp_del (char *name) +{ + FILE *in; + tItem item; + DB *db; + char *file_ptr; + char resolv_docdir[MAXPATHLEN]; + + if ((in = fopen (name, "r")) == NULL) + { + fprintf (stderr, "dhelp_parse: can't open %s\n\n", name); + return (1); + } + if ((db = db_open (O_RDWR|O_CREAT)) == NULL) + { + fprintf (stderr, "dhelp_parse: can't open %s\n\n", DBNAME); + return (1); + } + + /* relativen Pfad zum Dokument erzeugen */ + + realpath (DOCDIR, resolv_docdir); + file_ptr = name; + file_ptr += strlen (resolv_docdir); + file_ptr++; + file_ptr [strlen(file_ptr)-6] = '\0'; + + while (!(get_item (in, file_ptr, &item))) + db_del (db, &item); + + fclose (in); + db->close (db); + + return (0); +} + + +void dhelp_add_rec (char *dirname) +{ + DIR *dir; + struct dirent *dir_entry; + struct stat buf; + char zw[MAXPATHLEN]; + + dir = opendir (dirname); + + while ((dir_entry = readdir (dir)) != NULL) + { + if ((strcmp (dir_entry->d_name, ".") != 0) + && (strcmp (dir_entry->d_name, "..") != 0)) + { + strcpy (zw, dirname); + strcat (zw, "/"); + strcat (zw, dir_entry->d_name); + lstat (zw, &buf); + if (S_ISDIR (buf.st_mode)) + dhelp_add_rec (zw); + else + if (!strcmp (dir_entry->d_name, ".dhelp")) + dhelp_add (zw); + } + } + + closedir (dir); +} + +/* -------------------------------------------------------------- */ + +void help (void) +{ + printf ("\nUsage: dhelp_parse <option> <directories>\n\n"); + printf ("-a add dhelp file in <directories>\n"); + printf ("-d del dhelp file in <directories>\n"); + printf ("-r index all dhelp files in %s\n\n", DOCDIR); +} + + +int main (int argc, char *argv[]) +{ + int i; + char zw[MAXPATHLEN]; + char resolv_name[MAXPATHLEN]; + + if ((argc < 2) || (strlen (argv[1]) != 2) || (argv[1][0] != '-')) + { + help(); + return (1); + } + + if (!strcmp (argv[1], "-r")) + { + remove (DBNAME); /* loesche db, um alte/falsche Eintraege + zu loeschen */ + realpath (DOCDIR, resolv_name); + dhelp_add_rec (resolv_name); + } + else + { + mkdir ("/var/lib/dhelp/", 0755); + for (i=2; i < argc; i++) + { + if (!strncmp (argv[i], DOCDIR, strlen (DOCDIR))) + { + strcpy (zw, argv[i]); + strcat (zw, "/.dhelp"); + realpath (zw, resolv_name); + switch (argv[1][1]) + { + case 'a': dhelp_add (resolv_name); + break; + case 'd': dhelp_del (resolv_name); + break; + default: help (); + } + } + else + { + fprintf (stderr, "dhelp_parse: You can add only directories " + "under %s!\n\n", DOCDIR); + return (1); + } + } + } + + html_write (); + + return (0); +} diff --git a/man/dh_dhelp.1 b/man/dh_dhelp.1 new file mode 100644 index 0000000..026d4a4 --- /dev/null +++ b/man/dh_dhelp.1 @@ -0,0 +1,35 @@ +.TH DH_DHELP 1 "8 November 1999" "Debhelper Commands" "Debhelper Commands" +.SH NAME +dh_dhelp \- install dhelp files and create installation scripts +.SH SYNOPSIS +.B dh_dhelp +.I "[debhelper options]" +.SH "DESCRIPTION" +dh_dhelp is a debhelper program that is responsible for +installing files used by the debian dhelp (HTML online help) +package into package build directories. +.P +It also automatically generates the postinst and postrm +commands needed to interface with the debian dhelp package. +See +.BR dh_installdeb (1) +for an explanation of how this works. +.P +If a file named debian/dhelp.package exists, then it is installed as +usr/share/doc/package/.dhelp in the package build directory. +.P +For the first first binary package listed in the control file, you +may use debian/dhelp instead. +.SH OPTIONS +Only the -p and the -P options of the debhelper options +are supported. See +.BR debhelper (1) +for a description of these options. +.SH "SEE ALSO" +.BR debhelper (1) +, +.BR dhelp_parse (8) +.SH "CONFORMS TO" +Debian policy, version 3.1.0.0 +.SH AUTHOR +Budde <budde@debian.org> diff --git a/man/dhelp_parse.8 b/man/dhelp_parse.8 index 0c16252..a9e90c1 100644 --- a/man/dhelp_parse.8 +++ b/man/dhelp_parse.8 @@ -1,4 +1,4 @@ -.TH dhelp_parse 8 "10 April 1998" Debian "Debian Linux manual" +.TH dhelp_parse 8 "31 December 1999" Debian "Debian Linux manual" .SH NAME dhelp_parse \- Debian online help parser .SH SYNOPSIS @@ -13,7 +13,7 @@ of a Debian package. An index of the registered documents is written in the directory -.I /usr/doc/HTML +.I /usr/share/doc/HTML .SH OPTIONS .TP @@ -31,7 +31,7 @@ files in the given directories from the dhelp database. Add all .I .dhelp files in -.I /usr/doc +.I /usr/share/doc to the database. .SH PACKAGE DEVELOPERS @@ -41,17 +41,33 @@ have to call dhelp_parse like that: .SS postinst if [ -f /usr/sbin/dhelp_parse ]; then .br - dhelp_parse -a /usr/doc/foo + dhelp_parse -a /usr/share/doc/foo .br fi .SS prerm if [ -f /usr/sbin/dhelp_parse ]; then .br - dhelp_parse -d /usr/doc/foo + dhelp_parse -d /usr/share/doc/foo .br fi +If your package conforms to the Debian policy 3.1.0.0, +you can use +.B dhelp_parse +and +.B dhelp_parse_fsstnd. dhelp_parse +is responsible for +.I /usr/share/doc +and +.B dhelp_parse_fsstnd +for +.I /usr/doc. +A policy 3.1.0.0 conforming package should +.B not +call +.B dhelp_parse_fsstnd. + Or you can use .B dh_dhelp in your @@ -59,20 +75,20 @@ in your This script installs the .I debian/dhelp file in -.I debian/tmp/usr/doc/foo +.I debian/tmp/usr/share/doc/foo and creates the postinst and prerm scripts for all .I dhelp files found in -.I debian/tmp/usr/doc +.I debian/tmp/usr/share/doc You have to install a .I .dhelp file in -.I /usr/doc/foo +.I /usr/share/doc/foo - the format of .I .dhelp is described in -.I /usr/doc/dhelp/dhelp.html +.I /usr/share/doc/dhelp/dhelp.html If you want to support not only dhelp but also dwww, change in the directory with the installed |