aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGES29
-rw-r--r--Mk/bsd.port.mk10
-rw-r--r--Mk/bsd.sites.mk114
3 files changed, 136 insertions, 17 deletions
diff --git a/CHANGES b/CHANGES
index 5c8a641921fe..f440d7183b32 100644
--- a/CHANGES
+++ b/CHANGES
@@ -10,6 +10,35 @@ in the release notes and/or placed into UPDATING.
All ports committers are allowed to commit to this file.
+20150528:
+AUTHOR: mat@FreeBSD.org
+
+ USE_GITHUB can now fetch multiple distfiles. It uses a grouping feature
+ similar to MASTER_SITES/PATCH_SITES.
+
+ Some helpful variables are provided: WRKSRC_<group> for putting things in the
+ right place in post-extract, and DISTNAME_<group>/DISTFILE_<group> for use
+ with EXTRACT_ONLY.
+
+ A simple example:
+
+ PORTNAME= bar
+ PORTVERSION= 1.0
+ USE_GITHUB= yes
+ GH_ACCOUNT= foo
+ GH_PROJECT= ${PORTNAME}-images:images
+
+ post-extract:
+ @${MV} ${WRKSRC_images} ${WRKSRC}/images
+
+ It will fetch those two distfiles:
+
+ $ make fetch-urlall-list
+ https://codeload.github.com/foo/bar/tar.gz/1.0?dummy=/foo-bar-1.0_GH0.tar.gz
+ https://codeload.github.com/foo/bar-images/tar.gz/1.0?dummy=/foo-bar-images-1.0-1.0.tar.gz
+
+ It will then extract them to ${WRKDIR} in their respectives directories.
+
20150526:
AUTHOR: antoine@FreeBSD.org
diff --git a/Mk/bsd.port.mk b/Mk/bsd.port.mk
index a0a0a4b696b2..53d098535af2 100644
--- a/Mk/bsd.port.mk
+++ b/Mk/bsd.port.mk
@@ -1316,14 +1316,8 @@ _SUF2= ,${PORTEPOCH}
PKGVERSION= ${PORTVERSION:C/[-_,]/./g}${_SUF1}${_SUF2}
PKGNAME= ${PKGNAMEPREFIX}${PORTNAME}${PKGNAMESUFFIX}-${PKGVERSION}
DISTVERSIONFULL= ${DISTVERSIONPREFIX}${DISTVERSION:C/:(.)/\1/g}${DISTVERSIONSUFFIX}
-.if defined(USE_GITHUB) && empty(MASTER_SITES:MGHC)
-# Only add in DISTVERSIONFULL if GH_TAGNAME if set by port. Otherwise
-# GH_TAGNAME defaults to DISTVERSIONFULL; Avoid adding DISTVERSIONFULL in twice.
-. if defined(GH_TAGNAME)
-DISTNAME?= ${GH_ACCOUNT}-${GH_PROJECT}-${DISTVERSIONFULL}-${GH_TAGNAME_SANITIZED}
-. else
-DISTNAME?= ${GH_ACCOUNT}-${GH_PROJECT}-${GH_TAGNAME_SANITIZED}
-. endif
+.if defined(USE_GITHUB) && empty(MASTER_SITES:MGHC) && empty(DISTNAME)
+_GITHUB_MUST_SET_DISTNAME= yes
.else
DISTNAME?= ${PORTNAME}-${DISTVERSIONFULL}
.endif
diff --git a/Mk/bsd.sites.mk b/Mk/bsd.sites.mk
index 3a6ec1c855b2..99b9450975b2 100644
--- a/Mk/bsd.sites.mk
+++ b/Mk/bsd.sites.mk
@@ -523,23 +523,119 @@ MASTER_SITE_GITHUB_CLOUD+= http://cloud.github.com/downloads/%SUBDIR%
. if !defined(MASTER_SITES) || !${MASTER_SITES:MGH} && !${MASTER_SITES:MGHC}
MASTER_SITES+= GH
. endif
-GH_ACCOUNT?= ${PORTNAME}
-GH_PROJECT?= ${PORTNAME}
+_GH_ACCOUNT_DEFAULT= ${PORTNAME}
+GH_ACCOUNT?= ${_GH_ACCOUNT_DEFAULT}
+_GH_PROJECT_DEFAULT= ${PORTNAME}
+GH_PROJECT?= ${_GH_PROJECT_DEFAULT}
# Use full PREFIX/SUFFIX and converted DISTVERSION
-GH_TAGNAME?= ${DISTVERSIONFULL}
-# This new scheme rerolls distfiles. Also ensure they are renamed to avoid
-# conflicts. Use _GITHUB_REV in case github changes their zipping or structure
-# which has happened before.
-_GITHUB_REV= 0
-. if ${MASTER_SITES:MGH}
-DISTNAME:= ${DISTNAME}_GH${_GITHUB_REV}
+_GH_TAGNAME_DEFAULT= ${DISTVERSIONFULL}
+GH_TAGNAME?= ${_GH_TAGNAME_DEFAULT}
+# Iterate over GH_ACCOUNT, GH_PROJECT and GH_TAGNAME to extract groups
+_GITHUB_GROUPS= DEFAULT
+.for _A in ${GH_ACCOUNT}
+_S_TEMP= ${_A:S/^${_A:C@:[^/:]+$@@}//:S/^://}
+. if !empty(_S_TEMP)
+. for _group in ${_S_TEMP:S/,/ /g}
+. if ${_group} == all || ${_group} == ALL || ${_group} == default
+check-makevars::
+ @${ECHO_MSG} "Makefile error: the words all, ALL and default are reserved and cannot be"
+ @${ECHO_MSG} "used in group definitions. Please fix your GH_ACCOUNT"
+ @${FALSE}
+. endif
+. if !${_GITHUB_GROUPS:M${_group}}
+_GITHUB_GROUPS+= ${_group}
+. endif
+_GH_ACCOUNT_${_group}= ${_A:C@^(.*):[^/:]+$@\1@}
+. endfor
+. else
+_GH_ACCOUNT_DEFAULT= ${_A:C@^(.*):[^/:]+$@\1@}
+. endif
+.endfor
+.for _P in ${GH_PROJECT}
+_S_TEMP= ${_P:S/^${_P:C@:[^/:]+$@@}//:S/^://}
+. if !empty(_S_TEMP)
+. for _group in ${_S_TEMP:S/,/ /g}
+. if ${_group} == all || ${_group} == ALL || ${_group} == default
+check-makevars::
+ @${ECHO_MSG} "Makefile error: the words all, ALL and default are reserved and cannot be"
+ @${ECHO_MSG} "used in group definitions. Please fix your GH_PROJECT"
+ @${FALSE}
+. endif
+. if !${_GITHUB_GROUPS:M${_group}}
+_GITHUB_GROUPS+= ${_group}
+. endif
+_GH_PROJECT_${_group}= ${_P:C@^(.*):[^/:]+$@\1@}
+. endfor
+. else
+_GH_PROJECT_DEFAULT= ${_P:C@^(.*):[^/:]+$@\1@}
+. endif
+.endfor
+.for _T in ${GH_TAGNAME}
+_S_TEMP= ${_T:S/^${_T:C@:[^/:]+$@@}//:S/^://}
+. if !empty(_S_TEMP)
+. for _group in ${_S_TEMP:S/,/ /g}
+. if ${_group} == all || ${_group} == ALL || ${_group} == default
+check-makevars::
+ @${ECHO_MSG} "Makefile error: the words all, ALL and default are reserved and cannot be"
+ @${ECHO_MSG} "used in group definitions. Please fix your GH_TAGNAME"
+ @${FALSE}
+. endif
+. if !${_GITHUB_GROUPS:M${_group}}
+_GITHUB_GROUPS+= ${_group}
+. endif
+_GH_TAGNAME_${_group}= ${_T:C@^(.*):[^/:]+$@\1@}
+. endfor
+. else
+_GH_TAGNAME_DEFAULT= ${_T:C@^(.*):[^/:]+$@\1@}
. endif
+.endfor
+# Put the default values back into the variables so that the *default* behavior
+# is not changed.
+GH_ACCOUNT:= ${_GH_ACCOUNT_DEFAULT}
+GH_PROJECT:= ${_GH_PROJECT_DEFAULT}
+GH_TAGNAME:= ${_GH_TAGNAME_DEFAULT}
. if defined(GH_TAGNAME)
GH_TAGNAME_SANITIZED= ${GH_TAGNAME:S,/,-,}
# Github silently converts tags starting with v to not have v in the filename
# and extraction directory.
GH_TAGNAME_EXTRACT= ${GH_TAGNAME_SANITIZED:C/^[vV]([0-9])/\1/}
+. endif
+. if defined(_GITHUB_MUST_SET_DISTNAME)
+# GH_TAGNAME defaults to DISTVERSIONFULL; Avoid adding DISTVERSIONFULL in twice
+. if ${GH_TAGNAME} != ${DISTVERSIONFULL}
+DISTNAME= ${GH_ACCOUNT}-${GH_PROJECT}-${DISTVERSIONFULL}-${GH_TAGNAME_SANITIZED}
+. else
+DISTNAME= ${GH_ACCOUNT}-${GH_PROJECT}-${GH_TAGNAME_SANITIZED}
+. endif
. endif
+# This new scheme rerolls distfiles. Also ensure they are renamed to avoid
+# conflicts. Use _GITHUB_REV in case github changes their zipping or structure
+# which has happened before.
+_GITHUB_REV= 0
+. if ${MASTER_SITES:MGH}
+DISTNAME:= ${DISTNAME}_GH${_GITHUB_REV}
+. endif
+.endif
+_GITHUB_EXTRACT_SUFX= .tar.gz
+# If there are non default groups
+.if !empty(_GITHUB_GROUPS:NDEFAULT)
+# Put the DEFAULT distfile first
+DISTFILES+= ${DISTNAME}${_GITHUB_EXTRACT_SUFX}
+# Then for each of the remaining groups, add DISTFILES and MASTER_SITES
+# entries with the correct group and create {WRKSRC,DISTNAME,DISTFILES}_group
+# helper variables.
+. for _group in ${_GITHUB_GROUPS:NDEFAULT}
+_a_tmp= ${_GH_ACCOUNT_${_group}:U${_GH_ACCOUNT_DEFAULT}}
+_p_tmp= ${_GH_PROJECT_${_group}:U${_GH_PROJECT_DEFAULT}}
+_t_tmp= ${_GH_TAGNAME_${_group}:U${_GH_TAGNAME_DEFAULT}}
+_t_tmp_s= ${_t_tmp:S,/,-,}
+_t_tmp_e= ${_t_tmp_s:C/^[vV]([0-9])/\1/}
+DISTNAME_${_group}:= ${_a_tmp}-${_p_tmp}-${_t_tmp_s}
+DISTFILE_${_group}:= ${DISTNAME_${_group}}_GH${_GITHUB_REV}${_GITHUB_EXTRACT_SUFX}
+DISTFILES:= ${DISTFILES} ${DISTFILE_${_group}}:${_group}
+MASTER_SITES:= ${MASTER_SITES} ${MASTER_SITE_GITHUB:S@%SUBDIR%@${_a_tmp}/${_p_tmp}/tar.gz/${_t_tmp}?dummy=/:${_group}@}
+WRKSRC_${_group}:= ${WRKDIR}/${_p_tmp}-${_t_tmp_e}
+. endfor
.endif
.endif