pkgsrc-WIP-changes archive

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

mk/*-package.mk: ensure consistent handling of CHECKOUT_DATE



Module Name:	pkgsrc-wip
Committed By:	Roland Illig <rillig%NetBSD.org@localhost>
Pushed By:	rillig
Date:		Sat Mar 3 11:34:51 2018 +0000
Changeset:	5f28ca43f77b51f108193c6fe0dd48148f69bd9c

Modified Files:
	mk/cvs-package.mk
	mk/fossil-package.mk
	mk/git-package.mk
	mk/hg-package.mk
	mk/svn-package.mk
Added Files:
	mk-scm-tests/DESCR
	mk-scm-tests/Makefile
	mk-scm-tests/files/test

Log Message:
mk/*-package.mk: ensure consistent handling of CHECKOUT_DATE

Made CHECKOUT_DATE work for all SCMs.

Aligned code structure of the SCM files with each other.

Aligned documentation of the SCM documentation with each other.

Removed multiple-inclusion guards since they would silently ignore all
but the first definition.

For those SCMs that install the pkgsrc packages, changed the SCM
commands to use those from ${PREFIX}.

Removed HG_DISTDIR from the public API since it is an implementation
detail that is hidden in the other SCMs, too.

Removed SVN_ENV from the public API since it was most probably a
copy-and-paste mistake from CVS. No package in pkgsrc-wip actually
uses this feature.

Added test suite for the SCM integrations.

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

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

diffstat:
 mk-scm-tests/DESCR      |   3 +
 mk-scm-tests/Makefile   |  55 +++++++++++++
 mk-scm-tests/files/test | 201 ++++++++++++++++++++++++++++++++++++++++++++++++
 mk/cvs-package.mk       |  86 ++++++---------------
 mk/fossil-package.mk    |  96 +++++++++++------------
 mk/git-package.mk       |  91 +++++++++++-----------
 mk/hg-package.mk        | 175 +++++++++++++++++------------------------
 mk/svn-package.mk       |  94 ++++++++++------------
 8 files changed, 488 insertions(+), 313 deletions(-)

diffs:
diff --git a/mk-scm-tests/DESCR b/mk-scm-tests/DESCR
new file mode 100644
index 0000000000..92625353c1
--- /dev/null
+++ b/mk-scm-tests/DESCR
@@ -0,0 +1,3 @@
+This pseudo package ensures that the various source code management
+systems in wip/mk work similarly to each other and handle the typical use
+cases correctly.
diff --git a/mk-scm-tests/Makefile b/mk-scm-tests/Makefile
new file mode 100644
index 0000000000..b9eee9a0d0
--- /dev/null
+++ b/mk-scm-tests/Makefile
@@ -0,0 +1,55 @@
+# $NetBSD$
+
+DISTNAME=	pkgbase-1.0
+CATEGORIES=	pkgtools
+PLIST_SRC=	# none
+
+MAINTAINER=	rillig%NetBSD.org@localhost
+HOMEPAGE=	https://www.pkgsrc.org/
+COMMENT=	System tests for wip/mk infrastructure
+LICENSE=	2-clause-bsd
+
+.if empty(SCM_UNDER_TEST)
+DISTNAME=	mk-scm-tests-1.0
+DISTFILES=	# none
+NO_CHECKSUM=	yes
+NO_BUILD=	yes
+USE_TOOLS+=	bash
+
+run-tests: .PHONY
+	${BASH} files/test
+
+do-install:
+	${DO_NADA}
+.endif
+
+.include "../../mk/bsd.prefs.mk"
+
+SCM_UNDER_TEST?=	# none; is set by files/test
+
+.if ${SCM_UNDER_TEST} == CVS
+CVS_ROOT=	${.CURDIR}/tmp/repo
+.include "../../wip/mk/cvs-package.mk"
+.endif
+
+.if ${SCM_UNDER_TEST} == Fossil
+FOSSIL_REPO=	${.CURDIR}/tmp/repo/pkgbase/pkgbase.fossil
+.include "../../wip/mk/fossil-package.mk"
+.endif
+
+.if ${SCM_UNDER_TEST} == Git
+GIT_REPO=	${.CURDIR}/tmp/repo/pkgbase
+.include "../../wip/mk/git-package.mk"
+.endif
+
+.if ${SCM_UNDER_TEST} == Mercurial
+HG_REPO=	${.CURDIR}/tmp/repo/pkgbase
+.include "../../wip/mk/hg-package.mk"
+.endif
+
+.if ${SCM_UNDER_TEST} == Subversion
+SVN_REPO=	file://${.CURDIR}/tmp/repo/pkgbase
+.include "../../wip/mk/svn-package.mk"
+.endif
+
+.include "../../mk/bsd.pkg.mk"
diff --git a/mk-scm-tests/files/test b/mk-scm-tests/files/test
new file mode 100644
index 0000000000..6ec5a8fdce
--- /dev/null
+++ b/mk-scm-tests/files/test
@@ -0,0 +1,201 @@
+#! /usr/pkg/bin/bash
+set -eu
+
+step() {
+	echo ""
+	echo "T: $*" 1>&2
+}
+
+die() {
+	echo "E: $*" 1>&2
+	exit 1
+}
+
+# Sets up a repository in $repodir, with these commits:
+# - at 2018-01-01TZ, the file "today" contains "2018-01-01".
+# - at 2018-03-01TZ, the file "today" contains "2018-03-01".
+setup_repository() {
+	rm -rf "$repodir"
+
+	case "$1" in
+	(CVS)		setup_cvs_repository	;;
+	(Fossil)	setup_fossil_repository	;;
+	(Git)		setup_git_repository	;;
+	(Mercurial)	setup_hg_repository	;;
+	(Subversion)	setup_svn_repository	;;
+	(*)		die "setup_repository $1"
+	esac
+}
+
+setup_cvs_repository() {
+	cvs -d "$repodir" init
+	mkdir "$repodir/pkgbase"
+	# CVS doesn't let the user fake the dates, therefore it was easier
+	# to just manipulate the internal repository representation.
+	cat <<EOF >"$repodir/pkgbase/today,v"
+head	1.2;
+access;
+symbols;
+locks; strict;
+comment	@# @;
+
+
+1.2
+date	2018.03.01.00.00.00;	author rillig;	state Exp;
+branches;
+next	1.1;
+commitid	b4clY6GJWjcPmVsA;
+
+1.1
+date	2018.01.01.00.00.00;	author rillig;	state Exp;
+branches;
+next	;
+commitid	eFoplWznEAOOmVsA;
+
+
+desc
+@@
+
+
+1.2
+log
+@today is 2018-03-01
+@
+text
+@2018-03-01
+@
+
+
+1.1
+log
+@today is 2018-01-01
+@
+text
+@d1 1
+a1 1
+2018-01-01
+@
+
+
+EOF
+}
+
+setup_fossil_repository() {
+	mkdir -p "$repodir/pkgbase"
+	pushd "$repodir/pkgbase"
+	fossil init --date-override "2018-01-01" pkgbase.fossil
+	fossil open "pkgbase.fossil"
+
+	echo "2018-01-01" > today
+	fossil add today
+	fossil commit -m "today is 2018-01-01" --date-override "2018-01-01" --hash -- today
+
+	echo "2018-03-01" > today
+	fossil commit -m "today is 2018-03-01" --date-override "2018-03-01" --hash -- today
+
+	popd
+}
+
+setup_git_repository() {
+	git init "$repodir/pkgbase"
+	pushd "$repodir/pkgbase"
+
+	echo "2018-01-01" > today
+	git add today
+	GIT_AUTHOR_DATE="2018-01-01T00:00:00Z" GIT_COMMITTER_DATE="2018-01-01T00:00:00Z" \
+		git commit -m "today is 2018-01-01" -- today
+
+	echo "2018-03-01" > today
+	GIT_AUTHOR_DATE="2018-03-01T00:00:00Z" GIT_COMMITTER_DATE="2018-03-01T00:00:00Z" \
+		git commit -m "today is 2018-03-01" -- today
+
+	popd
+}
+
+setup_hg_repository() {
+	hg init "$repodir/pkgbase"
+	pushd "$repodir/pkgbase"
+
+	echo "2018-01-01" > today
+	hg add today
+	hg commit -m "today is 2018-01-01" -d "2018-01-01T00:00:00Z" -u "user" -- today
+
+	echo "2018-03-01" > today
+	hg commit -m "today is 2018-03-01" -d "2018-03-01T00:00:00Z" -u "user" -- today
+
+	popd
+}
+
+setup_svn_repository() {
+	mkdir "$repodir"
+	svnadmin create "$repodir/pkgbase"
+	hook="$repodir/pkgbase/hooks/pre-revprop-change"
+	printf '%s\n' '#! /bin/sh' '# allow everything' > "$hook"
+	chmod +x "$hook"
+	svn checkout "file://$repodir/pkgbase" "$basedir/svnwork"
+	pushd "$basedir/svnwork"
+
+	echo "2018-01-01" > today
+	svn add today
+	svn commit -m "today is 2018-01-01" -- today
+	svn propset "svn:date" --revprop -r HEAD "2018-01-01T00:00:00.000000Z"
+
+	echo "2018-03-01" > today
+	svn commit -m "today is 2018-03-01" -- today
+	svn propset "svn:date" --revprop -r HEAD "2018-03-01T00:00:00.000000Z"
+
+	popd
+}
+
+pkgsrc_make() {
+	DISTDIR="$basedir/distfiles" \
+	`type "bmake" 1>/dev/null 2>&1 && echo "bmake" || echo "make"` "$@"
+}
+
+assert_that() {
+	case "${1-}${3+:}${3-}${5+:}${5-}${7+:}${7-}" in
+	("--file:--has-content")
+		actual=`cat "$2"`
+		[ "$4" = "$actual" ] || die "expected file $2 to contain \"$4\", but found \"$actual\"."
+		;;
+	(*)	die "assert_that called with invalid arguments: $*"
+	esac
+}
+
+test_scm() { # usage: test_scm scm-name
+	step "Setting up $1 repository"
+	setup_repository "$1"
+	wrkdir=`pkgsrc_make show-var VARNAME=WRKDIR`
+
+	step "Testing $1"
+	SCM_UNDER_TEST="$1" pkgsrc_make clean
+	SCM_UNDER_TEST="$1" pkgsrc_make patch
+
+	assert_that --file "$wrkdir/pkgbase/today" --has-content "2018-03-01"
+
+	step "Testing $1 with CHECKOUT_DATE"
+	SCM_UNDER_TEST="$1" pkgsrc_make clean
+	SCM_UNDER_TEST="$1" CHECKOUT_DATE="2018-02-01" pkgsrc_make patch
+
+	assert_that --file "$wrkdir/pkgbase/today" --has-content "2018-01-01"
+
+	SCM_UNDER_TEST="$1" pkgsrc_make clean
+}
+
+main() {
+	basedir="$PWD/tmp"
+	repodir="$basedir/repo"
+	rm -rf "$basedir"
+	mkdir "$basedir"
+
+	test_scm "CVS"
+	test_scm "Fossil"
+	test_scm "Git"
+	test_scm "Mercurial"
+	test_scm "Subversion"
+
+	rm -rf "$basedir"
+	step "OK"
+}
+
+main
diff --git a/mk/cvs-package.mk b/mk/cvs-package.mk
index e5e47d580b..9dd2343432 100644
--- a/mk/cvs-package.mk
+++ b/mk/cvs-package.mk
@@ -38,32 +38,18 @@
 #	Default: (today at midnight)
 #	Example: v1.0.0
 #
-# 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.
-#
-# CVS_REPOSITORIES (required)
-#	A list of unique identifiers. For each of those identifiers, the
-#	following variables define the details of how to access the
-#	CVS repository.
-#
-# CVS_ROOT.${id} (required)
-#	The CVSROOT for the CVS repository, including anoncvs password,
-#	if applicable.
-#
-#	Examples:
-#		${CVS_ROOT_GNU}/emacs
-#		:pserver:anoncvs:@anoncvs.example.com:/cvsroot/project
-#
-# CVS_MODULE.${id} (optional)
-#	The CVS module to check out.
-#
-#	Default value: ${id}
-#
-# CVS_TAG.${id} (optional)
-#	The CVS tag to check out.
-#
-#	Default: ${CVS_TAG} (today at midnight)
+# CVS_REPOSITORIES (optional)
+#	If the package needs multiple CVS repositories, this
+#	is the list of repository IDs. For each of these repositories,
+#	parameterized variants of the above variables are defined.
+#
+#	Example:
+#	CVS_REPOSITORIES=	stable latest
+#	CVS_ROOT.stable=	${CVS_GNU_ROOT}/project
+#	CVS_MODULE.stable=	stable
+#	CVS_TAG.stable=		v1.2.3
+#	CVS_ROOT.latest=	${CVS_GNU_ROOT}/project/trunk
+#	CVS_MODULE.latest=	latest
 #
 # CVS_PROJECT
 #	The project name to be used in CVS_ROOT_SOURCEFORGE.
@@ -96,13 +82,7 @@
 #
 # Keywords: cvs
 
-.if !defined(_PKG_MK_CVS_PACKAGE_MK)
-_PKG_MK_CVS_PACKAGE_MK=	# defined
-
-#
-# defaults for user-visible input variables
-#
-
+# Defaults for package-settable variables
 DISTFILES?=		# empty
 PKGNAME?=		${DISTNAME:C,-[0-9].*,,}-cvs-${_CVS_PKGVERSION}
 # Enforce PKGREVISION unless CVS_TAG is set:
@@ -114,20 +94,6 @@ PKGREVISION?=		${_CVS_PKGVERSION:S/.//g}
 .  endif
 .endif
 
-#
-# definition of user-visible output variables
-#
-
-# commonly used repositories
-CVS_ROOT_GNU=		:pserver:anonymous:@cvs.savannah.gnu.org:/sources
-CVS_ROOT_NONGNU=	${CVS_ROOT_GNU}
-CVS_ROOT_SOURCEFORGE=	:pserver:anonymous:@${CVS_PROJECT}.cvs.sourceforge.net:/cvsroot/${CVS_PROJECT}
-CVS_PROJECT?=		${PKGBASE}
-
-#
-# End of the interface part. Start of the implementation part.
-#
-
 # The common case of a single repository
 .if defined(CVS_ROOT)
 CVS_MODULE?=		${PKGBASE:S,-cvs$,,}
@@ -140,25 +106,23 @@ ${varbase}._default=	${${varbase}}
 .  endfor
 .endif
 
-#
-# Input validation
-#
+# Commonly used repositories
+CVS_ROOT_GNU=		:pserver:anonymous:@cvs.savannah.gnu.org:/sources
+CVS_ROOT_NONGNU=	${CVS_ROOT_GNU}
+CVS_ROOT_SOURCEFORGE=	:pserver:anonymous:@${CVS_PROJECT}.cvs.sourceforge.net:/cvsroot/${CVS_PROJECT}
+CVS_PROJECT?=		${PKGBASE}
 
-.if !defined(CVS_REPOSITORIES)
-PKG_FAIL_REASON+=	"[cvs-package.mk] CVS_REPOSITORIES must be set."
 CVS_REPOSITORIES?=	# none
+.if empty(CVS_REPOSITORIES)
+PKG_FAIL_REASON+=	"[cvs-package.mk] CVS_REPOSITORIES must be set."
 .endif
 
 .for repo in ${CVS_REPOSITORIES}
-.  if !defined(CVS_ROOT.${repo})
+.  if empty(CVS_ROOT.${repo})
 PKG_FAIL_REASON+=	"[cvs-package.mk] CVS_ROOT."${repo:Q}" must be set."
 .  endif
 .endfor
 
-#
-# Internal variables
-#
-
 USE_TOOLS+=		date pax
 
 _CVS_RSH=		ssh
@@ -176,14 +140,10 @@ _CVS_PKGVERSION_CMD=	${DATE} -u +'%y.%m.%d'
 _CVS_PKGVERSION?=	${_CVS_PKGVERSION_CMD:sh}
 _CVS_DISTDIR=		${DISTDIR}/cvs-packages
 
-#
-# Generation of repository-specific variables
-#
-
 .for repo in ${CVS_REPOSITORIES}
 CVS_MODULE.${repo}?=		${repo}
 
-# determine appropriate checkout date or tag
+# Determine appropriate checkout date or tag
 .  if defined(CVS_TAG.${repo})
 _CVS_TAG_FLAG.${repo}=	-r${CVS_TAG.${repo}}
 _CVS_TAG.${repo}=	${CVS_TAG.${repo}}
@@ -268,5 +228,3 @@ _PKG_VARS.cvs+=		${varbase}.${repo}
 _SYS_VARS.cvs+=		${varbase}.${repo}
 .  endfor
 .endfor
-
-.endif
diff --git a/mk/fossil-package.mk b/mk/fossil-package.mk
index 7db780bed3..785bc3f38e 100644
--- a/mk/fossil-package.mk
+++ b/mk/fossil-package.mk
@@ -5,6 +5,16 @@
 # repository is fetched from Fossil, a copy of it is saved below ${DISTDIR},
 # to save bandwidth.
 #
+# User-settable variables:
+#
+# CHECKOUT_DATE (optional)
+#	Date to check out in ISO format (YYYY-MM-DD).
+#
+#	When a package doesn't specify a FOSSIL_VERSION, the latest commit
+#	is used, and the PKGREVISION is set based on the current date.
+#	To keep this date stable during a bulk build (which may span
+#	one or more midnights), this can be set to a fixed date.
+#
 # Package-settable variables:
 #
 # FOSSIL_REPO (required)
@@ -19,14 +29,10 @@
 #	Default: ${DISTNAME} without the version number
 #
 # FOSSIL_VERSION (optional)
-#	The revision, tag or branch to check out.
+#	The revision, tag, date or branch to check out.
 #
 #	Default: --latest
 #
-# Packages that access more than one Fossil repository have to list the
-# repositories in FOSSIL_REPOSITORIES and configure the remaining variables
-# for each repository individually.
-#
 # FOSSIL_REPOSITORIES (optional)
 #	If the package needs multiple Fossil repositories, this
 #	is the list of repository IDs. For each of these repositories,
@@ -41,60 +47,55 @@
 #	FOSSIL_MODULE.latest=	latest
 #	FOSSIL_VERSION.latest=	--latest
 #
+# Variables set by this file:
+#
+# DISTFILES
+#	Defaults to an empty list.
+#	This means that MASTER_SITES does not need to be defined.
+#
+# PKGREVISION
+#	If the package doesn't set a specific CVS_TAG, this defaults
+#	to today in the format yyyymmdd, e.g. 20180225.
+#	This keeps the packages distinguishable since the HEAD might
+#	change anytime.
+#
 # Keywords: fossil
 
-.if !defined(_PKG_MK_FOSSIL_PACKAGE_MK)
-_PKG_MK_FOSSIL_PACKAGE_MK=	# defined
-
 BUILD_DEPENDS+=		fossil-[0-9]*:../../devel/fossil
 
-#
-# defaults for user-visible input variables
-#
-
 DISTFILES?=		# empty
-PKGREVISION?=		${_FOSSIL_PKGREVISION_CMD:sh}
-
-#
-# End of the interface part. Start of the implementation part.
-#
+.if defined(CHECKOUT_DATE)
+PKGREVISION?=		${CHECKOUT_DATE:S/-//g}
+FOSSIL_VERSION?=	${CHECKOUT_DATE}
+.else
+PKGREVISION?=		${${DATE} -u +'%Y%m%d':L:sh}
+.endif
 
-# The common case of a single repository.
 .if defined(FOSSIL_REPO)
-FOSSIL_REPOSITORIES+=	_default
-FOSSIL_REPO._default=	${FOSSIL_REPO}
-FOSSIL_MODULE._default=	${FOSSIL_REPO:S,/$,,:T}
-WRKSRC?=		${WRKDIR}/${FOSSIL_MODULE._default}
+FOSSIL_REPOSITORIES+=	default
+FOSSIL_REPO.default=	${FOSSIL_REPO}
+FOSSIL_MODULE.default=	${DISTNAME:C,-[0-9].*,,}
+.if defined(FOSSIL_VERSION)
+FOSSIL_VERSION.default=	${FOSSIL_VERSION}
+.endif
+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
+.if empty(FOSSIL_REPOSITORIES)
+PKG_FAIL_REASON+=	"[fossil-package.mk] FOSSIL_REPOSITORIES must be set."
 .endif
 
 .for repo in ${FOSSIL_REPOSITORIES}
-.  if !defined(FOSSIL_REPO.${repo})
+.  if empty(FOSSIL_REPO.${repo})
 PKG_FAIL_REASON+=	"[fossil-package.mk] FOSSIL_REPO."${repo:Q}" must be set."
 .  endif
 .endfor
 
-#
-# Internal variables
-#
-
-USE_TOOLS+=			date pax
+USE_TOOLS+=		date pax
 
-_FOSSIL_CMD=			fossil
-_FOSSIL_PKGREVISION_CMD=	${DATE} -u +'%Y%m%d'
-_FOSSIL_DISTDIR=		${DISTDIR}/fossil-packages
-
-#
-# Generation of repository-specific variables
-#
+_FOSSIL_CMD=		${PREFIX}/bin/fossil
+_FOSSIL_DISTDIR=	${DISTDIR}/fossil-packages
 
 .for repo in ${FOSSIL_REPOSITORIES}
 FOSSIL_MODULE.${repo}?=		${repo}
@@ -122,22 +123,17 @@ _FOSSIL_CMD.open_repo.${repo}= \
 	${STEP_MSG} "Opening Fossil repo $${archive\#\#*/}.";		\
 	${MKDIR} "$$module";						\
 	cd "$$module";							\
-	${_FOSSIL_CMD} open "$$archive";				\
-	cd ${WRKDIR}
+	${_FOSSIL_CMD} open "$$archive"
 
 # 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}
