Hi. Christian Faulhammer wrote: > Hi, > > a user maintained a Bazaar overlay for some time now and introduced > some changes to bzr eclass, I would like to introduce into the tree. > Please review the attached patch. > > V-Li
I'm attaching a revised patch that tries to improve some issues in the current version in the tree, incorporates your changes and Peter Volkov's (pva) patch about sftp URIs. -- Regards, Jorge Vicetto (jmbsvicetto) - jmbsvicetto at gentoo dot org Gentoo- forums / Userrel / Devrel / SPARC / KDE
Index: bzr.eclass =================================================================== RCS file: /var/cvsroot/gentoo-x86/eclass/bzr.eclass,v retrieving revision 1.1 diff -u -b -B -r1.1 bzr.eclass --- bzr.eclass 25 Oct 2008 12:17:23 -0000 1.1 +++ bzr.eclass 14 Feb 2009 18:03:39 -0000 @@ -6,6 +6,8 @@ # @MAINTAINER: # Jorge Manuel B. S. Vicetto <jmbsvice...@gentoo.org>, # Ulrich Mueller <u...@gentoo.org>, +# Christian Faulhammer <fa...@gentoo.org> +# Mark Lee <bzr-gentoo-over...@lazymalevolence.com>, # and anyone who wants to help # @BLURB: This eclass provides support to use the Bazaar DSCM # @DESCRIPTION: @@ -25,7 +27,8 @@ HOMEPAGE="http://bazaar-vcs.org/" DESCRIPTION="Based on the ${EBZR} eclass" -DEPEND=">=dev-util/bzr-1.5" +DEPEND=">=dev-util/bzr-1.5 + dev-util/diffstat" # @ECLASS-VARIABLE: EBZR_STORE_DIR # @DESCRIPTION: @@ -35,17 +38,17 @@ # @ECLASS-VARIABLE: EBZR_FETCH_CMD # @DESCRIPTION: # The bzr command to fetch the sources. -EBZR_FETCH_CMD="bzr branch" +EBZR_FETCH_CMD="bzr checkout --lightweight" # @ECLASS-VARIABLE: EBZR_UPDATE_CMD # @DESCRIPTION: # The bzr command to update the sources. -EBZR_UPDATE_CMD="bzr pull" +EBZR_UPDATE_CMD="bzr update" # @ECLASS-VARIABLE: EBZR_DIFFSTAT_CMD # @DESCRIPTION: -# The bzr command to get the diffstat output. -EBZR_DIFFSTAT_CMD="bzr diff" +# The bzr command to get the diff output. +EBZR_DIFF_CMD="bzr diff" # @ECLASS-VARIABLE: EBZR_EXPORT_CMD # @DESCRIPTION: @@ -72,10 +75,10 @@ # - https:// # - sftp:// # - rsync:// -# - lp:// +# - lp: # @CODE # -# Note: lp = https://launchpad.net +# Note: lp: seems to be an alias to https://launchpad.net EBZR_REPO_URI="${EBZR_REPO_URI:-}" # @ECLASS-VARIABLE: EBZR_BOOTSTRAP @@ -112,12 +115,55 @@ # default: ${PN} EBZR_CACHE_DIR="${EBZR_CACHE_DIR:-${PN}}" +# @FUNCTION: bzr_initial_fetch +# @DESCRIPTION: +# Retrieves the source code from a repository for the first time, via +# ${EBZR_FETCH_CMD}. +bzr_initial_fetch() { + local repository="${1}"; + local branch_dir="${2}"; + + # fetch branch + einfo "bzr fetch start -->" + einfo " repository: ${repository} => ${branch_dir}" + + ${EBZR_FETCH_CMD} ${EBZR_OPTIONS} "${repository}" "${branch_dir}" \ + || die "${EBZR}: can't branch from ${repository}." +} + +# @FUNCTION: bzr_update +# @DESCRIPTION: +# Updates the source code from a repository, via ${EBZR_FETCH_CMD}. +bzr_update() { + local repository="${1}"; + local branch_dir="${2}"; + local repo_type=$(bzr info "${EBZR_BRANCH_DIR}" | head -n 1 | cut -d '(' -f 1) + + if [[ "${repo_type}" != "Lightweight checkout " ]]; then + + einfo "Re-fetching the branch to save space..." + rm -rf "${EBZR_BRANCH_DIR}" + bzr_initial_fetch "${repository}" "${EBZR_BRANCH_DIR}" + else + + # update branch + einfo "bzr update start -->" + einfo " repository: ${repository}" + + pushd "${EBZR_BRANCH_DIR}" + ${EBZR_UPDATE_CMD} ${EBZR_OPTIONS} \ + || die "${EBZR}: can't update from ${repository}." + ${EBZR_DIFF_CMD} | diffstat + popd + fi +} + # @FUNCTION: bzr_fetch # @DESCRIPTION: # Wrapper function to fetch sources from bazaar via bzr fetch or bzr update, # depending on whether there is an existing working copy in ${EBZR_BRANCH_DIR}. bzr_fetch() { - local EBZR_BRANCH_DIR + local EBZR_BRANCH_DIR repository # EBZR_REPO_URI is empty. [[ ${EBZR_REPO_URI} ]] || die "${EBZR}: EBZR_REPO_URI is empty." @@ -125,8 +171,15 @@ # check for the protocol or pull from a local repo. if [[ -z ${EBZR_REPO_URI%%:*} ]] ; then case ${EBZR_REPO_URI%%:*} in - # lp:// is https://launchpad.net - http|https|rsync|sftp|lp) + # lp: seems to be an alias to https://launchpad.net + http|https|rsync|lp) + ;; + sftp) + if ! built_with_use dev-util/bzr sftp; then + eerror "To fetch sources from ${EBZR_REPO_URI} you need sftp" + eerror "support in dev-util/bzr." + die "Please, rebuild dev-util/bzr with the sftp USE flag enabled." + fi ;; *) die "${EBZR}: fetch from ${EBZR_REPO_URI%:*} is not yet implemented." @@ -142,7 +195,7 @@ export SANDBOX_WRITE="${SANDBOX_WRITE%%:/}" fi - cd -P "${EBZR_STORE_DIR}" || die "${EBZR}: can't chdir to ${EBZR_STORE_DIR}" + pushd "${EBZR_STORE_DIR}" || die "${EBZR}: can't chdir to ${EBZR_STORE_DIR}" EBZR_BRANCH_DIR="${EBZR_STORE_DIR}/${EBZR_CACHE_DIR}" @@ -151,31 +204,18 @@ debug-print "${FUNCNAME}: EBZR_OPTIONS = ${EBZR_OPTIONS}" - local repository - if [[ ${EBZR_REPO_URI} == */* ]]; then - repository="${EBZR_REPO_URI}${EBZR_BRANCH}" + repository="${EBZR_REPO_URI}/${EBZR_BRANCH}" + elif [[ -n ${EBZR_BRANCH} ]] ; then + repository="${EBZR_REPO_URI}/${EBZR_BRANCH}" else repository="${EBZR_REPO_URI}" fi if [[ ! -d ${EBZR_BRANCH_DIR} ]] ; then - # fetch branch - einfo "bzr branch start -->" - einfo " repository: ${repository} => ${EBZR_BRANCH_DIR}" - - ${EBZR_FETCH_CMD} ${EBZR_OPTIONS} "${repository}" "${EBZR_BRANCH_DIR}" \ - || die "${EBZR}: can't branch from ${repository}." - + bzr_initial_fetch "${repository}" "${EBZR_BRANCH_DIR}" else - # update branch - einfo "bzr pull start -->" - einfo " repository: ${repository}" - - cd "${EBZR_BRANCH_DIR}" - ${EBZR_UPDATE_CMD} ${EBZR_OPTIONS} "${repository}" \ - || die "${EBZR}: can't merge from ${repository}." - ${EBZR_DIFFSTAT_CMD} + bzr_update "${repository}" "${EBZR_BRANCH_DIR}" fi cd "${EBZR_BRANCH_DIR}" @@ -193,7 +233,7 @@ einfo "Revision ${revision} is now in ${WORKDIR}/${P}" - cd "${WORKDIR}" + popd } # @FUNCTION: bzr_bootstrap @@ -202,7 +242,7 @@ bzr_bootstrap() { local patch lpatch - cd "${S}" + pushd "${S}" if [[ -n ${EBZR_PATCHES} ]] ; then einfo "apply patches -->" @@ -235,6 +275,8 @@ || die "${EBZR}: can't eval EBZR_BOOTSTRAP." fi fi + + popd } # @FUNCTION: bzr_src_unpack
signature.asc
Description: OpenPGP digital signature