1 |
commit: 40631c50150421f596445d04d897d9ecd40338ae |
2 |
Author: Sam James <sam <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Jul 25 01:27:34 2021 +0000 |
4 |
Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Apr 1 10:40:23 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/lisp.git/commit/?id=40631c50 |
7 |
|
8 |
darcs.eclass: Copy last version from gentoo repository |
9 |
|
10 |
Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org> |
11 |
|
12 |
eclass/darcs.eclass | 223 ++++++++++++++++++++++++++++++++++++++++++++++++++++ |
13 |
1 file changed, 223 insertions(+) |
14 |
|
15 |
diff --git a/eclass/darcs.eclass b/eclass/darcs.eclass |
16 |
new file mode 100644 |
17 |
index 00000000..1ed886fb |
18 |
--- /dev/null |
19 |
+++ b/eclass/darcs.eclass |
20 |
@@ -0,0 +1,223 @@ |
21 |
+# Copyright 1999-2021 Gentoo Authors |
22 |
+# Distributed under the terms of the GNU General Public License v2 |
23 |
+ |
24 |
+# @ECLASS: darcs.eclass |
25 |
+# @MAINTAINER: |
26 |
+# "Gentoo's Haskell Language team" <haskell@g.o> |
27 |
+# Sergei Trofimovich <slyfox@g.o> |
28 |
+# @AUTHOR: |
29 |
+# Original Author: Jeffrey Yasskin <jyasskin@×××××××××××.edu> |
30 |
+# <rphillips@g.o> (tla eclass author) |
31 |
+# Andres Loeh <kosmikus@g.o> (darcs.eclass author) |
32 |
+# Alexander Vershilov <alexander.vershilov@×××××.com> (various contributions) |
33 |
+# @BLURB: This eclass provides functions for fetch and unpack darcs repositories |
34 |
+# @DEPRECATED: none |
35 |
+# @DESCRIPTION: |
36 |
+# This eclass provides the generic darcs fetching functions. |
37 |
+# |
38 |
+# Define the EDARCS_REPOSITORY variable at least. |
39 |
+# The ${S} variable is set to ${WORKDIR}/${P}. |
40 |
+ |
41 |
+# TODO: |
42 |
+ |
43 |
+# support for tags |
44 |
+ |
45 |
+# eshopts_{push,pop} |
46 |
+case "${EAPI:-0}" in |
47 |
+ 4|5|6) inherit eutils ;; |
48 |
+ 7) inherit estack ;; |
49 |
+ *) ;; |
50 |
+esac |
51 |
+ |
52 |
+# Don't download anything other than the darcs repository |
53 |
+SRC_URI="" |
54 |
+ |
55 |
+# You shouldn't change these settings yourself! The ebuild/eclass inheriting |
56 |
+# this eclass will take care of that. |
57 |
+ |
58 |
+# --- begin ebuild-configurable settings |
59 |
+ |
60 |
+# darcs command to run |
61 |
+# @ECLASS-VARIABLE: EDARCS_DARCS_CMD |
62 |
+# @DESCRIPTION: |
63 |
+# Path to darcs binary. |
64 |
+: ${EDARCS_DARCS_CMD:=darcs} |
65 |
+ |
66 |
+# darcs commands with command-specific options |
67 |
+ |
68 |
+# @ECLASS-VARIABLE: EDARCS_GET_CMD |
69 |
+# @DESCRIPTION: |
70 |
+# First fetch darcs command. |
71 |
+: ${EDARCS_GET_CMD:=get --lazy} |
72 |
+ |
73 |
+# @ECLASS-VARIABLE: EDARCS_UPDATE_CMD |
74 |
+# @DESCRIPTION: |
75 |
+# Repo update darcs command. |
76 |
+: ${EDARCS_UPDATE_CMD:=pull} |
77 |
+ |
78 |
+# @ECLASS-VARIABLE: EDARCS_OPTIONS |
79 |
+# @DESCRIPTION: |
80 |
+# Options to pass to both the "get" and "update" commands |
81 |
+: ${EDARCS_OPTIONS:=--set-scripts-executable} |
82 |
+ |
83 |
+# @ECLASS-VARIABLE: EDARCS_TOP_DIR |
84 |
+# @DESCRIPTION: |
85 |
+# Where the darcs repositories are stored/accessed |
86 |
+: ${EDARCS_TOP_DIR:=${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/darcs-src} |
87 |
+ |
88 |
+# @ECLASS-VARIABLE: EDARCS_REPOSITORY |
89 |
+# @DESCRIPTION: |
90 |
+# The URI to the repository. |
91 |
+: ${EDARCS_REPOSITORY:=} |
92 |
+ |
93 |
+# @ECLASS-VARIABLE: EDARCS_OFFLINE |
94 |
+# @USER_VARIABLE |
95 |
+# @DESCRIPTION: |
96 |
+# Set this variable to a non-empty value to disable the automatic updating of |
97 |
+# a darcs repository. This is intended to be set outside the darcs source |
98 |
+# tree by users. Defaults to EVCS_OFFLINE value. |
99 |
+: ${EDARCS_OFFLINE:=${EVCS_OFFLINE}} |
100 |
+ |
101 |
+# @ECLASS-VARIABLE: EDARCS_CLEAN |
102 |
+# @DESCRIPTION: |
103 |
+# Set this to something to get a clean copy when updating |
104 |
+# (removes the working directory, then uses EDARCS_GET_CMD to |
105 |
+# re-download it.) |
106 |
+: ${EDARCS_CLEAN:=} |
107 |
+ |
108 |
+# --- end ebuild-configurable settings --- |
109 |
+ |
110 |
+PROPERTIES+=" live" |
111 |
+ |
112 |
+case ${EAPI:-0} in |
113 |
+ [0-6]) # no need to care about 5-HDEPEND and similar |
114 |
+ DEPEND="dev-vcs/darcs |
115 |
+ net-misc/rsync" |
116 |
+ ;; |
117 |
+ *) |
118 |
+ BDEPEND="dev-vcs/darcs |
119 |
+ net-misc/rsync" |
120 |
+ ;; |
121 |
+esac |
122 |
+ |
123 |
+# @FUNCTION: darcs_patchcount |
124 |
+# @INTERNAL |
125 |
+# @DESCRIPTION: |
126 |
+# Internal function to determine amount of patches in repository. |
127 |
+darcs_patchcount() { |
128 |
+ set -- $(HOME="${EDARCS_TOP_DIR}" ${EDARCS_DARCS_CMD} show repo --repodir="${EDARCS_TOP_DIR}/${EDARCS_LOCALREPO}" | grep "Num Patches") |
129 |
+ # handle string like: " Num Patches: 3860" |
130 |
+ echo ${3} |
131 |
+} |
132 |
+ |
133 |
+# @FUNCTION: darcs_fetch |
134 |
+# @INTERNAL |
135 |
+# @DESCRIPTION: |
136 |
+# Internal function is called from darcs_src_unpack |
137 |
+darcs_fetch() { |
138 |
+ # The local directory to store the repository (useful to ensure a |
139 |
+ # unique local name); relative to EDARCS_TOP_DIR |
140 |
+ [[ -z ${EDARCS_LOCALREPO} ]] && [[ -n ${EDARCS_REPOSITORY} ]] \ |
141 |
+ && EDARCS_LOCALREPO=${EDARCS_REPOSITORY%/} \ |
142 |
+ && EDARCS_LOCALREPO=${EDARCS_LOCALREPO##*/} |
143 |
+ |
144 |
+ debug-print-function ${FUNCNAME} $* |
145 |
+ |
146 |
+ if [[ -n ${EDARCS_CLEAN} ]]; then |
147 |
+ addwrite "${EDARCS_TOP_DIR}/${EDARCS_LOCALREPO}" |
148 |
+ rm -rf "${EDARCS_TOP_DIR}/${EDARCS_LOCALREPO}" |
149 |
+ fi |
150 |
+ |
151 |
+ # create the top dir if needed |
152 |
+ if [[ ! -d ${EDARCS_TOP_DIR} ]]; then |
153 |
+ # note that the addwrite statements in this block are only there to allow creating EDARCS_TOP_DIR; |
154 |
+ # we've already allowed writing inside it |
155 |
+ # this is because it's simpler than trying to find out the parent path of the directory, which |
156 |
+ # would need to be the real path and not a symlink for things to work (so we can't just remove |
157 |
+ # the last path element in the string) |
158 |
+ debug-print "${FUNCNAME}: checkout mode. creating darcs directory" |
159 |
+ addwrite /foobar |
160 |
+ addwrite / |
161 |
+ mkdir -p "${EDARCS_TOP_DIR}" |
162 |
+ export SANDBOX_WRITE="${SANDBOX_WRITE//:\/foobar:\/}" |
163 |
+ fi |
164 |
+ |
165 |
+ # in case EDARCS_DARCS_DIR is a symlink to a dir, get the real |
166 |
+ # dir's path, otherwise addwrite() doesn't work. |
167 |
+ pushd . || die |
168 |
+ cd -P "${EDARCS_TOP_DIR}" > /dev/null |
169 |
+ EDARCS_TOP_DIR="`/bin/pwd`" |
170 |
+ |
171 |
+ # disable the sandbox for this dir |
172 |
+ addwrite "${EDARCS_TOP_DIR}" |
173 |
+ |
174 |
+ # determine checkout or update mode and change to the right directory. |
175 |
+ if [[ ! -d "${EDARCS_TOP_DIR}/${EDARCS_LOCALREPO}/_darcs" ]]; then |
176 |
+ mode=get |
177 |
+ cd "${EDARCS_TOP_DIR}" |
178 |
+ else |
179 |
+ mode=update |
180 |
+ cd "${EDARCS_TOP_DIR}/${EDARCS_LOCALREPO}" |
181 |
+ fi |
182 |
+ |
183 |
+ # commands to run |
184 |
+ local cmdget="${EDARCS_DARCS_CMD} ${EDARCS_GET_CMD} ${EDARCS_OPTIONS} --repo-name=${EDARCS_LOCALREPO} ${EDARCS_REPOSITORY}" |
185 |
+ local cmdupdate="${EDARCS_DARCS_CMD} ${EDARCS_UPDATE_CMD} --all ${EDARCS_OPTIONS} ${EDARCS_REPOSITORY}" |
186 |
+ |
187 |
+ if [[ ${mode} == "get" ]]; then |
188 |
+ einfo "Running ${cmdget}" |
189 |
+ HOME="${EDARCS_TOP_DIR}" ${cmdget} || die "darcs get command failed" |
190 |
+ elif [[ -n ${EDARCS_OFFLINE} ]] ; then |
191 |
+ einfo "Offline update" |
192 |
+ elif [[ ${mode} == "update" ]]; then |
193 |
+ einfo "Running ${cmdupdate}" |
194 |
+ HOME="${EDARCS_TOP_DIR}" ${cmdupdate} || die "darcs update command failed" |
195 |
+ fi |
196 |
+ |
197 |
+ export EDARCS_PATCHCOUNT=$(darcs_patchcount) |
198 |
+ einfo " patches in repo: ${EDARCS_PATCHCOUNT}" |
199 |
+ |
200 |
+ popd || die |
201 |
+} |
202 |
+ |
203 |
+# @FUNCTION: darcs_src_unpack |
204 |
+# @DESCRIPTION: |
205 |
+# src_upack function |
206 |
+darcs_src_unpack() { |
207 |
+ # The local directory to store the repository (useful to ensure a |
208 |
+ # unique local name); relative to EDARCS_TOP_DIR |
209 |
+ [[ -z ${EDARCS_LOCALREPO} ]] && [[ -n ${EDARCS_REPOSITORY} ]] \ |
210 |
+ && EDARCS_LOCALREPO=${EDARCS_REPOSITORY%/} \ |
211 |
+ && EDARCS_LOCALREPO=${EDARCS_LOCALREPO##*/} |
212 |
+ |
213 |
+ debug-print-function ${FUNCNAME} $* |
214 |
+ |
215 |
+ debug-print "${FUNCNAME}: init: |
216 |
+ EDARCS_DARCS_CMD=${EDARCS_DARCS_CMD} |
217 |
+ EDARCS_GET_CMD=${EDARCS_GET_CMD} |
218 |
+ EDARCS_UPDATE_CMD=${EDARCS_UPDATE_CMD} |
219 |
+ EDARCS_OPTIONS=${EDARCS_OPTIONS} |
220 |
+ EDARCS_TOP_DIR=${EDARCS_TOP_DIR} |
221 |
+ EDARCS_REPOSITORY=${EDARCS_REPOSITORY} |
222 |
+ EDARCS_LOCALREPO=${EDARCS_LOCALREPO} |
223 |
+ EDARCS_CLEAN=${EDARCS_CLEAN}" |
224 |
+ |
225 |
+ einfo "Fetching darcs repository ${EDARCS_REPOSITORY} into ${EDARCS_TOP_DIR}..." |
226 |
+ darcs_fetch |
227 |
+ |
228 |
+ einfo "Copying ${EDARCS_LOCALREPO} from ${EDARCS_TOP_DIR}..." |
229 |
+ debug-print "Copying ${EDARCS_LOCALREPO} from ${EDARCS_TOP_DIR}..." |
230 |
+ |
231 |
+ # probably redundant, but best to make sure |
232 |
+ # Use ${WORKDIR}/${P} rather than ${S} so user can point ${S} to something inside. |
233 |
+ mkdir -p "${WORKDIR}/${P}" |
234 |
+ |
235 |
+ eshopts_push -s dotglob # get any dotfiles too. |
236 |
+ rsync -rlpgo "${EDARCS_TOP_DIR}/${EDARCS_LOCALREPO}"/* "${WORKDIR}/${P}" |
237 |
+ eshopts_pop |
238 |
+ |
239 |
+ einfo "Darcs repository contents are now in ${WORKDIR}/${P}" |
240 |
+ |
241 |
+} |
242 |
+ |
243 |
+EXPORT_FUNCTIONS src_unpack |