+	${_FOSSIL_CMD} pull "$$repo"
 
 # 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}
+	${_FOSSIL_CMD} checkout --force "$$version"
 .endfor
 
 pre-extract: do-fossil-extract
@@ -166,5 +162,3 @@ _PKG_VARS.fossil+=	${varbase}.${repo}
 _SYS_VARS.fossil+=	${varbase}.${repo}
 .  endfor
 .endfor
-
-.endif
diff --git a/mk/git-package.mk b/mk/git-package.mk
index 97e4781a28..672e5c7a57 100644
--- a/mk/git-package.mk
+++ b/mk/git-package.mk
@@ -5,6 +5,16 @@
 # package is fetched from Git, an archive is created from it and saved
 # below ${DISTDIR}, to save bandwidth.
 #
+# User-settable variables:
+#
+# CHECKOUT_DATE (optional)
+#	Date to check out in ISO format (YYYY-MM-DD).
+#
+#	When a package doesn't specify a GIT_TAG, it is checked out from
+#	the HEAD revision, and the PKGREVISION is set based on the date.
+#	To keep this date stable during a bulk build (which may span
+#	one or more midnights), this can be set to a fixed date.
+#
 # Package-settable variables:
 #
 # GIT_REPO (required)
@@ -32,7 +42,7 @@
 # GIT_BRANCH (optional)
 #	The branch to check out.
 #
