/[gentoo-x86]/eclass/darcs.eclass
Gentoo

Contents of /eclass/darcs.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.16 - (show annotations) (download)
Fri Jun 8 03:39:50 2012 UTC (2 years, 5 months ago) by vapier
Branch: MAIN
Changes since 1.15: +4 -5 lines
merge @THANKS into @AUTHOR as @THANKS does not exist

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

  ViewVC Help
Powered by ViewVC 1.1.20