Discussion:
pkg/49032: Package submission to add textproc/p5-Text-Hunspell to pkgsrc
d***@sympatico.ca
2014-07-25 03:35:00 UTC
Permalink
Number: 49032
Category: pkg
Synopsis: Package submission to add textproc/p5-Text-Hunspell to pkgsrc
Confidential: no
Severity: non-critical
Priority: medium
Responsible: pkg-manager
State: open
Class: change-request
Submitter-Id: net
Arrival-Date: Fri Jul 25 03:35:00 +0000 2014
Originator: David H. Gutteridge
Release: n/a
n/a
I've been using the CPAN package Text::Hunspell to do morphological
analysis of texts, and thought I'd tidy up my work and send it in, in
case someone else will find this of use. (What does Hunspell offer
that other spellers don't? Well, for one thing, word stemming in
English, and for another, more sophisticated facilities in languages
with better support, e.g. in French it'll identify genders of words,
and whether they're singular or plural, etc.)

The only quirk to deal with in packaging this is that pkgsrc doesn't
install an un-versioned symlink for libhunspell (unlike most other
libraries), so the input to MakeMaker has to be adjusted accordingly.
Assuming the hunspell package omits that symlink by design, I'm using
the Perl interface to Pkgconfig to get a usable name to link against,
as that seemed like the safest means.
(Look for this package and find it doesn't exist.)
DESCR:

This module provides a Perl interface to the OO Hunspell library.

# $NetBSD: Makefile Exp $

DISTNAME= Text-Hunspell-2.08
PKGNAME= p5-${DISTNAME}
CATEGORIES= textproc perl5
MASTER_SITES= ${MASTER_SITE_PERL_CPAN:=Text/}

MAINTAINER= pkgsrc-***@NetBSD.org
HOMEPAGE= http://search.cpan.org/dist/Text-Hunspell
COMMENT= Perl module to interface with GNU Hunspell
LICENSE= ${PERL5_LICENSE}

USE_LANGUAGES= c c++

PERL5_PACKLIST= auto/Text/Hunspell/.packlist

BUILD_DEPENDS+= p5-ExtUtils-PkgConfig:../../devel/p5-ExtUtils-PkgConfig

.include "../../lang/perl5/module.mk"
.include "../../textproc/hunspell/buildlink3.mk"
.include "../../mk/bsd.pkg.mk"

distinfo:

$NetBSD$

SHA1 (Text-Hunspell-2.08.tar.gz) = b83220400d473e7c5fce77d07d1df2a6ddea03f0
RMD160 (Text-Hunspell-2.08.tar.gz) = 065b863d2d5ea4a3ad0167d60ce29c0b9de5b24c
Size (Text-Hunspell-2.08.tar.gz) = 23590 bytes
SHA1 (patch-Makefile.PL) = 9d91c4c9b86b08d7dddf7463a9805f6a58963ccc

patch-Makefile.PL:

$NetBSD: patch-Makefile.PL Exp $

The check to see if libhunspell is installed is redundant, since it's
an explicit dependency that pkgsrc must provide. There's no unversioned
libhunspell link installed by pkgsrc, so we must substitute a link with
the major/minor suffix.

--- Makefile.PL.orig 2013-03-26 15:52:12.000000000 -0400
+++ Makefile.PL 2014-07-24 21:37:09.000000000 -0400
@@ -1,6 +1,6 @@
-use lib qw(inc);
-use Config;
-use Devel::CheckLib;
+#use lib qw(inc);
+#use Config;
+#use Devel::CheckLib;

#
# Try to warn the user if linking might fail.
@@ -8,44 +8,45 @@
#
# Probably too platform specific, but seemed an acceptable compromise.
#
-my $dlext = $Config{dlext} || 'so';
-my $candidate_lib;
-for (split " " => $Config{libpth}) {
- my $lib_path = "$_/libhunspell.$dlext";
- #warn "Checking $lib_path\n";
- if (-e $lib_path) {
- $candidate_lib++;
- warn "Found '$lib_path'. Good.\n";
- }
-}
-
-if (0 == $candidate_lib) {
- my $def_lib = "/usr/lib/libhunspell";
- my ($possible_candidate) = glob("$def_lib-*.so");
- $possible_candidate ||= "/usr/lib/libhunspell-<ver>.so";
- warn "---------------------------------------------------------------------\n";
- warn "Your system doesn't appear to have a libhunspell.$dlext link.\n";
- warn "Linking might fail. If it does, you might want to try installing\n";
- warn "the libhunspell-dev package (or the equivalent on your OS) or try:\n";
- warn "\n";
- warn " $Config{lns} $possible_candidate $def_lib.so\n";
- warn "---------------------------------------------------------------------\n";
- warn "\n";
-}
-
-check_lib_or_exit(
- lib => 'hunspell',
- header => 'hunspell/hunspell.h',
-);
+#my $dlext = $Config{dlext} || 'so';
+#my $candidate_lib;
+#for (split " " => $Config{libpth}) {
+# my $lib_path = "$_/libhunspell.$dlext";
+# #warn "Checking $lib_path\n";
+# if (-e $lib_path) {
+# $candidate_lib++;
+# warn "Found '$lib_path'. Good.\n";
+# }
+#}
+#
+#if (0 == $candidate_lib) {
+# my $def_lib = "/usr/lib/libhunspell";
+# my ($possible_candidate) = glob("$def_lib-*.so");
+# $possible_candidate ||= "/usr/lib/libhunspell-<ver>.so";
+# warn "---------------------------------------------------------------------\n";
+# warn "Your system doesn't appear to have a libhunspell.$dlext link.\n";
+# warn "Linking might fail. If it does, you might want to try installing\n";
+# warn "the libhunspell-dev package (or the equivalent on your OS) or try:\n";
+# warn "\n";
+# warn " $Config{lns} $possible_candidate $def_lib.so\n";
+# warn "---------------------------------------------------------------------\n";
+# warn "\n";
+#}
+#
+#check_lib_or_exit(
+# lib => 'hunspell',
+# header => 'hunspell/hunspell.h',
+#);

use ExtUtils::MakeMaker;
+use ExtUtils::PkgConfig;

my $CC = $ENV{"CXX"} || 'g++';

WriteMakefile(
NAME => 'Text::Hunspell',
VERSION_FROM => 'Hunspell.pm',
- LIBS => ['-lhunspell'],
+ LIBS => [ExtUtils::PkgConfig->libs_only_l('hunspell')],
CC => $CC,
LD => '$(CC)',
PREREQ_PM => {}, # e.g., Module::Name => 1.1
David H. Gutteridge
2014-10-17 04:10:09 UTC
Permalink
The following reply was made to PR pkg/49032; it has been noted by GNATS.

From: "David H. Gutteridge" <***@sympatico.ca>
To: gnats-***@NetBSD.org
Cc:
Subject: Re: pkg/49032: Package submission to add textproc/p5-Text-Hunspell to pkgsrc
Date: Thu, 16 Oct 2014 23:05:01 -0400

Following up on this, I've answered one of my questions. The hunspell
distribution expects pkgconfig will be used, in line with my patch to
Makefile.PL. The original patch I was using could be improved a bit
in terms of error handling, so I did so.

This has been reported upstream as cpan.org bug #99548, as noted in
the patch file.

Revised files:

distinfo:

$NetBSD$

SHA1 (Text-Hunspell-2.08.tar.gz) =3D =
b83220400d473e7c5fce77d07d1df2a6ddea03f0
RMD160 (Text-Hunspell-2.08.tar.gz) =3D =
065b863d2d5ea4a3ad0167d60ce29c0b9de5b24c
Size (Text-Hunspell-2.08.tar.gz) =3D 23590 bytes
SHA1 (patch-Makefile.PL) =3D ca0a4537935b7d333d0be2099be20ee1bd4b4aa8

patch-Makefile.PL:

$NetBSD: patch-Makefile.PL Exp $

The check to see if libhunspell is installed is redundant, since it's
an explicit dependency that pkgsrc must provide. There's no unversioned
libhunspell link installed by pkgsrc, so we must substitute a link with
the major/minor suffix, which we find using ExtUtils::PkgConfig.

This has been reported upstream as cpan.org bug #99548.

--- Makefile.PL.orig 2013-03-26 15:52:12.000000000 -0400
+++ Makefile.PL 2014-10-16 22:18:56.000000000 -0400
@@ -1,6 +1,6 @@
-use lib qw(inc);
-use Config;
-use Devel::CheckLib;
+#use lib qw(inc);
+#use Config;
+#use Devel::CheckLib;
=20
#
# Try to warn the user if linking might fail.
@@ -8,53 +8,66 @@
#
# Probably too platform specific, but seemed an acceptable compromise.
#
-my $dlext =3D $Config{dlext} || 'so';
-my $candidate_lib;
-for (split " " =3D> $Config{libpth}) {
- my $lib_path =3D "$_/libhunspell.$dlext";
- #warn "Checking $lib_path\n";
- if (-e $lib_path) {
- $candidate_lib++;
- warn "Found '$lib_path'. Good.\n";
- }
-}
-
-if (0 =3D=3D $candidate_lib) {
- my $def_lib =3D "/usr/lib/libhunspell";
- my ($possible_candidate) =3D glob("$def_lib-*.so");
- $possible_candidate ||=3D "/usr/lib/libhunspell-<ver>.so";
- warn =
"---------------------------------------------------------------------\n";=

- warn "Your system doesn't appear to have a libhunspell.$dlext =
link.\n";
- warn "Linking might fail. If it does, you might want to try =
installing\n";
- warn "the libhunspell-dev package (or the equivalent on your OS) or =
try:\n";
- warn "\n";
- warn " $Config{lns} $possible_candidate $def_lib.so\n";
- warn =
"---------------------------------------------------------------------\n";=

- warn "\n";
-}
-
-check_lib_or_exit(
- lib =3D> 'hunspell',
- header =3D> 'hunspell/hunspell.h',
-);
+#my $dlext =3D $Config{dlext} || 'so';
+#my $candidate_lib;
+#for (split " " =3D> $Config{libpth}) {
+# my $lib_path =3D "$_/libhunspell.$dlext";
+# #warn "Checking $lib_path\n";
+# if (-e $lib_path) {
+# $candidate_lib++;
+# warn "Found '$lib_path'. Good.\n";
+# }
+#}
+#
+#if (0 =3D=3D $candidate_lib) {
+# my $def_lib =3D "/usr/lib/libhunspell";
+# my ($possible_candidate) =3D glob("$def_lib-*.so");
+# $possible_candidate ||=3D "/usr/lib/libhunspell-<ver>.so";
+# warn =
"---------------------------------------------------------------------\n";=

+# warn "Your system doesn't appear to have a libhunspell.$dlext =
link.\n";
+# warn "Linking might fail. If it does, you might want to try =
installing\n";
+# warn "the libhunspell-dev package (or the equivalent on your OS) =
or try:\n";
+# warn "\n";
+# warn " $Config{lns} $possible_candidate $def_lib.so\n";
+# warn =
"---------------------------------------------------------------------\n";=

+# warn "\n";
+#}
+#
+#check_lib_or_exit(
+# lib =3D> 'hunspell',
+# header =3D> 'hunspell/hunspell.h',
+#);
=20
use ExtUtils::MakeMaker;
+use ExtUtils::PkgConfig;
=20
my $CC =3D $ENV{"CXX"} || 'g++';
=20
-WriteMakefile(
- NAME =3D> 'Text::Hunspell',
- VERSION_FROM =3D> 'Hunspell.pm',
- LIBS =3D> ['-lhunspell'],
- CC =3D> $CC,
- LD =3D> '$(CC)',
- PREREQ_PM =3D> {}, # e.g., Module::Name =3D> 1.1
- XSOPT =3D> '-C++',
- TYPEMAPS =3D> ['perlobject.map', 'typemap'],
- META_MERGE =3D> {
- resources =3D> {
- repository =3D> =
'https://github.com/cosimo/perl5-text-hunspell',
- },
- keywords =3D> [ qw(hunspell spelling spell-checker =
text-processing) ],
- },
-);
+my $shlib_location =3D ExtUtils::PkgConfig->libs_only_l('hunspell');
+my $header_location =3D ExtUtils::PkgConfig->cflags_only_I('hunspell');
+
+if ($shlib_location ne '' && $header_location ne '') {
+ WriteMakefile(
+ NAME =3D> 'Text::Hunspell',
+ VERSION_FROM =3D> 'Hunspell.pm',
+ LIBS =3D> [$shlib_location],
+ CC =3D> $CC,
+ LD =3D> '$(CC)',
+ PREREQ_PM =3D> {}, # e.g., Module::Name =3D> 1.1
+ XSOPT =3D> '-C++',
+ TYPEMAPS =3D> ['perlobject.map', 'typemap'],
+ META_MERGE =3D> {
+ resources =3D> {
+ repository =3D> =
'https://github.com/cosimo/perl5-text-hunspell',
+ },
+ keywords =3D> [ qw(hunspell spelling =
spell-checker text-processing) ],
+ },
+ );
+}
+else {
+ # By default, ExtUtils::PkgConfig provides a verbose warning =
about
+ # being unable to locate the pkgconfig file and such. This adds =
an
+ # additional comment after that output.
+ warn "You may need to install the libhunspell-dev package (or =
the ";
+ warn "equivalent on your OS).\n";
+}

Regards,

Dave

Loading...