@@ -54,12 +54,28 @@ _plain_svn() {
_svn export --ignore-keywords ${quiet} "${@}" "'${uri}@${rev}'" "'${basename}'"
+# For 'svn info', we only need the credentials, if any; other options
+# would be invalid, as they are intended for 'svn export'.
+# We can also consume the positional parameters, as we'll no longer
+# be calling any other remote-reaching svn command.
+creds=
+while [ ${#} -gt 0 ]; do
+ case "${1}" in
+ --username=*) creds+=" ${1}"; shift;;
+ --password=*) creds+=" ${1}"; shift;;
+ --username) creds+=" ${1} ${2}"; shift 2;;
+ --password) creds+=" ${1} ${2}"; shift 2;;
+ *) shift;;
+ esac
+done
+
# Get the date of the revision, to generate reproducible archives.
# The output format is YYYY-MM-DDTHH:MM:SS.mmmuuuZ (i.e. always in the
# UTC timezone), which we can feed as-is to the --mtime option for tar.
# In case there is a redirection (e.g. http -> https), just keep the
# last line (svn outputs everything on stdout)
-date="$( _plain_svn info "'${uri}@${rev}'" \
+# shellcheck disable=SC2086 # creds may be empty
+date="$( _plain_svn info ${creds} "'${uri}@${rev}'" \
|sed -r -e '/^Last Changed Date: /!d; s///'
)"
When an svn repository requires credentials, and they are passed in _DL_OPTS, they must be used also to retrieve the revision date. One could argue that credentials should not be handled in _DL_OPTS, but rather that they be fed through other means (e.g. by pre-authenticating manually once in an interactive session, or by filling them in the usual ~/svn/auth/* mechanisms for a CI). However, some public facing repositories are using authentication, even though the credentials are public. This is the case for example for: http://software.rtcm-ntrip.org/ In such a case, it does make sense to pass credentials via _DL_OPTS, because they are not really, even really not, secret. Another use-case (e.g. for a CI) is to pass the credentials as environment variables, with _DL_OPTS not hard-coded in the .mk file. However, _DL_OPTS may contain options that are not valid for 'svn info', as they are meant to be passed to 'svn export' in the first place. Since the only options common to 'svn info' and 'svn export' are the credentials, we just extract those and pass them to 'svn info'. Signed-off-by: Yann E. MORIN <yann.morin@orange.com> --- support/download/svn | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)