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

Contents of /eclass/darcs.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.15 - (hide annotations) (download)
Wed May 30 15:25:08 2012 UTC (2 years, 6 months ago) by slyfox
Branch: MAIN
Changes since 1.14: +2 -2 lines
Use 'darcs get --lazy' instead of 'darcs get --partial' (gone in darcs-2.8).

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

  ViewVC Help
Powered by ViewVC 1.1.20