• [gentoo-dev] [PATCH 1/2] bzr.eclass: Reinstate eclass

    From =?UTF-8?q?Ulrich=20M=C3=BCller?=@21:1/5 to All on Sat Sep 25 11:40:02 2021
    Taken from commit 320fcf034f5e860454e0d2a28ed405c5b843c60c.

    Signed-off-by: Ulrich Müller <ulm@gentoo.org>
    ---
    eclass/bzr.eclass | 289 ++++++++++++++++++++++++++++++++++++++++++++++
    1 file changed, 289 insertions(+)
    create mode 100644 eclass/bzr.eclass

    diff --git a/eclass/bzr.eclass b/eclass/bzr.eclass
    new file mode 100644
    index 000000000000..fc1de9dc9ccc
    --- /dev/null
    +++ b/eclass/bzr.eclass
    @@ -0,0 +1,289 @@
    +# Copyright 1999-2019 Gentoo Authors
    +# Distributed under the terms of the GNU General Public License v2
    +
    +# @ECLASS: bzr.eclass
    +# @MAINTAINER:
    +# Ulrich Müller <ulm@gentoo.org>
    +# @AUTHOR:
    +# Jorge Manuel B. S. Vicetto <jmbsvicetto@gentoo.org>
    +# Mark Lee <bzr-gentoo-overlay@lazymalevolence.com>
    +# Ulrich Müller <ulm@gentoo.org>
    +# Christian Faulhammer <fauli@gentoo.org>
    +# @SUPPORTED_EAPIS: 2 3 4 5 6 7
    +# @BLURB: generic fetching functions for the Bazaar VCS
    +# @DESCRIPTION:
    +# The bzr.eclass provides functions to fetch and unpack sources from
    +# repositories of the Bazaar distributed version control system.
    +# The eclass was originally derived from git.eclass.
    +#
    +# N
  • From =?UTF-8?Q?Micha=C5=82_G=C3=B3rny?=@21:1/5 to All on Sat Sep 25 12:00:01 2021
    On Sat, 2021-09-25 at 11:36 +0200, Ulrich Müller wrote:
    Taken from commit 320fcf034f5e860454e0d2a28ed405c5b843c60c.

    I suppose you'll want to apply my comments as followup changes.


    Signed-off-by: Ulrich Müller <ulm@gentoo.org>
    ---
    eclass/bzr.eclass | 289 ++++++++++++++++++++++++++++++++++++++++++++++
    1 file changed, 289 insertions(+)
    create mode 100644 eclass/bzr.eclass

    diff --git a/eclass/bzr.eclass b/eclass/bzr.eclass
    new file mode 100644
    index 000000000000..fc1de9dc9ccc
    --- /dev/null
    +++ b/eclass/bzr.eclass
    @@ -0,0 +1,289 @@
    +# Copyright 1999-2019 Gentoo Authors
    +# Distributed under the terms of the GNU General Public License v2
    +
    +# @ECLASS: bzr.eclass
    +# @MAINTAINER:
    +# Ulrich Müller <ulm@gentoo.org>
    +# @AUTHOR:
    +# Jorge Manuel B. S. Vicetto <jmbsvicetto@gentoo.org>
    +# Mark Lee <bzr-gentoo-overlay@lazymalevolence.com>
    +# Ulrich Müller <ulm@gentoo.org>
    +# Christian Faulhammer <fauli@gentoo.org>
    +# @SUPPORTED_EAPIS: 2 3 4 5 6 7
    +# @BLURB: generic fetching functions for the Bazaar VCS
    +# @DESCRIPTION:
    +# The bzr.eclass provides functions to fetch and unpack sources from
    +# repositories of the Bazaar distributed version control system.
    +# The eclass was originally derived from git.eclass.
    +#
    +# Note: Just set EBZR_REPO_URI to the URI of the branch and src_unpack()
    +# of this eclass will export the branch to ${WORKDIR}/${P}.
    +
    +EBZR="bzr.eclass"

    Why do we need this? It seems as if someone is reinventing ${ECLASS}.

    +
    +PROPERTIES+=" live"
    +
    +if [[ ${EBZR_REPO_URI%%:*} = sftp ]]; then
    + DEPEND=">=dev-vcs/bzr-2.6.0[sftp]"
    +else
    + DEPEND=">=dev-vcs/bzr-2.6.0"
    +fi
    +
    +case ${EAPI:-0} in
    + 2|3|4|5|6) ;;
    + 7) BDEPEND="${DEPEND}"; DEPEND="" ;;
    + *) die "${EBZR}: EAPI ${EAPI:-0} is not supported" ;;
    +esac
    +
    +EXPORT_FUNCTIONS src_unpack
    +
    +# @ECLASS-VARIABLE: EBZR_STORE_DIR

    @USER_VARIABLE?

    +# @DESCRIPTION:
    +# The directory to store all fetched Bazaar live sources.
    +: ${EBZR_STORE_DIR:=${PORTAGE_ACTUAL_DISTDIR:-${DISTDIR}}/bzr-src}
    +
    +# @ECLASS-VARIABLE: EBZR_UNPACK_DIR
    +# @DESCRIPTION:
    +# The working directory where the sources are copied to.
    +: ${EBZR_UNPACK_DIR:=${WORKDIR}/${P}}
    +
    +# @ECLASS-VARIABLE: EBZR_INIT_REPO_CMD
    +# @DESCRIPTION:
    +# The Bazaar command to initialise a shared repository.
    +: ${EBZR_INIT_REPO_CMD:="bzr init-repository --no-trees"}
    +
    +# @ECLASS-VARIABLE: EBZR_FETCH_CMD
    +# @DESCRIPTION:
    +# The Bazaar command to fetch the sources.
    +: ${EBZR_FETCH_CMD:="bzr branch --no-tree"}
    +
    +# @ECLASS-VARIABLE: EBZR_UPDATE_CMD
    +# @DESCRIPTION:
    +# The Bazaar command to update the sources.
    +: ${EBZR_UPDATE_CMD:="bzr pull --overwrite-tags"}
    +
    +# @ECLASS-VARIABLE: EBZR_EXPORT_CMD
    +# @DESCRIPTION:
    +# The Bazaar command to export a branch.
    +: ${EBZR_EXPORT_CMD:="bzr export"}
    +
    +# @ECLASS-VARIABLE: EBZR_CHECKOUT_CMD
    +# @DESCRIPTION:
    +# The Bazaar command to checkout a branch.
    +: ${EBZR_CHECKOUT_CMD:="bzr checkout --lightweight -q"}
    +
    +# @ECLASS-VARIABLE: EBZR_REVNO_CMD
    +# @DESCRIPTION:
    +# The Bazaar command to list a revision number of the branch.
    +: ${EBZR_REVNO_CMD:="bzr revno"}

    Are you sure that having these overrides is a good idea? Your followup
    patch pretty much proves that every ebuild redefining them would get
    broken by switch to breezy.

    +
    +# @ECLASS-VARIABLE: EBZR_OPTIONS
    +# @DEFAULT_UNSET
    +# @DESCRIPTION:
    +# The options passed to the fetch and update commands.

    Is this intended to be set by ebuild or by user?

    +
    +# @ECLASS-VARIABLE: EBZR_REPO_URI
    +# @DEFAULT_UNSET
    +# @REQUIRED
    +# @DESCRIPTION:
    +# The repository URI for the source package.
    +#
    +# Note: If the ebuild uses an sftp:// URI, then the eclass will depend
    +# on dev-vcs/bzr[sftp].
    +
    +# @ECLASS-VARIABLE: EBZR_INITIAL_URI
    +# @DEFAULT_UNSET
    +# @DESCRIPTION:
    +# The URI used for initial branching of the source repository. If this
    +# variable is set, the initial branch will be cloned from the location
    +# specified, followed by a pull from ${EBZR_REPO_URI}. This is intended
    +# for special cases, e.g. when download from the original repository is
    +# slow, but a fast mirror exists but may be out of date.
    +#
    +# Normally, this variable needs not be set.
    +
    +# @ECLASS-VARIABLE: EBZR_PROJECT
    +# @DESCRIPTION:
    +# The project name of your ebuild. Normally, the branch will be stored
    +# in the ${EBZR_STORE_DIR}/${EBZR_PROJECT} directory.
    +#
    +# If EBZR_BRANCH is set (see below), then a shared repository will be
    +# created in that directory, and the branch will be located in
    +# ${EBZR_STORE_DIR}/${EBZR_PROJECT}/${EBZR_BRANCH}.
    +: ${EBZR_PROJECT:=${PN}}
    +
    +# @ECLASS-VARIABLE: EBZR_BRANCH
    +# @DEFAULT_UNSET
    +# @DESCRIPTION:
    +# The directory where to store the branch within a shared repository,
    +# relative to ${EBZR_STORE_DIR}/${EBZR_PROJECT}.
    +#
    +# This variable should be set if there are several live ebuilds for
    +# different branches of the same upstream project. The branches can
    +# then share the same repository in EBZR_PROJECT, which will save both
    +# data traffic volume and disk space.
    +#
    +# If there is only a live ebuild for one single branch, EBZR_BRANCH
    +# needs not be set. In this case, the branch will be stored in a
    +# stand-alone repository directly in EBZR_PROJECT.
    +
    +# @ECLASS-VARIABLE: EBZR_REVISION
    +# @DEFAULT_UNSET
    +# @DESCRIPTION:
    +# Revision to fetch, defaults to the latest
    +# (see http://bazaar-vcs.org/BzrRevisionSpec or bzr help revisionspec).
    +
    +# @ECLASS-VARIABLE: EBZR_OFFLINE

    @USER_VARIABLE?

    +# @DESCRIPTION:
    +# Set this variable to a non-empty value to disable automatic updating
    +# of a bzr source tree. This is intended to be set outside the ebuild
    +# by users.
    +: ${EBZR_OFFLINE=${EVCS_OFFLINE}}
    +
    +# @ECLASS-VARIABLE: EVCS_UMASK

    @USER_VARIABLE?

    +# @DEFAULT_UNSET
    +# @DESCRIPTION:
    +# Set this variable to a custom umask. This is intended to be set by
    +# users. By setting this to something like 002, it can make life easier
    +# for people who do development as non-root (but are in the portage
    +# group), and then switch over to building with FEATURES=userpriv.
    +# Or vice-versa. Shouldn't be a security issue here as anyone who has
    +# portage group write access already can screw the system over in more
    +# creative ways.
    +
    +# @ECLASS-VARIABLE: EBZR_WORKDIR_CHECKOUT
    +# @DEFAULT_UNSET
    +# @DESCRIPTION:
    +# If this variable is set to a non-empty value, EBZR_CHECKOUT_CMD will
    +# be used instead of EBZR_EXPORT_CMD to copy the sources to WORKDIR.
    +
    +# @FUNCTION: bzr_initial_fetch

    @INTERNAL?

    +# @USAGE: <repository URI> <branch directory>
    +# @DESCRIPTION:
    +# Internal function, retrieves the source code from a repository for the
    +# first time, using ${EBZR_FETCH_CMD}.
    +bzr_initial_fetch() {
    + local repo_uri=$1 branch_dir=$2
    +
    + if [[ -n "${EBZR_OFFLINE}" ]]; then
    + ewarn "EBZR_OFFLINE cannot be used when there is no local branch yet."

    I dare say this is incorrect. If user says "no online operations", then
    the eclass should just fail, not ignore the user.

    + fi
    +
    + # fetch branch
    + einfo "bzr branch start -->"
    + einfo " repository: ${repo_uri} => ${branch_dir}"
    +
    + ${EBZR_FETCH_CMD} ${EBZR_OPTIONS} "${repo_uri}" "${branch_dir}" \
    + || die "${EBZR}: can't branch from ${repo_uri}"

    You can replace the backslash with '||'.

    +}
    +
    +# @FUNCTION: bzr_update

    @INTERNAL?

    +# @USAGE: <repository URI> <branch directory>
    +# @DESCRIPTION:
    +# Internal function, updates the source code from a repository, using
    +# ${EBZR_UPDATE_CMD}.
    +bzr_update() {
    + local repo_uri=$1 branch_dir=$2
    +
    + if [[ -n "${EBZR_OFFLINE}" ]]; then
    + einfo "skipping bzr pull -->"
    + einfo " repository: ${repo_uri}"
    + else
    + # update branch
    + einfo "bzr pull start -->"
    + einfo " repository: ${repo_uri}"
    +
    + pushd "${branch_dir}" > /dev/null \
    + || die "${EBZR}: can't chdir to ${branch_dir}"
    + ${EBZR_UPDATE_CMD} ${EBZR_OPTIONS} "${repo_uri}" \
    + || die "${EBZR}: can't pull from ${repo_uri}"
    + popd > /dev/null || die "${EBZR}: popd failed"
    + fi
    +}
    +
    +# @FUNCTION: bzr_fetch
    +# @DESCRIPTION:
    +# Wrapper function to fetch sources from a Bazaar repository with
    +# bzr branch or bzr pull, depending on whether there is an existing
    +# working copy.
    +bzr_fetch() {
    + local repo_dir branch_dir
    + local save_sandbox_write=${SANDBOX_WRITE} save_umask
    +
    + [[ -n ${EBZR_REPO_URI} ]] || die "${EBZR}: EBZR_REPO_URI is empty"
    +
    + if [[ ! -d ${EBZR_STORE_DIR} ]] ; then
    + addwrite /
    + mkdir -p "${EBZR_STORE_DIR}" \
    + || die "${EBZR}: can't mkdir ${EBZR_STORE_DIR}"
    + SANDBOX_WRITE=${save_sandbox_write}

    Looks like abusing implementation details.

    + fi
    +
    + pushd "${EBZR_STORE_DIR}" > /dev/null \
    + || die "${EBZR}: can't chdir to ${EBZR_STORE_DIR}"
    +
    + repo_dir=${EBZR_STORE_DIR}/${EBZR_PROJECT}
    + branch_dir=${repo_dir}${EBZR_BRANCH:+/${EBZR_BRANCH}}
    +
    + if [[ -n ${EVCS_UMASK} ]]; then
    + save_umask=$(umask)
    + umask "${EVCS_UMASK}" || die
    + fi
    + addwrite "${EBZR_STORE_DIR}"
    +
    + if [[ ! -d ${branch_dir}/.bzr ]]; then
    + if [[ ${repo_dir} != "${branch_dir}" && ! -d ${repo_dir}/.bzr ]]; then
    + einfo "creating shared bzr repository: ${repo_dir}"
    + ${EBZR_INIT_REPO_CMD} "${repo_dir}" \
    + || die "${EBZR}: can't create shared repository"
    + fi
    +
    + if [[ -z ${EBZR_INITIAL_URI} ]]; then
    + bzr_initial_fetch "${EBZR_REPO_URI}" "${branch_dir}"
    + else
    + # Workaround for faster initial download. This clones the
    + # branch from a fast server (which may be out of date), and
    + # subsequently pulls from the slow original repository. + bzr_initial_fetch "${EBZR_INITIAL_URI}" "${branch_dir}" + if [[ ${EBZR_REPO_URI} != "${EBZR_INITIAL_URI}" ]]; then
    + EBZR_UPDATE_CMD="${EBZR_UPDATE_CMD} --remember --overwrite" \
    + EBZR_OFFLINE="" \

    Why do you override EBZR_OFFLINE here?

    + bzr_update "${EBZR_REPO_URI}" "${branch_dir}"
    + fi
    + fi
    + else
    + bzr_update "${EBZR_REPO_URI}" "${branch_dir}"
    + fi
    +
    + # Restore sandbox environment and umask
    + SANDBOX_WRITE=${save_sandbox_write}
    + if [[ -n ${save_umask} ]]; then
    + umask "${save_umask}" || die
    + fi
    +
    + cd "${branch_dir}" || die "${EBZR}: can't chdir to ${branch_dir}"
    +
    + # Save revision number in environment. #311101
    + export EBZR_REVNO=$(${EBZR_REVNO_CMD})
    +
    + if [[ -n ${EBZR_WORKDIR_CHECKOUT} ]]; then
    + einfo "checking out ..."
    + ${EBZR_CHECKOUT_CMD} ${EBZR_REVISION:+-r ${EBZR_REVISION}} \
    + . "${EBZR_UNPACK_DIR}" || die "${EBZR}: checkout failed"
    + else
    + einfo "exporting ..."
    + ${EBZR_EXPORT_CMD} ${EBZR_REVISION:+-r ${EBZR_REVISION}} \
    + "${EBZR_UNPACK_DIR}" . || die "${EBZR}: export failed" + fi
    + einfo \
    + "revision ${EBZR_REVISION:-${EBZR_REVNO}} is now in ${EBZR_UNPACK_DIR}"
    +
    + popd > /dev/null || die "${EBZR}: popd failed"
    +}
    +
    +# @FUNCTION: bzr_src_unpack
    +# @DESCRIPTION:
    +# Default src_unpack(), calls bzr_fetch.
    +bzr_src_unpack() {
    + bzr_fetch
    +}

    --
    Best regards,
    Michał Górny

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Arthur Zamarin@21:1/5 to All on Sat Sep 25 12:30:02 2021
    To: ulm@gentoo.org (=?UTF-8?Q?Ulrich_M=c3=bcller?=)

    This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --V3ALRbfz8JgghT9vFAcvqpXYsdU4zoDlb
    Content-Type: text/plain; charset=utf-8; format=flowed
    Content-Language: en-US
    Content-Transfer-Encoding: quoted-printable

    On 25/09/2021 12:36, Ulrich Müller wrote:
    Taken from commit 320fcf034f5e860454e0d2a28ed405c5b843c60c.

    Signed-off-by: Ulrich Müller <ulm@gentoo.org>
    ---
    eclass/bzr.eclass | 289 ++++++++++++++++++++++++++++++++++++++++++++++
    1 file changed, 289 insertions(+)
    create mode 100644 eclass/bzr.eclass

    diff --git a/eclass/bzr.eclass b/eclass/bzr.eclass
    new file mode 100644
    index 000000000000..fc1de9dc9ccc
    --- /dev/null
    +++ b/eclass/bzr.eclass
    @@ -0,0 +1,289 @@
    +# Copyright 1999-2019 Gentoo Authors
    +# Distributed under the terms of the GNU General Public License v2
    +
    +# @ECLASS: bzr.eclass
    +# @MAINTAINER:
    +# Ulrich Müller <ulm@gentoo.org>
    +# @AUTHOR:
    +# Jorge Manuel B. S. Vicetto <jmbsvicetto@gentoo.org>
    +# Mark Lee <bzr-gentoo-overlay@lazymalevolence.com>
    +# Ulrich Müller <ulm@gentoo.org>
    +# Christian Faulhammer <fauli@gentoo.org>
    +# @SUPPORTED_EAPIS: 2 3 4 5 6 7
    +# @BLURB: generic fetching functions for the Bazaar VCS
    +# @DESCRIPTION:
    +# The bzr.eclass provides functions to fetch and unpack sources from
    +# repositories of the Bazaar distributed version control system.
    +# The eclass was originally derived from git.eclass.
    +#
    +# Note: Just set EBZR_REPO_URI to the URI of the branch and src_unpack()
    +# of this eclass will export the branch to ${WORKDIR}/${P}.
    +
    +EBZR="bzr.eclass"
    +
    +PROPERTIES+=" live"
    +
    +if [[ ${EBZR_REPO_URI%%:*} = sftp ]]; then
    + DEPEND=">=dev-vcs/bzr-2.6.0[sftp]"
    +else
    + DEPEND=">=dev-vcs/bzr-2.6.0"
    +fi
    +
    +case ${EAPI:-0} in
    + 2|3|4|5|6) ;;
    + 7) BDEPEND="${DEPEND}"; DEPEND="" ;;
    + *) die "${EBZR}: EAPI ${EAPI:-0} is not supported" ;;
    +esac
    +
    +EXPORT_FUNCTIONS src_unpack
    +
    +# @ECLASS-VARIABLE: EBZR_STORE_DIR
    +# @DESCRIPTION:
    +# The directory to store all fetched Bazaar live sources.
    +: ${EBZR_STORE_DIR:=${PORTAGE_ACTUAL_DISTDIR:-${DISTDIR}}/bzr-src}
    +
    +# @ECLASS-VARIABLE: EBZR_UNPACK_DIR
    +# @DESCRIPTION:
    +# The working directory where the sources are copied to.
    +: ${EBZR_UNPACK_DIR:=${WORKDIR}/${P}}
    +
    +# @ECLASS-VARIABLE: EBZR_INIT_REPO_CMD
    +# @DESCRIPTION:
    +# The Bazaar command to initialise a shared repository.
    +: ${EBZR_INIT_REPO_CMD:="bzr init-repository --no-trees"}
    +
    +# @ECLASS-VARIABLE: EBZR_FETCH_CMD
    +# @DESCRIPTION:
    +# The Bazaar command to fetch the sources.
    +: ${EBZR_FETCH_CMD:="bzr branch --no-tree"}
    +
    +# @ECLASS-VARIABLE: EBZR_UPDATE_CMD
    +# @DESCRIPTION:
    +# The Bazaar command to update the sources.
    +: ${EBZR_UPDATE_CMD:="bzr pull --overwrite-tags"}
    +
    +# @ECLASS-VARIABLE: EBZR_EXPORT_CMD
    +# @DESCRIPTION:
    +# The Bazaar command to export a branch.
    +: ${EBZR_EXPORT_CMD:="bzr export"}
    +
    +# @ECLASS-VARIABLE: EBZR_CHECKOUT_CMD
    +# @DESCRIPTION:
    +# The Bazaar command to checkout a branch.
    +: ${EBZR_CHECKOUT_CMD:="bzr checkout --lightweight -q"}
    +
    +# @ECLASS-VARIABLE: EBZR_REVNO_CMD
    +# @DESCRIPTION:
    +# The Bazaar command to list a revision number of the branch.
    +: ${EBZR_REVNO_CMD:="bzr revno"}
    +
    +# @ECLASS-VARIABLE: EBZR_OPTIONS
    +# @DEFAULT_UNSET
    +# @DESCRIPTION:
    +# The options passed to the fetch and update commands.
    +
    +# @ECLASS-VARIABLE: EBZR_REPO_URI
    +# @DEFAULT_UNSET
    +# @REQUIRED
    +# @DESCRIPTION:
    +# The repository URI for the source package.
    +#
    +# Note: If the ebuild uses an sftp:// URI, then the eclass will depend
    +# on dev-vcs/bzr[sftp].
    +
    +# @ECLASS-VARIABLE: EBZR_INITIAL_URI
    +# @DEFAULT_UNSET
    +# @DESCRIPTION:
    +# The URI used for initial branching of the source repository. If this
    +# variable is set, the initial branch will be cloned from the location
    +# specified, followed by a pull from ${EBZR_REPO_URI}. This is intended
    +# for special cases, e.g. when download from the original repository is
    +# slow, but a fast mirror exists but may be out of date.
    +#
    +# Normally, this variable needs not be set.
    +
    +# @ECLASS-VARIABLE: EBZR_PROJECT
    +# @DESCRIPTION:
    +# The project name of your ebuild. Normally, the branch will be stored
    +# in the ${EBZR_STORE_DIR}/${EBZR_PROJECT} directory.
    +#
    +# If EBZR_BRANCH is set (see below), then a shared repository will be
    +# created in that directory, and the branch will be located in
    +# ${EBZR_STORE_DIR}/${EBZR_PROJECT}/${EBZR_BRANCH}.
    +: ${EBZR_PROJECT:=${PN}}
    +
    +# @ECLASS-VARIABLE: EBZR_BRANCH
    +# @DEFAULT_UNSET
    +# @DESCRIPTION:
    +# The directory where to store the branch within a shared repository,
    +# relative to ${EBZR_STORE_DIR}/${EBZR_PROJECT}.
    +#
    +# This variable should be set if there are several live ebuilds for
    +# different branches of the same upstream project. The branches can
    +# then share the same repository in EBZR_PROJECT, which will save both
    +# data traffic volume and disk space.
    +#
    +# If there is only a live ebuild for one single branch, EBZR_BRANCH
    +# needs not be set. In this case, the branch will be stored in a
    +# stand-alone repository directly in EBZR_PROJECT.
    +
    +# @ECLASS-VARIABLE: EBZR_REVISION
    +# @DEFAULT_UNSET
    +# @DESCRIPTION:
    +# Revision to fetch, defaults to the latest
    +# (see http://bazaar-vcs.org/BzrRevisionSpec or bzr help revisionspec).
    +
    +# @ECLASS-VARIABLE: EBZR_OFFLINE
    +# @DESCRIPTION:
    +# Set this variable to a non-empty value to disable automatic updating
    +# of a bzr source tree. This is intended to be set outside the ebuild
    +# by users.
    +: ${EBZR_OFFLINE=${EVCS_OFFLINE}}
    +
    +# @ECLASS-VARIABLE: EVCS_UMASK
    +# @DEFAULT_UNSET
    +# @DESCRIPTION:
    +# Set this variable to a custom umask. This is intended to be set by
    +# users. By setting this to something like 002, it can make life easier
    +# for people who do development as non-root (but are in the portage
    +# group), and then switch over to building with FEATURES=userpriv.
    +# Or vice-versa. Shouldn't be a security issue here as anyone who has
    +# portage group write access already can screw the system over in more
    +# creative ways.
    +
    +# @ECLASS-VARIABLE: EBZR_WORKDIR_CHECKOUT
    +# @DEFAULT_UNSET
    +# @DESCRIPTION:
    +# If this variable is set to a non-empty value, EBZR_CHECKOUT_CMD will
    +# be used instead of EBZR_EXPORT_CMD to copy the sources to WORKDIR.
    +
    +# @FUNCTION: bzr_initial_fetch
    +# @USAGE: <repository URI> <branch directory>
    +# @DESCRIPTION:
    +# Internal function, retrieves the source code from a repository for the
    +# first time, using ${EBZR_FETCH_CMD}.
    +bzr_initial_fetch() {
    + local repo_uri=$1 branch_dir=$2
    +
    + if [[ -n "${EBZR_OFFLINE}" ]]; then
    + ewarn "EBZR_OFFLINE cannot be used when there is no local branch yet."
    + fi
    +
    + # fetch branch
    + einfo "bzr branch start -->"
    + einfo " repository: ${repo_uri} => ${branch_dir}"
    +
    + ${EBZR_FETCH_CMD} ${EBZR_OPTIONS} "${repo_uri}" "${branch_dir}" \
    + || die "${EBZR}: can't branch from ${repo_uri}"
    +}
    +
    +# @FUNCTION: bzr_update
    +# @USAGE: <repository URI> <branch directory>
    +# @DESCRIPTION:
    +# Internal function, updates the source code from a repository, using
    +# ${EBZR_UPDATE_CMD}.
    +bzr_update() {
    + local repo_uri=$1 branch_dir=$2
    +
    + if [[ -n "${EBZR_OFFLINE}" ]]; then
    + einfo "skipping bzr pull -->"
    + einfo " repository: ${repo_uri}"
    + else
    + # update branch
    + einfo "bzr pull start -->"
    + einfo " repository: ${repo_uri}"
    +
    + pushd "${branch_dir}" > /dev/null \
    + || die "${EBZR}: can't chdir to ${branch_dir}"
    + ${EBZR_UPDATE_CMD} ${EBZR_OPTIONS} "${repo_uri}" \
    + || die "${EBZR}: can't pull from ${repo_uri}"
    + popd > /dev/null || die "${EBZR}: popd failed"
    + fi
    +}
    +
    +# @FUNCTION: bzr_fetch
    +# @DESCRIPTION:
    +# Wrapper function to fetch sources from a Bazaar repository with
    +# bzr branch or bzr pull, depending on whether there is an existing
    +# working copy.
    +bzr_fetch() {
    + local repo_dir branch_dir
    + local save_sandbox_write=${SANDBOX_WRITE} save_umask
    +
    + [[ -n ${EBZR_REPO_URI} ]] || die "${EBZR}: EBZR_REPO_URI is empty"
    +
    + if [[ ! -d ${EBZR_STORE_DIR} ]] ; then
    + addwrite /
    + mkdir -p "${EBZR_STORE_DIR}" \
    + || die "${EBZR}: can't mkdir ${EBZR_STORE_DIR}"
    + SANDBOX_WRITE=${save_sandbox_write}
    + fi
    +
    + pushd "${EBZR_STORE_DIR}" > /dev/null \
    + || die "${EBZR}: can't chdir to ${EBZR_STORE_DIR}"
    +
    + repo_dir=${EBZR_STORE_DIR}/${EBZR_PROJECT}
    + branch_dir=${repo_dir}${EBZR_BRANCH:+/${EBZR_BRANCH}} > +
    + if [[ -n ${EVCS_UMASK} ]]; then
    + save_umask=$(umask)
    + umask "${EVCS_UMASK}" || die
    + fi
    + addwrite "${EBZR_STORE_DIR}"
    +
    + if [[ ! -d ${branch_dir}/.bzr ]]; then
    + if [[ ${repo_dir} != "${branch_dir}" && ! -d ${repo_dir}/.bzr ]]; then
    + einfo "creating shared bzr repository: ${repo_dir}"
    + ${EBZR_INIT_REPO_CMD} "${repo_dir}" \
    + || die "${EBZR}: can't create shared repository"
    + fi
    +
    + if [[ -z ${EBZR_INITIAL_URI} ]]; then
    + bzr_initial_fetch "${EBZR_REPO_URI}" "${branch_dir}"
    + else
    + # Workaround for faster initial download. This clones the
    + # branch from a fast server (which may be out of date), and
    + # subsequently pulls from the slow original repository. + bzr_initial_fetch "${EBZR_INITIAL_URI}" "${branch_dir}" + if [[ ${EBZR_REPO_URI} != "${EBZR_INITIAL_URI}" ]]; then
    + EBZR_UPDATE_CMD="${EBZR_UPDATE_CMD} --remember --overwrite" \
    + EBZR_OFFLINE="" \
    + bzr_update "${EBZR_REPO_URI}" "${branch_dir}"
    + fi

    This logic maybe can be improved and made easier, by defaulting EBZR_INITIAL_URI to be by default EBZR_REPO_URI (as a result, the first
    call to bzr_initial_fetch can be done outside the if), and if the ebuild
    writer changed it (check using the if here), then do the next bzr_update.

    Or another option, instead of setting by default, do the first fetch as: bzr_initial_fetch "${EBZR_INITIAL_URI:-${EBZR_REPO_URI}}" "${branch_dir}"
    But I think this one is less readable.

    + fi
    + else
    + bzr_update "${EBZR_REPO_URI}" "${branch_dir}"
    + fi
    +
    + # Restore sandbox environment and umask
    + SANDBOX_WRITE=${save_sandbox_write}
    + if [[ -n ${save_umask} ]]; then
    + umask "${save_umask}" || die
    + fi
    +
    + cd "${branch_dir}" || die "${EBZR}: can't chdir to ${branch_dir}"
    +
    + # Save revision number in environment. #311101
    + export EBZR_REVNO=$(${EBZR_REVNO_CMD})
    +
    + if [[ -n ${EBZR_WORKDIR_CHECKOUT} ]]; then
    + einfo "checking out ..."
    + ${EBZR_CHECKOUT_CMD} ${EBZR_REVISION:+-r ${EBZR_REVISION}} \
    + . "${EBZR_UNPACK_DIR}" || die "${EBZR}: checkout failed"
    + else
    + einfo "exporting ..."
    + ${EBZR_EXPORT_CMD} ${EBZR_REVISION:+-r ${EBZR_REVISION}} \
    + "${EBZR_UNPACK_DIR}" . || die "${EBZR}: export failed" + fi
    + einfo \
    + "revision ${EBZR_REVISION:-${EBZR_REVNO}} is now in ${EBZR_UNPACK_DIR}"
    +
    + popd > /dev/null || die "${EBZR}: popd failed"
    +}
    +
    +# @FUNCTION: bzr_src_unpack
    +# @DESCRIPTION:
    +# Default src_unpack(), calls bzr_fetch.
    +bzr_src_unpack() {
    + bzr_fetch
    +}


    Thank you for working on it!

    --
    Arthur Zamarin
    arthurzam@gentoo.org
    Gentoo Linux developer (Python, GURU)


    --V3ALRbfz8JgghT9vFAcvqpXYsdU4zoDlb--

    -----BEGIN PGP SIGNATURE-----

    iQEzBAEBCAAdFiEE/axFlFuH2ptjtO5EAqCvUD0SBQQFAmFO9+kACgkQAqCvUD0S BQROeggAqNjmiA5GHHgxIFOivg5f5BErfsyqTtJUhulQpHj4v8eBxdFz9iQog9rA +1yBeR5psZdKkiH+agUmbJIvqDxeRkBuEWxJiB04VVQCP7umYWnupndsLDcpJadR J3Cr/rnQwMsaK32eljgnveqh+/5+kADwjU1I52Y9wkeHZs5GjZBMtV4Ra1cebSaM YJ2/8E6gX7XQJ7oxwzd3qwG4NgvcnxAmUZB52dF1LVTZFnYKCNRUuRBvFptHDliQ DiUNz45eagYbjZ3L96iuPkLXszCsx+9l1hFo/3LMDxuVEdz6/d+RbyJiLJCrbGqu Qd3uEc31VtUWSc+fCWclfERJ/YLOnw==
    =4Ljl
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ulrich Mueller@21:1/5 to All on Sat Sep 25 14:40:02 2021
    On Sat, 25 Sep 2021, Arthur Zamarin wrote:

    On 25/09/2021 12:36, Ulrich Müller wrote:
    + if [[ -z ${EBZR_INITIAL_URI} ]]; then
    + bzr_initial_fetch "${EBZR_REPO_URI}" "${branch_dir}"
    + else
    + # Workaround for faster initial download. This clones the
    + # branch from a fast server (which may be out of date), and
    + # subsequently pulls from the slow original repository. >> + bzr_initial_fetch "${EBZR_INITIAL_URI}" "${branch_dir}" >> + if [[ ${EBZR_REPO_URI} != "${EBZR_INITIAL_URI}" ]]; then
    + EBZR_UPDATE_CMD="${EBZR_UPDATE_CMD} --remember --overwrite" \
    + EBZR_OFFLINE="" \
    + bzr_update "${EBZR_REPO_URI}" "${branch_dir}"
    + fi

    This logic maybe can be improved and made easier, by defaulting EBZR_INITIAL_URI to be by default EBZR_REPO_URI (as a result, the
    first call to bzr_initial_fetch can be done outside the if), and if
    the ebuild writer changed it (check using the if here), then do the
    next bzr_update.

    Or another option, instead of setting by default, do the first fetch as: bzr_initial_fetch "${EBZR_INITIAL_URI:-${EBZR_REPO_URI}}" "${branch_dir}"
    But I think this one is less readable.

    + fi

    I am going to drop support for EBZR_INITIAL_URI altogether. This was a
    special case used for GNU Emacs, which historically had a slow original repository and a fast (but possibly out of date) mirror. It is unlikely
    that we will need this again.

    Ulrich

    --=-=-Content-Type: application/pgp-signature; name="signature.asc"

    -----BEGIN PGP SIGNATURE-----

    iQFDBAEBCAAtFiEEtDnZ1O9xIP68rzDbUYgzUIhBXi4FAmFPFc4PHHVsbUBnZW50 b28ub3JnAAoJEFGIM1CIQV4uOYEH/AzsoTOsgvYBu61E7WhyB9UVQlia/gif8yYO xEab5wD69jeP1BZ9Z9oIQTWUD+e2nh9OLMwR679+A1ciCp9E/vgEABjuPopI6/RZ uKdrhKy5qyoqTojTflwyOiI6FO5jt8NhPEpcsBB1+20epfAnkzQZX9w7DzCpZ1bc KERuJje7ndKiV5e+TPVU2iPB3vQZmJHzFEOZkSohG0ubeoA0OKPZ+zVIX/YNp63p oo90zkHUCKRkfvS1rS2cIGZTStWm1XLwc9bY3Sk340RCStakz4qoaUGD6/toPn81 W8lJ3ouRt11+WSIJkUJQ9BNOPYprrXRzawO9vlW6VdJGYhN475g=1ODk
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?Micha=C5=82_G=C3=B3rny?=@21:1/5 to Ulrich Mueller on Mon Sep 27 20:00:01 2021
    On Mon, 2021-09-27 at 19:25 +0200, Ulrich Mueller wrote:
    On Sat, 25 Sep 2021, Michał Górny wrote:

    +EBZR="bzr.eclass"

    Why do we need this? It seems as if someone is reinventing
    ${ECLASS}.

    Replaced by ${ECLASS}.

    +# @ECLASS-VARIABLE: EBZR_STORE_DIR

    @USER_VARIABLE?

    Added.

    +# @DESCRIPTION:
    +# The directory to store all fetched Bazaar live sources.
    +: ${EBZR_STORE_DIR:=${PORTAGE_ACTUAL_DISTDIR:-${DISTDIR}}/bzr-
    src}
    +
    +# @ECLASS-VARIABLE: EBZR_UNPACK_DIR
    +# @DESCRIPTION:
    +# The working directory where the sources are copied to.
    +: ${EBZR_UNPACK_DIR:=${WORKDIR}/${P}}
    +
    +# @ECLASS-VARIABLE: EBZR_INIT_REPO_CMD
    +# @DESCRIPTION:
    +# The Bazaar command to initialise a shared repository.
    +: ${EBZR_INIT_REPO_CMD:="bzr init-repository --no-trees"}
    +
    +# @ECLASS-VARIABLE: EBZR_FETCH_CMD
    +# @DESCRIPTION:
    +# The Bazaar command to fetch the sources.
    +: ${EBZR_FETCH_CMD:="bzr branch --no-tree"}
    +
    +# @ECLASS-VARIABLE: EBZR_UPDATE_CMD
    +# @DESCRIPTION:
    +# The Bazaar command to update the sources.
    +: ${EBZR_UPDATE_CMD:="bzr pull --overwrite-tags"}
    +
    +# @ECLASS-VARIABLE: EBZR_EXPORT_CMD
    +# @DESCRIPTION:
    +# The Bazaar command to export a branch.
    +: ${EBZR_EXPORT_CMD:="bzr export"}
    +
    +# @ECLASS-VARIABLE: EBZR_CHECKOUT_CMD
    +# @DESCRIPTION:
    +# The Bazaar command to checkout a branch.
    +: ${EBZR_CHECKOUT_CMD:="bzr checkout --lightweight -q"}
    +
    +# @ECLASS-VARIABLE: EBZR_REVNO_CMD
    +# @DESCRIPTION:
    +# The Bazaar command to list a revision number of the branch.
    +: ${EBZR_REVNO_CMD:="bzr revno"}

    Are you sure that having these overrides is a good idea?

    Yes. Ebuilds had used them in the past.

    Your followup patch pretty much proves that every ebuild redefining
    them would get broken by switch to breezy.

    The only one where syntax has changed is EBZR_INIT_REPO_CMD (which has init-shared-repository instead of init-repository).

    You seem to be missing the fact that all of them hardcode "bzr".


    --
    Best regards,
    Michał Górny

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ulrich Mueller@21:1/5 to All on Mon Sep 27 19:30:02 2021
    On Sat, 25 Sep 2021, Michał Górny wrote:

    +EBZR="bzr.eclass"

    Why do we need this? It seems as if someone is reinventing ${ECLASS}.

    Replaced by ${ECLASS}.

    +# @ECLASS-VARIABLE: EBZR_STORE_DIR

    @USER_VARIABLE?

    Added.

    +# @DESCRIPTION:
    +# The directory to store all fetched Bazaar live sources.
    +: ${EBZR_STORE_DIR:=${PORTAGE_ACTUAL_DISTDIR:-${DISTDIR}}/bzr-src}
    +
    +# @ECLASS-VARIABLE: EBZR_UNPACK_DIR
    +# @DESCRIPTION:
    +# The working directory where the sources are copied to.
    +: ${EBZR_UNPACK_DIR:=${WORKDIR}/${P}}
    +
    +# @ECLASS-VARIABLE: EBZR_INIT_REPO_CMD
    +# @DESCRIPTION:
    +# The Bazaar command to initialise a shared repository.
    +: ${EBZR_INIT_REPO_CMD:="bzr init-repository --no-trees"}
    +
    +# @ECLASS-VARIABLE: EBZR_FETCH_CMD
    +# @DESCRIPTION:
    +# The Bazaar command to fetch the sources.
    +: ${EBZR_FETCH_CMD:="bzr branch --no-tree"}
    +
    +# @ECLASS-VARIABLE: EBZR_UPDATE_CMD
    +# @DESCRIPTION:
    +# The Bazaar command to update the sources.
    +: ${EBZR_UPDATE_CMD:="bzr pull --overwrite-tags"}
    +
    +# @ECLASS-VARIABLE: EBZR_EXPORT_CMD
    +# @DESCRIPTION:
    +# The Bazaar command to export a branch.
    +: ${EBZR_EXPORT_CMD:="bzr export"}
    +
    +# @ECLASS-VARIABLE: EBZR_CHECKOUT_CMD
    +# @DESCRIPTION:
    +# The Bazaar command to checkout a branch.
    +: ${EBZR_CHECKOUT_CMD:="bzr checkout --lightweight -q"}
    +
    +# @ECLASS-VARIABLE: EBZR_REVNO_CMD
    +# @DESCRIPTION:
    +# The Bazaar command to list a revision number of the branch.
    +: ${EBZR_REVNO_CMD:="bzr revno"}

    Are you sure that having these overrides is a good idea?

    Yes. Ebuilds had used them in the past.

    Your followup patch pretty much proves that every ebuild redefining
    them would get broken by switch to breezy.

    The only one where syntax has changed is EBZR_INIT_REPO_CMD (which has init-shared-repository instead of init-repository).

    +# @ECLASS-VARIABLE: EBZR_OPTIONS
    +# @DEFAULT_UNSET
    +# @DESCRIPTION:
    +# The options passed to the fetch and update commands.

    Is this intended to be set by ebuild or by user?

    Ebuild.

    +# @ECLASS-VARIABLE: EBZR_OFFLINE

    @USER_VARIABLE?

    +# @ECLASS-VARIABLE: EVCS_UMASK

    @USER_VARIABLE?

    Both added.

    +# @FUNCTION: bzr_initial_fetch

    @INTERNAL?

    Added, and renamed to _bzr_initial_fetch.

    + if [[ -n "${EBZR_OFFLINE}" ]]; then
    + ewarn "EBZR_OFFLINE cannot be used when there is no local branch yet."

    I dare say this is incorrect. If user says "no online operations", then
    the eclass should just fail, not ignore the user.

    Fixed.

    + ${EBZR_FETCH_CMD} ${EBZR_OPTIONS} "${repo_uri}" "${branch_dir}" \
    + || die "${EBZR}: can't branch from ${repo_uri}"

    You can replace the backslash with '||'.

    I think that splitting the line before the operator is clearer. (It is
    also what GNU coding standards recommend for C.)

    +# @FUNCTION: bzr_update

    @INTERNAL?

    Added, and renamed to _bzr_update.

    +bzr_fetch() {
    + local repo_dir branch_dir
    + local save_sandbox_write=${SANDBOX_WRITE} save_umask
    +
    + [[ -n ${EBZR_REPO_URI} ]] || die "${EBZR}: EBZR_REPO_URI is empty"
    +
    + if [[ ! -d ${EBZR_STORE_DIR} ]] ; then
    + addwrite /
    + mkdir -p "${EBZR_STORE_DIR}" \
    + || die "${EBZR}: can't mkdir ${EBZR_STORE_DIR}"
    + SANDBOX_WRITE=${save_sandbox_write}

    Looks like abusing implementation details.

    Replaced by subshell.

    + if [[ -z ${EBZR_INITIAL_URI} ]]; then
    + bzr_initial_fetch "${EBZR_REPO_URI}" "${branch_dir}"
    + else
    + # Workaround for faster initial download. This clones the
    + # branch from a fast server (which may be out of date), and
    + # subsequently pulls from the slow original repository. >> + bzr_initial_fetch "${EBZR_INITIAL_URI}" "${branch_dir}" >> + if [[ ${EBZR_REPO_URI} != "${EBZR_INITIAL_URI}" ]]; then
    + EBZR_UPDATE_CMD="${EBZR_UPDATE_CMD} --remember --overwrite" \
    + EBZR_OFFLINE="" \

    Why do you override EBZR_OFFLINE here?

    The whole else clause is dropped in a followup commit.

    Ulrich

    --=-=-Content-Type: application/pgp-signature; name="signature.asc"

    -----BEGIN PGP SIGNATURE-----

    iQFDBAEBCAAtFiEEtDnZ1O9xIP68rzDbUYgzUIhBXi4FAmFR/ocPHHVsbUBnZW50 b28ub3JnAAoJEFGIM1CIQV4umnkH/0P9ArsZGRAiGu8D8eY0pO5lYdRoPqjf/U1c 92Dp43e+KzjXoZ33CKrjcfvrGiC/W5Fu3ZkpQwqLHe8gAG3ZxDtaUaipKxjYhtnB zxaD03fX0G+f47COVcWpvf9iMXVAkvH1Bj2S5D7OUnn0S9g9aGjkE8EjDJtWO0kM 29TCsCSA2W4+MwOeNpdLQDgqxICEGbSumJl0Yr2JYn9A54JbeCc9Zot4aVd203R3 TYvyWY9Ci5rEM4G9E3LcmXMSkLS16cqKsSjsa5IJC3dgVW3JFAI+/4s1VElXNUEB yf/SIutOBMc/98ZRcVbbLSK8d4erj8+edJW+522zHO8K3mDArL0=RleU
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ulrich Mueller@21:1/5 to All on Mon Sep 27 20:10:01 2021
    On Mon, 27 Sep 2021, Michał Górny wrote:

    You seem to be missing the fact that all of them hardcode "bzr".

    Yes, and it is updated to "brz" in a followup commit. Would you prefer
    leaving them as "bzr"? I guess that backwards compatibility link will
    stay there for a long time.

    --=-=-Content-Type: application/pgp-signature; name="signature.asc"

    -----BEGIN PGP SIGNATURE-----

    iQFDBAEBCAAtFiEEtDnZ1O9xIP68rzDbUYgzUIhBXi4FAmFSBvoPHHVsbUBnZW50 b28ub3JnAAoJEFGIM1CIQV4u9e8IALhV72Fixz28/xAo70ccGz+9OxUAZKxtUSZB njqF5zo5+2vTQRMlKHHZ2uBiAMAIoVeHL/i3qYN6eoBRJgRKx5n91GMa57ferlrV N6PSSgSc43wNLaAKb4WFUDw6fEHDOPxOz9E2HOVxOVC5fox35TbW8Hqo5E7ju1S8 QBYPacuvs7Wp2qRZls5/YEjYeWk1WSFg2T9r633ZOmK9W5rJWDuc1XagvizgqBul XYQcalRouJ7cq4SMBtmA+COWr1pOtPe6fZzk9u3+5T8V7DRHz2oBjlmcvDBDvHwY JwJLkkT9DYdJESB9bh3O+Bd2MOenShsl15akGkke4I2XOv3U8xI=SAqM
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?Micha=C5=82_G=C3=B3rny?=@21:1/5 to Ulrich Mueller on Mon Sep 27 20:10:01 2021
    On Mon, 2021-09-27 at 20:01 +0200, Ulrich Mueller wrote:
    On Mon, 27 Sep 2021, Michał Górny wrote:

    You seem to be missing the fact that all of them hardcode "bzr".

    Yes, and it is updated to "brz" in a followup commit. Would you prefer leaving them as "bzr"? I guess that backwards compatibility link will
    stay there for a long time.

    What I'm saying is that if anyone overrides these commands, they will be
    broken when the symlink disappears.

    Then ofc there's the basic problem if anyone will ever actually need to
    do that. This doesn't sound likely for eclass that we expect to have approximately one consumer.

    --
    Best regards,
    Michał Górny

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)