# Copyright 1999-2006 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: /var/cvsroot/gentoo-x86/eclass/subversion.eclass,v 1.33 2006/07/22 13:52:38 hattya Exp $ ## --------------------------------------------------------------------------- # # Author: Mark Stier # # SVN caching and release tag handling. # # Usage (inside src_unpack): svncache_fetch https://...@reltag target_dir # # Derived from the subversion.eclass file. # ## --------------------------------------------------------------------------- # inherit eutils ESVN="svncache.eclass" EXPORT_FUNCTIONS src_unpack HOMEPAGE="" DESCRIPTION="" DEPEND="dev-util/subversion net-misc/rsync" ## -- ESVN_STORE_DIR: subversion sources store directory # ESVN_STORE_DIR="${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/svn-cache" ## -- ESVN_FETCH_CMD: subversion fetch command # ESVN_FETCH_CMD="svn checkout" ## -- ESVN_UPDATE_CMD: subversion update command # ESVN_UPDATE_CMD="svn update" ## -- ESVN_OPTIONS: # # the options passed to checkout or update. # : ESVN_OPTIONS=${ESVN_OPTIONS:=} ## -- ESVN_REPO_URI: repository uri # # e.g. http://foo/trunk, svn://bar/trunk # # supported protocols: # http:// # https:// # svn:// # svn+ssh:// # : ESVN_REPO_URI=${ESVN_REPO_URI:=} ## -- ESVN_PROJECT: project name of your ebuild (= name space) # # subversion eclass will check out the subversion repository like: # # ${ESVN_STORE_DIR}/${ESVN_PROJECT}/${ESVN_REPO_URI##*/} # # so if you define ESVN_REPO_URI as http://svn.collab.net/repo/svn/trunk or # http://svn.collab.net/repo/svn/trunk/. and PN is subversion-svn. # it will check out like: # # ${ESVN_STORE_DIR}/subversion/trunk # # this is not used in order to declare the name of the upstream project. # so that you can declare this like: # # # jakarta commons-loggin # ESVN_PROJECT=commons/logging # # default: ${PN/-svn}. # : ESVN_PROJECT=${ESVN_PROJECT:=${PN/-svn}} ## -- ESVN_BOOTSTRAP: # # bootstrap script or command like autogen.sh or etc.. # : ESVN_BOOTSTRAP=${ESVN_BOOTSTRAP:=} ## -- ESVN_PATCHES: # # subversion eclass can apply pathces in subversion_bootstrap(). # you can use regexp in this valiable like *.diff or *.patch or etc. # NOTE: this patches will apply before eval ESVN_BOOTSTRAP. # # the process of applying the patch is: # 1. just epatch it, if the patch exists in the path. # 2. scan it under FILESDIR and epatch it, if the patch exists in FILESDIR. # 3. die. # : ESVN_PATCHES=${ESVN_PATCHES:=} ## -- ESVN_RESTRICT: # # this should be a space delimited list of subversion eclass features to restrict. # export) # don't export the working copy to S. # : ESVN_RESTRICT=${ESVN_RESTRICT:=} function svncache_fetch() { local mypwd=$(pwd) local repo_uri=${1:-${ESVN_REPO_URI}} if [[ -z "${repo_uri}" ]]; then die "${ESVN}: ESVN_REPO_URI is empty." fi # delete trailing slash if [[ -z "${repo_uri##*/}" ]]; then repo_uri=${repo_uri%/} fi if [[ ! -d "${ESVN_STORE_DIR}" ]]; then debug-print "${FUNCNAME}: initial checkout. creating subversion directory" addwrite / mkdir -p "${ESVN_STORE_DIR}" || die "${ESVN}: can't mkdir ${ESVN_STORE_DIR}." export SANDBOX_WRITE=${SANDBOX_WRITE%%:/} fi cd "${ESVN_STORE_DIR}" || die "${ESVN}: can't chdir to ${ESVN_STORE_DIR}" # every time addwrite "/etc/subversion" addwrite "${ESVN_STORE_DIR}" if ! has userpriv ${FEATURES}; then # -userpriv addwrite "/root/.subversion" else # +userpriv ESVN_OPTIONS="${ESVN_OPTIONS} --config-dir ${ESVN_STORE_DIR}/.subversion" fi local wc_path="${1%%://*}/${1#*://}" # fix path (remove svn release tag) wc_path=${wc_path%@*} # strip last slash wc_path=${wc_path%/*} # determine release tag local rel=${1##*@} if [ "$rel" == "$1" ]; then rel="current" fi # append release tag to path wc_path="$wc_path""@""$rel" debug-print "${FUNCNAME}: ESVN_OPTIONS = \"${ESVN_OPTIONS}\"" if [[ ! -f "${wc_path}.done" ]]; then # checkout einfo "subversion check out start -->" einfo " repository: ${repo_uri}" rm -rf "${ESVN_STORE_DIR}/$wc_path" || die mkdir -p "${ESVN_STORE_DIR}" || die "${ESVN_STORE_DIR}: can't mkdir ${ESVN_STORE_DIR}." cd "${ESVN_STORE_DIR}" ${ESVN_FETCH_CMD} ${ESVN_OPTIONS} "${1}" "$wc_path" || die "${ESVN}: can't fetch from ${repo_uri}." touch "${wc_path}.done" elif [ "$rel" == "current" ]; then # update working copy einfo "subversion update start -->" einfo " repository: ${repo_uri}" cd "${ESVN_STORE_DIR}/${wc_path}" ${ESVN_UPDATE_CMD} ${ESVN_OPTIONS} || die "${ESVN}: can't update from ${repo_uri}." else einfo "subversion check out not needed, release tag \"$rel\" already fetched -->" einfo " repository: ${repo_uri}" fi einfo " working copy: ${ESVN_STORE_DIR}/${wc_path}" cd "${ESVN_STORE_DIR}/${wc_path}" # export to the ${WORKDIR} #* "svn export" has a bug. see http://bugs.gentoo.org/119236 #* svn export . "${S}" || die "${ESVN}: can't export to ${S}." einfo "Copying code from subversion cache..." [ -d "${mypwd}/$2" ] || mkdir -p "${mypwd}/$2" [ -d "${mypwd}/$2" ] || die "failed to create dir \"${mypwd}/$2\"" rsync -rlpgo . "${mypwd}/$2/." || die "${ESVN}: can't export to ${mypwd}/$2." echo cd "$mypwd" || die }