summaryrefslogtreecommitdiff
path: root/pkgtools
diff options
context:
space:
mode:
authorrodent <rodent@pkgsrc.org>2015-04-04 04:00:49 +0000
committerrodent <rodent@pkgsrc.org>2015-04-04 04:00:49 +0000
commitcaa14a525757bbd45c5312f2c0785a0562538336 (patch)
tree8f191aeada66dd1aa736691ff038c757a8eeef56 /pkgtools
parentc5c6114912f61e04cdadbd3569a52078367dfd9b (diff)
downloadpkgsrc-caa14a525757bbd45c5312f2c0785a0562538336.tar.gz
Initial support for automating the creation of Makefiles from GitHub URLs.
Initial support for automating the addition of DIST_SUBDIR. Bump PKGVERSION
Diffstat (limited to 'pkgtools')
-rw-r--r--pkgtools/url2pkg/Makefile4
-rw-r--r--pkgtools/url2pkg/files/url2pkg.pl46
2 files changed, 47 insertions, 3 deletions
diff --git a/pkgtools/url2pkg/Makefile b/pkgtools/url2pkg/Makefile
index 7a416a52e20..b44ceec7ab2 100644
--- a/pkgtools/url2pkg/Makefile
+++ b/pkgtools/url2pkg/Makefile
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.75 2014/10/09 14:06:50 wiz Exp $
+# $NetBSD: Makefile,v 1.76 2015/04/04 04:00:49 rodent Exp $
#
-PKGNAME= url2pkg-2.20
+PKGNAME= url2pkg-2.21
CATEGORIES= pkgtools
MAINTAINER= pkgsrc-users@NetBSD.org
diff --git a/pkgtools/url2pkg/files/url2pkg.pl b/pkgtools/url2pkg/files/url2pkg.pl
index fb4638f26be..7e32c826ce6 100644
--- a/pkgtools/url2pkg/files/url2pkg.pl
+++ b/pkgtools/url2pkg/files/url2pkg.pl
@@ -1,5 +1,5 @@
#! @PERL@
-# $NetBSD: url2pkg.pl,v 1.26 2014/08/01 15:44:13 schmonz Exp $
+# $NetBSD: url2pkg.pl,v 1.27 2015/04/04 04:00:49 rodent Exp $
#
# Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -120,6 +120,7 @@ my ($distname, $abs_wrkdir, $abs_wrksrc);
my (@wrksrc_files, @wrksrc_dirs);
my (@depends, @build_depends, @includes, @build_vars, @extra_vars, @todo);
my ($pkgname);
+my ($dist_subdir);
#
# And now to the real magic_* subroutines.
@@ -246,6 +247,7 @@ sub generate_initial_package($) {
my ($url) = @_;
my ($found, $master_site);
my ($master_sites, $distfile, $homepage, $dist_sufx, $category);
+ my ($gh_project, $gh_tag, $gh_release);
$found = false;
open(SITES, "<", "../../mk/fetch/sites.mk") or die;
@@ -302,6 +304,39 @@ sub generate_initial_package($) {
}
if (!$found) {
+ if ($url =~ qr"^https?://github\.com/") {
+ if ($url =~ qr"^https?://github\.com/(.*)/(.*)/archive/(.*)(\.tar\.gz|\.zip)$") {
+ $master_sites = "\${MASTER_SITE_GITHUB:=$1/}";
+ $homepage = "\${MASTER_SITE_GITHUB:=$1/$2/}";
+ $gh_project = $2;
+ $gh_tag = $3;
+ if (index($gh_tag, $gh_project) == -1 ) {
+ $pkgname = '${GITHUB_PROJECT}-${DISTNAME}';
+ $dist_subdir = '${GITHUB_PROJECT}';
+ }
+ $distfile = "$3$4";
+ $found = true;
+ } elsif ($url =~ qr"^https?://github\.com/(.*)/(.*)/releases/download/(.*)/(.*)(\.tar\.gz|\.zip)$") {
+ $master_sites = "\${MASTER_SITE_GITHUB:=$1/}";
+ $homepage = "\${MASTER_SITE_GITHUB:=$1/$2/}";
+ if (index($4, $2) == -1) {
+ $gh_project = $2;
+ $dist_subdir = '${GITHUB_PROJECT}';
+ }
+ if ($3 eq $4) {
+ $gh_release = '${DISTNAME}';
+ } else {
+ $gh_release = $3;
+ }
+ $distfile = "$4$5";
+ $found = true;
+ } else {
+ die("$0: ERROR: Invalid GitHub URL: ${url}\n");
+ }
+ }
+ }
+
+ if (!$found) {
if ($url =~ qr"^(.*/)(.*)$") {
($master_sites, $distfile) = ($1, $2);
$homepage = $master_sites;
@@ -328,11 +363,20 @@ sub generate_initial_package($) {
print MF ("# \$Net" . "BSD\$\n");
print MF ("\n");
print_section(*MF, [
+ (($gh_project ne "")
+ ? ["GITHUB_PROJECT", $gh_project]
+ : ()),
["DISTNAME", $distname],
["CATEGORIES", $category],
["MASTER_SITES", $master_sites],
+ (($gh_release ne "")
+ ? ["GITHUB_RELEASE", $gh_release]
+ : ()),
(($dist_sufx ne ".tar.gz" && $dist_sufx ne ".gem")
? ["EXTRACT_SUFX", $dist_sufx]
+ : ()),
+ (($dist_subdir ne "")
+ ? ["DIST_SUBDIR", $dist_subdir]
: ())
]);
print_section(*MF, [