Sun Nov 14 09:20:15 2021 UTC ()
pkgtools/url2pkg: update to 21.3.0

Changes since 21.1.0:

When creating a package from a GitHub archive URL, make the generated
package simpler and place the distfile in the main directory instead of
using DIST_SUBDIR.


(rillig)
diff -r1.120 -r1.121 pkgsrc/pkgtools/url2pkg/Makefile
diff -r1.32 -r1.33 pkgsrc/pkgtools/url2pkg/files/url2pkg.py
diff -r1.32 -r1.33 pkgsrc/pkgtools/url2pkg/files/url2pkg_test.py

cvs diff -r1.120 -r1.121 pkgsrc/pkgtools/url2pkg/Makefile (expand / switch to unified diff)

--- pkgsrc/pkgtools/url2pkg/Makefile 2021/11/14 08:57:15 1.120
+++ pkgsrc/pkgtools/url2pkg/Makefile 2021/11/14 09:20:15 1.121
@@ -1,17 +1,16 @@ @@ -1,17 +1,16 @@
1# $NetBSD: Makefile,v 1.120 2021/11/14 08:57:15 rillig Exp $ 1# $NetBSD: Makefile,v 1.121 2021/11/14 09:20:15 rillig Exp $
2 2
3PKGNAME= url2pkg-21.1.0 3PKGNAME= url2pkg-21.3.0
4PKGREVISION= 1 
5CATEGORIES= pkgtools 4CATEGORIES= pkgtools
6 5
7MAINTAINER= rillig@NetBSD.org 6MAINTAINER= rillig@NetBSD.org
8HOMEPAGE= https://www.NetBSD.org/docs/pkgsrc/creating.html 7HOMEPAGE= https://www.NetBSD.org/docs/pkgsrc/creating.html
9COMMENT= Tool to automate initial steps in building a package 8COMMENT= Tool to automate initial steps in building a package
10LICENSE= 2-clause-bsd 9LICENSE= 2-clause-bsd
11 10
12WRKSRC= ${WRKDIR} 11WRKSRC= ${WRKDIR}
13NO_CHECKSUM= yes 12NO_CHECKSUM= yes
14NO_BUILD= yes 13NO_BUILD= yes
15USE_LANGUAGES= # none 14USE_LANGUAGES= # none
16USE_TOOLS+= perl:run 15USE_TOOLS+= perl:run
17AUTO_MKDIRS= yes 16AUTO_MKDIRS= yes

cvs diff -r1.32 -r1.33 pkgsrc/pkgtools/url2pkg/files/url2pkg.py (expand / switch to unified diff)

