--- juman-5.1.orig/debian/patches/020_makepat.diff
+++ juman-5.1/debian/patches/020_makepat.diff
@@ -0,0 +1,11 @@
+--- juman-5.1/makepat/makepat.c~	2005-06-28 13:25:15.000000000 +0900
++++ juman-5.1/makepat/makepat.c	2006-08-25 01:18:47.000000000 +0900
+@@ -29,7 +29,7 @@
+   char comm;
+   int i;
+   pat_node *tmp;
+-  char kugiri[1]; /* 区切り文字 */
++  char kugiri[2]; /* 区切り文字 */
+   char rslt[50000];
+   char	CurPath[FILENAME_MAX];
+   char	JumanPath[FILENAME_MAX];
--- juman-5.1.orig/debian/patches/002_server_pidfile.diff
+++ juman-5.1/debian/patches/002_server_pidfile.diff
@@ -0,0 +1,59 @@
+--- juman-4.0/juman/server.c.orig	2003-04-04 19:43:25.000000000 +0900
++++ juman-4.0/juman/server.c	2003-08-13 12:08:51.000000000 +0900
+@@ -43,6 +43,9 @@
+ 
+ #endif
+ 
++#include <pwd.h>
++#include <grp.h>
++
+ #include <juman.h>
+ 
+ extern int errno;
+@@ -58,6 +61,8 @@
+ static int data_column = 0;
+ static int data_buff_cur = 0;
+ 
++#define JUMAN_PIDFILE     "/var/run/juman.pid"
++#define JUMAN_SERVER_USER "nobody"
+ 
+ /* Parameter Definition from juman.c
+    NACSIS 吉岡
+@@ -536,6 +541,8 @@
+     int foreground;
+ {
+     int pid, i;
++    FILE *pidfile;
++    struct passwd *ent_pw;
+     
+     if (!juman_init_rc(Jumanrc_Fileptr)) {	/* rcfile関係の初期化 */
+ 	fprintf(stderr, "error in .jumanrc\n");
+@@ -580,7 +587,27 @@
+ 
+     signal(SIGCHLD, sigchld_handler);
+ 
+-    fputs("JUMAN server started\n", stdout);
++    umask(022);
++    pidfile = fopen(JUMAN_PIDFILE, "w");
++    if( ! pidfile ){
++	fputs("Can't write pidfile: " JUMAN_PIDFILE "\n", stderr);
++    }
++    fprintf(pidfile, "%d\n", getpid() );
++    fclose(pidfile);
++    umask(0);
++
++    /* Change uid and gid for security */
++    ent_pw = getpwnam(JUMAN_SERVER_USER);
++    if( ent_pw ){
++	gid_t dummy;
++	struct group *gp;
++	/* remove all supplimentary groups */
++	setgroups(0, &dummy);
++	if ((gp = getgrgid(ent_pw->pw_gid)))
++	    setgid(gp->gr_gid); 
++	/* finally drop root */
++	setuid(ent_pw->pw_uid);
++    }
+ 
+     while(1)
+     {
--- juman-5.1.orig/debian/compat
+++ juman-5.1/debian/compat
@@ -0,0 +1 @@
+5
--- juman-5.1.orig/debian/.cvsignore
+++ juman-5.1/debian/.cvsignore
@@ -0,0 +1,6 @@
+files
+postinst.debhelper
+prerm.debhelper
+stampdir
+substvars
+tmp
--- juman-5.1.orig/debian/README.Debian
+++ juman-5.1/debian/README.Debian
@@ -0,0 +1,19 @@
+juman for Debian
+----------------
+
+Juman is a morphological analysis system.  It reads Japanese sentences
+from the standard input, segments them into morpheme sequences, and
+outputs them to the standard output with many additional pieces of
+information (pronunciation, semantic information, etc).
+
+Note: Juman can not process strings encoded in other coding systems
+than EUC-JP, and also its outputs are encoded in EUC-JP.
+
+If you want to use Juman server, try these steps.
+
+    cp -p /usr/share/doc/juman/juman-server /etc/init.d
+    chmod +x /etc/init.d/juman-server
+    update-rc.d juman-server defaults 99 1
+    /etc/init.t/juman-server start
+
+ -- TSUCHIYA Masatoshi <tsuchiya@namazu.org>, Fri Feb 20 14:24:18 2004
--- juman-5.1.orig/debian/changelog
+++ juman-5.1/debian/changelog
@@ -0,0 +1,106 @@
+juman (5.1-2) unstable; urgency=low
+
+  * Fix. (closes: #378301).
+
+ -- TSUCHIYA Masatoshi <tsuchiya@namazu.org>  Fri, 25 Aug 2006 01:20:10 +0900
+
+juman (5.1-1) unstable; urgency=low
+
+  * New upstream release (closes: #342525).
+
+ -- TSUCHIYA Masatoshi <tsuchiya@namazu.org>  Sat, 14 Jan 2006 23:57:03 +0900
+
+juman (4.0-7) unstable; urgency=low
+
+  * debian/rules: Improve documents.
+  * Removed the init script to start Juman server. (closes: #240680, #233553)
+
+ -- TSUCHIYA Masatoshi <tsuchiya@namazu.org>  Sat, 03 Apr 2004 23:47:16 +0900
+
+juman (4.0-6) unstable; urgency=low
+
+  * debian/control: Improve documents.
+  * debian/control, debian/juman.templates, debian/po/POTFILES.in,
+    debian/po/templates.pot: Switch to gettext-based debconf templates.
+    (closes: #233553)
+
+ -- TSUCHIYA Masatoshi <tsuchiya@namazu.org>  Thu, 19 Feb 2004 03:26:21 +0900
+
+juman (4.0-5) unstable; urgency=low
+
+  * debian/control: `libjuman4' package conflicts to `libjuman' package,
+    that is an obsolete package.
+
+ -- TSUCHIYA Masatoshi <tsuchiya@namazu.org>  Wed, 11 Feb 2004 11:30:02 +0900
+
+juman (4.0-4) unstable; urgency=low
+
+  * debian/control: `libjuman' package is renamed to `libjuman4'.
+  * debian/rules: Now, juman depends on libjuman4. (closes: #226393)
+
+ -- TSUCHIYA Masatoshi <tsuchiya@namazu.org>  Tue, 21 Oct 2003 21:05:08 +0900
+
+juman (4.0-3) unstable; urgency=low
+
+  * Use cdbs instead of dbs.
+
+ -- TSUCHIYA Masatoshi <tsuchiya@namazu.org>  Tue, 21 Oct 2003 21:05:08 +0900
+
+juman (4.0-2) unstable; urgency=low
+
+  * debian/copyright: Fix lintian warning.
+  * debian/control, debian/rules, debian/libjuman-dev.files,
+    debian/libjuman.files: In order to fix lintian error, split library
+    files and header files from `juman' package to `libjuman' package and
+    `libjuman-dev' package.
+  * debian/README.Debian, debian/control: Fix language bug. (closes: #215761)
+
+ -- TSUCHIYA Masatoshi <tsuchiya@namazu.org>  Tue, 21 Oct 2003 21:05:08 +0900
+
+juman (4.0-1) unstable; urgency=low
+
+  * Official release.
+
+ -- TSUCHIYA Masatoshi <tsuchiya@namazu.org>  Wed, 20 Aug 2003 14:53:54 +0900
+
+juman (4.0-0.3) unstable; urgency=low
+
+  * debian/rules: Move text files of dictionaries.
+
+ -- TSUCHIYA Masatoshi <tsuchiya@namazu.org>  Sat, 16 Aug 2003 19:15:54 +0900
+
+juman (4.0-0.2) unstable; urgency=low
+
+  * debian/juman.postrm: Remove /etc/juman_server_to_be_run when this
+    package is purged.
+
+ -- TSUCHIYA Masatoshi <tsuchiya@namazu.org>  Wed, 13 Aug 2003 22:30:55 +0900
+
+juman (4.0-0.1) unstable; urgency=low
+
+  * New upstream release.
+  * Repackaging.
+
+ -- TSUCHIYA Masatoshi <tsuchiya@namazu.org>  Wed, 13 Aug 2003 09:03:35 +0900
+
+juman (3.62+cvs20010528-3) unstable; urgency=low
+
+  * debian/patches/030_client_fflush.diff: Flush file handles always.
+
+ -- TSUCHIYA Masatoshi <tsuchiya@namazu.org>  Sun, 08 Dec 2002 00:53:43 +0900
+
+juman (3.62+cvs20010528-2) unstable; urgency=low
+
+  * debian/patches/002_server_pidfile.diff: New patch to create pid file
+    and to change uid and gid for security.
+  * debian/juman.init: New script to start Juman server.
+  * debian/conffiles: Removed.
+
+ -- TSUCHIYA Masatoshi <tsuchiya@namazu.org>  Sat, 05 Oct 2002 14:28:56 +0900
+
+juman (3.62+cvs20010528-1) unstable; urgency=low
+
+  * Initial Release.
+
+ -- TSUCHIYA Masatoshi <tsuchiya@namazu.org>  Sun, 16 Jun 2002 01:22:22 +0900
+
--- juman-5.1.orig/debian/control
+++ juman-5.1/debian/control
@@ -0,0 +1,42 @@
+Source: juman
+Section: misc
+Priority: optional
+Maintainer: TSUCHIYA Masatoshi <tsuchiya@namazu.org>
+Build-Depends: debhelper (>> 4.0.0), cdbs
+Standards-Version: 3.7.2
+
+Package: juman
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Suggests: juman-dic
+Description: Japanese morphological analysis system
+ Juman is a morphological analysis system.  It reads Japanese
+ sentences from the standard input, segments them into morpheme
+ sequences, and outputs them to the standard output with many
+ additional pieces of information (pronunciation, semantic
+ information, etc).
+
+Package: juman-dic
+Architecture: all
+Description: Juman dictionary in text format
+ This package provides Juman dictionary written in text format.
+
+Package: libjuman-dev
+Section: libdevel
+Architecture: any
+Depends: libjuman4 (= ${Source-Version})
+Description: Header files of JUMAN
+ This package provides header files which are necessary to development
+ programs using runtime libraries of Juman, that is a Japanese
+ morphological analysis system.
+
+Package: libjuman4
+Section: libs
+Architecture: any
+Depends: ${shlibs:Depends}
+Conflicts: libjuman
+Replaces: libjuman
+Provides: libjuman
+Description: Library of JUMAN
+ This package provides runtime libraries of Juman, that is a Japanese
+ morphological analysis system.
--- juman-5.1.orig/debian/copyright
+++ juman-5.1/debian/copyright
@@ -0,0 +1,39 @@
+This package was debianized by TSUCHIYA Masatoshi
+<tsuchiya@namazu.org> on Sun, 16 Jun 2002 01:22:22 +0900.
+
+It was downloaded from http://www.kc.t.u-tokyo.ac.jp/nl-resource/juman.html.
+
+Upstream Author: Sadao Kurohashi <nl-resource@kc.t.u-tokyo.ac.jp>.
+
+Copyright:
+
+Copyright (c) 2003 University of Tokyo
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+3. The name University of Tokyo may not be used to endorse or promote
+   products derived from this software without specific prior written
+   permission.
+
+
+THIS SOFTWARE IS PROVIDED BY University of Tokyo ``AS IS'' AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE Nara Institute of
+Science and Technology BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--- juman-5.1.orig/debian/juman-dic.dirs
+++ juman-5.1/debian/juman-dic.dirs
@@ -0,0 +1 @@
+usr/share/juman/dic
--- juman-5.1.orig/debian/juman-server
+++ juman-5.1/debian/juman-server
@@ -0,0 +1,41 @@
+#! /bin/sh
+#
+# If you want to use Juman server, copy this script to /etc/init.d/
+# and call update-rc.d to install the links of the copied script.
+#
+
+NAME=juman
+DAEMON="/usr/bin/$NAME"
+DESC="Juman server"
+
+test -f $DAEMON || exit 0
+
+PARAMS="-S"
+
+case "$1" in
+    start)
+	check_for_no_start
+	echo -n "Starting $DESC: "
+	start-stop-daemon --start --quiet --background --exec $DAEMON -- $PARAMS
+	echo "$NAME."
+	;;
+    stop)
+	echo -n "Stopping $DESC: "
+	start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid
+	echo "$NAME."
+	;;
+    restart|force-reload)
+	echo -n "Restarting $DESC: "
+	start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid
+	sleep 1
+	start-stop-daemon --start --quiet --background --exec $DAEMON -- $PARAMS
+	echo "$NAME."
+	;;
+    *)
+	N=/etc/init.d/$NAME
+	echo "Usage: $N {start|stop|restart|force-reload}" >&2
+	exit 1
+	;;
+esac
+
+exit 0
--- juman-5.1.orig/debian/juman.1
+++ juman-5.1/debian/juman.1
@@ -0,0 +1,40 @@
+.\"                                      Hey, EMACS: -*- nroff -*-
+.\" First parameter, NAME, should be all caps
+.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
+.\" other parameters are allowed: see man(7), man(1)
+.TH JUMAN 1 "Aug 13th, 2003"
+.\" Please adjust this date whenever revising the manpage.
+.\"
+.\" Some roff macros, for reference:
+.\" .nh        disable hyphenation
+.\" .hy        enable hyphenation
+.\" .ad l      left justify
+.\" .ad b      justify to both left and right margins
+.\" .nf        disable filling
+.\" .fi        enable filling
+.\" .br        insert line break
+.\" .sp <n>    insert n+1 empty lines
+.\" for manpage-specific macros, see man(7)
+.SH NAME
+juman \- a morphological analysys system
+.SH SYNOPSIS
+.B juman
+.RI [ options ]
+.SH DESCRIPTION
+.B JUMAN
+is a morphological analysys system.  It can segment and tokenize
+Japanese text string, and can output with many additional informations
+(pronunciation, semantic information, and others).  It will print the
+result of such an operation to the standard output, so that it can
+either written to a file or further processed.
+
+This manual page was written for the Debian distribution because the
+original program does not have a manual page.
+.SH OPTIONS
+.TP
+.B \-h, \-\-help
+Show summary of options.
+.br
+.SH AUTHOR
+This manual page was written by TSUCHIYA Masatoshi <tsuchiya@namazu.org>,
+for the Debian project (but may be used by others).
--- juman-5.1.orig/debian/juman.docs
+++ juman-5.1/debian/juman.docs
@@ -0,0 +1,3 @@
+build-tree/*/doc/manual.pdf
+build-tree/*/doc/manual.tex
+debian/juman-server
--- juman-5.1.orig/debian/juman.files
+++ juman-5.1/debian/juman.files
@@ -0,0 +1,3 @@
+etc/jumanrc
+usr/bin/*
+usr/lib/juman/*
--- juman-5.1.orig/debian/juman.manpages
+++ juman-5.1/debian/juman.manpages
@@ -0,0 +1 @@
+debian/juman.1
--- juman-5.1.orig/debian/juman.preinst
+++ juman-5.1/debian/juman.preinst
@@ -0,0 +1,35 @@
+#!/bin/sh
+# preinst script for juman
+#
+# see: dh_installdeb(1)
+
+set -e
+umask 022
+
+case "$1" in
+    upgrade|install)
+	# Does not start Juman server.
+	if ( dpkg --compare-versions "$2" lt "4.0-7" ); then
+	    if [ -f /etc/init.d/juman ]; then
+		rm -f /etc/init.d/juman
+	    fi
+	    update-rc.d -f juman remove
+	fi
+	if [ -f /etc/juman_server_to_be_run ]; then
+	    rm -f /etc/juman_server_to_be_run 2>/dev/null
+	fi
+	;;
+    abort-upgrade)
+	;;
+    *)
+        echo "preinst called with unknown argument \`$1'" >&2
+        exit 0
+	;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
--- juman-5.1.orig/debian/libjuman-dev.files
+++ juman-5.1/debian/libjuman-dev.files
@@ -0,0 +1,4 @@
+usr/include/*
+usr/lib/libjuman.a
+usr/lib/libjuman.la
+usr/lib/libjuman.so
--- juman-5.1.orig/debian/libjuman4.files
+++ juman-5.1/debian/libjuman4.files
@@ -0,0 +1 @@
+usr/lib/libjuman.so.*
--- juman-5.1.orig/debian/rules
+++ juman-5.1/debian/rules
@@ -0,0 +1,33 @@
+#!/usr/bin/make -f
+
+DEB_TAR_SRCDIR := juman-5.1
+
+binary/juman:: binary/libjuman4
+	dh_shlibdeps -p$(cdbs_curpkg) -l debian/libjuman4/usr/lib
+
+include /usr/share/cdbs/1/rules/debhelper.mk
+include /usr/share/cdbs/1/class/autotools.mk
+include /usr/share/cdbs/1/rules/simple-patchsys.mk
+include /usr/share/cdbs/1/rules/tarball.mk
+
+DEB_CONFIGURE_LIBEXECDIR := /usr/lib
+DEB_CONFIGURE_EXTRA_FLAGS := --datadir=/usr/lib
+
+install/juman::
+	dh_movefiles -p$(cdbs_curpkg)
+	rm -rf debian/juman/usr/lib/juman/doc
+
+DICDIR := debian/juman-dic/usr/share/juman/dic/
+install/juman-dic::
+	cp -p build-tree/$(DEB_TAR_SRCDIR)/dic/*.dic $(DICDIR)
+	for f in $(DICDIR)/* ; do \
+	  dh_link -pjuman-dic \
+		`echo $$f|sed s,debian/juman-dic/,,` \
+		`echo $$f|sed s,debian/juman-dic/usr/share/,usr/lib/,` ;\
+	done
+
+install/libjuman4::
+	dh_movefiles -p$(cdbs_curpkg)
+
+install/libjuman-dev::
+	dh_movefiles -p$(cdbs_curpkg)
