/[gentoo-alt]/trunk/prefix/eclass/tla.eclass
Gentoo

Contents of /trunk/prefix/eclass/tla.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 982 - (show annotations) (download)
Thu Feb 2 04:20:17 2006 UTC (13 years, 2 months ago) by kito
File size: 6616 byte(s)
Initial eclass import from gentoo-x86
1 # Copyright 1999-2004 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/tla.eclass,v 1.8 2005/07/11 15:08:06 swegener Exp $
4 #
5 # Original Author: Jeffrey Yasskin <jyasskin@mail.utexas.edu>
6 #
7 # Originally derived from the cvs eclass.
8 #
9 # This eclass provides the generic tla fetching functions.
10 # to use from an ebuild, set the 'ebuild-configurable settings' below in your
11 # ebuild before inheriting. then either leave the default src_unpack or extend
12 # over tla_src_unpack.
13
14 # Most of the time, you will define only $ETLA_VERSION and $ETLA_ARCHIVES in
15 # your ebuild.
16
17 # TODO:
18 # Make it support particular revisions.
19
20
21 # Don't download anything other than the tla archive
22 SRC_URI=""
23
24 # You shouldn't change these settings yourself! The ebuild/eclass inheriting
25 # this eclass will take care of that.
26
27 # --- begin ebuild-configurable settings
28
29 # tla command to run. Theoretically, substituting any arch derivative should be
30 # relatively easy.
31 [ -z "$ETLA_TLA_CMD" ] && ETLA_TLA_CMD="tla"
32
33 # tla commands with options
34 [ -z "$ETLA_GET_CMD" ] && ETLA_GET_CMD="get"
35 [ -z "$ETLA_UPDATE_CMD" ] && ETLA_UPDATE_CMD="replay"
36
37 # Where the tla modules are stored/accessed
38 [ -z "$ETLA_TOP_DIR" ] && ETLA_TOP_DIR="${DISTDIR}/tla-src"
39
40 # Name of tla version in the format
41 # user@example.com--archive-name/category--branch--version
42 # (in other words, an argument to tla get, update, or replay)
43 [ -z "$ETLA_VERSION" ] && ETLA_VERSION=""
44
45 # A space-separated list of significant archive URLs. You should definitely
46 # include the URL for the archive your version is stored in, and if it refers
47 # to any other archives, also list them.
48 [ -z "$ETLA_ARCHIVES" ] && ETLA_ARCHIVES=""
49
50 # The location in which to cache the version, relative to $ETLA_TOP_DIR.
51 [ -z "$ETLA_CACHE_DIR" ] && ETLA_CACHE_DIR="${ETLA_VERSION}"
52
53 # ETLA_CLEAN: set this to something to get a clean copy when updating (removes
54 # the working directory, then uses $ETLA_GET_CMD to re-download it.)
55
56 # --- end ebuild-configurable settings ---
57
58 # add tla to deps
59 DEPEND="dev-util/tla"
60
61 # registers archives mentioned in $ETLA_ARCHIVES
62 tla_register_archives() {
63 debug-print-function $FUNCNAME $* $ETLA_ARCHIVES
64
65 for archive in $ETLA_ARCHIVES; do
66 $ETLA_TLA_CMD register-archive -f $archive || die "Could not register archive $archive"
67 done
68 }
69
70 # checks that configuration variables have rational values.
71 tla_check_vars() {
72 [ -z "$ETLA_VERSION" ] && die "ETLA_VERSION must be set by the ebuild. Please fix this ebuild."
73 $ETLA_TLA_CMD valid-package-name --archive --vsn $ETLA_VERSION || \
74 die "ETLA_VERSION has an invalid format. Please fix this ebuild."
75 }
76
77 # is called from tla_src_unpack
78 tla_fetch() {
79
80 debug-print-function $FUNCNAME $*
81
82 if [ -n "$ETLA_CLEAN" ]; then
83 rm -rf $ETLA_TOP_DIR/$ETLA_CACHE_DIR
84 fi
85
86 # create the top dir if needed
87 if [ ! -d "$ETLA_TOP_DIR" ]; then
88 # note that the addwrite statements in this block are only there to allow creating ETLA_TOP_DIR;
89 # we've already allowed writing inside it
90 # this is because it's simpler than trying to find out the parent path of the directory, which
91 # would need to be the real path and not a symlink for things to work (so we can't just remove
92 # the last path element in the string)
93 debug-print "$FUNCNAME: checkout mode. creating tla directory"
94 addwrite /foobar
95 addwrite /
96 mkdir -p "$ETLA_TOP_DIR"
97 export SANDBOX_WRITE="${SANDBOX_WRITE//:\/foobar:\/}"
98 fi
99
100 # in case ETLA_TOP_DIR is a symlink to a dir, get the real dir's path,
101 # otherwise addwrite() doesn't work.
102 cd -P "$ETLA_TOP_DIR" > /dev/null
103 ETLA_TOP_DIR="`/bin/pwd`"
104
105 # disable the sandbox for this dir
106 addwrite "$ETLA_TOP_DIR"
107
108 # break $ETLA_VERSION into pieces
109 local tla_archive=`$ETLA_TLA_CMD parse-package-name --arch $ETLA_VERSION`
110 local tla_version=`$ETLA_TLA_CMD parse-package-name --package-version $ETLA_VERSION`
111 #local tla_revision=`$ETLA_TLA_CMD parse-package-name --lvl $ETLA_VERSION`
112
113 # determine checkout or update mode and change to the right directory.
114 if [ ! -d "$ETLA_TOP_DIR/$ETLA_CACHE_DIR/{arch}" ]; then
115 mode=get
116 mkdir -p "$ETLA_TOP_DIR/$ETLA_CACHE_DIR"
117 cd "$ETLA_TOP_DIR/$ETLA_CACHE_DIR/.."
118 rmdir "`basename "$ETLA_CACHE_DIR"`"
119 else
120 mode=update
121 cd "$ETLA_TOP_DIR/$ETLA_CACHE_DIR"
122 fi
123
124 # switch versions automagically if needed
125 if [ "$mode" == "update" ]; then
126 local oldversion="`$ETLA_TLA_CMD tree-version`"
127 if [ "$tla_archive/$tla_version" != "$oldversion" ]; then
128
129 einfo "Changing TLA version from $oldversion to $tla_archive/$tla_version:"
130 debug-print "$FUNCNAME: Changing TLA version from $oldversion to $tla_archive/$tla_version:"
131
132 $ETLA_TLA_CMD set-tree-version $tla_archive/$tla_version
133
134 fi
135 fi
136
137 # commands to run
138 local cmdget="${ETLA_TLA_CMD} ${ETLA_GET_CMD} ${ETLA_VERSION} `basename $ETLA_CACHE_DIR`"
139 local cmdupdate="${ETLA_TLA_CMD} ${ETLA_UPDATE_CMD} ${ETLA_VERSION}"
140
141 if [ "${mode}" == "get" ]; then
142 einfo "Running $cmdget"
143 eval $cmdget || die "tla get command failed"
144 elif [ "${mode}" == "update" ]; then
145 einfo "Running $cmdupdate"
146 eval $cmdupdate || die "tla update command failed"
147 fi
148
149 }
150
151
152 tla_src_unpack() {
153
154 debug-print-function $FUNCNAME $*
155
156 debug-print "$FUNCNAME: init:
157 ETLA_TLA_CMD=$ETLA_TLA_CMD
158 ETLA_GET_CMD=$ETLA_GET_CMD
159 ETLA_UPDATE_CMD=$ETLA_UPDATE_CMD
160 ETLA_TOP_DIR=$ETLA_TOP_DIR
161 ETLA_VERSION=$ETLA_VERSION
162 ETLA_ARCHIVES=$ETLA_ARCHIVES
163 ETLA_CACHE_DIR=$ETLA_CACHE_DIR
164 ETLA_CLEAN=$ETLA_CLEAN"
165
166 einfo "Registering Archives ..."
167 tla_register_archives
168
169 einfo "Checking that passed-in variables are rational ..."
170 tla_check_vars
171
172 einfo "Fetching tla version $ETLA_VERSION into $ETLA_TOP_DIR ..."
173 tla_fetch
174
175 einfo "Copying $ETLA_CACHE_DIR from $ETLA_TOP_DIR ..."
176 debug-print "Copying $ETLA_CACHE_DIR from $ETLA_TOP_DIR ..."
177
178 # probably redundant, but best to make sure
179 # Use ${WORKDIR}/${P} rather than ${S} so user can point ${S} to something inside.
180 mkdir -p "${WORKDIR}/${P}"
181
182 shopt -s dotglob # get any dotfiles too.
183 cp -Rf "$ETLA_TOP_DIR/$ETLA_CACHE_DIR"/* "${WORKDIR}/${P}"
184
185 # implement some of base_src_unpack's functionality;
186 # note however that base.eclass may not have been inherited!
187 #if [ -n "$PATCHES" ]; then
188 # debug-print "$FUNCNAME: PATCHES=$PATCHES, S=$S, autopatching"
189 # cd "$S"
190 # for x in $PATCHES; do
191 # debug-print "patching from $x"
192 # patch -p0 < "$x"
193 # done
194 # # make sure we don't try to apply patches more than once, since
195 # # tla_src_unpack may be called several times
196 # export PATCHES=""
197 #fi
198
199 einfo "Version ${ETLA_VERSION} is now in ${WORKDIR}/${P}"
200
201 }
202
203 EXPORT_FUNCTIONS src_unpack

  ViewVC Help
Powered by ViewVC 1.1.20