-#	This should seldomly be used since it prevents the build from being
+#	This should seldom be used since it prevents the build from being
 #	reproducible. Prefer a tag or a revision instead.
 #
 # GIT_REVISION (optional)
@@ -78,53 +88,39 @@
 #
 # Keywords: git github
 
-.if !defined(_PKG_MK_GIT_PACKAGE_MK)
-_PKG_MK_GIT_PACKAGE_MK=	# defined
-
 BUILD_DEPENDS+=		git-base>=1.6.4:../../devel/git-base
 
-#
-# defaults for user-visible input variables
-#
-
+# Defaults for package-settable variables
 DISTFILES?=		# empty
+.if defined(CHECKOUT_DATE)
+PKGREVISION?=		${CHECKOUT_DATE:S/-//g}
+.else
 PKGREVISION?=		${_GIT_PKGVERSION:S/.//g}
-
-#
-# End of the interface part. Start of the implementation part.
-#
+.endif
 
 # 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}
+GIT_REPOSITORIES+=	default
+GIT_MODULE.default?=	${GIT_REPO:T:.git=}
+WRKSRC?=		${WRKDIR}/${GIT_MODULE.default}
 .  for varbase in GIT_REPO GIT_BRANCH GIT_REVISION GIT_TAG GIT_ENV
 .    if defined(${varbase})
-${varbase}._default=	${${varbase}}
+${varbase}.default=	${${varbase}}
 .    endif
 .  endfor
 .endif
 
-#
-# Input validation
-#
-
-.if !defined(GIT_REPOSITORIES)
-PKG_FAIL_REASON+=	"[git-package.mk] GIT_REPOSITORIES must be set."
 GIT_REPOSITORIES?=	# none
+.if empty(GIT_REPOSITORIES)
+PKG_FAIL_REASON+=	"[git-package.mk] GIT_REPOSITORIES must be set."
 .endif
 
 .for repo in ${GIT_REPOSITORIES}
-.  if !defined(GIT_REPO.${repo})
+.  if empty(GIT_REPO.${repo})
 PKG_FAIL_REASON+=	"[git-package.mk] GIT_REPO."${repo:Q}" must be set."
 .  endif
 .endfor
 
-#
-# Internal variables
-#
-
 USE_TOOLS+=		date pax
 
 _GIT_CMD=		git
@@ -133,10 +129,7 @@ _GIT_PKGVERSION_CMD=	${DATE} -u +'%Y.%m.%d'
 _GIT_PKGVERSION=	${_GIT_PKGVERSION_CMD:sh}
 _GIT_DISTDIR=		${DISTDIR}/git-packages
 
-#
-# Generation of repository-specific variables
-#
-
+# Definition of repository-specific variables
 .for repo in ${GIT_REPOSITORIES}
 GIT_MODULE.${repo}?=	${repo}
 _GIT_ENV.${repo}=	${GIT_ENV.${repo}}
@@ -145,13 +138,13 @@ _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}}
+_GIT_REV.${repo}=	origin/${GIT_BRANCH.${repo}}
 .  elif defined(GIT_REVISION.${repo})
