[Dict-common-dev] myspell support

Rafael Laboissiere Rafael Laboissiere <laboissiere@psy.mpg.de>
Fri, 17 Oct 2003 23:17:46 +0200


--PuGuTyElPB9bOcsM
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

* Agustin Martin Domingo <agmartin@aq.upm.es> [2003-10-17 21:49]:

> Done. Note that currently they will not be installed. You will need to 
> uncomment four lines in Makefile.in for that.

Thanks, installdeb-myspell seems to work correctly for my br.ispell source
package.

You will find below a patch to this script that parses the info file to
extract the last token and assumes that it is the language code.  It
installs then the <language>.aff and <language>.dic files in
/usr/share/myspell/dicts and create the necessary symlinks (if the language
code has an underscore in it).  After running the modified script, this is
what I get:

$ ls -l debian/myspell-pt-br/usr/share/myspell/dicts 
total 608
-rw-r--r--    1 rafael   rafael      32421 2003-10-17 23:04 pt_BR.aff
lrwxrwxrwx    1 rafael   rafael          9 2003-10-17 23:04 pt-BR.aff -> pt_BR.aff
-rw-r--r--    1 rafael   rafael     582642 2003-10-17 23:04 pt_BR.dic
lrwxrwxrwx    1 rafael   rafael          9 2003-10-17 23:04 pt-BR.dic -> pt_BR.dic

I made the assumption that the upstream aff and dic files are located at the
top dir.  We might introduce an option to allow overrideing of the location
of the files in the build tree.

Also, my code is too strict and dies if the files do not exist.  This may be
changed to a warning.

Finally, I did not add any documentation to the POD section (too lazy...)

What do you think?

-- 
Rafael

--PuGuTyElPB9bOcsM
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="installdeb-myspell.patch"

--- installdeb-myspell	2003-10-17 22:35:14.000000000 +0200
+++ installdeb-myspell-new	2003-10-17 23:07:35.000000000 +0200
@@ -10,6 +10,7 @@
 
 my $class = "myspell";
 my $oooinfodir="/usr/share/myspell/infos/ooo";
+my $dictdir = "/usr/share/myspell/dicts";
 
 sub mydie {
     my $msg = shift;
@@ -37,6 +38,27 @@
     my $lib_dir = tmpdir ($package) . $oooinfodir;
     doit ("install", "-d", $lib_dir);
     doit ("install", "-m644", $infofile, "$lib_dir/$package");  
+    
+    # Get language name from info file
+    my $language = (reverse (split (/\s+/, `cat $infofile`)))[0];
+    
+    # Install .aff and .dic in dicts dir, as well all the symlinks if 
+    # the language name contains an underscore
+    $lib_dir = tmpdir ($package) . $dictdir;
+    doit ("install", "-d", $lib_dir);
+    
+    for my $ext ("aff", "dic") {
+	my $file = "$language.$ext";
+	mydie ("There is no $file file here")
+            if not -f $file;
+	doit ("install", "-m644", $file, $lib_dir);
+	if ($file =~ /_/) {
+	    my $link = $file;
+	    $link =~ tr/_/-/;
+	    doit ("ln", "-s", $file, "$lib_dir/$link");
+	}
+    }
+
 }
 
 __END__

--PuGuTyElPB9bOcsM--