pkgsrc-Changes archive

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

CVS commit: pkgsrc/pkgtools/url2pkg/files



Module Name:    pkgsrc
Committed By:   rillig
Date:           Sun Feb  6 21:07:44 UTC 2022

Modified Files:
        pkgsrc/pkgtools/url2pkg/files: url2pkg.py url2pkg_test.py

Log Message:
url2pkg: add support for metacpan.org URLs


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 pkgsrc/pkgtools/url2pkg/files/url2pkg.py
cvs rdiff -u -r1.39 -r1.40 pkgsrc/pkgtools/url2pkg/files/url2pkg_test.py

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/pkgtools/url2pkg/files/url2pkg.py
diff -u pkgsrc/pkgtools/url2pkg/files/url2pkg.py:1.40 pkgsrc/pkgtools/url2pkg/files/url2pkg.py:1.41
--- pkgsrc/pkgtools/url2pkg/files/url2pkg.py:1.40       Sun Feb  6 20:08:49 2022
+++ pkgsrc/pkgtools/url2pkg/files/url2pkg.py    Sun Feb  6 21:07:44 2022
@@ -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 @@ class PackageVars:
         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 @@ class PackageVars:
             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 @@ class PackageVars:
             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]
 

Index: pkgsrc/pkgtools/url2pkg/files/url2pkg_test.py
diff -u pkgsrc/pkgtools/url2pkg/files/url2pkg_test.py:1.39 pkgsrc/pkgtools/url2pkg/files/url2pkg_test.py:1.40
--- pkgsrc/pkgtools/url2pkg/files/url2pkg_test.py:1.39  Sun Feb  6 20:08:49 2022
+++ pkgsrc/pkgtools/url2pkg/files/url2pkg_test.py       Sun Feb  6 21:07:44 2022
@@ -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 @@ def test_PackageVars_adjust_site_from_si
         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