Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 May 2015 16:37:02 +0000 (UTC)
From:      Mathieu Arnold <mat@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r387742 - in head: . Mk
Message-ID:  <201505281637.t4SGb2DI020586@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mat
Date: Thu May 28 16:37:01 2015
New Revision: 387742
URL: https://svnweb.freebsd.org/changeset/ports/387742

Log:
  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.
  
  PR:		200483
  Differential Revision:	https://reviews.freebsd.org/D2608
  Submitted by:	mat
  With hat:	portmgr
  Exp run by:	antoine
  Sponsored by:	Absolight

Modified:
  head/CHANGES
  head/Mk/bsd.port.mk
  head/Mk/bsd.sites.mk

Modified: head/CHANGES
==============================================================================
--- head/CHANGES	Thu May 28 16:11:59 2015	(r387741)
+++ head/CHANGES	Thu May 28 16:37:01 2015	(r387742)
@@ -10,6 +10,35 @@ in the release notes and/or placed into 
 
 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
 

Modified: head/Mk/bsd.port.mk
==============================================================================
--- head/Mk/bsd.port.mk	Thu May 28 16:11:59 2015	(r387741)
+++ head/Mk/bsd.port.mk	Thu May 28 16:37:01 2015	(r387742)
@@ -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

Modified: head/Mk/bsd.sites.mk
==============================================================================
--- head/Mk/bsd.sites.mk	Thu May 28 16:11:59 2015	(r387741)
+++ head/Mk/bsd.sites.mk	Thu May 28 16:37:01 2015	(r387742)
@@ -523,23 +523,119 @@ MASTER_SITE_GITHUB_CLOUD+=	http://cloud.
 .  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
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201505281637.t4SGb2DI020586>