-_GIT_FLAG.${repo}=	${GIT_REVISION.${repo}}
+_GIT_REV.${repo}=	${GIT_REVISION.${repo}}
 .  elif defined(GIT_TAG.${repo})
-_GIT_FLAG.${repo}=	tags/${GIT_TAG.${repo}}
+_GIT_REV.${repo}=	tags/${GIT_TAG.${repo}}
 .  else
-_GIT_FLAG.${repo}=	origin/HEAD
+_GIT_REV.${repo}=	origin/HEAD
 .  endif
 
 _GIT_FETCH_FLAGS.${repo}=	--quiet --recurse-submodules=yes --tags
@@ -187,19 +180,33 @@ _GIT_CMD.checkout.${repo}= \
 	    clone ${_GIT_CLONE_FLAGS.${repo}} "$$repo" "$$module";	\
 	fi;								\
 	\
-	${STEP_MSG} "Fetching remote branches of "${_GIT_FLAG.${repo}:Q}"."; \
+	${STEP_MSG} "Fetching remote branches of $$module.";		\
 	${_GIT_CMDLINE.${repo}} -C "$$module"				\
 	  remote set-branches origin '*';				\
 	\
-	${STEP_MSG} "Updating Git archive $$module.";			\
+	${STEP_MSG} "Updating Git working area $$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};	\
+	revision=${_GIT_REV.${repo}:Q};					\
+	checkout_date=${CHECKOUT_DATE:Q};				\
+	if [ "$$checkout_date" ]; then					\
+	  ${STEP_MSG} "Checking out $$revision at $$checkout_date.";	\
+	  echo "rev=$$revision";\
+	  echo "date=$$checkout_date";\
+	  ref=`${_GIT_CMDLINE.${repo}} -C "$$module" rev-list -n 1 --before="$${checkout_date}T00:00:01Z" "$$revision"`; \
+	  echo "ref=$$ref"; \
+	  [ "$$ref" ] || ${FAIL_MSG} "[git-package.mk] Cannot find commit for module $$module revision $$revision at $$checkout_date"; \
+	  ${_GIT_CMDLINE.${repo}} -C "$$module"				\
+	    checkout ${_GIT_CHECKOUT_FLAGS} "$$ref";			\
+	else								\
+	  ${STEP_MSG} "Checking out $$revision.";			\
+	  ${_GIT_CMDLINE.${repo}} -C "$$module"				\
+	    checkout ${_GIT_CHECKOUT_FLAGS} "$$revision";		\
+	fi;								\
 	\
 	${STEP_MSG} "Updating submodules of $$module.";			\
+	: "XXX: The revision of the submodules is not correct";		\
 	${_GIT_CMDLINE.${repo}} -C "$$module" submodule update --recursive
 
 # Create the cached archive from the checked out repository
