pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

mk/*-package.mk: align VCS infrastructure with each other



Module Name:	pkgsrc-wip
Committed By:	Roland Illig <rillig%NetBSD.org@localhost>
Pushed By:	rillig
Date:		Wed Feb 28 03:58:26 2018 +0000
Changeset:	e5a422454d3fedd8794c59da0992f80837f4bd08

Modified Files:
	mk/cvs-package.mk
	mk/fossil-package.mk
	mk/git-package.mk
	mk/svn-package.mk

Log Message:
mk/*-package.mk: align VCS infrastructure with each other

The behavior of the various version control systems is very similar in
pkgsrc, therefore the code should be similar, too.

Removed CVS_EXTRACTDIR (added a few days ago) since it is not needed.

Removed FOSSIL_BRANCH, FOSSIL_REVISION, FOSSIL_TAG (added while
copy-and-pasting git-package.mk) since they are not needed and fossil
uses the term VERSION for this concept.

Removed the duplicate archive generation from svn-package.mk. It didn't
seem to be necessary.

In the shell commands, replaced Make variables with shell variables since
they are easier to read (lowercase, fewer punctuation).

Extracted the individual commands into Make variables so that they can be
defined conditionally (_CVS_CMD.login) and to make the do-*-extract
target a high-level overview when reading.

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=e5a422454d3fedd8794c59da0992f80837f4bd08

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 mk/cvs-package.mk    |  28 +++-----
 mk/fossil-package.mk | 186 ++++++++++++++++++++++++---------------------------
 mk/git-package.mk    | 129 +++++++++++++++++++----------------
 mk/svn-package.mk    | 144 +++++++++++++++++++--------------------
 4 files changed, 239 insertions(+), 248 deletions(-)

diffs:
diff --git a/mk/cvs-package.mk b/mk/cvs-package.mk
index 0a1669e523..e5e47d580b 100644
--- a/mk/cvs-package.mk
+++ b/mk/cvs-package.mk
@@ -38,12 +38,6 @@
 #	Default: (today at midnight)
 #	Example: v1.0.0
 #
-# CVS_EXTRACTDIR (optional)
-#	The directory relative to WRKDIR where the files from the CVS
-#	repository are extracted.
-#
-#	Default: ${CVS_MODULE}
-#
 # If a package needs to checkout from more than one CVS repository, the
 # setup is a little more complicated, using parameterized variants of
 # the above variables.
@@ -71,12 +65,6 @@
 #
 #	Default: ${CVS_TAG} (today at midnight)
 #
-# CVS_EXTRACTDIR.${id} (optional)
-#	The directory relative to WRKDIR where the files from the CVS
-#	repository are extracted.
-#
-#	Default: ${id}
-#
 # CVS_PROJECT
 #	The project name to be used in CVS_ROOT_SOURCEFORGE.
 #
@@ -140,12 +128,12 @@ CVS_PROJECT?=		${PKGBASE}
 # End of the interface part. Start of the implementation part.
 #
 
-# The common case of a single CVS repository.
+# The common case of a single repository
 .if defined(CVS_ROOT)
 CVS_MODULE?=		${PKGBASE:S,-cvs$,,}
 CVS_REPOSITORIES+=	_default
 WRKSRC?=		${WRKDIR}/${CVS_MODULE}
-.  for varbase in CVS_ROOT CVS_MODULE CVS_TAG CVS_EXTRACTDIR
+.  for varbase in CVS_ROOT CVS_MODULE CVS_TAG
 .    if defined(${varbase})
 ${varbase}._default=	${${varbase}}
 .    endif
@@ -194,7 +182,6 @@ _CVS_DISTDIR=		${DISTDIR}/cvs-packages
 
 .for repo in ${CVS_REPOSITORIES}
 CVS_MODULE.${repo}?=		${repo}
-CVS_EXTRACTDIR.${repo}?=	${CVS_MODULE.${repo}}
 
 # determine appropriate checkout date or tag
 .  if defined(CVS_TAG.${repo})
@@ -222,7 +209,7 @@ _CVS_CMD.vars.${repo}= \
 
 # Extract the cached archive
 _CVS_CMD.extract_archive.${repo}= \
-	if [ -f "$$archive" ]; then	\
+	if [ -f "$$archive" ]; then					\
 	  ${STEP_MSG} "Extracting cached CVS archive $${archive\#\#*/}."; \
 	  gzip -d -c "$$archive" | pax -r;				\
 	  exit 0;							\
@@ -244,13 +231,14 @@ _CVS_CMD.checkout.${repo}= \
 	${STEP_MSG} "Checking out $$module from $$root.";		\
 	${_CVS_CMDLINE} -d "$$root"					\
 	    checkout ${_CVS_CHECKOUT_FLAGS} ${_CVS_TAG_FLAG.${repo}}	\
-	      -d ${CVS_EXTRACTDIR.${repo}:Q} "$$module"
+	      -d "$$module" "$$module"
 
 # Create the cached archive from the checked out repository
 _CVS_CMD.create_archive.${repo}= \
 	${STEP_MSG} "Creating cached CVS archive $${archive\#\#*/}.";	\
 	${MKDIR} "$${archive%/*}";					\
-	pax -w ${CVS_EXTRACTDIR.${repo}:Q} | gzip > "$$archive"
+	pax -w "$$module" | gzip > "$$archive.tmp";			\
+	${MV} "$$archive.tmp" "$$archive"
 .endfor
 
 pre-extract: do-cvs-extract
