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

Contents of /eclass/darcs.eclass

Parent Directory Parent Directory | Revision Log Revision Log


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

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 vapier 1.16 # $Header: /var/cvsroot/gentoo-x86/eclass/darcs.eclass,v 1.15 2012/05/30 15:25:08 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 vapier 1.16 # <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 slyfox 1.11 # @BLURB: This eclass provides functions for fetch and unpack darcs repositories
15     # @DESCRIPTION:
16     # This eclass provides the generic darcs fetching functions.
17 kosmikus 1.1 #
18 slyfox 1.11 # Define the EDARCS_REPOSITORY variable at least.
19     # The ${S} variable is set to ${WORKDIR}/${P}.
20 kosmikus 1.1
21 slyfox 1.11 # TODO:
22 kosmikus 1.1
23 slyfox 1.11 # support for tags
24 kosmikus 1.1
25 slyfox 1.9 inherit eutils # eshopts_{push,pop}
26    
27 kosmikus 1.1 # 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 slyfox 1.11 # @ECLASS-VARIABLE: EDARCS_DARCS_CMD
37     # @DESCRIPTION:
38     # Path to darcs binary.
39     : ${EDARCS_DARCS_CMD:=darcs}
40 kosmikus 1.1
41 dcoutts 1.2 # darcs commands with command-specific options
42 kosmikus 1.1
43 slyfox 1.11 # @ECLASS-VARIABLE: EDARCS_GET_CMD
44     # @DESCRIPTION:
45     # First fetch darcs command.
46 slyfox 1.15 : ${EDARCS_GET_CMD:=get --lazy}
47 slyfox 1.11
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 dcoutts 1.2
58 slyfox 1.11 # @ECLASS-VARIABLE: EDARCS_TOP_DIR
59     # @DESCRIPTION:
60 kosmikus 1.1 # Where the darcs repositories are stored/accessed
61 slyfox 1.11 : ${EDARCS_TOP_DIR:=${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/darcs-src}
62 kosmikus 1.1
63 slyfox 1.11 # @ECLASS-VARIABLE: EDARCS_REPOSITORY
64     # @DESCRIPTION:
65 kosmikus 1.1 # The URI to the repository.
66 slyfox 1.11 : ${EDARCS_REPOSITORY:=}
67 kosmikus 1.1
68 slyfox 1.11 # @ECLASS-VARIABLE: EDARCS_OFFLINE
69     # @DESCRIPTION:
70     # Set this variable to a non-empty value to disable the automatic updating of
71 slyfox 1.14 # 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 slyfox 1.11
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 kosmikus 1.1 # re-download it.)
80 slyfox 1.11 : ${EDARCS_CLEAN:=}
81 kosmikus 1.1
82     # --- end ebuild-configurable settings ---
83    
84 slyfox 1.14 DEPEND="dev-vcs/darcs
85     net-misc/rsync"
86 kosmikus 1.1
87 slyfox 1.11 # @FUNCTION: darcs_patchcount
88     # @DESCRIPTION:
89     # Internal function to determine amount of patches in repository.
90 slyfox 1.10 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 slyfox 1.11 # @FUNCTION: darcs_fetch
97     # @DESCRIPTION:
98     # Internal function is called from darcs_src_unpack
99 kosmikus 1.1 darcs_fetch() {
100 kolmodin 1.7 # The local directory to store the repository (useful to ensure a
101     # unique local name); relative to EDARCS_TOP_DIR
102 slyfox 1.11 [[ -z ${EDARCS_LOCALREPO} ]] && [[ -n ${EDARCS_REPOSITORY} ]] \
103 kolmodin 1.7 && EDARCS_LOCALREPO=${EDARCS_REPOSITORY%/} \
104     && EDARCS_LOCALREPO=${EDARCS_LOCALREPO##*/}
105    
106 slyfox 1.11 debug-print-function ${FUNCNAME} $*
107 kosmikus 1.1
108 slyfox 1.11 if [[ -n ${EDARCS_CLEAN} ]]; then
109     addwrite "${EDARCS_TOP_DIR}/${EDARCS_LOCALREPO}"
110     rm -rf "${EDARCS_TOP_DIR}/${EDARCS_LOCALREPO}"
111 kosmikus 1.1 fi
112    
113     # create the top dir if needed
114 slyfox 1.11 if [[ ! -d ${EDARCS_TOP_DIR} ]]; then
115 kosmikus 1.1 # 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 slyfox 1.11 debug-print "${FUNCNAME}: checkout mode. creating darcs directory"
121 kosmikus 1.1 addwrite /foobar
122     addwrite /
123 slyfox 1.11 mkdir -p "${EDARCS_TOP_DIR}"
124 kosmikus 1.1 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 kolmodin 1.5 pushd .
130 slyfox 1.11 cd -P "${EDARCS_TOP_DIR}" > /dev/null
131 kosmikus 1.1 EDARCS_TOP_DIR="`/bin/pwd`"
132    
133     # disable the sandbox for this dir
134 slyfox 1.11 addwrite "${EDARCS_TOP_DIR}"
135 kosmikus 1.1
136     # determine checkout or update mode and change to the right directory.
137 slyfox 1.11 if [[ ! -d "${EDARCS_TOP_DIR}/${EDARCS_LOCALREPO}/_darcs" ]]; then
138 kosmikus 1.1 mode=get
139 slyfox 1.11 cd "${EDARCS_TOP_DIR}"
140 kosmikus 1.1 else
141     mode=update
142 slyfox 1.11 cd "${EDARCS_TOP_DIR}/${EDARCS_LOCALREPO}"
143 kosmikus 1.1 fi
144    
145     # commands to run
146 slyfox 1.11 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 kosmikus 1.1
149 slyfox 1.11 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 kosmikus 1.1 fi
158    
159 slyfox 1.10 export EDARCS_PATCHCOUNT=$(darcs_patchcount)
160     einfo " patches in repo: ${EDARCS_PATCHCOUNT}"
161    
162 kolmodin 1.5 popd
163 kosmikus 1.1 }
164    
165 slyfox 1.11 # @FUNCTION: darcs_src_unpack
166     # @DESCRIPTION:
167     # src_upack function
168 kosmikus 1.1 darcs_src_unpack() {
169 kolmodin 1.7 # The local directory to store the repository (useful to ensure a
170     # unique local name); relative to EDARCS_TOP_DIR
171 slyfox 1.11 [[ -z ${EDARCS_LOCALREPO} ]] && [[ -n ${EDARCS_REPOSITORY} ]] \
172 kolmodin 1.7 && EDARCS_LOCALREPO=${EDARCS_REPOSITORY%/} \
173     && EDARCS_LOCALREPO=${EDARCS_LOCALREPO##*/}
174 kosmikus 1.1
175 slyfox 1.11 debug-print-function ${FUNCNAME} $*
176 kosmikus 1.1
177 slyfox 1.11 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 kosmikus 1.1
187 slyfox 1.11 einfo "Fetching darcs repository ${EDARCS_REPOSITORY} into ${EDARCS_TOP_DIR}..."
188 kosmikus 1.1 darcs_fetch
189    
190 slyfox 1.11 einfo "Copying ${EDARCS_LOCALREPO} from ${EDARCS_TOP_DIR}..."
191     debug-print "Copying ${EDARCS_LOCALREPO} from ${EDARCS_TOP_DIR}..."
192 kosmikus 1.1
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 slyfox 1.9 eshopts_push -s dotglob # get any dotfiles too.
198 slyfox 1.14 rsync -rlpgo "${EDARCS_TOP_DIR}/${EDARCS_LOCALREPO}"/* "${WORKDIR}/${P}"
199 slyfox 1.9 eshopts_pop
200 kosmikus 1.1
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