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

Contents of /eclass/darcs.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.11 - (show annotations) (download)
Sun Jan 30 10:27:20 2011 UTC (3 years, 6 months ago) by slyfox
Branch: MAIN
Changes since 1.10: +102 -62 lines
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)

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

  ViewVC Help
Powered by ViewVC 1.1.20