pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/pkgtools/url2pkg/files url2pkg: add support for metacp...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/8858c2a72c41
branches:  trunk
changeset: 373127:8858c2a72c41
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sun Feb 06 21:07:44 2022 +0000

description:
url2pkg: add support for metacpan.org URLs

diffstat:

 pkgtools/url2pkg/files/url2pkg.py      |  29 +++++++++++++++++++++++++++--
 pkgtools/url2pkg/files/url2pkg_test.py |  10 ++++------
 2 files changed, 31 insertions(+), 8 deletions(-)

diffs (85 lines):

diff -r f1a1d14c1373 -r 8858c2a72c41 pkgtools/url2pkg/files/url2pkg.py
--- a/pkgtools/url2pkg/files/url2pkg.py Sun Feb 06 20:54:24 2022 +0000
+++ b/pkgtools/url2pkg/files/url2pkg.py Sun Feb 06 21:07:44 2022 +0000
@@ -1,5 +1,5 @@
 #! @PYTHONBIN@
-# $NetBSD: url2pkg.py,v 1.40 2022/02/06 20:08:49 rillig Exp $
+# $NetBSD: url2pkg.py,v 1.41 2022/02/06 21:07:44 rillig Exp $
 
 # Copyright (c) 2019 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -353,6 +353,7 @@
         self.adjust_site_SourceForge()
         self.adjust_site_GitHub_archive()
         self.adjust_site_GitHub_release()
+        self.adjust_site_CPAN()
         self.adjust_site_from_sites_mk(pkgsrcdir)
         self.adjust_site_PyPI()
         self.adjust_site_other()
@@ -401,6 +402,30 @@
             sys.exit('url2pkg: to create R packages, '
                      'use pkgtools/R2pkg instead')
 
+    def adjust_site_CPAN(self):
+        pattern = r'''(?x)
+            ^
+            https://cpan.metacpan.org/authors
+            /id/(?:\w+/)+
+            (\w+-)+         # namespace prefixes
+            (               # distname
+                (\w+)       # project name
+                -v?[0-9].+
+            )
+            $
+            '''
+        m = re.search(pattern, self.url)
+        if not m:
+            return
+
+        prefixes, distfile, name = m.groups()
+        prefixes_slash = prefixes.replace('-', '/')
+        prefixes_colon = prefixes.replace('-', '::')
+        self.master_sites = f'${{MASTER_SITE_PERL_CPAN:={prefixes_slash}}}'
+        self.homepage = f'https://metacpan.org/pod/{prefixes_colon}{name}'
+        self.distfile = f'{prefixes}{distfile}'
+        self.pkgname_prefix = 'p5-'
+
     def adjust_site_SourceForge(self):
         pattern = r'''(?x)
             ^
@@ -551,7 +576,7 @@
             return ''
         if 'MASTER_SITE_PYPI' in self.master_sites:
             return f'py-{m[1]}'
-        if 'MASTER_SITE_CPAN' in self.master_sites:
+        if 'MASTER_SITE_PERL_CPAN' in self.master_sites:
             return f'p5-{m[1]}'
         return m[1]
 
diff -r f1a1d14c1373 -r 8858c2a72c41 pkgtools/url2pkg/files/url2pkg_test.py
--- a/pkgtools/url2pkg/files/url2pkg_test.py    Sun Feb 06 20:54:24 2022 +0000
+++ b/pkgtools/url2pkg/files/url2pkg_test.py    Sun Feb 06 21:07:44 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: url2pkg_test.py,v 1.39 2022/02/06 20:08:49 rillig Exp $
+# $NetBSD: url2pkg_test.py,v 1.40 2022/02/06 21:07:44 rillig Exp $
 
 import pytest
 from url2pkg import *
@@ -587,14 +587,12 @@
         mkcvsid,
         '',
         'DISTNAME=       Algorithm-CheckDigits-v1.3.6',
-        'PKGNAME=        ${DISTNAME:S,-v,-,}',
+        'PKGNAME=        p5-${DISTNAME:S,-v,-,}',
         'CATEGORIES=     pkgtools',
-        # TODO: Use MASTER_SITE_CPAN instead.
-        'MASTER_SITES=   https://cpan.metacpan.org/authors/id/M/MA/MAMAWE/',
+        'MASTER_SITES=   ${MASTER_SITE_PERL_CPAN:=Algorithm/}',
         '',
         'MAINTAINER=     INSERT_YOUR_MAIL_ADDRESS_HERE # or use pkgsrc-users%NetBSD.org@localhost',
-        # TODO: Use https://metacpan.org/dist/Algorithm-CheckDigits instead.
-        'HOMEPAGE=       https://cpan.metacpan.org/authors/id/M/MA/MAMAWE/',
+        'HOMEPAGE=       https://metacpan.org/pod/Algorithm::CheckDigits',
         'COMMENT=        TODO: Short description of the package',
         '#LICENSE=       # TODO: (see mk/license.mk)',
         '',



Home | Main Index | Thread Index | Old Index