summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorSergei Trofimovich <slyfox@gentoo.org>2011-01-30 10:27:20 +0000
committerSergei Trofimovich <slyfox@gentoo.org>2011-01-30 10:27:20 +0000
commit5524f5463f92c58ed52a5f58c6c109b5b21dc688 (patch)
tree9b8c18612144df305c961672fbe37e70eabe3e35 /eclass
parentRemove mask for virtual/emacs-24. (diff)
downloadgentoo-2-5524f5463f92c58ed52a5f58c6c109b5b21dc688.tar.gz
gentoo-2-5524f5463f92c58ed52a5f58c6c109b5b21dc688.tar.bz2
gentoo-2-5524f5463f92c58ed52a5f58c6c109b5b21dc688.zip
Add ESCM_OFFLINE variable support.
Cleaned-up an eclass. Make it 'eclass-manpages' friendly. Thanks to Alexander Vershilov for ESCM_OFFLINE support (bug #353052) and thanks to mren <bugs@rennings.net> for documentation support (bug #211221)
Diffstat (limited to 'eclass')
-rw-r--r--eclass/darcs.eclass168
1 files changed, 104 insertions, 64 deletions
diff --git a/eclass/darcs.eclass b/eclass/darcs.eclass
index a4b4a777251c..15def8ae6ed4 100644
--- a/eclass/darcs.eclass
+++ b/eclass/darcs.eclass
@@ -1,23 +1,28 @@
-# Copyright 2004 Gentoo Technologies, Inc.
+# Copyright 2011 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/darcs.eclass,v 1.10 2010/11/01 20:54:46 slyfox Exp $
-#
-# darcs eclass author: Andres Loeh <kosmikus@gentoo.org>
-# tla eclass author: <rphillips@gentoo.org>
-# Original Author: Jeffrey Yasskin <jyasskin@mail.utexas.edu>
+# $Header: /var/cvsroot/gentoo-x86/eclass/darcs.eclass,v 1.11 2011/01/30 10:27:20 slyfox Exp $
+
+# @ECLASS: darcs.eclass
+# @MAINTAINER:
+# "Gentoo's Haskell Language team" <haskell@gentoo.org>
#
-# Originally derived from the tla eclass, which is derived from the
-# cvs eclass.
+# Sergei Trofimovich <slyfox@gentoo.org>
#
+# Original Author: Jeffrey Yasskin <jyasskin@mail.utexas.edu>
+# @BLURB: This eclass provides functions for fetch and unpack darcs repositories
+# @DESCRIPTION:
# This eclass provides the generic darcs fetching functions.
-# to use from an ebuild, set the 'ebuild-configurable settings' below in your
-# ebuild before inheriting. then either leave the default src_unpack or extend
-# over darcs_src_unpack.
+#
+# Define the EDARCS_REPOSITORY variable at least.
+# The ${S} variable is set to ${WORKDIR}/${P}.
+# @THANKS TO:
+# <rphillips@gentoo.org> (tla eclass author)
+# Andres Loeh <kosmikus@gentoo.org> (darcs.eclass author)
+# Alexander Vershilov <alexander.vershilov@gmail.com> (various contributions)
-# Most of the time, you will define only $EDARCS_REPOSITORY in your
-# ebuild.
+# TODO:
-# TODO: support for tags, ...
+# support for tags
inherit eutils # eshopts_{push,pop}
@@ -30,94 +35,127 @@ SRC_URI=""
# --- begin ebuild-configurable settings
# darcs command to run
-[ -z "$EDARCS_DARCS_CMD" ] && EDARCS_DARCS_CMD="darcs"
+# @ECLASS-VARIABLE: EDARCS_DARCS_CMD
+# @DESCRIPTION:
+# Path to darcs binary.
+: ${EDARCS_DARCS_CMD:=darcs}
# darcs commands with command-specific options
-[ -z "$EDARCS_GET_CMD" ] && EDARCS_GET_CMD="get --partial"
-[ -z "$EDARCS_UPDATE_CMD" ] && EDARCS_UPDATE_CMD="pull"
-# options to pass to both the "get" and "update" commands
-[ -z "$EDARCS_OPTIONS" ] && EDARCS_OPTIONS="--set-scripts-executable"
+# @ECLASS-VARIABLE: EDARCS_GET_CMD
+# @DESCRIPTION:
+# First fetch darcs command.
+: ${EDARCS_GET_CMD:=get --partial}
-# Where the darcs repositories are stored/accessed
-[ -z "$EDARCS_TOP_DIR" ] && EDARCS_TOP_DIR="${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/darcs-src"
+# @ECLASS-VARIABLE: EDARCS_UPDATE_CMD
+# @DESCRIPTION:
+# Repo update darcs command.
+: ${EDARCS_UPDATE_CMD:=pull}
-# The URI to the repository.
-[ -z "$EDARCS_REPOSITORY" ] && EDARCS_REPOSITORY=""
+# @ECLASS-VARIABLE: EDARCS_OPTIONS
+# @DESCRIPTION:
+# Options to pass to both the "get" and "update" commands
+: ${EDARCS_OPTIONS:=--set-scripts-executable}
+# @ECLASS-VARIABLE: EDARCS_TOP_DIR
+# @DESCRIPTION:
+# Where the darcs repositories are stored/accessed
+: ${EDARCS_TOP_DIR:=${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/darcs-src}
-# EDARCS_CLEAN: set this to something to get a clean copy when updating
-# (removes the working directory, then uses $EDARCS_GET_CMD to
+# @ECLASS-VARIABLE: EDARCS_REPOSITORY
+# @DESCRIPTION:
+# The URI to the repository.
+: ${EDARCS_REPOSITORY:=}
+
+# @ECLASS-VARIABLE: EDARCS_OFFLINE
+# @DESCRIPTION:
+# Set this variable to a non-empty value to disable the automatic updating of
+# a darcs repository. this is intended to be set outside the darcs source
+# tree by users.
+: ${EDARCS_OFFLINE:=${ESCM_OFFLINE}}
+
+# @ECLASS-VARIABLE: EDARCS_CLEAN
+# @DESCRIPTION:
+# Set this to something to get a clean copy when updating
+# (removes the working directory, then uses EDARCS_GET_CMD to
# re-download it.)
+: ${EDARCS_CLEAN:=}
# --- end ebuild-configurable settings ---
# add darcs to deps
DEPEND="dev-vcs/darcs"
+# @FUNCTION: darcs_patchcount
+# @DESCRIPTION:
+# Internal function to determine amount of patches in repository.
darcs_patchcount() {
set -- $(${EDARCS_DARCS_CMD} show repo | grep "Num Patches")
# handle string like: " Num Patches: 3860"
echo ${3}
}
-# is called from darcs_src_unpack
+# @FUNCTION: darcs_fetch
+# @DESCRIPTION:
+# Internal function is called from darcs_src_unpack
darcs_fetch() {
-
# The local directory to store the repository (useful to ensure a
# unique local name); relative to EDARCS_TOP_DIR
- [ -z "$EDARCS_LOCALREPO" ] && [ -n "$EDARCS_REPOSITORY" ] \
+ [[ -z ${EDARCS_LOCALREPO} ]] && [[ -n ${EDARCS_REPOSITORY} ]] \
&& EDARCS_LOCALREPO=${EDARCS_REPOSITORY%/} \
&& EDARCS_LOCALREPO=${EDARCS_LOCALREPO##*/}
- debug-print-function $FUNCNAME $*
+ debug-print-function ${FUNCNAME} $*
- if [ -n "$EDARCS_CLEAN" ]; then
- rm -rf $EDARCS_TOP_DIR/$EDARCS_LOCALREPO
+ if [[ -n ${EDARCS_CLEAN} ]]; then
+ addwrite "${EDARCS_TOP_DIR}/${EDARCS_LOCALREPO}"
+ rm -rf "${EDARCS_TOP_DIR}/${EDARCS_LOCALREPO}"
fi
# create the top dir if needed
- if [ ! -d "$EDARCS_TOP_DIR" ]; then
+ if [[ ! -d ${EDARCS_TOP_DIR} ]]; then
# note that the addwrite statements in this block are only there to allow creating EDARCS_TOP_DIR;
# we've already allowed writing inside it
# this is because it's simpler than trying to find out the parent path of the directory, which
# would need to be the real path and not a symlink for things to work (so we can't just remove
# the last path element in the string)
- debug-print "$FUNCNAME: checkout mode. creating darcs directory"
+ debug-print "${FUNCNAME}: checkout mode. creating darcs directory"
addwrite /foobar
addwrite /
- mkdir -p "$EDARCS_TOP_DIR"
+ mkdir -p "${EDARCS_TOP_DIR}"
export SANDBOX_WRITE="${SANDBOX_WRITE//:\/foobar:\/}"
fi
# in case EDARCS_DARCS_DIR is a symlink to a dir, get the real
# dir's path, otherwise addwrite() doesn't work.
pushd .
- cd -P "$EDARCS_TOP_DIR" > /dev/null
+ cd -P "${EDARCS_TOP_DIR}" > /dev/null
EDARCS_TOP_DIR="`/bin/pwd`"
# disable the sandbox for this dir
- addwrite "$EDARCS_TOP_DIR"
+ addwrite "${EDARCS_TOP_DIR}"
# determine checkout or update mode and change to the right directory.
- if [ ! -d "$EDARCS_TOP_DIR/$EDARCS_LOCALREPO/_darcs" ]; then
+ if [[ ! -d "${EDARCS_TOP_DIR}/${EDARCS_LOCALREPO}/_darcs" ]]; then
mode=get
- cd "$EDARCS_TOP_DIR"
+ cd "${EDARCS_TOP_DIR}"
else
mode=update
- cd "$EDARCS_TOP_DIR/$EDARCS_LOCALREPO"
+ cd "${EDARCS_TOP_DIR}/${EDARCS_LOCALREPO}"
fi
# commands to run
- local cmdget="${EDARCS_DARCS_CMD} ${EDARCS_GET_CMD} ${EDARCS_OPTIONS} --repo-name=${EDARCS_LOCALREPO} ${EDARCS_REPOSITORY}"
- local cmdupdate="${EDARCS_DARCS_CMD} ${EDARCS_UPDATE_CMD} --all ${EDARCS_OPTIONS} ${EDARCS_REPOSITORY}"
-
- if [ "${mode}" == "get" ]; then
- einfo "Running $cmdget"
- eval $cmdget || die "darcs get command failed"
- elif [ "${mode}" == "update" ]; then
- einfo "Running $cmdupdate"
- eval $cmdupdate || die "darcs update command failed"
+ local cmdget="${EDARCS_DARCS_CMD} ${EDARCS_GET_CMD} ${EDARCS_OPTIONS} --repo-name=${EDARCS_LOCALREPO} ${EDARCS_REPOSITORY}"
+ local cmdupdate="${EDARCS_DARCS_CMD} ${EDARCS_UPDATE_CMD} --all ${EDARCS_OPTIONS} ${EDARCS_REPOSITORY}"
+
+ if [[ ${mode} == "get" ]]; then
+ einfo "Running ${cmdget}"
+ eval ${cmdget} || die "darcs get command failed"
+ elif [[ -n ${EDARCS_OFFLINE} ]] ; then
+ einfo "Offline update"
+ elif [[ ${mode} == "update" ]]; then
+ einfo "Running ${cmdupdate}"
+ eval ${cmdupdate} || die "darcs update command failed"
fi
export EDARCS_PATCHCOUNT=$(darcs_patchcount)
@@ -126,38 +164,40 @@ darcs_fetch() {
popd
}
-
+# @FUNCTION: darcs_src_unpack
+# @DESCRIPTION:
+# src_upack function
darcs_src_unpack() {
# The local directory to store the repository (useful to ensure a
# unique local name); relative to EDARCS_TOP_DIR
- [ -z "$EDARCS_LOCALREPO" ] && [ -n "$EDARCS_REPOSITORY" ] \
+ [[ -z ${EDARCS_LOCALREPO} ]] && [[ -n ${EDARCS_REPOSITORY} ]] \
&& EDARCS_LOCALREPO=${EDARCS_REPOSITORY%/} \
&& EDARCS_LOCALREPO=${EDARCS_LOCALREPO##*/}
- debug-print-function $FUNCNAME $*
+ debug-print-function ${FUNCNAME} $*
- debug-print "$FUNCNAME: init:
- EDARCS_DARCS_CMD=$EDARCS_DARCS_CMD
- EDARCS_GET_CMD=$EDARCS_GET_CMD
- EDARCS_UPDATE_CMD=$EDARCS_UPDATE_CMD
- EDARCS_OPTIONS=$EDARCS_OPTIONS
- EDARCS_TOP_DIR=$EDARCS_TOP_DIR
- EDARCS_REPOSITORY=$EDARCS_REPOSITORY
- EDARCS_LOCALREPO=$EDARCS_LOCALREPO
- EDARCS_CLEAN=$EDARCS_CLEAN"
+ debug-print "${FUNCNAME}: init:
+ EDARCS_DARCS_CMD=${EDARCS_DARCS_CMD}
+ EDARCS_GET_CMD=${EDARCS_GET_CMD}
+ EDARCS_UPDATE_CMD=${EDARCS_UPDATE_CMD}
+ EDARCS_OPTIONS=${EDARCS_OPTIONS}
+ EDARCS_TOP_DIR=${EDARCS_TOP_DIR}
+ EDARCS_REPOSITORY=${EDARCS_REPOSITORY}
+ EDARCS_LOCALREPO=${EDARCS_LOCALREPO}
+ EDARCS_CLEAN=${EDARCS_CLEAN}"
- einfo "Fetching darcs repository $EDARCS_REPOSITORY into $EDARCS_TOP_DIR..."
+ einfo "Fetching darcs repository ${EDARCS_REPOSITORY} into ${EDARCS_TOP_DIR}..."
darcs_fetch
- einfo "Copying $EDARCS_LOCALREPO from $EDARCS_TOP_DIR..."
- debug-print "Copying $EDARCS_LOCALREPO from $EDARCS_TOP_DIR..."
+ einfo "Copying ${EDARCS_LOCALREPO} from ${EDARCS_TOP_DIR}..."
+ debug-print "Copying ${EDARCS_LOCALREPO} from ${EDARCS_TOP_DIR}..."
# probably redundant, but best to make sure
# Use ${WORKDIR}/${P} rather than ${S} so user can point ${S} to something inside.
mkdir -p "${WORKDIR}/${P}"
eshopts_push -s dotglob # get any dotfiles too.
- rsync -rlpgo --exclude="_darcs/" "$EDARCS_TOP_DIR/$EDARCS_LOCALREPO"/* "${WORKDIR}/${P}"
+ rsync -rlpgo --exclude="_darcs/" "${EDARCS_TOP_DIR}/${EDARCS_LOCALREPO}"/* "${WORKDIR}/${P}"
eshopts_pop
einfo "Darcs repository contents are now in ${WORKDIR}/${P}"