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