@@ -268,12 +256,12 @@ do-cvs-extract: .PHONY
 
 # Debug info for show-all and show-all-cvs
 _VARGROUPS+=		cvs
-_PKG_VARS.cvs+=		CVS_ROOT CVS_MODULE CVS_TAG CHECKOUT_DATE CVS_EXTRACTDIR CVS_REPOSITORIES
+_PKG_VARS.cvs+=		CVS_ROOT CVS_MODULE CVS_TAG CHECKOUT_DATE CVS_REPOSITORIES
 _SYS_VARS.cvs+=		DISTFILES PKGNAME PKGREVISION WRKSRC
 _SYS_VARS.cvs+=		CVS_ROOT_GNU CVS_ROOT_NONGNU CVS_ROOT_SOURCEFORGE CVS_PROJECT
 _SYS_VARS.cvs+=		_CVS_DISTDIR _CVS_PKGVERSION
 .for repo in ${CVS_REPOSITORIES}
-.  for varbase in CVS_ROOT CVS_MODULE CVS_TAG CVS_EXTRACTDIR
+.  for varbase in CVS_ROOT CVS_MODULE CVS_TAG
 _PKG_VARS.cvs+=		${varbase}.${repo}
 .  endfor
 .  for varbase in _CVS_DISTFILE
diff --git a/mk/fossil-package.mk b/mk/fossil-package.mk
index 5e6ad6f796..7db780bed3 100644
--- a/mk/fossil-package.mk
+++ b/mk/fossil-package.mk
@@ -1,14 +1,24 @@
 # $NetBSD$
 #
 # This file provides simple access to Fossil repositories, so that packages
-# can be created from Fossil instead of from released tarballs.
+# can be created from Fossil instead of from released tarballs. Whenever a
+# repository is fetched from Fossil, a copy of it is saved below ${DISTDIR},
+# to save bandwidth.
 #
 # Package-settable variables:
 #
 # FOSSIL_REPO (required)
 #	The URL of the Fossil repository.
 #
-# FOSSIL_REVISION (optional)
+#	If the package needs more than one repository, see
+#	FOSSIL_REPOSITORIES below.
+#
+# FOSSIL_MODULE (optional)
+#	The directory where the files are extracted, relative to WRKDIR.
+#
+#	Default: ${DISTNAME} without the version number
+#
+# FOSSIL_VERSION (optional)
 #	The revision, tag or branch to check out.
 #
 #	Default: --latest
@@ -17,24 +27,21 @@
 # repositories in FOSSIL_REPOSITORIES and configure the remaining variables
 # for each repository individually.
 #
-# FOSSIL_REPOSITORIES (required)
-#	A list of unique identifiers /id/ for which appropriate
-#	FOSSIL_REPO must be defined.
-#
-# FOSSIL_REPO.${id} (required)
-#	The fossil repository
-#
-# FOSSIL_BRANCH.${id} (optional)
-#	The branch to check out.
-#
-# FOSSIL_REVISION.${id} (optional)
-#	The revision to check out.
+# FOSSIL_REPOSITORIES (optional)
+#	If the package needs multiple Fossil repositories, this
+#	is the list of repository IDs. For each of these repositories,
+#	parameterized variants of the above variables are defined.
 #
-# FOSSIL_TAG.${id} (optional)
-#	Overridable FOSSIL tag for a repository.
+#	Example:
+#	FOSSIL_REPOSITORIES=	stable latest
+#	FOSSIL_REPO.stable=	http://core.tcl.tk/tcl/
+#	FOSSIL_MODULE.stable=	stable
+#	FOSSIL_VERSION.stable=	v1.2.3
+#	FOSSIL_REPO.latest=	http://core.tcl.tk/tcl/
+#	FOSSIL_MODULE.latest=	latest
+#	FOSSIL_VERSION.latest=	--latest
 #
-# FOSSIL_ENV.${id} (optional)
-#	The environment for fossil, to set e.g. FOSSIL_SSL_NO_VERIFY=true
+# Keywords: fossil
 
 .if !defined(_PKG_MK_FOSSIL_PACKAGE_MK)
 _PKG_MK_FOSSIL_PACKAGE_MK=	# defined
@@ -46,16 +53,13 @@ BUILD_DEPENDS+=		fossil-[0-9]*:../../devel/fossil
 #
 
 DISTFILES?=		# empty