--- pkgsrc/pkgtools/url2pkg/files/url2pkg.py 2021/05/25 17:56:24 1.32
+++ pkgsrc/pkgtools/url2pkg/files/url2pkg.py 2021/11/14 09:20:15 1.33
@@ -1,15 +1,15 @@ @@ -1,15 +1,15 @@
1#! @PYTHONBIN@ 1#! @PYTHONBIN@
2# $NetBSD: url2pkg.py,v 1.32 2021/05/25 17:56:24 rillig Exp $ 2# $NetBSD: url2pkg.py,v 1.33 2021/11/14 09:20:15 rillig Exp $
3 3
4# Copyright (c) 2019 The NetBSD Foundation, Inc. 4# Copyright (c) 2019 The NetBSD Foundation, Inc.
5# All rights reserved. 5# All rights reserved.
6# 6#
7# This code is derived from software contributed to The NetBSD Foundation 7# This code is derived from software contributed to The NetBSD Foundation
8# by Roland Illig. 8# by Roland Illig.
9# 9#
10# Redistribution and use in source and binary forms, with or without 10# Redistribution and use in source and binary forms, with or without
11# modification, are permitted provided that the following conditions 11# modification, are permitted provided that the following conditions
12# are met: 12# are met:
13# 1. Redistributions of source code must retain the above copyright 13# 1. Redistributions of source code must retain the above copyright
14# notice, this list of conditions and the following disclaimer. 14# notice, this list of conditions and the following disclaimer.
15# 2. Redistributions in binary form must reproduce the above copyright 15# 2. Redistributions in binary form must reproduce the above copyright
@@ -421,30 +421,38 @@ class Generator: @@ -421,30 +421,38 @@ class Generator:
421 (.+)/ # org 421 (.+)/ # org
422 (.+)/archive/ # proj 422 (.+)/archive/ # proj
423 ((?:.+/)? # tag 423 ((?:.+/)? # tag
424 (.+)) # distname 424 (.+)) # distname
425 (\.tar\.gz|\.zip) # ext 425 (\.tar\.gz|\.zip) # ext
426 $ 426 $
427 ''' 427 '''
428 m = re.search(pattern, self.url) 428 m = re.search(pattern, self.url)
429 if not m: 429 if not m:
430 return 430 return
431 431
432 org, proj, tag, distname, ext = m.groups() 432 org, proj, tag, distname, ext = m.groups()
433 433
434 self.github_project = proj 
435 self.github_tag = tag 
436 self.master_sites = f'${{MASTER_SITE_GITHUB:={org}/}}' 434 self.master_sites = f'${{MASTER_SITE_GITHUB:={org}/}}'
437 self.homepage = f'https://github.com/{org}/{proj}/' 435 self.homepage = f'https://github.com/{org}/{proj}/'
 436
 437 m = re.search(r'^refs/tags/v(\d[\d.]*)$', tag)
 438 if m:
 439 version = m.group(1)
 440 self.distfile = f'{proj}-{version}{ext}'
 441 self.github_tag = f'refs/tags/v${{PKGVERSION_NOREV}}'
 442 return
 443
 444 self.github_project = proj
 445 self.github_tag = tag
438 if proj not in tag: 446 if proj not in tag:
439 self.pkgname_prefix = '${GITHUB_PROJECT}-' 447 self.pkgname_prefix = '${GITHUB_PROJECT}-'
440 self.dist_subdir = '${GITHUB_PROJECT}' 448 self.dist_subdir = '${GITHUB_PROJECT}'
441 self.distfile = distname + ext 449 self.distfile = distname + ext
442 450
443 def adjust_site_GitHub_release(self): 451 def adjust_site_GitHub_release(self):
444 pattern = r'''(?x) 452 pattern = r'''(?x)
445 ^https://github\.com/ 453 ^https://github\.com/
446 (.+)/ # org 454 (.+)/ # org
447 (.+)/ # proj 455 (.+)/ # proj
448 releases/download/ 456 releases/download/
449 (.+)/ # tag 457 (.+)/ # tag
450 (.+) # base 458 (.+) # base

cvs diff -r1.32 -r1.33 pkgsrc/pkgtools/url2pkg/files/url2pkg_test.py (expand / switch to unified diff)

