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