@@ -231,9 +238,7 @@ _SYS_VARS.git=		DISTFILES PKGREVISION WRKSRC
 .  for varbase in GIT_REPO GIT_MODULE GIT_BRANCH GIT_REVISION GIT_TAG GIT_ENV
 _PKG_VARS.git+=		${varbase}.${repo}
 .  endfor
-.  for varbase in _GIT_FLAG _GIT_DISTFILE
+.  for varbase in _GIT_REV _GIT_DISTFILE
 _SYS_VARS.git+=		${varbase}.${repo}
 .  endfor
 .endfor
-
-.endif
diff --git a/mk/hg-package.mk b/mk/hg-package.mk
index 781281804d..f91190941c 100644
--- a/mk/hg-package.mk
+++ b/mk/hg-package.mk
@@ -3,16 +3,17 @@
 # This file provides simple access to Mercurial repositories, so that packages
 # can be created from Mercurial instead of from released tarballs.
 #
-# === User-settable variables ===
+# User-settable variables:
 #
-# CHECKOUT_DATE
+# CHECKOUT_DATE (optional)
 #	Date to check out in ISO format (YYYY-MM-DD).
 #
-# HG_DISTDIR
-#	A directory where to store the cached repositories (default:
-#	distfiles/hg-packages)
+#	When a package doesn't specify a HG_TAG, it is checked out from
+#	the HEAD revision, and the PKGREVISION is set based on the date.
+#	To keep this date stable during a bulk build (which may span
+#	one or more midnights), this can be set to a fixed date.
 #
