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

Diff of /eclass/darcs.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.14

  ViewVC Help
Powered by ViewVC 1.1.20