[Dict-common-dev] debhelper-like scripts for myspell support

Rafael Laboissiere Rafael Laboissiere <rafael@debian.org>
Mon, 20 Oct 2003 12:32:22 +0200


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

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

> You are right, looking at dh_installinit I had the hope that new options 
> could be added there, but I was clearly wrong. May be you can hijack the 
> --sourcedir option. Seems that it is not a debhelper global option, and 
> I see no other possible use for it in installdeb-myspell.

Look at the patch attached below.  It addresses the issues discussed: (1)
Installation of aff and dic files is not done by default, but only if the
--srcdir is specified.  (2) The symlinks are created by default. (3) The
--srcdir flag is hijacked from @ARGV before init() is called.  debhelper's
parseopt will never see this option.  

If you prefer another name for the flag (like --sourcedir), change the
variable $srcdir_flag at the top of the script.

The POD section is not yet updated.

-- 
Rafael

--OROCMA9jn6tkzFBc
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-20 12:30:53.000000000 +0200
@@ -6,10 +6,22 @@
 $Text::Wrap::columns = 72;
 
 use Debian::Debhelper::Dh_Lib;
+
+my $srcdir_flag = "srcdir";
+
+# Hijacks the --${srcdir_flag} option from the command line, before 
+# debhelper's parseopt can see it. 
+my $srcdir = (reverse (grep {/^--$srcdir_flag=/} @ARGV))[0];
+if (defined $srcdir) {
+    $srcdir =~ s/--$srcdir_flag=//;
+    @ARGV = grep {!/^--$srcdir_flag=/} @ARGV;
+}
+
 init();
 
 my $class = "myspell";
 my $oooinfodir="/usr/share/myspell/infos/ooo";
+my $dictdir = "/usr/share/myspell/dicts";
 
 sub mydie {
     my $msg = shift;
@@ -37,6 +49,28 @@
     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", "$srcdir/$file", $lib_dir)
+	    if defined $srcdir;
+	if ($file =~ /_/) {
+	    my $link = $file;
+	    $link =~ tr/_/-/;
+	    doit ("ln", "-fs", $file, "$lib_dir/$link");
+	}
+    }
+
 }
 
 __END__

--OROCMA9jn6tkzFBc--