-# === Package-settable variables ===
+# Package-settable variables:
 #
 # HG_REPO (required)
 #	The Mercurial repository URL.
@@ -29,92 +30,61 @@
 # the above variables.
 #
 # HG_REPOSITORIES (required)
-#	A list of unique identifiers /id/ for which appropriate
-#	HG_REPO must be defined.
+#	If the package needs multiple Mercurial repositories, this
+#	is the list of repository IDs. For each of these repositories,
+#	parameterized variants of the above variables are defined.
 #
-# HG_REPO.${id} (required)
-#	The Mercurial repository URL.
-#
-#	Example: https://hg.mozilla.org/projects/nspr
-#
-# HG_TAG.${id} (optional)
-#	The Mercurial tag to check out.
-#
-#	Default: ${HG_TAG}
-#
-# HG_TAG (optional)
-#	The fallback Mercurial tag to check out.
-#
-#	Default: HEAD
+#	Example:
+#	HG_REPOSITORIES=	stable latest
+#	HG_REPO.stable=		https://hg.mozilla.org/projects/nspr
+#	HG_TAG.stable=		v1.2.3
+#	HG_REPO.latest=		https://hg.mozilla.org/projects/nspr
 #
-
-.if !defined(_PKG_MK_HG_PACKAGE_MK)
-_PKG_MK_HG_PACKAGE_MK=	# defined
+# Keywords: hg mercurial
 
 BUILD_DEPENDS+=		mercurial>=0.9:../../devel/mercurial
 
-#
-# defaults for user-visible input variables
-#
-
+# Defaults for package-settable variables
 DISTFILES?=		# empty
 PKGNAME?=		${DISTNAME:C,-[0-9].*,,}-hg-${_HG_PKGVERSION}
-# Enforce PKGREVISION unless HG_TAG is set:
 .if empty(HG_TAG)
