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.diff -r1.120 -r1.121 pkgsrc/pkgtools/url2pkg/Makefile
(rillig)
@@ -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 | |||
3 | PKGNAME= url2pkg-21.1.0 | 3 | PKGNAME= url2pkg-21.3.0 | |
4 | PKGREVISION= 1 | |||
5 | CATEGORIES= pkgtools | 4 | CATEGORIES= pkgtools | |
6 | 5 | |||
7 | MAINTAINER= rillig@NetBSD.org | 6 | MAINTAINER= rillig@NetBSD.org | |
8 | HOMEPAGE= https://www.NetBSD.org/docs/pkgsrc/creating.html | 7 | HOMEPAGE= https://www.NetBSD.org/docs/pkgsrc/creating.html | |
9 | COMMENT= Tool to automate initial steps in building a package | 8 | COMMENT= Tool to automate initial steps in building a package | |
10 | LICENSE= 2-clause-bsd | 9 | LICENSE= 2-clause-bsd | |
11 | 10 | |||
12 | WRKSRC= ${WRKDIR} | 11 | WRKSRC= ${WRKDIR} | |
13 | NO_CHECKSUM= yes | 12 | NO_CHECKSUM= yes | |
14 | NO_BUILD= yes | 13 | NO_BUILD= yes | |
15 | USE_LANGUAGES= # none | 14 | USE_LANGUAGES= # none | |
16 | USE_TOOLS+= perl:run | 15 | USE_TOOLS+= perl:run | |
17 | AUTO_MKDIRS= yes | 16 | AUTO_MKDIRS= yes |
@@ -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 |
@@ -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 | |||
3 | import pytest | 3 | import pytest | |
4 | from url2pkg import * | 4 | from url2pkg import * | |
5 | from textwrap import dedent | 5 | from textwrap import dedent | |
6 | 6 | |||
7 | mkcvsid = '# $''NetBSD$' | 7 | mkcvsid = '# $''NetBSD$' | |
8 | g: Globals | 8 | g: Globals | |
9 | prev_dir = Path.cwd() | 9 | prev_dir = Path.cwd() | |
10 | 10 | |||
11 | 11 | |||
12 | def setup_function(_): | 12 | def 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} | |||
463 | def test_Generator_adjust_site_GitHub_archive__tag_v(): | 459 | def 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 | |||
488 | def test_Generator_adjust_site_GitHub_release__containing_project_name(): | 481 | def 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' |