-PKGREVISION?=		${_FOSSIL_PKGVERSION:S/.//g}
+PKGREVISION?=		${_FOSSIL_PKGREVISION_CMD:sh}
 
 #
 # End of the interface part. Start of the implementation part.
 #
 
-#
-# Input validation
-#
-
+# The common case of a single repository.
 .if defined(FOSSIL_REPO)
 FOSSIL_REPOSITORIES+=	_default
 FOSSIL_REPO._default=	${FOSSIL_REPO}
@@ -63,14 +67,18 @@ FOSSIL_MODULE._default=	${FOSSIL_REPO:S,/$,,:T}
 WRKSRC?=		${WRKDIR}/${FOSSIL_MODULE._default}
 .endif
 
+#
+# Input validation
+#
+
 .if !defined(FOSSIL_REPOSITORIES)
 PKG_FAIL_REASON+=	"[fossil-package.mk] FOSSIL_REPOSITORIES must be set."
 FOSSIL_REPOSITORIES?=	# none
 .endif
 
-.for _repo_ in ${FOSSIL_REPOSITORIES}
-.  if !defined(FOSSIL_REPO.${_repo_})
-PKG_FAIL_REASON+=	"[fossil-package.mk] FOSSIL_REPO."${_repo_:Q}" must be set."
+.for repo in ${FOSSIL_REPOSITORIES}
+.  if !defined(FOSSIL_REPO.${repo})
+PKG_FAIL_REASON+=	"[fossil-package.mk] FOSSIL_REPO."${repo:Q}" must be set."
 .  endif
 .endfor
 
@@ -78,101 +86,83 @@ PKG_FAIL_REASON+=	"[fossil-package.mk] FOSSIL_REPO."${_repo_:Q}" must be set."
 # Internal variables
 #
 
-USE_TOOLS+=		date pax
+USE_TOOLS+=			date pax
 
-_FOSSIL_CMD=		fossil
-_FOSSIL_PKGVERSION_CMD=	${DATE} -u +'%Y.%m.%d'
-_FOSSIL_PKGVERSION=	${_FOSSIL_PKGVERSION_CMD:sh}
-_FOSSIL_DISTDIR=	${DISTDIR}/fossil-packages
+_FOSSIL_CMD=			fossil
+_FOSSIL_PKGREVISION_CMD=	${DATE} -u +'%Y%m%d'
+_FOSSIL_DISTDIR=		${DISTDIR}/fossil-packages
 
 #
 # Generation of repository-specific variables
 #
 
 .for repo in ${FOSSIL_REPOSITORIES}
-FOSSIL_MODULE.${repo}?=	${repo}
-_FOSSIL_ENV.${repo}=	${FOSSIL_ENV.${repo}}
-
-# In reality there is no difference for fossil
-.  if defined(FOSSIL_BRANCH.${repo})
-_FOSSIL_VERSION.${repo}=	${FOSSIL_BRANCH.${repo}}
-.  elif defined(FOSSIL_REVISION.${repo})
-_FOSSIL_VERSION.${repo}=	${FOSSIL_REVISION.${repo}}
-.  elif defined(FOSSIL_TAG.${repo})
-_FOSSIL_VERSION.${repo}=	${FOSSIL_TAG.${repo}}
-.  else
-_FOSSIL_VERSION.${repo}=	--latest
-.  endif
+FOSSIL_MODULE.${repo}?=		${repo}
+FOSSIL_VERSION.${repo}?=	--latest
 
-# Ignore modified files in the current checkout
-_FOSSIL_FLAG.${repo}=	--force ${_FOSSIL_VERSION.${repo}}
-
-# Cache support:
-#   cache file name
+# The cached archive
 _FOSSIL_DISTFILE.${repo}=	${PKGBASE}-${FOSSIL_MODULE.${repo}}.clone
-_FOSSIL_CLONE.${repo}=		${_FOSSIL_DISTDIR:Q}/${_FOSSIL_DISTFILE.${repo}:Q}
-
-#   clone remote repository and save it in directory with distfiles
-_FOSSIL_CLONE_REPO.${repo}=	\
-	if [ ! -f ${_FOSSIL_DISTDIR}/${_FOSSIL_DISTFILE.${repo}:Q} ]; then	\
-	  ${STEP_MSG} "Cloning FOSSIL archive "${_FOSSIL_DISTFILE.${repo}:Q}".";\
-	  ${SETENV} ${_FOSSIL_ENV.${repo}} ${_FOSSIL_CMD}			\
-	    clone ${_FOSSIL_CLONE_FLAGS.${repo}}				\
-	    ${FOSSIL_REPO.${repo}:Q} ${_FOSSIL_CLONE.${repo}};			\
-	fi
 
-#   open cloned repository
-_FOSSIL_OPEN_REPO.${repo}=	\
-	${MKDIR} -p ${FOSSIL_MODULE.${repo}:Q};					\
-	(									\
-		${STEP_MSG} "Opening FOSSIL repo "${_FOSSIL_DISTFILE.${repo}:Q}".";\
-		cd ${FOSSIL_MODULE.${repo}:Q}; 					\
-		${SETENV} ${_FOSSIL_ENV.${repo}} ${_FOSSIL_CMD}			\
-		  open ${_FOSSIL_CLONE.${repo}};				\
-	)
-
-#   pull changs from remote repository, save in local clone and checkout it
-_FOSSIL_PULL_VERSION.${repo}=	\
-	if [ ! -d ${FOSSIL_MODULE.${repo}:Q} ]; then				\
-	  ${STEP_MSG} "Cannot pull changes. Missing "${FOSSIL_MODULE.${repo}:Q}".";	\
-	fi;									\
-	(									\
-		cd ${FOSSIL_MODULE.${repo}:Q};					\
-		${STEP_MSG} "Pulling changes from "${_FOSSIL_FLAG.${repo}:Q}".";\
-		${SETENV} ${_FOSSIL_ENV.${repo}} ${_FOSSIL_CMD}			\
-		  pull ${FOSSIL_REPO.${repo}:Q};				\
-		${STEP_MSG} "Checkout "${_FOSSIL_VERSION.${repo}:Q}".";		\
-		${SETENV} ${_FOSSIL_ENV.${repo}} ${_FOSSIL_CMD}			\
-		  checkout ${_FOSSIL_FLAG.${repo}}				\
-	)
+# Define the shell variables used by the following commands
+_FOSSIL_CMD.vars.${repo}= \
+	repo=${FOSSIL_REPO.${repo}:Q}; \
+	module=${FOSSIL_MODULE.${repo}:Q}; \
+	archive=${_FOSSIL_DISTDIR}/${_FOSSIL_DISTFILE.${repo}:Q}; \
+	version=${FOSSIL_VERSION.${repo}:Q}
+
+# Clone remote repository and save it in directory with distfiles
+_FOSSIL_CMD.clone_repo.${repo}= \
+	if [ ! -f "$$archive" ]; then					\
+	  ${STEP_MSG} "Cloning Fossil repository $$repo.";		\
+	  ${_FOSSIL_CMD} clone "$$repo" "$$archive";			\
+	fi
 
+# Open the cloned repository
+_FOSSIL_CMD.open_repo.${repo}= \
+	${STEP_MSG} "Opening Fossil repo $${archive\#\#*/}.";		\
+	${MKDIR} "$$module";						\
+	cd "$$module";							\
+	${_FOSSIL_CMD} open "$$archive";				\
+	cd ${WRKDIR}
+
+# Pull changes from remote repository and save them in local repository
+_FOSSIL_CMD.pull.${repo}= \
+	${STEP_MSG} "Pulling changes from $$repo.";			\
+	cd "$$module";							\
+	${_FOSSIL_CMD} pull "$$repo";					\
+	cd ${WRKDIR}
+
+# Check out the desired version from the local repository
+_FOSSIL_CMD.checkout.${repo}= \
+	${STEP_MSG} "Checking out $$version.";				\
+	cd "$$module";							\
+	${_FOSSIL_CMD} checkout --force "$$version";			\
+	cd ${WRKDIR}
 .endfor
 
 pre-extract: do-fossil-extract
 
-.PHONY: do-fossil-extract
-do-fossil-extract:
-.for _repo_ in ${FOSSIL_REPOSITORIES}
-	${RUN} cd ${WRKDIR};							\
-	if [ ! -d ${_FOSSIL_DISTDIR:Q} ]; then 					\
-		mkdir -p ${_FOSSIL_DISTDIR:Q};					\
-	fi;									\
-	${_FOSSIL_CLONE_REPO.${_repo_}};					\
-	${_FOSSIL_OPEN_REPO.${_repo_}};						\
-	${_FOSSIL_PULL_VERSION.${_repo_}};
-
+do-fossil-extract: .PHONY
+.for repo in ${FOSSIL_REPOSITORIES}
+	${RUN} cd ${WRKDIR};						\
+	${MKDIR} ${_FOSSIL_DISTDIR:Q};					\
+	${_FOSSIL_CMD.vars.${repo}};					\
+	${_FOSSIL_CMD.clone_repo.${repo}};				\
+	${_FOSSIL_CMD.open_repo.${repo}};				\
+	${_FOSSIL_CMD.pull.${repo}};					\
+	${_FOSSIL_CMD.checkout.${repo}};
 .endfor
 
 # Debug info for show-all and show-all-fossil
 _VARGROUPS+=		fossil
-_PKG_VARS.fossil+=	FOSSIL_REPO FOSSIL_MODULE FOSSIL_REPOSITORIES
+_PKG_VARS.fossil+=	FOSSIL_REPO FOSSIL_MODULE FOSSIL_VERSION FOSSIL_REPOSITORIES
 _SYS_VARS.fossil+=	DISTFILES PKGREVISION WRKSRC
-_SYS_VARS.fossil+=	_FOSSIL_PKGVERSION _FOSSIL_DISTDIR
+_SYS_VARS.fossil+=	_FOSSIL_DISTDIR
 .for repo in ${FOSSIL_REPOSITORIES}
-.  for varbase in FOSSIL_REPO FOSSIL_MODULE FOSSIL_ENV FOSSIL_BRANCH FOSSIL_REVISION FOSSIL_TAG
+.  for varbase in FOSSIL_REPO FOSSIL_MODULE FOSSIL_VERSION
 _PKG_VARS.fossil+=	${varbase}.${repo}
 .  endfor
-.  for varbase in _FOSSIL_ENV _FOSSIL_FLAG _FOSSIL_DISTFILE _FOSSIL_CLONE
+.  for varbase in _FOSSIL_DISTFILE
 _SYS_VARS.fossil+=	${varbase}.${repo}
 .  endfor
 .endfor
diff --git a/mk/git-package.mk b/mk/git-package.mk
index c853608f95..97e4781a28 100644
--- a/mk/git-package.mk
+++ b/mk/git-package.mk
@@ -1,11 +1,13 @@
 # $NetBSD$
 #
 # This file provides simple access to Git repositories, so that packages
-# can be created from Git instead of from released tarballs.
+# can be created from Git instead of from released tarballs. Whenever a
+# package is fetched from Git, an archive is created from it and saved
+# below ${DISTDIR}, to save bandwidth.
 #
 # Package-settable variables:
 #
-# GIT_REPO
+# GIT_REPO (required)
 #	The URL of the Git repository.
 #
 #	If the package needs more than one repository, see GIT_REPOSITORIES
@@ -55,23 +57,24 @@
 #	above GIT_REPO.
 #
 #	Example:
-#
-#		GIT_REPOSITORIES=	first second
-#		GIT_MODULE.first=	first
-#		GIT_REPO.first=		git://git%github.com@localhost:NetBSD/pkgsrc.git
-#		GIT_REVISION.first=	8a311b3069ee79731eec38ca13eb13772cc49223
-#		GIT_MODULE.second=	second
-#		GIT_REPO.second=	git://git%github.com@localhost:NetBSD/pkgsrc.git
-#		GIT_BRANCH.second=	master
+#	GIT_REPOSITORIES=	first second
+#	GIT_MODULE.first=	first
+#	GIT_REPO.first=		git://git%github.com@localhost:NetBSD/pkgsrc.git
+#	GIT_REVISION.first=	8a311b3069ee79731eec38ca13eb13772cc49223
+#	GIT_MODULE.second=	second
+#	GIT_REPO.second=	git://git%github.com@localhost:NetBSD/pkgsrc.git
+#	GIT_BRANCH.second=	master
 #
 # Variables set by this file:
 #
 # DISTFILES
-#	Defaults to an empty list, which means that MASTER_SITES does not
-#	need to be defined.
+#	Defaults to an empty list.
+#	This means that MASTER_SITES does not need to be defined.
 #
 # PKGREVISION
-#	Defaults to the current date in the format yyyymmdd, e.g. 20180225.
+#	Defaults to today in the format yyyymmdd, e.g. 20180225.
+#	This keeps the packages distinguishable since the HEAD might
+#	change anytime.
 #
 # Keywords: git github
 
@@ -91,16 +94,16 @@ PKGREVISION?=		${_GIT_PKGVERSION:S/.//g}
 # End of the interface part. Start of the implementation part.
 #
 
-# The standard case of a single repository
+# The common case of a single repository
 .if defined(GIT_REPO)
+GIT_MODULE._default?=	${GIT_REPO:T:.git=}
 GIT_REPOSITORIES+=	_default
+WRKSRC?=		${WRKDIR}/${GIT_MODULE._default}
 .  for varbase in GIT_REPO GIT_BRANCH GIT_REVISION GIT_TAG GIT_ENV
 .    if defined(${varbase})
 ${varbase}._default=	${${varbase}}
 .    endif
 .  endfor
-GIT_MODULE._default?=	${GIT_REPO:T:.git=}
-WRKSRC?=		${WRKDIR}/${GIT_MODULE._default}
 .endif
 
 #
@@ -132,12 +135,14 @@ _GIT_DISTDIR=		${DISTDIR}/git-packages
 
 #
 # Generation of repository-specific variables
-
+#
 
 .for repo in ${GIT_REPOSITORIES}
 GIT_MODULE.${repo}?=	${repo}
 _GIT_ENV.${repo}=	${GIT_ENV.${repo}}
 
+_GIT_CMDLINE.${repo}=	${SETENV} ${_GIT_ENV.${repo}} ${_GIT_CMD}
+
 # determine appropriate checkout branch or tag
 .  if defined(GIT_BRANCH.${repo})
 _GIT_FLAG.${repo}=	origin/${GIT_BRANCH.${repo}}
@@ -158,57 +163,63 @@ _GIT_FETCH_FLAGS.${repo}+=	--depth 1
 _GIT_CLONE_FLAGS.${repo}+=	--depth 1
 . endif
 
-# Cache support:
-#   cache file name
+# The cached archive
 _GIT_DISTFILE.${repo}=	${PKGBASE}-${GIT_MODULE.${repo}}-gitarchive.tar.gz
 
-#   command to extract cache file
-_GIT_EXTRACT_CACHED.${repo}=	\
-	if [ -f ${_GIT_DISTDIR}/${_GIT_DISTFILE.${repo}:Q} ]; then		\
-	  ${STEP_MSG} "Extracting cached Git archive "${_GIT_DISTFILE.${repo}:Q}"."; \
-	  gzip -d -c ${_GIT_DISTDIR}/${_GIT_DISTFILE.${repo}:Q} | pax -r;	\
+# Define the shell variables used by the following commands
+_GIT_CMD.vars.${repo}= \
+	repo=${GIT_REPO.${repo}:Q}; \
+	module=${GIT_MODULE.${repo}:Q}; \
+	archive=${_GIT_DISTDIR}/${_GIT_DISTFILE.${repo}:Q}
+
+# Extract the cached archive
+_GIT_CMD.extract_archive.${repo}= \
+	if [ -f "$$archive" ]; then					\
+	  ${STEP_MSG} "Extracting cached Git archive $${archive\#\#*/}."; \
+	  gzip -d -c "$$archive" | pax -r;				\
 	fi
 
-#   create cache archive
-_GIT_CREATE_CACHE.${repo}=	\
-	${STEP_MSG} "Creating cached Git archive "${_GIT_DISTFILE.${repo}:Q}"."; \
-	${MKDIR} ${_GIT_DISTDIR:Q};					\
-	pax -w ${GIT_MODULE.${repo}:Q} | gzip > ${_GIT_DISTDIR}/${_GIT_DISTFILE.${repo}:Q}.tmp;	\
-	${MV} '${_GIT_DISTDIR}/${_GIT_DISTFILE.${repo}:Q}.tmp' '${_GIT_DISTDIR}/${_GIT_DISTFILE.${repo}:Q}'
-
-#   fetch Git repo or update cached one
-_GIT_FETCH_REPO.${repo}=	\
-	if [ ! -d ${GIT_MODULE.${repo}:Q} ]; then				\
-	  ${STEP_MSG} "Cloning Git archive "${GIT_MODULE.${repo}:Q}".";		\
-	  ${SETENV} ${_GIT_ENV.${repo}} ${_GIT_CMD}				\
-	    clone ${_GIT_CLONE_FLAGS.${repo}}					\
-	    ${GIT_REPO.${repo}:Q} ${GIT_MODULE.${repo}:Q};			\
-	fi;									\
-	${STEP_MSG} "Fetching remote branches of "${_GIT_FLAG.${repo}:Q}".";	\
-	${SETENV} ${_GIT_ENV.${repo}} ${_GIT_CMD} -C ${GIT_MODULE.${repo}:Q}	\
-	  remote set-branches origin '*';					\
-	${STEP_MSG} "Updating Git archive "${GIT_MODULE.${repo}:Q}".";		\
-	${SETENV} ${_GIT_ENV.${repo}} ${_GIT_CMD} -C ${GIT_MODULE.${repo}:Q}	\
-	  fetch ${_GIT_FETCH_FLAGS.${repo}};					\
-	${STEP_MSG} "Checking out Git "${_GIT_FLAG.${repo}:Q}".";		\
-	${SETENV} ${_GIT_ENV.${repo}} ${_GIT_CMD} -C ${GIT_MODULE.${repo}:Q}	\
-	  checkout ${_GIT_CHECKOUT_FLAGS} ${_GIT_FLAG.${repo}:Q};		\
-	${STEP_MSG} "Updating submodules of "${_GIT_FLAG.${repo}:Q}".";		\
-	${SETENV} ${_GIT_ENV.${repo}} ${_GIT_CMD} -C ${GIT_MODULE.${repo}:Q}	\
-	  submodule update --recursive
+# Check out and update the repository
+_GIT_CMD.checkout.${repo}= \
+	if [ ! -d "$$module" ]; then					\
+	  ${STEP_MSG} "Cloning Git archive $$module.";			\
+	  ${_GIT_CMDLINE.${repo}}					\
+	    clone ${_GIT_CLONE_FLAGS.${repo}} "$$repo" "$$module";	\
+	fi;								\
+	\
+	${STEP_MSG} "Fetching remote branches of "${_GIT_FLAG.${repo}:Q}"."; \
+	${_GIT_CMDLINE.${repo}} -C "$$module"				\
+	  remote set-branches origin '*';				\
+	\
+	${STEP_MSG} "Updating Git archive $$module.";			\
+	${_GIT_CMDLINE.${repo}} -C "$$module"				\
+	  fetch ${_GIT_FETCH_FLAGS.${repo}};				\
+	\
+	${STEP_MSG} "Checking out Git "${_GIT_FLAG.${repo}:Q}".";	\
+	${_GIT_CMDLINE.${repo}} -C "$$module"				\
+	  checkout ${_GIT_CHECKOUT_FLAGS} ${_GIT_FLAG.${repo}:Q};	\
+	\
+	${STEP_MSG} "Updating submodules of $$module.";			\
+	${_GIT_CMDLINE.${repo}} -C "$$module" submodule update --recursive
+
+# Create the cached archive from the checked out repository
+_GIT_CMD.create_archive.${repo}= \
+	${STEP_MSG} "Creating cached Git archive $${archive\#\#*/}.";	\
+	${MKDIR} "$${archive%/*}";					\
+	pax -w "$$module" | gzip > "$$archive.tmp";			\
+	${MV} "$$archive.tmp" "$$archive"
 .endfor
 
 pre-extract: do-git-extract
 
-.PHONY: do-git-extract
-do-git-extract:
+do-git-extract: .PHONY
 .for repo in ${GIT_REPOSITORIES}
-	${RUN} cd ${WRKDIR};							\
-	if [ ! -d ${_GIT_DISTDIR:Q} ]; then mkdir -p ${_GIT_DISTDIR:Q}; fi;	\
-	${_GIT_EXTRACT_CACHED.${repo}};						\
-	${_GIT_FETCH_REPO.${repo}};						\
-	${_GIT_CREATE_CACHE.${repo}};
-
+	${RUN} \
+	cd ${WRKDIR}; \
+	${_GIT_CMD.vars.${repo}}; \
+	${_GIT_CMD.extract_archive.${repo}}; \
+	${_GIT_CMD.checkout.${repo}}; \
+	${_GIT_CMD.create_archive.${repo}}
 .endfor
 
 # Debug info for show-all and show-all-git
diff --git a/mk/svn-package.mk b/mk/svn-package.mk
index 98f285f102..ae9031301f 100644
--- a/mk/svn-package.mk
+++ b/mk/svn-package.mk
@@ -1,14 +1,19 @@
 # $NetBSD$
 #
-# This file provides simple access to svn repositories, so that packages
-# can be created from svn instead of from released tarballs.
+# This file provides simple access to Subversion repositories, so that
+# packages can be created from Subversion instead of from released
+# tarballs. Whenever a package is fetched from Subversion, an archive
+# is created from it and saved below ${DISTDIR}, to save bandwidth.
 #
 # Package-settable variables:
 #
 # SVN_REPO (required)
 #	The URL of the Subversion repository.
 #
-#	Example: http://svn.code.sf.net/p/projectname/code/trunk
+#	Example: https://svn.code.sf.net/p/projectname/code/trunk
+#
+# SVN_MODULE (optional)
+#	The directory where the files are extracted, relative to WRKDIR.
 #
 # SVN_REVISION (optional)
 #	The revision to check out.
@@ -19,20 +24,18 @@
 # the setup is a little more complicated, using parameterized variants of
 # the above variables.
 #
-# SVN_REPOSITORIES (required)
-#	A list of unique identifiers /id/ for which appropriate
-#	SVN_REPO must be defined.
-#
-# SVN_REPO.${id} (required)
-#	The svn repository
-#
-# SVN_MODULE.${id} (optional)
-#	The svn module to check out.
+# SVN_REPOSITORIES (optional)
+#	For packages that need multiple Subversion repositories, this is the list
+#	of repository IDs. Each of these repositories is configured separately,
+#	using parameterized variables like SVN_REPO.${repo} instead of the
+#	above SVN_REPO.
 #
-#	Default value: ${id}
-#
-# SVN_REVISION.${id} (optional)
-#	The revision to check out.
+#	Example:
+#	SVN_REPOSITORIES=	stable latest
+#	SVN_REPO.stable=	https://svn.code.sf.net/p/project/code/tag/1.0.0
+#	SVN_MODULE.stable=	stable
+#	SVN_REPO.latest=	https://svn.code.sf.net/p/project/code/trunk
+#	SVN_MODULE.latest=	latest
 #
 # SVN_ENV.${id} (optional)
 #	The environment for the svn command.
@@ -49,7 +52,7 @@ BUILD_DEPENDS+=		subversion-base-[0-9]*:../../devel/subversion-base
 #
 
 DISTFILES?=		# empty
-PKGREVISION?=		${_SVN_PKGVERSION:S/.//g}
+PKGREVISION?=		${_SVN_PKGREVISION_CMD:sh}
 
 #
 # End of the interface part. Start of the implementation part.
@@ -57,7 +60,7 @@ PKGREVISION?=		${_SVN_PKGVERSION:S/.//g}
 
 # The common case of a single repository.
 .if defined(SVN_REPO)
-SVN_MODULE?=		${SVN_REPO:S,/$,,:S,/trunk,,:S,/code,,:T}
+SVN_MODULE?=		${SVN_REPO:S,/$,,:S,/trunk$,,:S,/code$,,:T}
 SVN_REPOSITORIES+=	_default
 SVN_REPO._default=	${SVN_REPO}
 SVN_MODULE._default=	${SVN_MODULE}
@@ -73,9 +76,9 @@ PKG_FAIL_REASON+=	"[svn-package.mk] SVN_REPOSITORIES must be set."
 SVN_REPOSITORIES?=	# none
 .endif
 
-.for _repo_ in ${SVN_REPOSITORIES}
-.  if !defined(SVN_REPO.${_repo_})
-PKG_FAIL_REASON+=	"[svn-package.mk] SVN_REPO."${_repo_:Q}" must be set."
+.for repo in ${SVN_REPOSITORIES}
+.  if !defined(SVN_REPO.${repo})
+PKG_FAIL_REASON+=	"[svn-package.mk] SVN_REPO."${repo:Q}" must be set."
 .  endif
 .endfor
 
@@ -88,84 +91,83 @@ USE_TOOLS+=		date pax
 _SVN_CMD=		svn
 _SVN_CONFIG_DIR=	${WRKDIR}/.subversion
 _SVN_CHECKOUT_FLAGS=	--config-dir=${_SVN_CONFIG_DIR} --non-interactive
-_SVN_PKGVERSION_CMD=	${DATE} -u +'%Y.%m.%d'
-_SVN_PKGVERSION=	${_SVN_PKGVERSION_CMD:sh}
+_SVN_PKGREVISION_CMD=	${DATE} -u +'%Y%m%d'
 _SVN_DISTDIR=		${DISTDIR}/svn-packages
 
 #
 # Generation of repository-specific variables
-
+#
 
 .for repo in ${SVN_REPOSITORIES}
 SVN_MODULE.${repo}?=	${repo}
+SVN_REVISION.${repo}?=	HEAD
 _SVN_ENV.${repo}=	${SVN_ENV.${repo}}
 
-# determine appropriate checkout option
-.  if defined(SVN_REVISION.${repo})
-_SVN_FLAG.${repo}=	-r ${SVN_REVISION.${repo}}
-.  else
-_SVN_FLAG.${repo}=	-r HEAD
-.  endif
-
-# Cache support:
-#   cache file name
+# The cached archive
 _SVN_DISTFILE.${repo}=	${PKGBASE}-${SVN_MODULE.${repo}}-svnarchive.tar.gz
 
-#   command to extract cache file
-_SVN_EXTRACT_CACHED.${repo}=	\
-	if [ -f ${_SVN_DISTDIR}/${_SVN_DISTFILE.${repo}:Q} ]; then		\
-	  ${STEP_MSG} "Extracting cached SVN archive "${_SVN_DISTFILE.${repo}:Q}"."; \
-	  gzip -d -c ${_SVN_DISTDIR}/${_SVN_DISTFILE.${repo}:Q} | pax -r;	\
+# Define the shell variables used by the following commands
+_SVN_CMD.vars.${repo}= \
+	repo=${SVN_REPO.${repo}:Q}; \
+	module=${SVN_MODULE.${repo}:Q}; \
+	archive=${_SVN_DISTDIR}/${_SVN_DISTFILE.${repo}:Q}; \
+	revision=${SVN_REVISION.${repo}:Q}
+
+# Extract the cached archive
+_SVN_CMD.extract_archive.${repo}= \
+	if [ -f "$$archive" ]; then					\
+	  ${STEP_MSG} "Extracting cached Subversion archive $${archive\#\#*/}."; \
+	  gzip -d -c "$$archive" | pax -r;				\
 	fi
 
-#   create cache archive
-_SVN_CREATE_CACHE.${repo}=	\
-	${STEP_MSG} "Creating cached SVN archive "${_SVN_DISTFILE.${repo}:Q}"."; \
-	${MKDIR} ${_SVN_DISTDIR:Q};					\
-	pax -w ${SVN_MODULE.${repo}:Q} | gzip > ${_SVN_DISTDIR}/${_SVN_DISTFILE.${repo}:Q}.tmp;	\
-	${MV} '${_SVN_DISTDIR}/${_SVN_DISTFILE.${repo}:Q}.tmp' '${_SVN_DISTDIR}/${_SVN_DISTFILE.${repo}:Q}'
-
-#   fetch svn repo or update cached one
-_SVN_FETCH_REPO.${repo}=	\
-	if [ ! -d ${SVN_MODULE.${repo}:Q} ]; then				\
-	  ${STEP_MSG} "Cloning SVN repository "${SVN_MODULE.${repo}:Q}".";	\
-	  ${SETENV} ${_SVN_ENV.${repo}} ${_SVN_CMD}				\
-	    checkout ${_SVN_FLAG.${repo}} ${SVN_CHECKOUT_FLAGS}			\
-	    ${SVN_REPO.${repo}:Q} ${SVN_MODULE.${repo}:Q};			\
-	else									\
-	  ${STEP_MSG} "Updating SVN repository "${_SVN_FLAG.${repo}:Q}".";	\
-	  ${SETENV} ${_SVN_ENV.${repo}} ${_SVN_CMD}				\
-	    update ${_SVN_FLAG.${repo}} ${SVN_CHECKOUT_FLAGS}			\
-	    ${SVN_MODULE.${repo}:Q};						\
+# Check out the repository or update the cached one
+_SVN_CMD.fetch_repo.${repo}= \
+	if [ ! -d "$$module" ]; then			\
+	  ${STEP_MSG} "Checking out Subversion repository $$repo.";	\
+	  ${SETENV} ${_SVN_ENV.${repo}} ${_SVN_CMD}			\
+	    checkout -r "$$revision" ${SVN_CHECKOUT_FLAGS}		\
+	    "$$repo" "$$module";					\
+	else								\
+	  ${STEP_MSG} "Updating Subversion repository $$repo.";		\
+	  ${SETENV} ${_SVN_ENV.${repo}} ${_SVN_CMD}			\
+	    update -r "$$revision" ${SVN_CHECKOUT_FLAGS} "$$module";	\
 	fi
+
+# Create the cached archive
+_SVN_CMD.create_archive.${repo}= \
+	${STEP_MSG} "Creating cached Subversion archive $${archive\#\#*/}."; \
+	${MKDIR} "$${archive%/*}";					\
+	pax -w "$$module" | gzip > "$$archive.tmp";			\
+	${MV} "$$archive.tmp" "$$archive"
 .endfor
 
 pre-extract: do-svn-extract
 
-.PHONY: do-svn-extract
-do-svn-extract:
-.for _repo_ in ${SVN_REPOSITORIES}
-.if defined(SVN_CERTS.${_repo_}) && !empty(SVN_CERTS.${_repo_})
-	${RUN}${MKDIR} -p ${_SVN_CONFIG_DIR}/auth/svn.ssl.server
-	${RUN}${CP} ${SVN_CERTS.${_repo_}} ${_SVN_CONFIG_DIR}/auth/svn.ssl.server
+do-svn-extract: .PHONY
+.for repo in ${SVN_REPOSITORIES}
+.if defined(SVN_CERTS.${repo}) && !empty(SVN_CERTS.${repo})
+	${RUN} ${MKDIR} ${_SVN_CONFIG_DIR}/auth/svn.ssl.server
+	${RUN} ${CP} ${SVN_CERTS.${repo}} ${_SVN_CONFIG_DIR}/auth/svn.ssl.server
 .endif
-	${RUN} cd ${WRKDIR};							\
-	if [ ! -d ${_SVN_DISTDIR:Q} ]; then mkdir -p ${_SVN_DISTDIR:Q}; fi;	\
-	${_SVN_EXTRACT_CACHED.${_repo_}};					\
-	${_SVN_FETCH_REPO.${_repo_}};						\
-	${_SVN_CREATE_CACHE.${_repo_}};
+	${RUN} \
+	cd ${WRKDIR}; \
+	${MKDIR} ${_SVN_DISTDIR:Q}; \
+	${_SVN_CMD.vars.${repo}}; \
+	${_SVN_CMD.extract_archive.${repo}}; \
+	${_SVN_CMD.fetch_repo.${repo}}; \
+	${_SVN_CMD.create_archive.${repo}};
 .endfor
 
 # Debug info for show-all and show-all-svn
 _VARGROUPS+=	svn
-_PKG_VARS.svn+=	SVN_REPOSITORIES
+_PKG_VARS.svn+=	SVN_REPO SVN_REVISION SVN_REPOSITORIES
 _SYS_VARS.svn+=	DISTFILES PKGREVISION
-_SYS_VARS.svn+=	_SVN_PKGVERSION _SVN_DISTDIR
+_SYS_VARS.svn+=	_SVN_DISTDIR
 .for repo in ${SVN_REPOSITORIES}
 .  for varbase in SVN_REPO SVN_MODULE SVN_REVISION SVN_CERTS
 _PKG_VARS.svn+=	${varbase}.${repo}
 .  endfor
-.  for varbase in _SVN_FLAG _SVN_DISTFILE
+.  for varbase in _SVN_DISTFILE
 _SYS_VARS.svn+=	${varbase}.${repo}
 .  endfor
 .endfor


Home | Main Index | Thread Index | Old Index