--- pkgsrc/pkgtools/url2pkg/files/url2pkg_test.py 2021/11/14 08:57:15 1.32
+++ pkgsrc/pkgtools/url2pkg/files/url2pkg_test.py 2021/11/14 09:20:15 1.33
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: url2pkg_test.py,v 1.32 2021/11/14 08:57:15 rillig Exp $ 1# $NetBSD: url2pkg_test.py,v 1.33 2021/11/14 09:20:15 rillig Exp $
2 2
3import pytest 3import pytest
4from url2pkg import * 4from url2pkg import *
5from textwrap import dedent 5from textwrap import dedent
6 6
7mkcvsid = '# $''NetBSD$' 7mkcvsid = '# $''NetBSD$'
8g: Globals 8g: Globals
9prev_dir = Path.cwd() 9prev_dir = Path.cwd()
10 10
11 11
12def setup_function(_): 12def setup_function(_):
13 global g 13 global g
14 14
@@ -446,44 +446,37 @@ def test_Generator_adjust_site_GitHub_ar @@ -446,44 +446,37 @@ def test_Generator_adjust_site_GitHub_ar
446 'MASTER_SITES= ${MASTER_SITE_GITHUB:=org/}', 446 'MASTER_SITES= ${MASTER_SITE_GITHUB:=org/}',
447 'DIST_SUBDIR= ${GITHUB_PROJECT}', 447 'DIST_SUBDIR= ${GITHUB_PROJECT}',
448 '', 448 '',
449 'MAINTAINER= INSERT_YOUR_MAIL_ADDRESS_HERE # or use pkgsrc-users@NetBSD.org', 449 'MAINTAINER= INSERT_YOUR_MAIL_ADDRESS_HERE # or use pkgsrc-users@NetBSD.org',
450 'HOMEPAGE= https://github.com/org/proj/', 450 'HOMEPAGE= https://github.com/org/proj/',
451 'COMMENT= TODO: Short description of the package', 451 'COMMENT= TODO: Short description of the package',
452 '#LICENSE= # TODO: (see mk/license.mk)', 452 '#LICENSE= # TODO: (see mk/license.mk)',
453 '', 453 '',
454 '# url2pkg-marker (please do not remove this line.)', 454 '# url2pkg-marker (please do not remove this line.)',
455 ".include \"../../mk/bsd.pkg.mk\"", 455 ".include \"../../mk/bsd.pkg.mk\"",
456 ] 456 ]
457 457
458 458
459# TODO: There is a simpler package definition for this scenario, see 
460# wip/netmask. That package only defines: 
461# DISTNAME=proj-version 
462# GITHUB_TAG=v${PKGVERSION_NOREV} 
463def test_Generator_adjust_site_GitHub_archive__tag_v(): 459def test_Generator_adjust_site_GitHub_archive__tag_v():
464 url = 'https://github.com/org/proj/archive/refs/tags/v1.0.0.tar.gz' 460 url = 'https://github.com/org/proj/archive/refs/tags/v1.0.0.tar.gz'
465 461
466 lines = Generator(url).generate_Makefile() 462 lines = Generator(url).generate_Makefile()
467 assert detab(lines) == [ 463 assert detab(lines) == [
468 mkcvsid, 464 mkcvsid,
469 '', 465 '',
470 'GITHUB_PROJECT= proj', 466 'GITHUB_TAG= refs/tags/v${PKGVERSION_NOREV}',
471 'GITHUB_TAG= refs/tags/v1.0.0', 467 'DISTNAME= proj-1.0.0',
472 'DISTNAME= v1.0.0', 
473 'PKGNAME= ${GITHUB_PROJECT}-${DISTNAME:S,^v,,}', 
474 'CATEGORIES= pkgtools', 468 'CATEGORIES= pkgtools',
475 'MASTER_SITES= ${MASTER_SITE_GITHUB:=org/}', 469 'MASTER_SITES= ${MASTER_SITE_GITHUB:=org/}',
476 'DIST_SUBDIR= ${GITHUB_PROJECT}', 
477 '', 470 '',
478 'MAINTAINER= INSERT_YOUR_MAIL_ADDRESS_HERE # or use pkgsrc-users@NetBSD.org', 471 'MAINTAINER= INSERT_YOUR_MAIL_ADDRESS_HERE # or use pkgsrc-users@NetBSD.org',
479 'HOMEPAGE= https://github.com/org/proj/', 472 'HOMEPAGE= https://github.com/org/proj/',
480 'COMMENT= TODO: Short description of the package', 473 'COMMENT= TODO: Short description of the package',
481 '#LICENSE= # TODO: (see mk/license.mk)', 474 '#LICENSE= # TODO: (see mk/license.mk)',
482 '', 475 '',
483 '# url2pkg-marker (please do not remove this line.)', 476 '# url2pkg-marker (please do not remove this line.)',
484 ".include \"../../mk/bsd.pkg.mk\"", 477 ".include \"../../mk/bsd.pkg.mk\"",
485 ] 478 ]
486 479
487 480
488def test_Generator_adjust_site_GitHub_release__containing_project_name(): 481def test_Generator_adjust_site_GitHub_release__containing_project_name():
489 url = 'https://github.com/org/proj/releases/download/1.0.0/proj.zip' 482 url = 'https://github.com/org/proj/releases/download/1.0.0/proj.zip'