summaryrefslogtreecommitdiff
path: root/mk
diff options
context:
space:
mode:
authortnn <tnn@pkgsrc.org>2015-03-07 21:14:32 +0000
committertnn <tnn@pkgsrc.org>2015-03-07 21:14:32 +0000
commit81fcba18057452d58defaf207bfe816a44067012 (patch)
treed18fff182a5a12ae373c933b891f03d5ed58e40d /mk
parentbf6508dc403f19fcb5e7c6d4ddca56c34e08e0b0 (diff)
downloadpkgsrc-81fcba18057452d58defaf207bfe816a44067012.tar.gz
Address issues raised by agc@ to make the github master site handling
more pkgsrcesque. 1) turn _USE_GITHUB into an internal infrastructure variable 2) put back MASTER_SITES in packages' Makefiles. 3) encode the account in the master site URL, remove GH_ACCOUNT 4) rename GH_PROJECT to GITHUB_PROJECT 5) rename GH_TAGNAME to GITHUB_TAG and allow it to accept commit hash as well as tag. GH_COMMIT is gone. 6) turn on this functionality when MASTER_SITES matches a predefined github pattern instead of via explicit USE_GITHUB setting.
Diffstat (limited to 'mk')
-rw-r--r--mk/bsd.pkg.mk10
-rw-r--r--mk/fetch/bsd.fetch-vars.mk7
-rw-r--r--mk/fetch/github.mk85
3 files changed, 49 insertions, 53 deletions
diff --git a/mk/bsd.pkg.mk b/mk/bsd.pkg.mk
index 5f38185fa51..00a0a6cf88e 100644
--- a/mk/bsd.pkg.mk
+++ b/mk/bsd.pkg.mk
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.pkg.mk,v 1.2010 2015/03/07 14:17:51 tnn Exp $
+# $NetBSD: bsd.pkg.mk,v 1.2011 2015/03/07 21:14:32 tnn Exp $
#
# This file is in the public domain.
#
@@ -96,12 +96,8 @@ MAINTAINER?= pkgsrc-users@NetBSD.org
.endif
PKGWILDCARD?= ${PKGBASE}-[0-9]*
TOOL_DEPENDS?= # empty
-.if defined(USE_GITHUB) && !empty(USE_GITHUB:M[yY][eE][sS]) && \
- defined(GH_COMMIT) && !empty(GH_COMMIT)
-WRKSRC?= ${WRKDIR}/${GH_PROJECT}-${GH_COMMIT}
-.elif defined(USE_GITHUB) && !empty(USE_GITHUB:M[yY][eE][sS]) && \
- defined(GH_TAGNAME) && !empty(GH_TAGNAME)
-WRKSRC?= ${WRKDIR}/${GH_PROJECT}-${GH_TAGNAME:C/^v//}
+.if defined(GITHUB_TAG)
+WRKSRC?= ${WRKDIR}/${GITHUB_PROJECT}-${GITHUB_TAG:C/^v//}
.else
WRKSRC?= ${WRKDIR}/${DISTNAME:U${PKGNAME_NOREV}}
.endif
diff --git a/mk/fetch/bsd.fetch-vars.mk b/mk/fetch/bsd.fetch-vars.mk
index 0f13be2afaa..0eadd0b1776 100644
--- a/mk/fetch/bsd.fetch-vars.mk
+++ b/mk/fetch/bsd.fetch-vars.mk
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.fetch-vars.mk,v 1.17 2015/03/07 14:17:52 tnn Exp $
+# $NetBSD: bsd.fetch-vars.mk,v 1.18 2015/03/07 21:14:32 tnn Exp $
#
# This Makefile fragment is included separately by bsd.pkg.mk and
# defines some variables which must be defined earlier than where
@@ -37,8 +37,9 @@ _SYS_VARS.fetch= DEFAULT_DISTFILES
_DISTDIR= ${DISTDIR}/${DIST_SUBDIR}
.if defined(DISTNAME) && !empty(DISTNAME)
-. if defined(GH_COMMIT) && !empty(GH_COMMIT)
-DEFAULT_DISTFILES= ${DISTNAME}-${GH_COMMIT}${EXTRACT_SUFX}
+. if defined(GITHUB_TAG) && !empty(GITHUB_TAG:M[a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]*)
+# if the github tag is a git hash (7 or more hex digits), encode it in the distfile name
+DEFAULT_DISTFILES= ${DISTNAME}-${GITHUB_TAG}${EXTRACT_SUFX}
. else
DEFAULT_DISTFILES= ${DISTNAME}${EXTRACT_SUFX}
. endif
diff --git a/mk/fetch/github.mk b/mk/fetch/github.mk
index 83f7ce71fb3..7a66c39e0d4 100644
--- a/mk/fetch/github.mk
+++ b/mk/fetch/github.mk
@@ -1,69 +1,68 @@
-# $NetBSD: github.mk,v 1.4 2015/03/07 16:54:28 tnn Exp $
+# $NetBSD: github.mk,v 1.5 2015/03/07 21:14:32 tnn Exp $
#
# github.com master site handling
#
# To use, set in Makefile:
#
# DISTNAME= exampleproject-1.2
-# USE_GITHUB= YES
+# MASTER_SITES= ${MASTER_SITE_GITHUB:=accountname/}
#
-# The following variables alter USE_GITHUB behavior:
+# The following variables alter github.mk behavior:
#
-# GH_ACCOUNT defaults to PKGBASE
-# GH_PROJECT defaults to PKGBASE
-# GH_TAGNAME defaults to PKGVERSION_NOREV
-# (sometimes you want to override with v${PKGVERSION_NOREV})
-# GH_COMMIT explicit commit hash if no tag is available
-# GH_RELEASE default empty, may be set to ${DISTNAME} for example
-# GH_TYPE overrides the autodetected MASTER_SITE URL scheme:
+# GITHUB_PROJECT defaults to PKGBASE
+# GITHUB_TAG defaults to PKGVERSION_NOREV
+# sometimes you want to override with v${PKGVERSION_NOREV}
+# SHA-1 commit ids are also acceptable
+# GITHUB_RELEASE defaults to not defined, set this to ${DISTNAME}
+# when packaging a release not based on a git tag.
+# GITHUB_TYPE overrides the autodetected MASTER_SITE URL scheme:
#
# "tag"
-# This is the default when GH_TAGNAME is set or no type was specified. Exampe URL:
-# http://github.com/acct/proj/archive/{GH_TAGNAME}.tar.gz
+# This is the default when GITHUB_RELEASE is not defined. Example URL:
+# http://github.com/acct/${GITHUB_PROJECT}/archive/{GITHUB_TAG}.tar.gz
#
# "release"
-# This is the default when GH_RELEASE is set. Example URL:
-# http://github.com/acct/proj/releases/download/${GH_RELEASE}/${DISTNAME}.tar.gz
-#
-# "commit"
-# This is the default when GH_COMMIT is set. Example URL:
-# http://github.com/acct/proj/archive/${GH_COMMIT}.tar.gz
+# This is the default when GITHUB_RELEASE is set. Example URL:
+# http://github.com/acct/${GITHUB_PROJECT}/releases/download/${GITHUB_RELEASE}/${DISTNAME}.tar.gz
#
# Keywords: github
-.if defined(USE_GITHUB) && !empty(USE_GITHUB:M[yY][eE][sS])
+# xxx move this to sites.mk
+MASTER_SITE_GITHUB?= https://github.com/
+
+.if defined(MASTER_SITES) && !empty(MASTER_SITES:C,^https\://github.com/[a-zA-Z0-9]*/$,match,:Mmatch)
+_USE_GITHUB= YES
+.endif
+
+.if (defined(GITHUB_TAG) || defined(GITHUB_RELEASE)) && !defined(_USE_GITHUB)
+PKG_FAIL_REASON+= "MASTER_SITES must match https://github.com/account/" \
+ "when GITHUB_TAG or GITHUB_RELEASE is in use." \
+ "For more information: make help topic=github"
+.endif
-# maybe move this to sites.mk
-MASTER_SITE_GITHUB?= https://github.com/
+.if defined(_USE_GITHUB) && !empty(_USE_GITHUB:M[yY][eE][sS])
-GH_ACCOUNT?= ${PKGBASE}
-GH_PROJECT?= ${PKGBASE}
-GH_TAGNAME?= ${PKGVERSION_NOREV}
+GITHUB_PROJECT?= ${PKGBASE}
+GITHUB_TAG?= ${PKGVERSION_NOREV}
-. if !empty(GH_TAGNAME:Mmaster)
-PKG_FAIL_REASON+= "master is not a valid tag name, use an explicit commit hash (hint: set GH_COMMIT)"
+. if !empty(GITHUB_TAG:Mmaster)
+PKG_FAIL_REASON+= "master is not a valid tag name, use an explicit commit hash"
. endif
-. if !defined(GH_TYPE)
-. if defined(GH_COMMIT) && !empty(GH_COMMIT:M*)
-GH_TYPE= commit
-. elif defined(GH_RELEASE) && !empty(GH_RELEASE:M*)
-GH_TYPE= release
-. else
-GH_TYPE= tag
+. if !defined(GITHUB_TYPE)
+. if defined(GITHUB_RELEASE) && !empty(GITHUB_RELEASE)
+GITHUB_TYPE= release
+. else
+GITHUB_TYPE= tag
. endif
. endif
-.if !empty(GH_TYPE:Mrelease)
-MASTER_SITES?= ${MASTER_SITE_GITHUB}${GH_ACCOUNT}/${GH_PROJECT}/releases/download/${GH_RELEASE}/
-.endif
-
-.if !empty(GH_TYPE:Mcommit)
-MASTER_SITES?= -${MASTER_SITE_GITHUB}${GH_ACCOUNT}/${GH_PROJECT}/archive/${GH_COMMIT}${EXTRACT_SUFX}
-.endif
+. if !empty(GITHUB_TYPE:Mrelease)
+MASTER_SITES:= ${MASTER_SITES:=${GITHUB_PROJECT}/releases/download/${GITHUB_RELEASE}/}
+. endif
-.if !empty(GH_TYPE:Mtag)
-MASTER_SITES?= -${MASTER_SITE_GITHUB}${GH_ACCOUNT}/${GH_PROJECT}/archive/${GH_TAGNAME}${EXTRACT_SUFX}
-.endif
+. if !empty(GITHUB_TYPE:Mtag)
+MASTER_SITES:= -${MASTER_SITES:=${GITHUB_PROJECT}/archive/${GITHUB_TAG}${EXTRACT_SUFX}}
+. endif
.endif