From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: From: Stephan Linz Date: Thu, 8 Aug 2013 21:36:51 +0200 Message-Id: In-Reply-To: <358e045015fc92c1f4d1ade5a8d2d5059e12a477.1375989870.git.linz@li-pro.net> References: <358e045015fc92c1f4d1ade5a8d2d5059e12a477.1375989870.git.linz@li-pro.net> In-Reply-To: <358e045015fc92c1f4d1ade5a8d2d5059e12a477.1375989870.git.linz@li-pro.net> References: <358e045015fc92c1f4d1ade5a8d2d5059e12a477.1375989870.git.linz@li-pro.net> Subject: [ptxdist] [PATCH 2/2] ptxd_make_get: support svn urls Reply-To: ptxdist@pengutronix.de List-Id: PTXdist Development Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: ptxdist-bounces@pengutronix.de Errors-To: ptxdist-bounces@pengutronix.de To: ptxdist@pengutronix.de Cc: j.beisert@pengutronix.de, mkl@pengutronix.de 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 --- 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 8507dd5..bfb03a3 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 -- 1.7.1 -- ptxdist mailing list ptxdist@pengutronix.de