From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1LfUtA-0007SK-Ck for garchives@archives.gentoo.org; Fri, 06 Mar 2009 07:54:37 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 55EC3E0466; Fri, 6 Mar 2009 07:54:35 +0000 (UTC) Received: from mo-p05-ob.rzone.de (mo-p05-ob.rzone.de [81.169.146.182]) by pigeon.gentoo.org (Postfix) with ESMTP id C2748E0466 for ; Fri, 6 Mar 2009 07:54:34 +0000 (UTC) X-RZG-AUTH: :K2kKYU+nW/MMMlTokcN5Yot1/Bj/FTl+WviP6RIJci0HRMpbh/x+X6ShOQvVOjw+sRFXd0IMI7w= X-RZG-CLASS-ID: mo05 Received: from terra.solaris (p57A4C85E.dip.t-dialin.net [87.164.200.94]) by post.strato.de (mrclete mo37) (RZmta 18.25) with ESMTP id 401933l266vV6A for ; Fri, 6 Mar 2009 08:54:31 +0100 (MET) Date: Fri, 6 Mar 2009 08:54:54 +0100 From: Christian Faulhammer To: gentoo-dev@lists.gentoo.org Subject: [gentoo-dev] bzr.eclass: The next level (this time with patch) Message-ID: <20090306085454.52f4263b@terra.solaris> X-Mailer: Claws Mail 3.7.0 (GTK+ 2.12.11; i686-pc-linux-gnu) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/P+V4RVjceaQBCaJCHmEjTz7"; protocol="application/pgp-signature"; micalg=PGP-SHA1 X-Archives-Salt: 555e6aee-ef7b-4e87-ad21-b332ddcacf7b X-Archives-Hash: 459ac7021a470ba4fd71b60794589cbe --Sig_/P+V4RVjceaQBCaJCHmEjTz7 Content-Type: multipart/mixed; boundary="MP_/Ul=zQoo0q_p0UrxN8UL6iZY" --MP_/Ul=zQoo0q_p0UrxN8UL6iZY Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi, after the review and more suggestions I would like to post the current version of the patch: * EAPI aware (ulm) * Better documentation * Some clean ups (a lot of people) V-Li --=20 Christian Faulhammer, Gentoo Lisp project , #gentoo-lisp on FreeNode --MP_/Ul=zQoo0q_p0UrxN8UL6iZY Content-Type: text/x-patch Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename=bzr.patch --- /usr/portage/eclass/bzr.eclass 2008-10-25 14:17:23.000000000 +0200 +++ bzr.eclass 2009-03-06 08:48:23.000000000 +0100 @@ -1,11 +1,13 @@ -# Copyright 1999-2008 Gentoo Foundation +# Copyright 1999-2009 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/bzr.eclass,v 1.1 2008/10/25 12:1= 7:23 ulm Exp $ +# $Header: $ # # @ECLASS: bzr.eclass # @MAINTAINER: # Jorge Manuel B. S. Vicetto , # Ulrich Mueller , +# Christian Faulhammer +# Mark Lee , # and anyone who wants to help # @BLURB: This eclass provides support to use the Bazaar DSCM # @DESCRIPTION: @@ -13,14 +15,17 @@ # (distributed source control management system). # The eclass was originally derived from the git eclass. # -# Note: Just set EBZR_REPO_URI to the url of the branch and the src_unpack -# this eclass provides will put an export of the branch in ${WORKDIR}/${PN= }. +# Note: Just set EBZR_REPO_URI to the URI of the branch and the src_unpack= () +# of this eclass will put an export of the branch in ${WORKDIR}/${PN}. =20 inherit eutils =20 EBZR=3D"bzr.eclass" =20 -EXPORT_FUNCTIONS src_unpack +case "${EAPI:-0}" in + 0|1) EXPORT_FUNCTIONS src_unpack ;; + *) EXPORT_FUNCTIONS src_unpack src_prepare ;; +esac =20 HOMEPAGE=3D"http://bazaar-vcs.org/" DESCRIPTION=3D"Based on the ${EBZR} eclass" @@ -29,32 +34,32 @@ =20 # @ECLASS-VARIABLE: EBZR_STORE_DIR # @DESCRIPTION: -# The dir to store the bzr sources. +# The directory to store all fetched Bazaar live sources. EBZR_STORE_DIR=3D"${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/bzr-src" =20 # @ECLASS-VARIABLE: EBZR_FETCH_CMD # @DESCRIPTION: -# The bzr command to fetch the sources. -EBZR_FETCH_CMD=3D"bzr branch" +# The Bazaar command to fetch the sources. +EBZR_FETCH_CMD=3D"bzr checkout --lightweight" =20 # @ECLASS-VARIABLE: EBZR_UPDATE_CMD # @DESCRIPTION: -# The bzr command to update the sources. -EBZR_UPDATE_CMD=3D"bzr pull" +# The Bazaar command to update the sources. +EBZR_UPDATE_CMD=3D"bzr update" =20 -# @ECLASS-VARIABLE: EBZR_DIFFSTAT_CMD +# @ECLASS-VARIABLE: EBZR_DIFF_CMD # @DESCRIPTION: -# The bzr command to get the diffstat output. -EBZR_DIFFSTAT_CMD=3D"bzr diff" +# The Bazaar command to get the diff output. +EBZR_DIFF_CMD=3D"bzr diff" =20 # @ECLASS-VARIABLE: EBZR_EXPORT_CMD # @DESCRIPTION: -# The bzr command to export a branch. +# The Bazaar command to export a branch. EBZR_EXPORT_CMD=3D"bzr export" =20 # @ECLASS-VARIABLE: EBZR_REVNO_CMD # @DESCRIPTION: -# The bzr command to list revision number of the branch. +# The Bazaar command to list a revision number of the branch. EBZR_REVNO_CMD=3D"bzr revno" =20 # @ECLASS-VARIABLE: EBZR_OPTIONS @@ -64,7 +69,7 @@ =20 # @ECLASS-VARIABLE: EBZR_REPO_URI # @DESCRIPTION: -# The repository uri for the source package. +# The repository URI for the source package. # # @CODE # Supported protocols: @@ -72,10 +77,10 @@ # - https:// # - sftp:// # - rsync:// -# - lp:// +# - lp: # @CODE # -# Note: lp =3D https://launchpad.net +# Note: lp: seems to be an alias for https://launchpad.net EBZR_REPO_URI=3D"${EBZR_REPO_URI:-}" =20 # @ECLASS-VARIABLE: EBZR_BOOTSTRAP @@ -86,38 +91,68 @@ # @ECLASS-VARIABLE: EBZR_PATCHES # @DESCRIPTION: # bzr eclass can apply patches in bzr_bootstrap(). -# you can use regexp in this valiable like *.diff or *.patch or etc. -# NOTE: this patches will applied before EBZR_BOOTSTRAP is processed. +# You can use regular expressions in this variable like *.diff or +# *.patch and the like. +# NOTE: These patches will bei applied before EBZR_BOOTSTRAP is processed. # # Patches are searched both in ${PWD} and ${FILESDIR}, if not found in eit= her # location, the installation dies. EBZR_PATCHES=3D"${EBZR_PATCHES:-}" =20 -# @ECLASS-VARIABLE: EBZR_BRANCH -# @DESCRIPTION: -# The branch to fetch in bzr_fetch(). -# -# default: trunk -EBZR_BRANCH=3D"${EBZR_BRANCH:-trunk}" - # @ECLASS-VARIABLE: EBZR_REVISION # @DESCRIPTION: -# Revision to get, if not latest (see http://bazaar-vcs.org/BzrRevisionSpe= c) +# Revision to fetch, defaults to the latest (see +# http://bazaar-vcs.org/BzrRevisionSpec or bzr help revisionspec) EBZR_REVISION=3D"${EBZR_REVISION:-}" =20 # @ECLASS-VARIABLE: EBZR_CACHE_DIR # @DESCRIPTION: -# The dir to store the source for the package, relative to EBZR_STORE_DIR. +# The directory to store the source for the package, relative to +# EBZR_STORE_DIR. # # default: ${PN} EBZR_CACHE_DIR=3D"${EBZR_CACHE_DIR:-${PN}}" =20 +# @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=3D"${1}"; + local branch_dir=3D"${2}"; + + # fetch branch + einfo "bzr fetch start -->" + einfo " repository: ${repository} =3D> ${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_UPDATE_CMD}. +bzr_update() { + local repository=3D"${1}"; + + # 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}." + popd +} + + # @FUNCTION: bzr_fetch # @DESCRIPTION: -# Wrapper function to fetch sources from bazaar via bzr fetch or bzr updat= e, -# depending on whether there is an existing working copy in ${EBZR_BRANCH_= DIR}. +# Wrapper function to fetch sources from a Bazaar repository 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=3D"${EBZR_REPO_URI}" =20 # EBZR_REPO_URI is empty. [[ ${EBZR_REPO_URI} ]] || die "${EBZR}: EBZR_REPO_URI is empty." @@ -125,8 +160,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 --missing true 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." @@ -135,14 +177,14 @@ fi =20 if [[ ! -d ${EBZR_STORE_DIR} ]] ; then - debug-print "${FUNCNAME}: initial branch. creating bzr directory" + debug-print "${FUNCNAME}: initial branch. Creating bzr directory" addwrite / mkdir -p "${EBZR_STORE_DIR}" \ || die "${EBZR}: can't mkdir ${EBZR_STORE_DIR}." export SANDBOX_WRITE=3D"${SANDBOX_WRITE%%:/}" fi =20 - cd -P "${EBZR_STORE_DIR}" || die "${EBZR}: can't chdir to ${EBZR_STORE_DI= R}" + pushd "${EBZR_STORE_DIR}" || die "${EBZR}: can't chdir to ${EBZR_STORE_DI= R}" =20 EBZR_BRANCH_DIR=3D"${EBZR_STORE_DIR}/${EBZR_CACHE_DIR}" =20 @@ -151,31 +193,17 @@ =20 debug-print "${FUNCNAME}: EBZR_OPTIONS =3D ${EBZR_OPTIONS}" =20 - local repository - - if [[ ${EBZR_REPO_URI} =3D=3D */* ]]; then - repository=3D"${EBZR_REPO_URI}${EBZR_BRANCH}" - else - repository=3D"${EBZR_REPO_URI}" - fi - + # Run bzr_initial_fetch() only if the branch has not been pulled + # before or if the existing local copy is a full checkout (as did + # an older version of bzr.eclass) if [[ ! -d ${EBZR_BRANCH_DIR} ]] ; then - # fetch branch - einfo "bzr branch start -->" - einfo " repository: ${repository} =3D> ${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}" + elif [[ -d "${EBZR_BRANCH_DIR}"/.bzr/repository/ ]]; 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 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 =20 cd "${EBZR_BRANCH_DIR}" @@ -193,16 +221,16 @@ =20 einfo "Revision ${revision} is now in ${WORKDIR}/${P}" =20 - cd "${WORKDIR}" + popd } =20 # @FUNCTION: bzr_bootstrap # @DESCRIPTION: -# Apply patches in ${EBZR_PATCHES} and run ${EBZR_BOOTSTRAP} if specified +# Apply patches in ${EBZR_PATCHES} and run ${EBZR_BOOTSTRAP} if specified. bzr_bootstrap() { - local patch lpatch + local patch =20 - cd "${S}" + pushd "${S}" =20 if [[ -n ${EBZR_PATCHES} ]] ; then einfo "apply patches -->" @@ -210,14 +238,10 @@ for patch in ${EBZR_PATCHES} ; do if [[ -f ${patch} ]] ; then epatch ${patch} + elif [[ -f "${FILESDIR}/${patch}" ]] ; then + epatch "${FILESDIR}/${patch}" else - for lpatch in "${FILESDIR}"/${patch} ; do - if [[ -f ${lpatch} ]] ; then - epatch ${lpatch} - else - die "${EBZR}: ${patch} is not found" - fi - done + die "${EBZR}: ${patch} is not found" fi done fi @@ -235,12 +259,30 @@ || die "${EBZR}: can't eval EBZR_BOOTSTRAP." fi fi + + popd } =20 # @FUNCTION: bzr_src_unpack # @DESCRIPTION: -# default src_unpack. fetch and bootstrap. +# Default src_unpack(). Includes bzr_fetch() and bootstrap(). bzr_src_unpack() { + if [ -n ${EBZR_BRANCH} ]; then + # This test will go away on 01 Jan 2010 + eerror "This ebuild uses EBZR_BRANCH which is not supported anymore" + eerror "by the bzr.eclass. Please report this to the ebuild maintainer." + die "EBZR_BRANCH still defined" + fi bzr_fetch || die "${EBZR}: unknown problem in bzr_fetch()." + case "${EAPI:-0}" in + 0|1) bzr_src_prepare ;; + esac +} + +# @FUNCTION: bzr_src_prepare +# @DESCRIPTION: +# Default src_prepare(). Executes bzr_bootstrap() for patch +# application and Make file generation (if needed). +bzr_src_prepare() { bzr_bootstrap || die "${EBZR}: unknown problem in bzr_bootstrap()." } --MP_/Ul=zQoo0q_p0UrxN8UL6iZY-- --Sig_/P+V4RVjceaQBCaJCHmEjTz7 Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) iEYEARECAAYFAkmw1s4ACgkQNQqtfCuFnePNHACfXcHKXZdGBJjSl+XiSkYfN/qE 2/UAoI3syleeY2rVYFUceIhFxD4/iSNy =sqXu -----END PGP SIGNATURE----- --Sig_/P+V4RVjceaQBCaJCHmEjTz7--