mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
From: Stephan Linz <linz@li-pro.net>
To: ptxdist@pengutronix.de
Cc: j.beisert@pengutronix.de, mkl@pengutronix.de
Subject: [ptxdist] [PATCH 2/2] ptxd_make_get: support svn urls
Date: Thu,  8 Aug 2013 21:36:51 +0200	[thread overview]
Message-ID: <c761b9c85973fcd9b7f92ba2685dfc1ccbedd7b2.1375989870.git.linz@li-pro.net> (raw)
In-Reply-To: <358e045015fc92c1f4d1ade5a8d2d5059e12a477.1375989870.git.linz@li-pro.net>
In-Reply-To: <358e045015fc92c1f4d1ade5a8d2d5059e12a477.1375989870.git.linz@li-pro.net>

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>
---
 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

  reply	other threads:[~2013-08-08 19:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-08 19:36 [ptxdist] [PATCH 1/2] ptxd_make_get: fix typo: .zup -> .zip Stephan Linz
2013-08-08 19:36 ` Stephan Linz [this message]
2013-08-12 17:13   ` [ptxdist] [PATCH 2/2] ptxd_make_get: support svn urls Marc Kleine-Budde
2013-08-12 17:10 ` [ptxdist] [PATCH 1/2] ptxd_make_get: fix typo: .zup -> .zip Marc Kleine-Budde

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c761b9c85973fcd9b7f92ba2685dfc1ccbedd7b2.1375989870.git.linz@li-pro.net \
    --to=linz@li-pro.net \
    --cc=j.beisert@pengutronix.de \
    --cc=mkl@pengutronix.de \
    --cc=ptxdist@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox