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

Contents of /eclass/darcs.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.9 - (hide annotations) (download)
Mon Jul 19 02:52:14 2010 UTC (4 years, 5 months ago) by slyfox
Branch: MAIN
Changes since 1.8: +5 -5 lines
convert to eshopts_{push,pop} (bug #328869)

Thanks to Mike Frysinger <vapier@gentoo.org> for the report and fix.

1 kosmikus 1.1 # Copyright 2004 Gentoo Technologies, Inc.
2     # Distributed under the terms of the GNU General Public License v2
3 slyfox 1.9 # $Header: /var/cvsroot/gentoo-x86/eclass/darcs.eclass,v 1.8 2010/03/14 12:31:41 kolmodin Exp $
4 kosmikus 1.1 #
5     # darcs eclass author: Andres Loeh <kosmikus@gentoo.org>
6     # tla eclass author: <rphillips@gentoo.org>
7     # Original Author: Jeffrey Yasskin <jyasskin@mail.utexas.edu>
8     #
9     # Originally derived from the tla eclass, which is derived from the
10     # cvs eclass.
11     #
12     # This eclass provides the generic darcs fetching functions.
13     # to use from an ebuild, set the 'ebuild-configurable settings' below in your
14     # ebuild before inheriting. then either leave the default src_unpack or extend
15     # over darcs_src_unpack.
16    
17     # Most of the time, you will define only $EDARCS_REPOSITORY in your
18     # ebuild.
19    
20     # TODO: support for tags, ...
21    
22 slyfox 1.9 inherit eutils # eshopts_{push,pop}
23    
24 kosmikus 1.1 # Don't download anything other than the darcs repository
25     SRC_URI=""
26    
27     # You shouldn't change these settings yourself! The ebuild/eclass inheriting
28     # this eclass will take care of that.
29    
30     # --- begin ebuild-configurable settings
31    
32     # darcs command to run
33     [ -z "$EDARCS_DARCS_CMD" ] && EDARCS_DARCS_CMD="darcs"
34    
35 dcoutts 1.2 # darcs commands with command-specific options
36 kosmikus 1.3 [ -z "$EDARCS_GET_CMD" ] && EDARCS_GET_CMD="get --partial"
37 kosmikus 1.1 [ -z "$EDARCS_UPDATE_CMD" ] && EDARCS_UPDATE_CMD="pull"
38    
39 dcoutts 1.2 # options to pass to both the "get" and "update" commands
40     [ -z "$EDARCS_OPTIONS" ] && EDARCS_OPTIONS="--set-scripts-executable"
41    
42 kosmikus 1.1 # Where the darcs repositories are stored/accessed
43     [ -z "$EDARCS_TOP_DIR" ] && EDARCS_TOP_DIR="${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/darcs-src"
44    
45     # The URI to the repository.
46     [ -z "$EDARCS_REPOSITORY" ] && EDARCS_REPOSITORY=""
47    
48    
49     # EDARCS_CLEAN: set this to something to get a clean copy when updating
50     # (removes the working directory, then uses $EDARCS_GET_CMD to
51     # re-download it.)
52    
53     # --- end ebuild-configurable settings ---
54    
55     # add darcs to deps
56 kolmodin 1.8 DEPEND="dev-vcs/darcs"
57 kosmikus 1.1
58     # is called from darcs_src_unpack
59     darcs_fetch() {
60    
61 kolmodin 1.7 # The local directory to store the repository (useful to ensure a
62     # unique local name); relative to EDARCS_TOP_DIR
63     [ -z "$EDARCS_LOCALREPO" ] && [ -n "$EDARCS_REPOSITORY" ] \
64     && EDARCS_LOCALREPO=${EDARCS_REPOSITORY%/} \
65     && EDARCS_LOCALREPO=${EDARCS_LOCALREPO##*/}
66    
67 kosmikus 1.1 debug-print-function $FUNCNAME $*
68    
69     if [ -n "$EDARCS_CLEAN" ]; then
70     rm -rf $EDARCS_TOP_DIR/$EDARCS_LOCALREPO
71     fi
72    
73     # create the top dir if needed
74     if [ ! -d "$EDARCS_TOP_DIR" ]; then
75     # note that the addwrite statements in this block are only there to allow creating EDARCS_TOP_DIR;
76     # we've already allowed writing inside it
77     # this is because it's simpler than trying to find out the parent path of the directory, which
78     # would need to be the real path and not a symlink for things to work (so we can't just remove
79     # the last path element in the string)
80     debug-print "$FUNCNAME: checkout mode. creating darcs directory"
81     addwrite /foobar
82     addwrite /
83     mkdir -p "$EDARCS_TOP_DIR"
84     export SANDBOX_WRITE="${SANDBOX_WRITE//:\/foobar:\/}"
85     fi
86    
87     # in case EDARCS_DARCS_DIR is a symlink to a dir, get the real
88     # dir's path, otherwise addwrite() doesn't work.
89 kolmodin 1.5 pushd .
90 kosmikus 1.1 cd -P "$EDARCS_TOP_DIR" > /dev/null
91     EDARCS_TOP_DIR="`/bin/pwd`"
92    
93     # disable the sandbox for this dir
94     addwrite "$EDARCS_TOP_DIR"
95    
96     # determine checkout or update mode and change to the right directory.
97     if [ ! -d "$EDARCS_TOP_DIR/$EDARCS_LOCALREPO/_darcs" ]; then
98     mode=get
99     cd "$EDARCS_TOP_DIR"
100     else
101     mode=update
102     cd "$EDARCS_TOP_DIR/$EDARCS_LOCALREPO"
103     fi
104    
105     # commands to run
106 dcoutts 1.2 local cmdget="${EDARCS_DARCS_CMD} ${EDARCS_GET_CMD} ${EDARCS_OPTIONS} --repo-name=${EDARCS_LOCALREPO} ${EDARCS_REPOSITORY}"
107     local cmdupdate="${EDARCS_DARCS_CMD} ${EDARCS_UPDATE_CMD} --all ${EDARCS_OPTIONS} ${EDARCS_REPOSITORY}"
108 kosmikus 1.1
109     if [ "${mode}" == "get" ]; then
110     einfo "Running $cmdget"
111     eval $cmdget || die "darcs get command failed"
112     elif [ "${mode}" == "update" ]; then
113     einfo "Running $cmdupdate"
114     eval $cmdupdate || die "darcs update command failed"
115     fi
116    
117 kolmodin 1.5 popd
118 kosmikus 1.1 }
119    
120    
121     darcs_src_unpack() {
122 kolmodin 1.7 # The local directory to store the repository (useful to ensure a
123     # unique local name); relative to EDARCS_TOP_DIR
124     [ -z "$EDARCS_LOCALREPO" ] && [ -n "$EDARCS_REPOSITORY" ] \
125     && EDARCS_LOCALREPO=${EDARCS_REPOSITORY%/} \
126     && EDARCS_LOCALREPO=${EDARCS_LOCALREPO##*/}
127 kosmikus 1.1
128     debug-print-function $FUNCNAME $*
129    
130     debug-print "$FUNCNAME: init:
131     EDARCS_DARCS_CMD=$EDARCS_DARCS_CMD
132     EDARCS_GET_CMD=$EDARCS_GET_CMD
133     EDARCS_UPDATE_CMD=$EDARCS_UPDATE_CMD
134 dcoutts 1.2 EDARCS_OPTIONS=$EDARCS_OPTIONS
135 kosmikus 1.1 EDARCS_TOP_DIR=$EDARCS_TOP_DIR
136     EDARCS_REPOSITORY=$EDARCS_REPOSITORY
137     EDARCS_LOCALREPO=$EDARCS_LOCALREPO
138     EDARCS_CLEAN=$EDARCS_CLEAN"
139    
140     einfo "Fetching darcs repository $EDARCS_REPOSITORY into $EDARCS_TOP_DIR..."
141     darcs_fetch
142    
143     einfo "Copying $EDARCS_LOCALREPO from $EDARCS_TOP_DIR..."
144     debug-print "Copying $EDARCS_LOCALREPO from $EDARCS_TOP_DIR..."
145    
146     # probably redundant, but best to make sure
147     # Use ${WORKDIR}/${P} rather than ${S} so user can point ${S} to something inside.
148     mkdir -p "${WORKDIR}/${P}"
149    
150 slyfox 1.9 eshopts_push -s dotglob # get any dotfiles too.
151 kolmodin 1.6 rsync -rlpgo --exclude="_darcs/" "$EDARCS_TOP_DIR/$EDARCS_LOCALREPO"/* "${WORKDIR}/${P}"
152 slyfox 1.9 eshopts_pop
153 kosmikus 1.1
154     einfo "Darcs repository contents are now in ${WORKDIR}/${P}"
155    
156     }
157    
158     EXPORT_FUNCTIONS src_unpack

  ViewVC Help
Powered by ViewVC 1.1.20