diff options
author | Stephan Linz <linz@li-pro.net> | 2013-08-08 21:36:51 +0200 |
---|---|---|
committer | Marc Kleine-Budde <mkl@pengutronix.de> | 2013-08-12 19:27:09 +0200 |
commit | 2efcc90490c1773b413f5b11df6abff6d8350bc0 (patch) | |
tree | 16245ee500f3c4aecbe6f6245e33af4e43f03a8d | |
parent | 46ed51af315914ed6270baf950ed19b28bf1a776 (diff) | |
download | ptxdist-2efcc90490c1773b413f5b11df6abff6d8350bc0.tar.gz ptxdist-2efcc90490c1773b413f5b11df6abff6d8350bc0.tar.xz |
ptxd_make_get: support svn urlsptxdist-2013.08.0
In some circumstances it is important to fetch source code
directly from a repository, for example for software development
and/or evaluation. There are some few software projects that
still stay on Subversion, especially vendor specific projects.
In very rare cases the project maintainer will never provide
release tarballs and you have to fetch the Subversion release
branch (for example the eglibc project).
Signed-off-by: Stephan Linz <linz@li-pro.net>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
-rw-r--r-- | scripts/lib/ptxd_make_get.sh | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/scripts/lib/ptxd_make_get.sh b/scripts/lib/ptxd_make_get.sh index 8507dd518..bfb03a34b 100644 --- a/scripts/lib/ptxd_make_get.sh +++ b/scripts/lib/ptxd_make_get.sh @@ -141,6 +141,76 @@ export -f ptxd_make_get_git # +# in env: +# +# ${path} : local file name +# ${url} : the url to download +# ${opts[]} : an array of options +# +ptxd_make_get_svn() { + set -- "${opts[@]}" + unset opts + local rev + local tarcomp + local mirror="${url#[a-z]*//}" + mirror="$(dirname "${path}")/${mirror//\//.}" + local prefix="$(basename "${path}")" + prefix="${prefix%.tar.*}" + + case "${path}" in + *.tar.gz) + tarcomp="--gzip" + ;; + *.tar.bz2) + tarcomp="--bzip2" + ;; + *.tar.xz) + tarcomp="--xz" + ;; + *) + ptxd_bailout "Only .tar.gz, .tar.bz2, .tar.xz and archives are supported for svn downloads." + ;; + esac + + # + # scan for valid options + # + while [ ${#} -ne 0 ]; do + local opt="${1}" + shift + + case "${opt}" in + rev=*) + rev="${opt#rev=}" + ;; + *) + ptxd_bailout "invalid option '${opt}' to ${FUNCNAME}" + ;; + esac + done + unset opt + + if [ -z "${rev}" ]; then + ptxd_bailout "svn url '${url}' has no 'rev' option" + fi + + echo "${PROMPT}svn: fetching '${url} into '${mirror}'..." + if [ ! -d "${mirror}" ]; then + svn checkout -r ${rev} "${url}" "${mirror}" + else + svn update -r ${rev} "${mirror}" + fi && + lmtime=$(svn info -r ${rev} "${mirror}" | \ + awk '/^Last Changed Date:/ {print $4 " " $5 " " $6}') && + echo "${PROMPT}svn: last modification time '${lmtime}'" && + tar --exclude-vcs --show-stored-names ${tarcomp} \ + --mtime="${lmtime}" --transform "s|^\.|${prefix}|g" \ + --create --file "${path}" -C "${mirror}" . +} +export -f ptxd_make_get_svn + + +# # check if download is disabled # # in env: @@ -234,6 +304,18 @@ ptxd_make_get() { mrd=true fi ;; + svn://*) + # restrict donwload only to the PTXMIRROR + if [ -z "${PTXCONF_SETUP_PTXMIRROR_ONLY}" ]; then + # keep original URL + argv[${#argv[@]}]="${url}" + fi + # add mirror to URLs, but only once + if ! ${mrd}; then + ptxmirror_url="${path/#\/*\//${PTXCONF_SETUP_PTXMIRROR}/}" + mrd=true + fi + ;; http://*|https://*|ftp://*) # restrict donwload only to the PTXMIRROR if [ -z "${PTXCONF_SETUP_PTXMIRROR_ONLY}" ]; then @@ -280,6 +362,10 @@ ptxd_make_get() { ptxd_make_get_download_permitted && ptxd_make_get_git && return ;; + svn://*) + ptxd_make_get_download_permitted && + ptxd_make_get_svn && return + ;; http://*|https://*|ftp://*) ptxd_make_get_download_permitted && ptxd_make_get_http && return |