svn commit: r510950 - in head/Mk: . Scripts

Baptiste Daroussin bapt at FreeBSD.org
Tue Sep 3 14:36:01 UTC 2019


Author: bapt
Date: Tue Sep  3 14:36:00 2019
New Revision: 510950
URL: https://svnweb.freebsd.org/changeset/ports/510950

Log:
  Add support for overlays
  
  overlays are a way to help users to integrate their own ports tree
  with the official ports tree without having to maintain clone of the
  official tree and remerge on regular basis.
  
  The ports tree will lookup in the overlays (in the order the are listed in
  OVERLAY variable) for the dependencies and the USES. It will use the first
  found.
  
  in order to use it the user have to declare his overlays that way in their
  make.conf:
  OVERLAYS= overlay1 overlay2 overlay3
  
  Reviewed by:	manu
  Approved by:	swills
  Differential Revision:	https://reviews.freebsd.org/D21468

Modified:
  head/Mk/Scripts/depends-list.sh
  head/Mk/Scripts/do-depends.sh
  head/Mk/bsd.port.mk
  head/Mk/bsd.sanity.mk

Modified: head/Mk/Scripts/depends-list.sh
==============================================================================
--- head/Mk/Scripts/depends-list.sh	Tue Sep  3 14:35:13 2019	(r510949)
+++ head/Mk/Scripts/depends-list.sh	Tue Sep  3 14:36:00 2019	(r510950)
@@ -37,7 +37,7 @@ while getopts "fmrw" FLAG; do
 done
 shift $((OPTIND-1))
 
-validate_env PORTSDIR dp_PKGNAME
+validate_env PORTSDIR dp_OVERLAYS dp_PKGNAME
 if [ ${recursive} -eq 1 -o ${requires_wrkdir} -eq 1 ]; then
 	validate_env dp_MAKE
 	# Cache command executions to avoid looking them up again in every
@@ -65,16 +65,25 @@ check_dep() {
 
 		case "${2}" in
 		/*) d=${2} ;;
-		*) d=${PORTSDIR}/${2} ;;
+		*) for overlay in ${dp_OVERLAYS} ${PORTSDIR}; do
+			d=${overlay}/${2}
+			f=
+			case "${d}" in
+			*@*/*) ;; # Ignore @ in the path which would not be a flavor
+			*@*)
+				f=${d##*@}
+				d=${d%@*}
+				;;
+			esac
+			if [ -f ${d}/Makefile ]; then
+				if [ -n $f ]; then
+					export FLAVOR=$f
+				fi
+				break
+			fi
+		done
 		esac
 
-		case "${d}" in
-		*@*/*) ;; # Ignore @ in the path which would not be a flavor
-		*@*)
-			export FLAVOR=${d##*@}
-			d=${d%@*}
-			;;
-		esac
 		if [ ${flavors} -eq 1 -a -n "${FLAVOR:-}" ]; then
 			port_display="${d}@${FLAVOR}"
 		else

Modified: head/Mk/Scripts/do-depends.sh
==============================================================================
--- head/Mk/Scripts/do-depends.sh	Tue Sep  3 14:35:13 2019	(r510949)
+++ head/Mk/Scripts/do-depends.sh	Tue Sep  3 14:36:00 2019	(r510950)
@@ -11,7 +11,7 @@ validate_env dp_RAWDEPENDS dp_DEPTYPE dp_DEPENDS_TARGE
 	dp_DEPENDS_CLEAN dp_DEPENDS_ARGS dp_USE_PACKAGE_DEPENDS \
 	dp_USE_PACKAGE_DEPENDS_ONLY dp_PKG_ADD dp_PKG_INFO dp_WRKDIR \
 	dp_PKGNAME dp_STRICT_DEPENDS dp_LOCALBASE dp_LIB_DIRS dp_SH \
-	dp_SCRIPTSDIR PORTSDIR dp_MAKE dp_MAKEFLAGS
+	dp_SCRIPTSDIR PORTSDIR dp_MAKE dp_MAKEFLAGS dp_OVERLAYS
 
 [ -n "${DEBUG_MK_SCRIPTS}" -o -n "${DEBUG_MK_SCRIPTS_DO_DEPENDS}" ] && set -x
 
@@ -125,7 +125,15 @@ for _line in ${dp_RAWDEPENDS} ; do
 
 	case "${origin}" in
 	/*) ;;
-	*) origin="${PORTSDIR}/${origin}" ;;
+	*)
+		for overlay in ${dp_OVERLAYS} ${PORTSDIR}; do
+			orig="${overlay}/${origin}"
+			if [ -f "${orig}/Makefile" ]; then
+				break
+			fi
+		done
+		origin="${orig}"
+		;;
 	esac
 	case "${origin}" in
 	*@*/*) ;; # Ignore @ in the path which would not be a flavor

