pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/pkgtools/url2pkg pkgtools/url2pkg: update to 19.3.1
details: https://anonhg.NetBSD.org/pkgsrc/rev/1c2080f6b7ae
branches: trunk
changeset: 340452:1c2080f6b7ae
user: rillig <rillig%pkgsrc.org@localhost>
date: Thu Oct 03 09:37:40 2019 +0000
description:
pkgtools/url2pkg: update to 19.3.1
Changes since 19.3.0:
* Added an alternative url2pkg implementation in Python that will
eventually replace the Perl implementation. Reasons are:
* Perl is cumbersome to type with all the special characters
* Perl does not even have a Boolean type, after all the years
* Perl cannot check the number of arguments passed to subs
* Python does not suffer from the above limitations
* Python is available on as many platforms as Perl
* The two implementations will be kept in sync until all the features
have made it into the Python implementation, and everything has
automatic tests.
* Added the -v or --verbose command line option.
diffstat:
pkgtools/url2pkg/Makefile | 15 +-
pkgtools/url2pkg/PLIST | 3 +-
pkgtools/url2pkg/files/url2pkg.8 | 7 +-
pkgtools/url2pkg/files/url2pkg.py | 859 +++++++++++++++++++++++++++++++++
pkgtools/url2pkg/files/url2pkg_test.py | 447 +++++++++++++++++
5 files changed, 1321 insertions(+), 10 deletions(-)
diffs (truncated from 1398 to 300 lines):
diff -r 605386cf05c7 -r 1c2080f6b7ae pkgtools/url2pkg/Makefile
--- a/pkgtools/url2pkg/Makefile Thu Oct 03 09:31:36 2019 +0000
+++ b/pkgtools/url2pkg/Makefile Thu Oct 03 09:37:40 2019 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.102 2019/10/01 19:41:23 rillig Exp $
+# $NetBSD: Makefile,v 1.103 2019/10/03 09:37:40 rillig Exp $
-PKGNAME= url2pkg-19.3.0
+PKGNAME= url2pkg-19.3.1
CATEGORIES= pkgtools
MAINTAINER= rillig%NetBSD.org@localhost
@@ -15,24 +15,27 @@
USE_TOOLS+= perl:run
AUTO_MKDIRS= yes
+TEST_DEPENDS+= ${PYPKGPREFIX}-test>=0:../../devel/py-test
+
do-extract:
${RUN} cd ${FILESDIR} && cp *.* ${WRKSRC}/
do-test:
${RUN} cd ${WRKSRC} && env PKGSRCDIR=${PKGSRCDIR} perl -I. url2pkg.t
+ ${RUN} cd ${WRKSRC} && env PKGSRCDIR=${PKGSRCDIR} ${PREFIX}/bin/pytest-${PYVERSSUFFIX}
.include "../../mk/bsd.prefs.mk"
SUBST_CLASSES+= up
SUBST_STAGE.up= do-configure
SUBST_MESSAGE.up= Replacing variable placeholders
-SUBST_FILES.up= url2pkg.pl MakeMaker.pm
-SUBST_VARS.up= MAKE PERL5 PYTHONBIN
-SUBST_SED.up+= -e 's,@LIBDIR@,${PREFIX}/lib/url2pkg,g'
-SUBST_SED.up+= -e 's,@PKGSRCDIR@,${BATCH:D/usr/pkgsrc:U${PKGSRCDIR}},g'
+SUBST_FILES.up= url2pkg.pl MakeMaker.pm url2pkg.py
+SUBST_VARS.up= MAKE PERL5 PKGSRCDIR PYTHONBIN
+SUBST_SED.up= -e 's,@LIBDIR@,${PREFIX}/lib/url2pkg,g'
do-install:
${INSTALL_SCRIPT} ${WRKSRC}/url2pkg.pl ${DESTDIR}${PREFIX}/bin/url2pkg
+ ${INSTALL_SCRIPT} ${WRKSRC}/url2pkg.py ${DESTDIR}${PREFIX}/bin/url2pkg-py
${INSTALL_MAN} ${FILESDIR}/url2pkg.8 ${DESTDIR}${PREFIX}/${PKGMANDIR}/man8
${INSTALL_DATA} ${WRKSRC}/Build.pm ${DESTDIR}${PREFIX}/lib/url2pkg/Module/
${INSTALL_DATA} ${WRKSRC}/MakeMaker.pm ${DESTDIR}${PREFIX}/lib/url2pkg/ExtUtils/
diff -r 605386cf05c7 -r 1c2080f6b7ae pkgtools/url2pkg/PLIST
--- a/pkgtools/url2pkg/PLIST Thu Oct 03 09:31:36 2019 +0000
+++ b/pkgtools/url2pkg/PLIST Thu Oct 03 09:37:40 2019 +0000
@@ -1,5 +1,6 @@
-@comment $NetBSD: PLIST,v 1.5 2019/09/12 18:23:00 rillig Exp $
+@comment $NetBSD: PLIST,v 1.6 2019/10/03 09:37:40 rillig Exp $
bin/url2pkg
+bin/url2pkg-py
lib/url2pkg/ExtUtils/MakeMaker.pm
lib/url2pkg/Module/Build.pm
lib/url2pkg/setuptools.py
diff -r 605386cf05c7 -r 1c2080f6b7ae pkgtools/url2pkg/files/url2pkg.8
--- a/pkgtools/url2pkg/files/url2pkg.8 Thu Oct 03 09:31:36 2019 +0000
+++ b/pkgtools/url2pkg/files/url2pkg.8 Thu Oct 03 09:37:40 2019 +0000
@@ -1,6 +1,6 @@
-.\" $NetBSD: url2pkg.8,v 1.12 2018/08/22 20:48:38 maya Exp $
+.\" $NetBSD: url2pkg.8,v 1.13 2019/10/03 09:37:41 rillig Exp $
.\"
-.\" Copyright (c) 2001 The NetBSD Foundation, Inc.
+.\" Copyright (c) 2001, 2019 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" This code is derived from software contributed to The NetBSD Foundation
@@ -27,7 +27,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd May 29, 2013
+.Dd Oct 3, 2019
.Dt URL2PKG 8
.Os
.Sh NAME
@@ -35,6 +35,7 @@
.Nd Automatic pkgsrc package generator
.Sh SYNOPSIS
.Nm
+.Op Fl v|--verbose
.Op Ar URL
.Sh DESCRIPTION
.Nm
diff -r 605386cf05c7 -r 1c2080f6b7ae pkgtools/url2pkg/files/url2pkg.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/url2pkg/files/url2pkg.py Thu Oct 03 09:37:40 2019 +0000
@@ -0,0 +1,859 @@
+#! @PYTHONBIN@
+# $NetBSD: url2pkg.py,v 1.1 2019/10/03 09:37:41 rillig Exp $
+
+# Copyright (c) 2019 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Roland Illig.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+import getopt
+import glob
+import os
+import re
+import subprocess
+import sys
+from os.path import isfile
+from typing import Callable, Dict, Iterator, List, Optional, Sequence, Union
+
+
+def cvsid(fmt: str) -> str:
+ return fmt % ('$' + 'NetBSD$')
+
+
+class Config:
+
+ def __init__(self):
+ self.make = '@MAKE@'
+ self.libdir = '@LIBDIR@'
+ self.perl5 = '@PERL5@'
+ self.pkgsrcdir = '@PKGSRCDIR@'
+ self.pythonbin = '@PYTHONBIN@'
+ self.verbose = False
+
+
+config = Config()
+distname = ''
+
+
+def debug(fmt: str, *args):
+ if config.verbose:
+ msg = fmt % map(repr, args)
+ sys.stderr.write('url2pkg: %s\n' % msg)
+
+
+def run_editor(fname: str, lineno: int):
+ editor = os.getenv('PKGEDITOR') or os.getenv('EDITOR') or 'vi'
+
+ args: List[str] = [editor]
+ if re.search(editor, r'(^|/)(mcedit|nano|pico|vi|vim)$'):
+ args.append(f'+{lineno}')
+ args.append(fname)
+
+ code = subprocess.check_call(args)
+
+
+def generate_initial_package_Makefile_lines(url):
+ global distname
+
+ master_site = ''
+ master_sites = ''
+ distfile = ''
+ homepage = ''
+ extract_sufx = ''
+ categories = ''
+ github_project = ''
+ github_release = ''
+ dist_subdir = ''
+ pkgname_prefix = ''
+ pkgname_transform = ''
+
+ with open('../../mk/fetch/sites.mk') as sites_mk:
+ for line in sites_mk:
+ m = re.search(r'^(MASTER_SITE_.*)\+=', line)
+ if m:
+ master_site = m[1]
+ continue
+
+ m = re.search(r'^\t(.*?)(?:\s+\\)?$', line)
+ if not m:
+ continue
+
+ site = m[1]
+ if not url.startswith(site):
+ continue
+
+ rest = url[len(site):]
+ m = re.search(r'^(.+)/([^/]+)$', rest)
+ if not m:
+ master_sites = "${%s}" % master_site
+ continue
+
+ subdir, distfile = m.groups()
+
+ master_sites = '${%s:=%s/}' % (master_site, subdir)
+ if master_site == 'MASTER_SITE_SOURCEFORGE':
+ homepage = f'https://{subdir}.sourceforge.net/'
+ elif master_site == 'MASTER_SITE_GNU':
+ homepage = f'https://www.gnu.org/software/{subdir}/'
+ else:
+ homepage = url[:-len(distfile)]
+
+ m = re.search(r'^https://downloads\.sourceforge\.net/project/([^/?]+)/[^?]+/([^/?]+)(?:[?].*)?$', url)
+ if m:
+ project, filename = m.groups()
+
+ master_sites = '${MASTER_SITE_SOURCEFORGE:=%s/}' % project
+ homepage = 'https://%s.sourceforge.net/' % project
+ distfile = filename
+
+ m = re.search(r'^https://github\.com/(.+)/(.+)/archive/(.+)(\.tar\.gz|\.zip)$', url)
+ if m:
+ org, proj, tag, ext = m.groups()
+
+ github_project = proj
+ master_sites = '${MASTER_SITE_GITHUB:=%s/}' % org
+ homepage = 'https://github.com/%s/%s/' % (org, proj)
+ if github_project not in tag:
+ pkgname_prefix = '${GITHUB_PROJECT}-'
+ dist_subdir = '${GITHUB_PROJECT}'
+ distfile = tag + ext
+
+ m = re.search(r'^https://github\.com/(.+)/(.+)/releases/download/(.+)/(.+)(\.tar\.gz|\.zip)$', url)
+ if m:
+ org, proj, tag, base, ext = m.groups()
+
+ github_project = proj
+ master_sites = '${MASTER_SITE_GITHUB:=%s/}' % org
+ homepage = 'https://github.com/%s/%s/' % (org, proj)
+ if proj not in base:
+ github_project = proj
+ dist_subdir = '${GITHUB_PROJECT}'
+ github_release = '${DISTNAME}' if tag == base else tag
+ distfile = base + ext
+
+ if master_sites == '':
+ m = re.search(r'^(.*/)(.*)$', url)
+ master_sites = m[1]
+ distfile = m[2]
+ homepage = master_sites
+
+ m = re.search(r'^(.*?)((?:\.tar)?\.\w+)$', distfile)
+ if m:
+ distname, extract_sufx = m.groups()
+ else:
+ distname, extract_sufx = distfile, '# none'
+
+ m = re.search(r'^v\d', distname)
+ if m:
+ pkgname_transform = ':S,^v,,'
+ elif re.search(r'-v\d', distname) and not re.search(r'-v.*-v\d', distname):
+ pkgname_transform = ':S,-v,-,'
+
+ main_category = re.search(r'.*/([^/]+)/[^/]+$', os.getcwd())[1]
+
+ categories = main_category if main_category != 'wip' else '# TODO: add primary category'
+
+ if extract_sufx == '.tar.gz' or extract_sufx == '.gem':
+ extract_sufx = ''
+
+ pkgname = '%s${DISTNAME%s}' % (pkgname_prefix, pkgname_transform)
+ if pkgname == '${DISTNAME}':
+ pkgname = ''
+
+ maintainer = \
+ os.getenv('PKGMAINTAINER') or os.getenv('REPLYTO') \
+ or 'INSERT_YOUR_MAIL_ADDRESS_HERE'
+
+ lines = Lines()
+ lines.add(cvsid('# %s'))
+ lines.add('')
+
+ lines.add_vars(
+ Var('GITHUB_PROJECT', '=', github_project),
+ Var('DISTNAME', '=', distname),
+ Var('PKGNAME', '=', pkgname),
+ Var('CATEGORIES', '=', categories),
+ Var('MASTER_SITES', '=', master_sites),
+ Var('GITHUB_RELEASE', '=', github_release),
+ Var('EXTRACT_SUFX', '=', extract_sufx),
+ Var('DIST_SUBDIR', '=', dist_subdir),
+ )
+
+ lines.add_vars(
+ Var('MAINTAINER', '=', maintainer),
+ Var('HOMEPAGE', '=', homepage),
+ Var('COMMENT', '=', 'TODO: Short description of the package'),
+ Var('#LICENSE', '=', '# TODO: (see mk/license.mk)'),
+ )
+
+ lines.add('# url2pkg-marker (please do not remove this line.)')
+ lines.add('.include "../../mk/bsd.pkg.mk"')
Home |
Main Index |
Thread Index |
Old Index