-. if defined(CHECKOUT_DATE)
+.  if defined(CHECKOUT_DATE)
 PKGREVISION?=		${CHECKOUT_DATE:S/-//g}
-. else
+.  else
 PKGREVISION?=		${_HG_PKGVERSION:S/.//g}
-. endif
+.  endif
 .endif
 
-#
-# definition of user-visible output variables
-#
-
-#
-# End of the interface part. Start of the implementation part.
-#
-
-# The common case of a single repository.
+# The common case of a single repository
 .if defined(HG_REPO)
 HG_MODULE?=		${HG_REPO:S,/$,,:T}
-HG_REPOSITORIES+=	_default
-HG_REPO._default=	${HG_REPO}
-HG_MODULE._default=	${HG_MODULE}
+HG_REPOSITORIES+=	default
+HG_REPO.default=	${HG_REPO}
+HG_MODULE.default=	${HG_MODULE}
 WRKSRC?=		${WRKDIR}/${HG_MODULE}
 .endif
 
-#
-# Input validation
-#
-
-.if !defined(HG_REPOSITORIES)
-PKG_FAIL_REASON+=	"[hg-package.mk] HG_REPOSITORIES must be set."
 HG_REPOSITORIES?=	# none
+.if empty(HG_REPOSITORIES)
+PKG_FAIL_REASON+=	"[hg-package.mk] HG_REPOSITORIES must be set."
 .endif
 
-.for _repo_ in ${HG_REPOSITORIES}
-.  if !defined(HG_REPO.${_repo_})
-PKG_FAIL_REASON+=	"[hg-package.mk] HG_REPO."${_repo_:Q}" must be set."
+.for repo in ${HG_REPOSITORIES}
+.  if empty(HG_REPO.${repo})
+PKG_FAIL_REASON+=	"[hg-package.mk] HG_REPO."${repo:Q}" must be set."
 .  endif
 .endfor
 
-#
-# Internal variables
-#
-
 USE_TOOLS+=		date pax
 
-_HG_CMD=		hg
-_HG_ENV=		# empty
+_HG_CMD=		${PREFIX}/bin/hg
 _HG_FLAGS=		-q
-_HG_CONFIG_DIR=	${WRKDIR}/.hg
+_HG_CONFIG_DIR=		${WRKDIR}/.hg
 _HG_TODAY_CMD=		${DATE} -u +'%Y-%m-%d'
 _HG_TODAY=		${_HG_TODAY_CMD:sh}
 _HG_PKGVERSION_CMD=	${DATE} -u +'%Y.%m.%d'
 _HG_PKGVERSION=		${_HG_PKGVERSION_CMD:sh}
-HG_DISTDIR?=		${DISTDIR}/hg-packages
+_HG_DISTDIR?=		${DISTDIR}/hg-packages
 
 #
 # Generation of repository-specific variables
@@ -131,7 +101,7 @@ _HG_TAG.${repo}=	${HG_TAG.${repo}}
 _HG_TAG_FLAG.${repo}=	-r${HG_TAG}
 _HG_TAG.${repo}=	${HG_TAG}
 .  elif defined(CHECKOUT_DATE)
-_HG_TAG_FLAG.${repo}=	-d${CHECKOUT_DATE:Q}
+_HG_TAG_FLAG.${repo}=	-d<${CHECKOUT_DATE:Q}
 _HG_TAG.${repo}=	${CHECKOUT_DATE:Q}
 .  else
 _HG_TAG_FLAG.${repo}=	-d<${_HG_TODAY} 00:00:00
@@ -142,64 +112,65 @@ _HG_TAG.${repo}=	${_HG_TODAY:Q}
 #   cache file name
 _HG_DISTFILE.${repo}=	${PKGBASE}-${HG_MODULE.${repo}}-${_HG_TAG.${repo}}.tar.gz
 
-#   command to extract cache file
-_HG_EXTRACT_CACHED.${repo}=	\
-	if [ -f ${HG_DISTDIR}/${_HG_DISTFILE.${repo}:Q} ]; then		\
-	  ${STEP_MSG} "Extracting cached Mercurial archive "${_HG_DISTFILE.${repo}:Q}"."; \
-	  gzip -d -c ${HG_DISTDIR}/${_HG_DISTFILE.${repo}:Q} | pax -r;	\
+# Define the shell variables used by the following commands
+_HG_CMD.vars.${repo}= \
+	repo=${HG_REPO.${repo}:Q};					\
+	module=${HG_MODULE.${repo}:Q};					\
+	archive=${_HG_DISTDIR}/${_HG_DISTFILE.${repo}:Q}
+
+# Extract the cached archive
+_HG_CMD.extract_archive.${repo}= \
+	if [ -f "$$archive" ]; then		\
+	  ${STEP_MSG} "Extracting cached Mercurial archive $${archive\#\#*/}."; \
+	  gzip -d -c "$$archive" | pax -r;				\
 	  exit 0;							\
 	fi
 
-#   create cache archive
-_HG_CREATE_CACHE.${repo}=	\
-	${STEP_MSG} "Creating cached Mercurial archive "${_HG_DISTFILE.${repo}:Q}"."; \
-	${MKDIR} ${HG_DISTDIR:Q};					\
-	pax -w ${HG_MODULE.${repo}:Q} | gzip > ${HG_DISTDIR}/${_HG_DISTFILE.${repo}:Q}
+_HG_CMD.checkout.${repo}= \
+	${STEP_MSG} "Checking out $$module from $$repo.";		\
+	${_HG_CMD} clone ${_HG_FLAGS} "$$repo" "$$module";		\
+	${_HG_CMD} --cwd "$$module" update ${_HG_FLAGS} ${_HG_TAG_FLAG.${repo}:Q}
+
+# Create the cached archive from the checked out repository
+_HG_CMD.create_archive.${repo}= \
+	${STEP_MSG} "Creating cached Mercurial archive $${archive\#\#*/}."; \
+	${MKDIR} "$${archive%/*}";					\
+	pax -w "$$module" | gzip > "$$archive"
 .endfor
 
-.PHONY: hg-cleandir
-hg-cleandir:
-.for _repo_ in ${HG_REPOSITORIES}
+hg-cleandir: .PHONY
+.for repo in ${HG_REPOSITORIES}
 	${RUN} cd ${WRKDIR};						\
-	if [ -d ${HG_MODULE.${_repo_}:Q} ]; then			\
-		cd ${HG_MODULE.${_repo_}:Q} && rm -rf *;		\
+	if [ -d ${HG_MODULE.${repo}:Q} ]; then				\
+		cd ${HG_MODULE.${repo}:Q} && rm -rf *;			\
 	fi
 .endfor
 	${RUN} cd ${WRKDIR} && rm -f .*_done && rm -rf .cwrapper
 
 pre-extract: do-hg-extract
 
-.PHONY: do-hg-extract
-do-hg-extract:
-.for _repo_ in ${HG_REPOSITORIES}
-	${RUN} cd ${WRKDIR};						\
-	if [ ! -d ${HG_DISTDIR:Q} ]; then mkdir -p ${HG_DISTDIR:Q}; fi;	\
-	if [ ! -d ${HG_MODULE.${_repo_}:Q}/.hg ]; then			\
-		${_HG_EXTRACT_CACHED.${_repo_}};			\
-		${SETENV} ${_HG_ENV}					\
-		       ${_HG_CMD} clone ${_HG_FLAGS}			\
-			       ${HG_REPO.${_repo_}:Q}			\
-				${HG_MODULE.${_repo_}} &&		\
-		(cd ${HG_MODULE.${_repo_}:Q} && 			\
-		${SETENV} ${_HG_ENV}					\
-			${_HG_CMD} update ${_HG_FLAGS}			\
-				 ${_HG_TAG_FLAG.${_repo_}:Q}) &&	\
-		${_HG_CREATE_CACHE.${_repo_}};				\
+do-hg-extract: .PHONY
+.for repo in ${HG_REPOSITORIES}
+	${RUN}								\
+	cd ${WRKDIR};							\
+	${_HG_CMD.vars.${repo}};					\
+	if [ ! -d "$$module/.hg" ]; then				\
+		${_HG_CMD.extract_archive.${repo}};			\
+		${_HG_CMD.checkout.${repo}};				\
+		${_HG_CMD.create_archive.${repo}};			\
 	else								\
-		(cd ${HG_MODULE.${_repo_}:Q} &&				\
-		${SETENV} ${_HG_ENV}					\
-			${_HG_CMD} pull ${_HG_FLAGS} &&			\
-		${SETENV} ${_HG_ENV}					\
-			${_HG_CMD} update -C ${_HG_FLAGS})		\
+		cd "$$module";						\
+		${_HG_CMD} pull ${_HG_FLAGS};				\
+		${_HG_CMD} update -C ${_HG_FLAGS};			\
 	fi
 .endfor
 
 # Debug info for show-all and show-all-hg
 _VARGROUPS+=	hg
-_USR_VARS.hg+=	CHECKOUT_DATE HG_DISTDIR
+_USR_VARS.hg+=	CHECKOUT_DATE
 _PKG_VARS.hg+=	HG_REPO HG_MODULE HG_TAG HG_REPOSITORIES
 _SYS_VARS.hg+=	DISTFILES PKGNAME PKGREVISION WRKSRC
-_SYS_VARS.hg+=	_HG_PKGVERSION
+_SYS_VARS.hg+=	_HG_PKGVERSION _HG_DISTDIR
 .for repo in ${HG_REPOSITORIES}
 .  for varbase in HG_REPO HG_MODULE HG_TAG
 _PKG_VARS.hg+=	${varbase}.${repo}
@@ -208,5 +179,3 @@ _PKG_VARS.hg+=	${varbase}.${repo}
 _SYS_VARS.hg+=	${varbase}.${repo}
 .  endfor
 .endfor
-
-.endif
diff --git a/mk/svn-package.mk b/mk/svn-package.mk
index ae9031301f..acee0b5e1b 100644
--- a/mk/svn-package.mk
+++ b/mk/svn-package.mk
@@ -5,6 +5,16 @@
 # tarballs. Whenever a package is fetched from Subversion, an archive
 # is created from it and saved below ${DISTDIR}, to save bandwidth.
 #
+# User-settable variables:
+#
+# CHECKOUT_DATE (optional)
+#	Date to check out in ISO format (YYYY-MM-DD).
+#
+#	When a package doesn't specify a CVS_TAG, it is checked out from
+#	the HEAD revision, and the PKGREVISION is set based on the date.
+#	To keep this date stable during a bulk build (which may span
+#	one or more midnights), this can be set to a fixed date.
+#
 # Package-settable variables:
 #
 # SVN_REPO (required)
@@ -20,15 +30,10 @@
 #
 #	Example: 12345
 #
-# If a package needs to checkout from more than one Subversion repository,
-# the setup is a little more complicated, using parameterized variants of
-# the above variables.
-#
 # 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.
+#	If the package needs multiple Subversion repositories, this
+#	is the list of repository IDs. For each of these repositories,
+#	parameterized variants of the above variables are defined.
 #
 #	Example:
 #	SVN_REPOSITORIES=	stable latest
@@ -37,28 +42,19 @@
 #	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.
-#
 # Keywords: svn subversion
 
-.if !defined(_PKG_MK_SVN_PACKAGE_MK)
-_PKG_MK_SVN_PACKAGE_MK=	# defined
-
 BUILD_DEPENDS+=		subversion-base-[0-9]*:../../devel/subversion-base
 
-#
-# defaults for user-visible input variables
-#
-
+# Defaults for package-settable variables
 DISTFILES?=		# empty
+.if defined(CHECKOUT_DATE)
+PKGREVISION?=		${CHECKOUT_DATE:S/-//g}
+.else
 PKGREVISION?=		${_SVN_PKGREVISION_CMD:sh}
+.endif
 
-#
-# End of the interface part. Start of the implementation part.
-#
-
-# The common case of a single repository.
+# The common case of a single repository
 .if defined(SVN_REPO)
 SVN_MODULE?=		${SVN_REPO:S,/$,,:S,/trunk$,,:S,/code$,,:T}
 SVN_REPOSITORIES+=	_default
@@ -67,25 +63,17 @@ SVN_MODULE._default=	${SVN_MODULE}
 WRKSRC?=		${WRKDIR}/${SVN_MODULE}
 .endif
 
-#
-# Input validation
-#
-
-.if !defined(SVN_REPOSITORIES)
-PKG_FAIL_REASON+=	"[svn-package.mk] SVN_REPOSITORIES must be set."
 SVN_REPOSITORIES?=	# none
+.if empty(SVN_REPOSITORIES)
+PKG_FAIL_REASON+=	"[svn-package.mk] SVN_REPOSITORIES must be set."
 .endif
 
 .for repo in ${SVN_REPOSITORIES}
-.  if !defined(SVN_REPO.${repo})
+.  if empty(SVN_REPO.${repo})
 PKG_FAIL_REASON+=	"[svn-package.mk] SVN_REPO."${repo:Q}" must be set."
 .  endif
 .endfor
 
-#
-# Internal variables
-#
-
 USE_TOOLS+=		date pax
 
 _SVN_CMD=		svn
@@ -94,14 +82,14 @@ _SVN_CHECKOUT_FLAGS=	--config-dir=${_SVN_CONFIG_DIR} --non-interactive
 _SVN_PKGREVISION_CMD=	${DATE} -u +'%Y%m%d'
 _SVN_DISTDIR=		${DISTDIR}/svn-packages
 
-#
-# Generation of repository-specific variables
-#
-
+# Definition of repository-specific variables
 .for repo in ${SVN_REPOSITORIES}
 SVN_MODULE.${repo}?=	${repo}
+.  if defined(CHECKOUT_DATE)
+SVN_REVISION.${repo}?=	{${CHECKOUT_DATE}}
+.  else
 SVN_REVISION.${repo}?=	HEAD
-_SVN_ENV.${repo}=	${SVN_ENV.${repo}}
+.  endif
 
 # The cached archive
 _SVN_DISTFILE.${repo}=	${PKGBASE}-${SVN_MODULE.${repo}}-svnarchive.tar.gz
@@ -120,20 +108,28 @@ _SVN_CMD.extract_archive.${repo}= \
 	  gzip -d -c "$$archive" | pax -r;				\
 	fi
 
+# Install client certificates for authentication
+.if !empty(SVN_CERTS.${repo})
+_SVN_CMD.install_certs.${repo}= \
+	${MKDIR} ${_SVN_CONFIG_DIR}/auth/svn.ssl.server;		\
+	${CP} ${SVN_CERTS.${repo}} ${_SVN_CONFIG_DIR}/auth/svn.ssl.server
+.else
+_SVN_CMD.install_certs.${repo}= \
+	${DO_NADA}
+.endif
+
 # 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}		\
+	  ${_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";	\
+	  ${_SVN_CMD} update -r "$$revision" ${SVN_CHECKOUT_FLAGS} "$$module"; \
 	fi
 
-# Create the cached archive
+# Create the cached archive from the checked out repository
 _SVN_CMD.create_archive.${repo}= \
 	${STEP_MSG} "Creating cached Subversion archive $${archive\#\#*/}."; \
 	${MKDIR} "$${archive%/*}";					\
@@ -145,17 +141,13 @@ pre-extract: do-svn-extract
 
 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}; \
-	${MKDIR} ${_SVN_DISTDIR:Q}; \
 	${_SVN_CMD.vars.${repo}}; \
+	${_SVN_CMD.install_certs.${repo}}; \
 	${_SVN_CMD.extract_archive.${repo}}; \
 	${_SVN_CMD.fetch_repo.${repo}}; \
-	${_SVN_CMD.create_archive.${repo}};
+	${_SVN_CMD.create_archive.${repo}}
 .endfor
 
 # Debug info for show-all and show-all-svn
@@ -171,5 +163,3 @@ _PKG_VARS.svn+=	${varbase}.${repo}
 _SYS_VARS.svn+=	${varbase}.${repo}
 .  endfor
 .endfor
-
-.endif


Home | Main Index | Thread Index | Old Index