Gentoo Archives: gentoo-commits

From: "Sergei Trofimovich (slyfox)" <slyfox@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in eclass: darcs.eclass
Date: Sun, 30 Jan 2011 10:27:34
Message-Id: 20110130102720.B9AEE20054@flycatcher.gentoo.org
1 slyfox 11/01/30 10:27:20
2
3 Modified: darcs.eclass
4 Log:
5 Add ESCM_OFFLINE variable support.
6
7 Cleaned-up an eclass. Make it 'eclass-manpages' friendly.
8
9 Thanks to Alexander Vershilov for ESCM_OFFLINE support (bug #353052)
10 and thanks to mren <bugs@××××××××.net> for documentation support (bug #211221)
11
12 Revision Changes Path
13 1.11 eclass/darcs.eclass
14
15 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/darcs.eclass?rev=1.11&view=markup
16 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/darcs.eclass?rev=1.11&content-type=text/plain
17 diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/darcs.eclass?r1=1.10&r2=1.11
18
19 Index: darcs.eclass
20 ===================================================================
21 RCS file: /var/cvsroot/gentoo-x86/eclass/darcs.eclass,v
22 retrieving revision 1.10
23 retrieving revision 1.11
24 diff -u -r1.10 -r1.11
25 --- darcs.eclass 1 Nov 2010 20:54:46 -0000 1.10
26 +++ darcs.eclass 30 Jan 2011 10:27:20 -0000 1.11
27 @@ -1,23 +1,28 @@
28 -# Copyright 2004 Gentoo Technologies, Inc.
29 +# Copyright 2011 Gentoo Technologies, Inc.
30 # Distributed under the terms of the GNU General Public License v2
31 -# $Header: /var/cvsroot/gentoo-x86/eclass/darcs.eclass,v 1.10 2010/11/01 20:54:46 slyfox Exp $
32 -#
33 -# darcs eclass author: Andres Loeh <kosmikus@g.o>
34 -# tla eclass author: <rphillips@g.o>
35 -# Original Author: Jeffrey Yasskin <jyasskin@×××××××××××.edu>
36 +# $Header: /var/cvsroot/gentoo-x86/eclass/darcs.eclass,v 1.11 2011/01/30 10:27:20 slyfox Exp $
37 +
38 +# @ECLASS: darcs.eclass
39 +# @MAINTAINER:
40 +# "Gentoo's Haskell Language team" <haskell@g.o>
41 #
42 -# Originally derived from the tla eclass, which is derived from the
43 -# cvs eclass.
44 +# Sergei Trofimovich <slyfox@g.o>
45 #
46 +# Original Author: Jeffrey Yasskin <jyasskin@×××××××××××.edu>
47 +# @BLURB: This eclass provides functions for fetch and unpack darcs repositories
48 +# @DESCRIPTION:
49 # This eclass provides the generic darcs fetching functions.
50 -# to use from an ebuild, set the 'ebuild-configurable settings' below in your
51 -# ebuild before inheriting. then either leave the default src_unpack or extend
52 -# over darcs_src_unpack.
53 +#
54 +# Define the EDARCS_REPOSITORY variable at least.
55 +# The ${S} variable is set to ${WORKDIR}/${P}.
56 +# @THANKS TO:
57 +# <rphillips@g.o> (tla eclass author)
58 +# Andres Loeh <kosmikus@g.o> (darcs.eclass author)
59 +# Alexander Vershilov <alexander.vershilov@×××××.com> (various contributions)
60
61 -# Most of the time, you will define only $EDARCS_REPOSITORY in your
62 -# ebuild.
63 +# TODO:
64
65 -# TODO: support for tags, ...
66 +# support for tags
67
68 inherit eutils # eshopts_{push,pop}
69
70 @@ -30,94 +35,127 @@
71 # --- begin ebuild-configurable settings
72
73 # darcs command to run
74 -[ -z "$EDARCS_DARCS_CMD" ] && EDARCS_DARCS_CMD="darcs"
75 +# @ECLASS-VARIABLE: EDARCS_DARCS_CMD
76 +# @DESCRIPTION:
77 +# Path to darcs binary.
78 +: ${EDARCS_DARCS_CMD:=darcs}
79
80 # darcs commands with command-specific options
81 -[ -z "$EDARCS_GET_CMD" ] && EDARCS_GET_CMD="get --partial"
82 -[ -z "$EDARCS_UPDATE_CMD" ] && EDARCS_UPDATE_CMD="pull"
83
84 -# options to pass to both the "get" and "update" commands
85 -[ -z "$EDARCS_OPTIONS" ] && EDARCS_OPTIONS="--set-scripts-executable"
86 +# @ECLASS-VARIABLE: EDARCS_GET_CMD
87 +# @DESCRIPTION:
88 +# First fetch darcs command.
89 +: ${EDARCS_GET_CMD:=get --partial}
90 +
91 +# @ECLASS-VARIABLE: EDARCS_UPDATE_CMD
92 +# @DESCRIPTION:
93 +# Repo update darcs command.
94 +: ${EDARCS_UPDATE_CMD:=pull}
95 +
96 +# @ECLASS-VARIABLE: EDARCS_OPTIONS
97 +# @DESCRIPTION:
98 +# Options to pass to both the "get" and "update" commands
99 +: ${EDARCS_OPTIONS:=--set-scripts-executable}
100
101 +# @ECLASS-VARIABLE: EDARCS_TOP_DIR
102 +# @DESCRIPTION:
103 # Where the darcs repositories are stored/accessed
104 -[ -z "$EDARCS_TOP_DIR" ] && EDARCS_TOP_DIR="${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/darcs-src"
105 +: ${EDARCS_TOP_DIR:=${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/darcs-src}
106
107 +# @ECLASS-VARIABLE: EDARCS_REPOSITORY
108 +# @DESCRIPTION:
109 # The URI to the repository.
110 -[ -z "$EDARCS_REPOSITORY" ] && EDARCS_REPOSITORY=""
111 +: ${EDARCS_REPOSITORY:=}
112
113 -
114 -# EDARCS_CLEAN: set this to something to get a clean copy when updating
115 -# (removes the working directory, then uses $EDARCS_GET_CMD to
116 +# @ECLASS-VARIABLE: EDARCS_OFFLINE
117 +# @DESCRIPTION:
118 +# Set this variable to a non-empty value to disable the automatic updating of
119 +# a darcs repository. this is intended to be set outside the darcs source
120 +# tree by users.
121 +: ${EDARCS_OFFLINE:=${ESCM_OFFLINE}}
122 +
123 +# @ECLASS-VARIABLE: EDARCS_CLEAN
124 +# @DESCRIPTION:
125 +# Set this to something to get a clean copy when updating
126 +# (removes the working directory, then uses EDARCS_GET_CMD to
127 # re-download it.)
128 +: ${EDARCS_CLEAN:=}
129
130 # --- end ebuild-configurable settings ---
131
132 # add darcs to deps
133 DEPEND="dev-vcs/darcs"
134
135 +# @FUNCTION: darcs_patchcount
136 +# @DESCRIPTION:
137 +# Internal function to determine amount of patches in repository.
138 darcs_patchcount() {
139 set -- $(${EDARCS_DARCS_CMD} show repo | grep "Num Patches")
140 # handle string like: " Num Patches: 3860"
141 echo ${3}
142 }
143
144 -# is called from darcs_src_unpack
145 +# @FUNCTION: darcs_fetch
146 +# @DESCRIPTION:
147 +# Internal function is called from darcs_src_unpack
148 darcs_fetch() {
149 -
150 # The local directory to store the repository (useful to ensure a
151 # unique local name); relative to EDARCS_TOP_DIR
152 - [ -z "$EDARCS_LOCALREPO" ] && [ -n "$EDARCS_REPOSITORY" ] \
153 + [[ -z ${EDARCS_LOCALREPO} ]] && [[ -n ${EDARCS_REPOSITORY} ]] \
154 && EDARCS_LOCALREPO=${EDARCS_REPOSITORY%/} \
155 && EDARCS_LOCALREPO=${EDARCS_LOCALREPO##*/}
156
157 - debug-print-function $FUNCNAME $*
158 + debug-print-function ${FUNCNAME} $*
159
160 - if [ -n "$EDARCS_CLEAN" ]; then
161 - rm -rf $EDARCS_TOP_DIR/$EDARCS_LOCALREPO
162 + if [[ -n ${EDARCS_CLEAN} ]]; then
163 + addwrite "${EDARCS_TOP_DIR}/${EDARCS_LOCALREPO}"
164 + rm -rf "${EDARCS_TOP_DIR}/${EDARCS_LOCALREPO}"
165 fi
166
167 # create the top dir if needed
168 - if [ ! -d "$EDARCS_TOP_DIR" ]; then
169 + if [[ ! -d ${EDARCS_TOP_DIR} ]]; then
170 # note that the addwrite statements in this block are only there to allow creating EDARCS_TOP_DIR;
171 # we've already allowed writing inside it
172 # this is because it's simpler than trying to find out the parent path of the directory, which
173 # would need to be the real path and not a symlink for things to work (so we can't just remove
174 # the last path element in the string)
175 - debug-print "$FUNCNAME: checkout mode. creating darcs directory"
176 + debug-print "${FUNCNAME}: checkout mode. creating darcs directory"
177 addwrite /foobar
178 addwrite /
179 - mkdir -p "$EDARCS_TOP_DIR"
180 + mkdir -p "${EDARCS_TOP_DIR}"
181 export SANDBOX_WRITE="${SANDBOX_WRITE//:\/foobar:\/}"
182 fi
183
184 # in case EDARCS_DARCS_DIR is a symlink to a dir, get the real
185 # dir's path, otherwise addwrite() doesn't work.
186 pushd .
187 - cd -P "$EDARCS_TOP_DIR" > /dev/null
188 + cd -P "${EDARCS_TOP_DIR}" > /dev/null
189 EDARCS_TOP_DIR="`/bin/pwd`"
190
191 # disable the sandbox for this dir
192 - addwrite "$EDARCS_TOP_DIR"
193 + addwrite "${EDARCS_TOP_DIR}"
194
195 # determine checkout or update mode and change to the right directory.
196 - if [ ! -d "$EDARCS_TOP_DIR/$EDARCS_LOCALREPO/_darcs" ]; then
197 + if [[ ! -d "${EDARCS_TOP_DIR}/${EDARCS_LOCALREPO}/_darcs" ]]; then
198 mode=get
199 - cd "$EDARCS_TOP_DIR"
200 + cd "${EDARCS_TOP_DIR}"
201 else
202 mode=update
203 - cd "$EDARCS_TOP_DIR/$EDARCS_LOCALREPO"
204 + cd "${EDARCS_TOP_DIR}/${EDARCS_LOCALREPO}"
205 fi
206
207 # commands to run
208 - local cmdget="${EDARCS_DARCS_CMD} ${EDARCS_GET_CMD} ${EDARCS_OPTIONS} --repo-name=${EDARCS_LOCALREPO} ${EDARCS_REPOSITORY}"
209 - local cmdupdate="${EDARCS_DARCS_CMD} ${EDARCS_UPDATE_CMD} --all ${EDARCS_OPTIONS} ${EDARCS_REPOSITORY}"
210 + local cmdget="${EDARCS_DARCS_CMD} ${EDARCS_GET_CMD} ${EDARCS_OPTIONS} --repo-name=${EDARCS_LOCALREPO} ${EDARCS_REPOSITORY}"
211 + local cmdupdate="${EDARCS_DARCS_CMD} ${EDARCS_UPDATE_CMD} --all ${EDARCS_OPTIONS} ${EDARCS_REPOSITORY}"
212
213 - if [ "${mode}" == "get" ]; then
214 - einfo "Running $cmdget"
215 - eval $cmdget || die "darcs get command failed"
216 - elif [ "${mode}" == "update" ]; then
217 - einfo "Running $cmdupdate"
218 - eval $cmdupdate || die "darcs update command failed"
219 + if [[ ${mode} == "get" ]]; then
220 + einfo "Running ${cmdget}"
221 + eval ${cmdget} || die "darcs get command failed"
222 + elif [[ -n ${EDARCS_OFFLINE} ]] ; then
223 + einfo "Offline update"
224 + elif [[ ${mode} == "update" ]]; then
225 + einfo "Running ${cmdupdate}"
226 + eval ${cmdupdate} || die "darcs update command failed"
227 fi
228
229 export EDARCS_PATCHCOUNT=$(darcs_patchcount)
230 @@ -126,38 +164,40 @@
231 popd
232 }
233
234 -
235 +# @FUNCTION: darcs_src_unpack
236 +# @DESCRIPTION:
237 +# src_upack function
238 darcs_src_unpack() {
239 # The local directory to store the repository (useful to ensure a
240 # unique local name); relative to EDARCS_TOP_DIR
241 - [ -z "$EDARCS_LOCALREPO" ] && [ -n "$EDARCS_REPOSITORY" ] \
242 + [[ -z ${EDARCS_LOCALREPO} ]] && [[ -n ${EDARCS_REPOSITORY} ]] \
243 && EDARCS_LOCALREPO=${EDARCS_REPOSITORY%/} \
244 && EDARCS_LOCALREPO=${EDARCS_LOCALREPO##*/}
245
246 - debug-print-function $FUNCNAME $*
247 + debug-print-function ${FUNCNAME} $*
248
249 - debug-print "$FUNCNAME: init:
250 - EDARCS_DARCS_CMD=$EDARCS_DARCS_CMD
251 - EDARCS_GET_CMD=$EDARCS_GET_CMD
252 - EDARCS_UPDATE_CMD=$EDARCS_UPDATE_CMD
253 - EDARCS_OPTIONS=$EDARCS_OPTIONS
254 - EDARCS_TOP_DIR=$EDARCS_TOP_DIR
255 - EDARCS_REPOSITORY=$EDARCS_REPOSITORY
256 - EDARCS_LOCALREPO=$EDARCS_LOCALREPO
257 - EDARCS_CLEAN=$EDARCS_CLEAN"
258 + debug-print "${FUNCNAME}: init:
259 + EDARCS_DARCS_CMD=${EDARCS_DARCS_CMD}
260 + EDARCS_GET_CMD=${EDARCS_GET_CMD}
261 + EDARCS_UPDATE_CMD=${EDARCS_UPDATE_CMD}
262 + EDARCS_OPTIONS=${EDARCS_OPTIONS}
263 + EDARCS_TOP_DIR=${EDARCS_TOP_DIR}
264 + EDARCS_REPOSITORY=${EDARCS_REPOSITORY}
265 + EDARCS_LOCALREPO=${EDARCS_LOCALREPO}
266 + EDARCS_CLEAN=${EDARCS_CLEAN}"
267
268 - einfo "Fetching darcs repository $EDARCS_REPOSITORY into $EDARCS_TOP_DIR..."
269 + einfo "Fetching darcs repository ${EDARCS_REPOSITORY} into ${EDARCS_TOP_DIR}..."
270 darcs_fetch
271
272 - einfo "Copying $EDARCS_LOCALREPO from $EDARCS_TOP_DIR..."
273 - debug-print "Copying $EDARCS_LOCALREPO from $EDARCS_TOP_DIR..."
274 + einfo "Copying ${EDARCS_LOCALREPO} from ${EDARCS_TOP_DIR}..."
275 + debug-print "Copying ${EDARCS_LOCALREPO} from ${EDARCS_TOP_DIR}..."
276
277 # probably redundant, but best to make sure
278 # Use ${WORKDIR}/${P} rather than ${S} so user can point ${S} to something inside.
279 mkdir -p "${WORKDIR}/${P}"
280
281 eshopts_push -s dotglob # get any dotfiles too.
282 - rsync -rlpgo --exclude="_darcs/" "$EDARCS_TOP_DIR/$EDARCS_LOCALREPO"/* "${WORKDIR}/${P}"
283 + rsync -rlpgo --exclude="_darcs/" "${EDARCS_TOP_DIR}/${EDARCS_LOCALREPO}"/* "${WORKDIR}/${P}"
284 eshopts_pop
285
286 einfo "Darcs repository contents are now in ${WORKDIR}/${P}"