summaryrefslogtreecommitdiff
path: root/mk
diff options
context:
space:
mode:
authortnn <tnn@pkgsrc.org>2015-03-07 14:17:51 +0000
committertnn <tnn@pkgsrc.org>2015-03-07 14:17:51 +0000
commit6370898cba24215be2489e33c04c45c7d10c624c (patch)
treee48a0c7459988ce75818375808c9e213e55a77b5 /mk
parent18291a436d9933cf32026c4c23385a98b57ab5df (diff)
downloadpkgsrc-6370898cba24215be2489e33c04c45c7d10c624c.tar.gz
Adopt USE_GITHUB from FreeBSD ports to make github MASTER_SITE
handling less painful. See: https://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/makefile-distfiles.html#makefile-master_sites-github To use, set in Makefile: DISTNAME= exampleproject-1.2 USE_GITHUB= YES The following variables alter USE_GITHUB 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
Diffstat (limited to 'mk')
-rw-r--r--mk/bsd.pkg.mk10
-rw-r--r--mk/fetch/bsd.fetch-vars.mk6
-rw-r--r--mk/fetch/bsd.fetch.mk4
-rw-r--r--mk/fetch/github.mk68
4 files changed, 85 insertions, 3 deletions
diff --git a/mk/bsd.pkg.mk b/mk/bsd.pkg.mk
index 5603a63d66e..5f38185fa51 100644
--- a/mk/bsd.pkg.mk
+++ b/mk/bsd.pkg.mk
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.pkg.mk,v 1.2009 2015/01/01 07:51:47 dholland Exp $
+# $NetBSD: bsd.pkg.mk,v 1.2010 2015/03/07 14:17:51 tnn Exp $
#
# This file is in the public domain.
#
@@ -96,7 +96,15 @@ 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//}
+.else
WRKSRC?= ${WRKDIR}/${DISTNAME:U${PKGNAME_NOREV}}
+.endif
# Override for SU_CMD user check
_IS_ROOT_CMD?= ${TEST} `${ID} -u` = `${ID} -u ${_SU_ROOT_USER}`
diff --git a/mk/fetch/bsd.fetch-vars.mk b/mk/fetch/bsd.fetch-vars.mk
index da063360b54..0f13be2afaa 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.16 2014/03/02 08:54:41 obache Exp $
+# $NetBSD: bsd.fetch-vars.mk,v 1.17 2015/03/07 14:17:52 tnn Exp $
#
# This Makefile fragment is included separately by bsd.pkg.mk and
# defines some variables which must be defined earlier than where
@@ -37,7 +37,11 @@ _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}
+. else
DEFAULT_DISTFILES= ${DISTNAME}${EXTRACT_SUFX}
+. endif
.endif
DISTFILES?= ${DEFAULT_DISTFILES}
diff --git a/mk/fetch/bsd.fetch.mk b/mk/fetch/bsd.fetch.mk
index 31b4b98b5c6..c4b305f5b0c 100644
--- a/mk/fetch/bsd.fetch.mk
+++ b/mk/fetch/bsd.fetch.mk
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.fetch.mk,v 1.7 2009/07/15 09:40:30 joerg Exp $
+# $NetBSD: bsd.fetch.mk,v 1.8 2015/03/07 14:17:52 tnn Exp $
#
# This Makefile fragment is included by bsd.pkg.mk and defines the
# relevant variables and targets for the "fetch" step.
@@ -38,3 +38,5 @@
.include "fetch.mk"
.include "fetch-list.mk"
.include "distclean.mk"
+.include "github.mk"
+
diff --git a/mk/fetch/github.mk b/mk/fetch/github.mk
new file mode 100644
index 00000000000..fba1ce246e3
--- /dev/null
+++ b/mk/fetch/github.mk
@@ -0,0 +1,68 @@
+# $NetBSD: github.mk,v 1.1 2015/03/07 14:17:52 tnn Exp $
+#
+# github.com master site handling
+#
+# To use, set in Makefile:
+#
+# DISTNAME= exampleproject-1.2
+# USE_GITHUB= YES
+#
+# The following variables alter USE_GITHUB 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:
+#
+# "tag"
+# This is the default when GH_TAGNAME is set. Exampe URL:
+# http://www.github.com/acct/proj/archive/{GH_TAGNAME}.tar.gz
+#
+# "release"
+# This is the default when GH_RELEASE is set. Example URL:
+# http://www.github.com/acct/proj/releases/download/${GH_RELEASE}/${DISTNAME}${EXTRACT_SUFX}
+#
+# "commit"
+# This is the default when GH_TAGNAME and GH_COMMIT are empty.
+# -${MASTER_SITE_GITHUB}${GH_ACCOUNT}/{GH_PROJECT}/releases/download/${PKGVERSION_NOREV}${EXTRACT_SUFX}
+
+
+.if defined(USE_GITHUB) && !empty(USE_GITHUB:M[yY][eE][sS])
+
+# maybe move this to sites.mk
+MASTER_SITE_GITHUB?= http://github.com/
+
+GH_ACCOUNT?= ${PKGBASE}
+GH_PROJECT?= ${PKGBASE}
+GH_TAGNAME?= ${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)"
+. 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
+. 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(GH_TYPE:Mtag)
+MASTER_SITES?= -${MASTER_SITE_GITHUB}${GH_ACCOUNT}/${GH_PROJECT}/archive/${GH_TAGNAME}${EXTRACT_SUFX}
+.endif
+
+.endif