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

Contents of /eclass/darcs.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.11 - (hide annotations) (download)
Sun Jan 30 10:27:20 2011 UTC (3 years, 5 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 slyfox 1.11 # Copyright 2011 Gentoo Technologies, Inc.
2 kosmikus 1.1 # Distributed under the terms of the GNU General Public License v2
3 slyfox 1.11 # $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 kosmikus 1.1 #
9 slyfox 1.11 # Sergei Trofimovich <slyfox@gentoo.org>
10 kosmikus 1.1 #
11 slyfox 1.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 kosmikus 1.1 #
16 slyfox 1.11 # 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 kosmikus 1.1
23 slyfox 1.11 # TODO:
24 kosmikus 1.1
25 slyfox 1.11 # support for tags
26 kosmikus 1.1
27 slyfox 1.9 inherit eutils # eshopts_{push,pop}
28    
29 kosmikus 1.1 # 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 slyfox 1.11 # @ECLASS-VARIABLE: EDARCS_DARCS_CMD
39     # @DESCRIPTION:
40     # Path to darcs binary.
41     : ${EDARCS_DARCS_CMD:=darcs}
42 kosmikus 1.1
43 dcoutts 1.2 # darcs commands with command-specific options
44 kosmikus 1.1
45 slyfox 1.11 # @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 dcoutts 1.2
60 slyfox 1.11 # @ECLASS-VARIABLE: EDARCS_TOP_DIR
61     # @DESCRIPTION:
62 kosmikus 1.1 # Where the darcs repositories are stored/accessed
63 slyfox 1.11 : ${EDARCS_TOP_DIR:=${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/darcs-src}
64 kosmikus 1.1
65 slyfox 1.11 # @ECLASS-VARIABLE: EDARCS_REPOSITORY
66     # @DESCRIPTION:
67 kosmikus 1.1 # The URI to the repository.
68 slyfox 1.11 : ${EDARCS_REPOSITORY:=}
69 kosmikus 1.1
70 slyfox 1.11 # @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 kosmikus 1.1 # re-download it.)
82 slyfox 1.11 : ${EDARCS_CLEAN:=}
83 kosmikus 1.1
84     # --- end ebuild-configurable settings ---
85    
86     # add darcs to deps
87 kolmodin 1.8 DEPEND="dev-vcs/darcs"
88 kosmikus 1.1
89 slyfox 1.11 # @FUNCTION: darcs_patchcount
90     # @DESCRIPTION:
91     # Internal function to determine amount of patches in repository.
92 slyfox 1.10 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 slyfox 1.11 # @FUNCTION: darcs_fetch
99     # @DESCRIPTION:
100     # Internal function is called from darcs_src_unpack
101 kosmikus 1.1 darcs_fetch() {
102 kolmodin 1.7 # The local directory to store the repository (useful to ensure a
103     # unique local name); relative to EDARCS_TOP_DIR
104 slyfox 1.11 [[ -z ${EDARCS_LOCALREPO} ]] && [[ -n ${EDARCS_REPOSITORY} ]] \
105 kolmodin 1.7 && EDARCS_LOCALREPO=${EDARCS_REPOSITORY%/} \
106     && EDARCS_LOCALREPO=${EDARCS_LOCALREPO##*/}
107    
108 slyfox 1.11 debug-print-function ${FUNCNAME} $*
109 kosmikus 1.1
110 slyfox 1.11 if [[ -n ${EDARCS_CLEAN} ]]; then
111     addwrite "${EDARCS_TOP_DIR}/${EDARCS_LOCALREPO}"
112     rm -rf "${EDARCS_TOP_DIR}/${EDARCS_LOCALREPO}"
113 kosmikus 1.1 fi
114    
115     # create the top dir if needed
116 slyfox 1.11 if [[ ! -d ${EDARCS_TOP_DIR} ]]; then
117 kosmikus 1.1 # 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 slyfox 1.11 debug-print "${FUNCNAME}: checkout mode. creating darcs directory"
123 kosmikus 1.1 addwrite /foobar
124     addwrite /
125 slyfox 1.11 mkdir -p "${EDARCS_TOP_DIR}"
126 kosmikus 1.1 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 kolmodin 1.5 pushd .
132 slyfox 1.11 cd -P "${EDARCS_TOP_DIR}" > /dev/null
133 kosmikus 1.1 EDARCS_TOP_DIR="`/bin/pwd`"
134    
135     # disable the sandbox for this dir
136 slyfox 1.11 addwrite "${EDARCS_TOP_DIR}"
137 kosmikus 1.1
138     # determine checkout or update mode and change to the right directory.
139 slyfox 1.11 if [[ ! -d "${EDARCS_TOP_DIR}/${EDARCS_LOCALREPO}/_darcs" ]]; then
140 kosmikus 1.1 mode=get
141 slyfox 1.11 cd "${EDARCS_TOP_DIR}"
142 kosmikus 1.1 else
143     mode=update
144 slyfox 1.11 cd "${EDARCS_TOP_DIR}/${EDARCS_LOCALREPO}"
145 kosmikus 1.1 fi
146    
147     # commands to run
148 slyfox 1.11 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 kosmikus 1.1
151 slyfox 1.11 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 kosmikus 1.1 fi
160    
161 slyfox 1.10 export EDARCS_PATCHCOUNT=$(darcs_patchcount)
162     einfo " patches in repo: ${EDARCS_PATCHCOUNT}"
163    
164 kolmodin 1.5 popd
165 kosmikus 1.1 }
166    
167 slyfox 1.11 # @FUNCTION: darcs_src_unpack
168     # @DESCRIPTION:
169     # src_upack function
170 kosmikus 1.1 darcs_src_unpack() {
171 kolmodin 1.7 # The local directory to store the repository (useful to ensure a
172     # unique local name); relative to EDARCS_TOP_DIR
173 slyfox 1.11 [[ -z ${EDARCS_LOCALREPO} ]] && [[ -n ${EDARCS_REPOSITORY} ]] \
174 kolmodin 1.7 && EDARCS_LOCALREPO=${EDARCS_REPOSITORY%/} \
175     && EDARCS_LOCALREPO=${EDARCS_LOCALREPO##*/}
176 kosmikus 1.1
177 slyfox 1.11 debug-print-function ${FUNCNAME} $*
178 kosmikus 1.1
179 slyfox 1.11 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 kosmikus 1.1
189 slyfox 1.11 einfo "Fetching darcs repository ${EDARCS_REPOSITORY} into ${EDARCS_TOP_DIR}..."
190 kosmikus 1.1 darcs_fetch
191    
192 slyfox 1.11 einfo "Copying ${EDARCS_LOCALREPO} from ${EDARCS_TOP_DIR}..."
193     debug-print "Copying ${EDARCS_LOCALREPO} from ${EDARCS_TOP_DIR}..."
194 kosmikus 1.1
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 slyfox 1.9 eshopts_push -s dotglob # get any dotfiles too.
200 slyfox 1.11 rsync -rlpgo --exclude="_darcs/" "${EDARCS_TOP_DIR}/${EDARCS_LOCALREPO}"/* "${WORKDIR}/${P}"
201 slyfox 1.9 eshopts_pop
202 kosmikus 1.1
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