Modified: head/Mk/bsd.port.mk
==============================================================================
--- head/Mk/bsd.port.mk	Tue Sep  3 14:35:13 2019	(r510949)
+++ head/Mk/bsd.port.mk	Tue Sep  3 14:36:00 2019	(r510950)
@@ -1029,6 +1029,7 @@ STAGEDIR?=	${WRKDIR}/stage
 NOTPHONY?=
 FLAVORS?=
 FLAVOR?=
+OVERLAYS?=
 # Disallow forced FLAVOR as make argument since we cannot change it to the
 # proper default.
 .if empty(FLAVOR) && !empty(.MAKEOVERRIDES:MFLAVOR)
@@ -1450,8 +1451,18 @@ ${_f}_ARGS:=	${f:C/^[^\:]*(\:|\$)//:S/,/ /g}
 .endif
 .endfor
 .for f in ${USES}
-.include "${USESDIR}/${f:C/\:.*//}.mk"
+.undef _usefound
+.for udir in ${OVERLAYS:C,$,/Mk/Uses,} ${USESDIR}
+_usefile=	${udir}/${f:C/\:.*//}.mk
+.if exists(${_usefile}) && !defined(_usefound)
+_usefound=
+.include "${_usefile}"
+.endif
 .endfor
+.if !defined(_usefound)
+ERROR+=	"Unkonwn USES=${f:C/\:.*//}"
+.endif
+.endfor
 
 .if !empty(FLAVORS)
 .  if ${FLAVORS:Mall}
@@ -1962,8 +1973,18 @@ ${_f}_ARGS:=	${f:C/^[^\:]*(\:|\$)//:S/,/ /g}
 .endif
 .endfor
 .for f in ${_USES_POST}
-.include "${USESDIR}/${f:C/\:.*//}.mk"
+.undef _usefound
+.for udir in ${OVERLAYS:C,$,/Mk/Uses,} ${USESDIR}
+_usefile=	${udir}/${f:C/\:.*//}.mk
+.if exists(${_usefile}) && !defined(_usefound)
+_usefound=
+.include "${_usefile}"
+.endif
 .endfor
+.if !defined(_usefound)
+ERROR+=	"Unkonwn USES=${f:C/\:.*//}"
+.endif
+.endfor
 
 .if defined(PORTNAME)
 .include "${PORTSDIR}/Mk/bsd.sanity.mk"
@@ -3964,6 +3985,7 @@ ${deptype:tl}-depends:
 		dp_SH="${SH}" \
 		dp_SCRIPTSDIR="${SCRIPTSDIR}" \
 		PORTSDIR="${PORTSDIR}" \
+		dp_OVERLAYS="${OVERLAYS}" \
 		dp_MAKE="${MAKE}" \
 		dp_MAKEFLAGS='${.MAKEFLAGS}' \
 		${SH} ${SCRIPTSDIR}/do-depends.sh
@@ -4018,6 +4040,7 @@ DEPENDS-LIST= \
 			dp_PKGNAME="${PKGNAME}" \
 			dp_PKG_INFO="${PKG_INFO}" \
 			dp_SCRIPTSDIR="${SCRIPTSDIR}" \
+			dp_OVERLAYS="${OVERLAYS}" \
 			${SH} ${SCRIPTSDIR}/depends-list.sh \
 			${DEPENDS_SHOW_FLAVOR:D-f}
 

Modified: head/Mk/bsd.sanity.mk
==============================================================================
--- head/Mk/bsd.sanity.mk	Tue Sep  3 14:35:13 2019	(r510949)
+++ head/Mk/bsd.sanity.mk	Tue Sep  3 14:36:00 2019	(r510950)
@@ -58,7 +58,7 @@ ERROR+=	"${a} is unsupported, please use ${${a}_ALT}"
 
 # Warnings only when DEVELOPER=yes
 
-.if exists(${.CURDIR}/../../Mk/bsd.port.mk)
+.if exists(${.CURDIR}/../../Mk/bsd.port.mk) || ${OVERLAYS:tA:M${.CURDIR:H:H}} == ${.CURDIR:H:H}
 .if ${.CURDIR:H:T} != ${PKGCATEGORY}
 DEV_ERROR+=	"The first entry in CATEGORIES should be the directory where the port lives"
 .endif


More information about the svn-ports-head mailing list