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

Contents of /eclass/darcs.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.10 - (hide annotations) (download)
Mon Nov 1 20:54:46 2010 UTC (3 years, 9 months ago) by slyfox
Branch: MAIN
Changes since 1.9: +10 -1 lines
darcs.eclass: export EDARCS_PATCHCOUNT: var shows amount of patches in pulled repository

This feature is requested for 'app-portage/smart-live-rebuild' program
(already provided by other SCM eclasses) (bug #343581)

Thre request and implementation hints by
Alexander Vershilov <alexander.vershilov@gmail.com>.
Implementation by Michał Górny <mgorny@gentoo.org>.

Thank you, guys!

1 kosmikus 1.1 # Copyright 2004 Gentoo Technologies, Inc.
2     # Distributed under the terms of the GNU General Public License v2
3 slyfox 1.10 # $Header: /var/cvsroot/gentoo-x86/eclass/darcs.eclass,v 1.9 2010/07/19 02:52:14 slyfox 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 slyfox 1.10 darcs_patchcount() {
59     set -- $(${EDARCS_DARCS_CMD} show repo | grep "Num Patches")
60     # handle string like: " Num Patches: 3860"
61     echo ${3}
62     }
63    
64 kosmikus 1.1 # is called from darcs_src_unpack
65     darcs_fetch() {
66    
67 kolmodin 1.7 # The local directory to store the repository (useful to ensure a
68     # unique local name); relative to EDARCS_TOP_DIR
69     [ -z "$EDARCS_LOCALREPO" ] && [ -n "$EDARCS_REPOSITORY" ] \
70     && EDARCS_LOCALREPO=${EDARCS_REPOSITORY%/} \
71     && EDARCS_LOCALREPO=${EDARCS_LOCALREPO##*/}
72    
73 kosmikus 1.1 debug-print-function $FUNCNAME $*
74    
75     if [ -n "$EDARCS_CLEAN" ]; then
76     rm -rf $EDARCS_TOP_DIR/$EDARCS_LOCALREPO
77     fi
78    
79     # create the top dir if needed
80     if [ ! -d "$EDARCS_TOP_DIR" ]; then
81     # note that the addwrite statements in this block are only there to allow creating EDARCS_TOP_DIR;
82     # we've already allowed writing inside it
83     # this is because it's simpler than trying to find out the parent path of the directory, which
84     # would need to be the real path and not a symlink for things to work (so we can't just remove
85     # the last path element in the string)
86     debug-print "$FUNCNAME: checkout mode. creating darcs directory"
87     addwrite /foobar
88     addwrite /
89     mkdir -p "$EDARCS_TOP_DIR"
90     export SANDBOX_WRITE="${SANDBOX_WRITE//:\/foobar:\/}"
91     fi
92    
93     # in case EDARCS_DARCS_DIR is a symlink to a dir, get the real
94     # dir's path, otherwise addwrite() doesn't work.
95 kolmodin 1.5 pushd .
96 kosmikus 1.1 cd -P "$EDARCS_TOP_DIR" > /dev/null
97     EDARCS_TOP_DIR="`/bin/pwd`"
98    
99     # disable the sandbox for this dir
100     addwrite "$EDARCS_TOP_DIR"
101    
102     # determine checkout or update mode and change to the right directory.
103     if [ ! -d "$EDARCS_TOP_DIR/$EDARCS_LOCALREPO/_darcs" ]; then
104     mode=get
105     cd "$EDARCS_TOP_DIR"
106     else
107     mode=update
108     cd "$EDARCS_TOP_DIR/$EDARCS_LOCALREPO"
109     fi
110    
111     # commands to run
112 dcoutts 1.2 local cmdget="${EDARCS_DARCS_CMD} ${EDARCS_GET_CMD} ${EDARCS_OPTIONS} --repo-name=${EDARCS_LOCALREPO} ${EDARCS_REPOSITORY}"
113     local cmdupdate="${EDARCS_DARCS_CMD} ${EDARCS_UPDATE_CMD} --all ${EDARCS_OPTIONS} ${EDARCS_REPOSITORY}"
114 kosmikus 1.1
115     if [ "${mode}" == "get" ]; then
116     einfo "Running $cmdget"
117     eval $cmdget || die "darcs get command failed"
118     elif [ "${mode}" == "update" ]; then
119     einfo "Running $cmdupdate"
120     eval $cmdupdate || die "darcs update command failed"
121     fi
122    
123 slyfox 1.10 export EDARCS_PATCHCOUNT=$(darcs_patchcount)
124     einfo " patches in repo: ${EDARCS_PATCHCOUNT}"
125    
126 kolmodin 1.5 popd
127 kosmikus 1.1 }
128    
129    
130     darcs_src_unpack() {
131 kolmodin 1.7 # The local directory to store the repository (useful to ensure a
132     # unique local name); relative to EDARCS_TOP_DIR
133     [ -z "$EDARCS_LOCALREPO" ] && [ -n "$EDARCS_REPOSITORY" ] \
134     && EDARCS_LOCALREPO=${EDARCS_REPOSITORY%/} \
135     && EDARCS_LOCALREPO=${EDARCS_LOCALREPO##*/}
136 kosmikus 1.1
137     debug-print-function $FUNCNAME $*
138    
139     debug-print "$FUNCNAME: init:
140     EDARCS_DARCS_CMD=$EDARCS_DARCS_CMD
141     EDARCS_GET_CMD=$EDARCS_GET_CMD
142     EDARCS_UPDATE_CMD=$EDARCS_UPDATE_CMD
143 dcoutts 1.2 EDARCS_OPTIONS=$EDARCS_OPTIONS
144 kosmikus 1.1 EDARCS_TOP_DIR=$EDARCS_TOP_DIR
145     EDARCS_REPOSITORY=$EDARCS_REPOSITORY
146     EDARCS_LOCALREPO=$EDARCS_LOCALREPO
147     EDARCS_CLEAN=$EDARCS_CLEAN"
148    
149     einfo "Fetching darcs repository $EDARCS_REPOSITORY into $EDARCS_TOP_DIR..."
150     darcs_fetch
151    
152     einfo "Copying $EDARCS_LOCALREPO from $EDARCS_TOP_DIR..."
153     debug-print "Copying $EDARCS_LOCALREPO from $EDARCS_TOP_DIR..."
154    
155     # probably redundant, but best to make sure
156     # Use ${WORKDIR}/${P} rather than ${S} so user can point ${S} to something inside.
157     mkdir -p "${WORKDIR}/${P}"
158    
159 slyfox 1.9 eshopts_push -s dotglob # get any dotfiles too.
160 kolmodin 1.6 rsync -rlpgo --exclude="_darcs/" "$EDARCS_TOP_DIR/$EDARCS_LOCALREPO"/* "${WORKDIR}/${P}"
161 slyfox 1.9 eshopts_pop
162 kosmikus 1.1
163     einfo "Darcs repository contents are now in ${WORKDIR}/${P}"
164    
165     }
166    
167     EXPORT_FUNCTIONS src_unpack

  ViewVC Help
Powered by ViewVC 1.1.20