public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Jonas Bernoulli" <jonas@bernoulli.cc>
To: gentoo-dev@lists.gentoo.org
Subject: Re: [gentoo-dev] Re: bzr.eclass into Portage
Date: Sun, 5 Oct 2008 22:54:23 +0200	[thread overview]
Message-ID: <201bac3a0810051354v4e22eb6fv1837142ee3a1a2bd@mail.gmail.com> (raw)
In-Reply-To: <18664.63712.432021.661712@a1ihome1.kph.uni-mainz.de>

[-- Attachment #1: Type: text/plain, Size: 7992 bytes --]

Here is a patch that adds support for shared repositories. Since bzr
is still a bit slow this is quite useful when using multiple branches.

For example I have modified the live emacs(-cvs) ebuild to use the bzr
mirror of emacs instead of cvs. I also have my own emacs branches, and
sometimes want to install from one of these and at other times from
trunk. Without support for shared repositories this would require the
standalone branches to be manually moved out of the way everytime I
want to switch branches. (Or worse the complete tree to be checked out
from scratch every time I switch branches.)

Please consider these changes

Jonas

--- /usr/local/portage/layman/emacs/eclass/bzr.eclass	2008-10-05
22:40:18.000000000 +0200
+++ /usr/portage/eclass/bzr.eclass	2008-10-05 10:22:12.000000000 +0200
@@ -9,6 +9,7 @@
 # @DESCRIPTION:
 # The bzr.eclass provides support for apps using the bazaar DSCM
(distributed source control management system).
 # The eclass was originally derived from the git eclass.
+# Shared repository support added by Jonas Bernoulli <jonas@bernoulli.cc>.
 #
 # 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}.
@@ -22,13 +23,23 @@
 HOMEPAGE="http://bazaar-vcs.org/"
 DESCRIPTION="Based on the ${EBZR} eclass"

-DEPEND=">=dev-util/bzr-0.92"
+DEPEND=">=dev-util/bzr-1.6"

 # @ECLASS-VARIABLE: EBZR_STORE_DIR
 # @DESCRIPTION:
 # The dir to store the bzr sources.
 EBZR_STORE_DIR="${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/bzr-src"

+# @ECLASS-VARIABLE: EBZR_SHARED_REPO
+# @DESCRIPTION:
+# Whether to use a shared repository (see bzr help repositories).
+EBZR_SHARED_REPO="${EBZR_SHARED_REPO:-}"
+
+# @ECLASS-VARIABLE: EBZR_INIT_REPO_CMD
+# @DESCRIPTION:
+# The bzr command to initialize the shared repository.
+EBZR_INIT_REPO_CMD="bzr init-repo"
+
 # @ECLASS-VARIABLE: EBZR_FETCH_CMD
 # @DESCRIPTION:
 # The bzr command to fetch the sources.
@@ -54,9 +65,24 @@
 # The bzr command to list revision number of the branch.
 EBZR_REVNO_CMD="bzr revno"

+# @ECLASS-VARIABLE: EBZR_INIT_REPO_OPTS
+# @DESCRIPTION:
+# Options passed to the init-repo commands.
+EBZR_INIT_REPO_OPTS="${EBZR_INIT_REPO_OPTS:-}"
+
+# @ECLASS-VARIABLE: EBZR_FETCH_OPTS
+# @DESCRIPTION:
+# Options passed to the fetch commands in additon to EBZR_OPTIONS.
+EBZR_FETCH_OPTS="${EBZR_FETCH_OPTS:-}"
+
+# @ECLASS-VARIABLE: EBZR_UPDATE_OPTS
+# @DESCRIPTION:
+# Options passed to the update commands in additon to EBZR_OPTIONS.
+EBZR_UPDATE_OPTS="${EBZR_UPDATE_OPTS:-}"
+
 # @ECLASS-VARIABLE: EBZR_OPTIONS
 # @DESCRIPTION:
-# The options passed to the fetch and update commands.
+# The common options passed to the fetch and update commands.
 EBZR_OPTIONS="${EBZR_OPTIONS:-}"

 # @ECLASS-VARIABLE: EBZR_REPO_URI
@@ -72,7 +98,7 @@
 # 		- lp://
 # @CODE
 #
-# Note: lp = https://launchpad.net
+# Note: lp = http://launchpad.net
 EBZR_REPO_URI="${EBZR_REPO_URI:-}"

 # @ECLASS-VARIABLE: EBZR_BOOTSTRAP
@@ -93,21 +119,26 @@
 # @ECLASS-VARIABLE: EBZR_BRANCH
 # @DESCRIPTION:
 # The branch to fetch in bzr_fetch().
-#
-# default: trunk
-EBZR_BRANCH="${EBZR_BRANCH:-trunk}"
+EBZR_BRANCH="${EBZR_BRANCH:-}"

 # @ECLASS-VARIABLE: EBZR_REVISION
 # @DESCRIPTION:
 # Revision to get, if not latest (see http://bazaar-vcs.org/BzrRevisionSpec)
 EBZR_REVISION="${EBZR_REVISION:-}"

-# @ECLASS-VARIABLE: EBZR_CACHE_DIR
+# @ECLASS-VARIABLE: EBZR_CACHE_REPO_DIR
 # @DESCRIPTION:
-# The dir to store the source for the package, relative to EBZR_STORE_DIR.
+# The dir name of the local shared repository (if any).
 #
 # default: ${PN}
-EBZR_CACHE_DIR="${EBZR_CACHE_DIR:-${PN}}"
+EBZR_CACHE_REPO_DIR="${EBZR_CACHE_REPO_DIR:-}"
+
+# @ECLASS-VARIABLE: EBZR_CACHE_BRANCH_DIR
+# @DESCRIPTION:
+# The dir name of the local branch.
+#
+# default: ${EBZR_BRANCH} when using a shared repository or ${PN} otherwise
+EBZR_CACHE_BRANCH_DIR="${EBZR_CACHE_BRANCH_DIR:-}"

 # @FUNCTION: bzr_fetch
 # @DESCRIPTION:
@@ -143,37 +174,64 @@

 	cd -P "${EBZR_STORE_DIR}" || die "${EBZR}: can't chdir to ${EBZR_STORE_DIR}"

-	EBZR_BRANCH_DIR="${EBZR_STORE_DIR}/${EBZR_CACHE_DIR}"
-
 	addwrite "${EBZR_STORE_DIR}"
-	addwrite "${EBZR_BRANCH_DIR}"

-	debug-print "${FUNCNAME}: EBZR_OPTIONS = ${EBZR_OPTIONS}"
+	if [[ -n ${EBZR_SHARED_REPO} ]]; then
+		# using shared repository
+		EBZR_REPO_DIR="${EBZR_STORE_DIR}/${EBZR_CACHE_REPO_DIR:-${PN}}"
+		EBZR_BRANCH_DIR="${EBZR_REPO_DIR}/${EBZR_CACHE_BRANCH_DIR:-${EBZR_BRANCH}}"
+
+		addwrite "${EBZR_REPO_DIR}"
+	else
+		# using stand-alone branch
+		EBZR_BRANCH_DIR="${EBZR_STORE_DIR}/${EBZR_CACHE_BRANCH_DIR:-${PN}}"
+	fi
+
+	addwrite "${EBZR_BRANCH_DIR}"

-	local repository
+	local branch

-	if [[ ${EBZR_REPO_URI} == */* ]]; then
-		repository="${EBZR_REPO_URI}${EBZR_BRANCH}"
+	if [[ -n ${EBZR_BRANCH} ]] ; then
+		branch="${EBZR_REPO_URI}/${EBZR_BRANCH}"
 	else
-		repository="${EBZR_REPO_URI}"
+		branch="${EBZR_REPO_URI}"
+	fi
+
+	if [[ ${EBZR_SHARED_REPO} && ! -d ${EBZR_REPO_DIR} ]] ; then
+		# create shared repository
+		debug-print "${FUNCNAME}: EBZR_INIT_REPO_OPTS = ${EBZR_INIT_REPO_OPTS}"
+
+		${EBZR_INIT_REPO_CMD} ${EBZR_INIT_REPO_OPTS} ${EBZR_REPO_DIR} \
+			|| die "${EBZR}: can't initialize shared repository."
+	fi
+
+	if [[ ${EBZR_BRANCH} == */* && ! -f $(dirname ${EBZR_BRANCH}) ]]; then
+		# prepare path to branch
+		mkdir -p "${EBZR_REPO_DIR}/$(dirname ${EBZR_BRANCH})"
 	fi

 	if [[ ! -d ${EBZR_BRANCH_DIR} ]] ; then
 		# fetch branch
 		einfo "bzr branch start -->"
-		einfo "   repository: ${repository} => ${EBZR_BRANCH_DIR}"
+		einfo "   branch: ${branch} => ${EBZR_BRANCH_DIR}"
+
+		EBZR_OPTIONS="${EBZR_OPTIONS} ${EBZR_FETCH_OPTS}"
+		debug-print "${FUNCNAME}: EBZR_OPTIONS = ${EBZR_OPTIONS}"

-		${EBZR_FETCH_CMD} ${EBZR_OPTIONS} "${repository}" "${EBZR_BRANCH_DIR}" \
-			|| die "${EBZR}: can't branch from ${repository}."
+		${EBZR_FETCH_CMD} ${EBZR_OPTIONS} "${branch}" "${EBZR_BRANCH_DIR}" \
+			|| die "${EBZR}: can't branch from ${branch}."

 	else
 		# update branch
 		einfo "bzr pull start -->"
-		einfo "   repository: ${repository}"
+		einfo "   branch: ${branch} => ${EBZR_BRANCH_DIR}"
+
+		EBZR_OPTIONS="${EBZR_OPTIONS} ${EBZR_UPDATE_OPTS}"
+		debug-print "${FUNCNAME}: EBZR_OPTIONS = ${EBZR_OPTIONS}"

 		cd "${EBZR_BRANCH_DIR}"
-		${EBZR_UPDATE_CMD} ${EBZR_OPTIONS} "${repository}" \
-			|| die "${EBZR}: can't merge from ${repository}."
+		${EBZR_UPDATE_CMD} ${EBZR_OPTIONS} "${branch}" \
+			|| die "${EBZR}: can't merge from ${branch}."
 		${EBZR_DIFFSTAT_CMD}
 	fi

On Sun, Oct 5, 2008 at 7:26 PM, Ulrich Mueller <ulm@gentoo.org> wrote:
>>>>>> On Fri, 21 Mar 2008, Christian Faulhammer wrote:
>
>> "Jorge Manuel B. S. Vicetto" <jmbsvicetto@gentoo.org>:
>>> With the help of Ingmar we did some cleanup and added support for
>>> eclass-manpages at
>>> http://git.overlays.gentoo.org/gitweb/?p=proj/desktop-effects.git;a=blob_plain;f=eclass/bzr.eclass;hb=bzr.
>>> I'll be moving the updated eclass to the master branch, testing and
>>> asking users to try it out during this weekend.
>>> This eclass is used in the overlay for the live
>>> avant-window-navigator ebuilds, so it's probably not as used/tested
>>> as the remaining packages. It has provided us the support we needed
>>> for awn, but you might need additional features or to review existing
>>> ones. Please test the updated eclass on your overlay, feel free to
>>> maintain it and, when you think its ready, add it to the tree. When
>>> you do so, I'll remove it from our overlay and we'll use the eclass
>>> on the tree.
>
>>  We have a prior version for some time now in the Emacs overlay for
>> two live ebuilds...so we go and merge your changed (ulm already
>> did), test it and report any problems.
>
> As I just learned there are (at least) three overlays using
> bzr.eclass, namely desktop-effects, emacs, and ltsp.
>
> So I think it is justified to move bzr.eclass to the Portage tree.
> Currect version of bzr.eclass is attached.
>
> Please raise your objections *now*.
>
> Ulrich

[-- Attachment #2: bzr.eclass.patch --]
[-- Type: application/octet-stream, Size: 5883 bytes --]

--- /usr/local/portage/layman/emacs/eclass/bzr.eclass	2008-10-05 22:40:18.000000000 +0200
+++ /usr/portage/eclass/bzr.eclass	2008-10-05 10:22:12.000000000 +0200
@@ -9,6 +9,7 @@
 # @DESCRIPTION:
 # The bzr.eclass provides support for apps using the bazaar DSCM (distributed source control management system).
 # The eclass was originally derived from the git eclass.
+# Shared repository support added by Jonas Bernoulli <jonas@bernoulli.cc>.
 #
 # 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}.
@@ -22,13 +23,23 @@
 HOMEPAGE="http://bazaar-vcs.org/"
 DESCRIPTION="Based on the ${EBZR} eclass"
 
-DEPEND=">=dev-util/bzr-0.92"
+DEPEND=">=dev-util/bzr-1.6"
 
 # @ECLASS-VARIABLE: EBZR_STORE_DIR
 # @DESCRIPTION:
 # The dir to store the bzr sources.
 EBZR_STORE_DIR="${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/bzr-src"
 
+# @ECLASS-VARIABLE: EBZR_SHARED_REPO
+# @DESCRIPTION:
+# Whether to use a shared repository (see bzr help repositories).
+EBZR_SHARED_REPO="${EBZR_SHARED_REPO:-}"
+
+# @ECLASS-VARIABLE: EBZR_INIT_REPO_CMD
+# @DESCRIPTION:
+# The bzr command to initialize the shared repository.
+EBZR_INIT_REPO_CMD="bzr init-repo"
+
 # @ECLASS-VARIABLE: EBZR_FETCH_CMD
 # @DESCRIPTION:
 # The bzr command to fetch the sources.
@@ -54,9 +65,24 @@
 # The bzr command to list revision number of the branch.
 EBZR_REVNO_CMD="bzr revno"
 
+# @ECLASS-VARIABLE: EBZR_INIT_REPO_OPTS
+# @DESCRIPTION:
+# Options passed to the init-repo commands.
+EBZR_INIT_REPO_OPTS="${EBZR_INIT_REPO_OPTS:-}"
+
+# @ECLASS-VARIABLE: EBZR_FETCH_OPTS
+# @DESCRIPTION:
+# Options passed to the fetch commands in additon to EBZR_OPTIONS.
+EBZR_FETCH_OPTS="${EBZR_FETCH_OPTS:-}"
+
+# @ECLASS-VARIABLE: EBZR_UPDATE_OPTS
+# @DESCRIPTION:
+# Options passed to the update commands in additon to EBZR_OPTIONS.
+EBZR_UPDATE_OPTS="${EBZR_UPDATE_OPTS:-}"
+
 # @ECLASS-VARIABLE: EBZR_OPTIONS
 # @DESCRIPTION:
-# The options passed to the fetch and update commands.
+# The common options passed to the fetch and update commands.
 EBZR_OPTIONS="${EBZR_OPTIONS:-}"
 
 # @ECLASS-VARIABLE: EBZR_REPO_URI
@@ -72,7 +98,7 @@
 # 		- lp://
 # @CODE
 #
-# Note: lp = https://launchpad.net
+# Note: lp = http://launchpad.net
 EBZR_REPO_URI="${EBZR_REPO_URI:-}"
 
 # @ECLASS-VARIABLE: EBZR_BOOTSTRAP
@@ -93,21 +119,26 @@
 # @ECLASS-VARIABLE: EBZR_BRANCH
 # @DESCRIPTION:
 # The branch to fetch in bzr_fetch().
-#
-# default: trunk
-EBZR_BRANCH="${EBZR_BRANCH:-trunk}"
+EBZR_BRANCH="${EBZR_BRANCH:-}"
 
 # @ECLASS-VARIABLE: EBZR_REVISION
 # @DESCRIPTION:
 # Revision to get, if not latest (see http://bazaar-vcs.org/BzrRevisionSpec)
 EBZR_REVISION="${EBZR_REVISION:-}"
 
-# @ECLASS-VARIABLE: EBZR_CACHE_DIR
+# @ECLASS-VARIABLE: EBZR_CACHE_REPO_DIR
 # @DESCRIPTION:
-# The dir to store the source for the package, relative to EBZR_STORE_DIR.
+# The dir name of the local shared repository (if any).
 #
 # default: ${PN}
-EBZR_CACHE_DIR="${EBZR_CACHE_DIR:-${PN}}"
+EBZR_CACHE_REPO_DIR="${EBZR_CACHE_REPO_DIR:-}"
+
+# @ECLASS-VARIABLE: EBZR_CACHE_BRANCH_DIR
+# @DESCRIPTION:
+# The dir name of the local branch.
+#
+# default: ${EBZR_BRANCH} when using a shared repository or ${PN} otherwise
+EBZR_CACHE_BRANCH_DIR="${EBZR_CACHE_BRANCH_DIR:-}"
 
 # @FUNCTION: bzr_fetch
 # @DESCRIPTION:
@@ -143,37 +174,64 @@
 
 	cd -P "${EBZR_STORE_DIR}" || die "${EBZR}: can't chdir to ${EBZR_STORE_DIR}"
 
-	EBZR_BRANCH_DIR="${EBZR_STORE_DIR}/${EBZR_CACHE_DIR}"
-
 	addwrite "${EBZR_STORE_DIR}"
-	addwrite "${EBZR_BRANCH_DIR}"
 
-	debug-print "${FUNCNAME}: EBZR_OPTIONS = ${EBZR_OPTIONS}"
+	if [[ -n ${EBZR_SHARED_REPO} ]]; then
+		# using shared repository
+		EBZR_REPO_DIR="${EBZR_STORE_DIR}/${EBZR_CACHE_REPO_DIR:-${PN}}"
+		EBZR_BRANCH_DIR="${EBZR_REPO_DIR}/${EBZR_CACHE_BRANCH_DIR:-${EBZR_BRANCH}}"
+
+		addwrite "${EBZR_REPO_DIR}"
+	else
+		# using stand-alone branch
+		EBZR_BRANCH_DIR="${EBZR_STORE_DIR}/${EBZR_CACHE_BRANCH_DIR:-${PN}}"
+	fi
+
+	addwrite "${EBZR_BRANCH_DIR}"
 
-	local repository
+	local branch
 
-	if [[ ${EBZR_REPO_URI} == */* ]]; then
-		repository="${EBZR_REPO_URI}${EBZR_BRANCH}"
+	if [[ -n ${EBZR_BRANCH} ]] ; then
+		branch="${EBZR_REPO_URI}/${EBZR_BRANCH}"
 	else
-		repository="${EBZR_REPO_URI}"
+		branch="${EBZR_REPO_URI}"
+	fi
+
+	if [[ ${EBZR_SHARED_REPO} && ! -d ${EBZR_REPO_DIR} ]] ; then
+		# create shared repository
+		debug-print "${FUNCNAME}: EBZR_INIT_REPO_OPTS = ${EBZR_INIT_REPO_OPTS}"
+
+		${EBZR_INIT_REPO_CMD} ${EBZR_INIT_REPO_OPTS} ${EBZR_REPO_DIR} \
+			|| die "${EBZR}: can't initialize shared repository."
+	fi
+
+	if [[ ${EBZR_BRANCH} == */* && ! -f $(dirname ${EBZR_BRANCH}) ]]; then
+		# prepare path to branch
+		mkdir -p "${EBZR_REPO_DIR}/$(dirname ${EBZR_BRANCH})"
 	fi
 
 	if [[ ! -d ${EBZR_BRANCH_DIR} ]] ; then
 		# fetch branch
 		einfo "bzr branch start -->"
-		einfo "   repository: ${repository} => ${EBZR_BRANCH_DIR}"
+		einfo "   branch: ${branch} => ${EBZR_BRANCH_DIR}"
+
+		EBZR_OPTIONS="${EBZR_OPTIONS} ${EBZR_FETCH_OPTS}"
+		debug-print "${FUNCNAME}: EBZR_OPTIONS = ${EBZR_OPTIONS}"
 
-		${EBZR_FETCH_CMD} ${EBZR_OPTIONS} "${repository}" "${EBZR_BRANCH_DIR}" \
-			|| die "${EBZR}: can't branch from ${repository}."
+		${EBZR_FETCH_CMD} ${EBZR_OPTIONS} "${branch}" "${EBZR_BRANCH_DIR}" \
+			|| die "${EBZR}: can't branch from ${branch}."
 
 	else
 		# update branch
 		einfo "bzr pull start -->"
-		einfo "   repository: ${repository}"
+		einfo "   branch: ${branch} => ${EBZR_BRANCH_DIR}"
+
+		EBZR_OPTIONS="${EBZR_OPTIONS} ${EBZR_UPDATE_OPTS}"
+		debug-print "${FUNCNAME}: EBZR_OPTIONS = ${EBZR_OPTIONS}"
 
 		cd "${EBZR_BRANCH_DIR}"
-		${EBZR_UPDATE_CMD} ${EBZR_OPTIONS} "${repository}" \
-			|| die "${EBZR}: can't merge from ${repository}."
+		${EBZR_UPDATE_CMD} ${EBZR_OPTIONS} "${branch}" \
+			|| die "${EBZR}: can't merge from ${branch}."
 		${EBZR_DIFFSTAT_CMD}
 	fi
 

  reply	other threads:[~2008-10-05 20:54 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-17 18:31 [gentoo-dev] bzr.eclass into Portage Christian Faulhammer
2008-03-18  0:37 ` Petteri Räty
2008-03-19  4:40   ` Jorge Manuel B. S. Vicetto
2008-03-20  7:38     ` [gentoo-dev] " Christian Faulhammer
2008-03-21  3:47       ` Jorge Manuel B. S. Vicetto
2008-03-21 11:49         ` Christian Faulhammer
2008-03-25  1:28           ` René 'Necoro' Neumann
2008-03-25 15:19             ` René 'Necoro' Neumann
2008-03-25 20:08               ` Christian Faulhammer
2008-10-05 17:26           ` Ulrich Mueller
2008-10-05 20:54             ` Jonas Bernoulli [this message]
2008-10-06  0:58             ` Jorge Manuel B. S. Vicetto
2008-10-06  6:14               ` Ulrich Mueller
2008-10-13  2:43                 ` Steve Long
2008-10-13  6:29                   ` Ulrich Mueller
2008-10-13 15:23                   ` Bo Ørsted Andresen
2008-10-15  9:36                     ` [gentoo-dev] " Steve Long
2008-10-25 12:19               ` [gentoo-dev] " Ulrich Mueller

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=201bac3a0810051354v4e22eb6fv1837142ee3a1a2bd@mail.gmail.com \
    --to=jonas@bernoulli.cc \
    --cc=gentoo-dev@lists.gentoo.org \
    /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