Gentoo Archives: gentoo-commits

From: "Tomas Chvatal (scarabeus)" <scarabeus@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in eclass: git-2.eclass
Date: Sat, 30 Jul 2011 16:02:17
Message-Id: 20110730151034.D24BD2004B@flycatcher.gentoo.org
1 scarabeus 11/07/30 15:10:34
2
3 Modified: git-2.eclass
4 Log:
5 Implement support for multiple checkouts from one ebuild by cleaning up environment. Also allow overriding unpacking of . This is required for live libreoffice ebuild.
6
7 Revision Changes Path
8 1.13 eclass/git-2.eclass
9
10 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/git-2.eclass?rev=1.13&view=markup
11 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/git-2.eclass?rev=1.13&content-type=text/plain
12 diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/git-2.eclass?r1=1.12&r2=1.13
13
14 Index: git-2.eclass
15 ===================================================================
16 RCS file: /var/cvsroot/gentoo-x86/eclass/git-2.eclass,v
17 retrieving revision 1.12
18 retrieving revision 1.13
19 diff -u -r1.12 -r1.13
20 --- git-2.eclass 16 Jul 2011 13:11:54 -0000 1.12
21 +++ git-2.eclass 30 Jul 2011 15:10:34 -0000 1.13
22 @@ -1,6 +1,6 @@
23 # Copyright 1999-2011 Gentoo Foundation
24 # Distributed under the terms of the GNU General Public License v2
25 -# $Header: /var/cvsroot/gentoo-x86/eclass/git-2.eclass,v 1.12 2011/07/16 13:11:54 mgorny Exp $
26 +# $Header: /var/cvsroot/gentoo-x86/eclass/git-2.eclass,v 1.13 2011/07/30 15:10:34 scarabeus Exp $
27
28 # @ECLASS: git-2.eclass
29 # @MAINTAINER:
30 @@ -57,7 +57,7 @@
31 # @ECLASS-VARIABLE: EGIT_DIR
32 # @DESCRIPTION:
33 # Directory where we want to store the git data.
34 -# This should not be overriden unless really required.
35 +# This variable should not be overriden.
36 #
37 # EGIT_DIR="${EGIT_STORE_DIR}/${EGIT_PROJECT}"
38
39 @@ -113,6 +113,12 @@
40 # non bare repositories. This is useful if you can't operate with bare
41 # checkouts for some reason.
42
43 +# @ECLASS-VARIABLE: EGIT_NOUNPACK
44 +# @DEFAULT_UNSET
45 +# @DESCRIPTION:
46 +# If non-empty this variable bans unpacking of ${A} content into the srcdir.
47 +# Default behaviour is to unpack ${A} content.
48 +
49 # @FUNCTION: git-2_init_variables
50 # @DESCRIPTION:
51 # Internal function initializing all git variables.
52 @@ -185,6 +191,8 @@
53 git-2_branch() {
54 debug-print-function ${FUNCNAME} "$@"
55
56 + local branchname src
57 +
58 debug-print "${FUNCNAME}: working in \"${EGIT_SOURCEDIR}\""
59 pushd "${EGIT_SOURCEDIR}" > /dev/null
60
61 @@ -198,8 +206,6 @@
62 || die "${FUNCNAME}: changing the branch failed"
63
64 popd > /dev/null
65 -
66 - unset branchname src
67 }
68
69 # @FUNCTION: git-2_gc
70 @@ -208,10 +214,11 @@
71 git-2_gc() {
72 debug-print-function ${FUNCNAME} "$@"
73
74 + local args
75 +
76 pushd "${EGIT_DIR}" > /dev/null
77 if [[ -n ${EGIT_REPACK} || -n ${EGIT_PRUNE} ]]; then
78 ebegin "Garbage collecting the repository"
79 - local args
80 [[ -n ${EGIT_PRUNE} ]] && args='--prune'
81 debug-print "${FUNCNAME}: git gc ${args}"
82 git gc ${args}
83 @@ -281,8 +288,8 @@
84
85 EGIT_REPO_URI_SELECTED=""
86 for repo_uri in ${EGIT_REPO_URI}; do
87 - debug-print "${FUNCNAME}: git clone ${EGIT_OPTIONS} \"${repo_uri}\" \"${EGIT_DIR}\""
88 - git clone ${EGIT_OPTIONS} "${repo_uri}" "${EGIT_DIR}"
89 + debug-print "${FUNCNAME}: git clone ${EGIT_LOCAL_OPTIONS} \"${repo_uri}\" \"${EGIT_DIR}\""
90 + git clone ${EGIT_LOCAL_OPTIONS} "${repo_uri}" "${EGIT_DIR}"
91 if [[ $? -eq 0 ]]; then
92 # global variable containing the repo_name we will be using
93 debug-print "${FUNCNAME}: EGIT_REPO_URI_SELECTED=\"${repo_uri}\""
94 @@ -304,7 +311,7 @@
95
96 local repo_uri
97
98 - if [[ -n ${EGIT_NONBARE} ]]; then
99 + if [[ -n ${EGIT_LOCAL_NONBARE} ]]; then
100 # checkout master branch and drop all other local branches
101 git checkout ${EGIT_MASTER} || die "${FUNCNAME}: can't checkout master branch ${EGIT_MASTER}"
102 for x in $(git branch | grep -v "* ${EGIT_MASTER}" | tr '\n' ' '); do
103 @@ -342,7 +349,7 @@
104
105 local oldsha cursha repo_type
106
107 - [[ -n ${EGIT_NONBARE} ]] && repo_type="non-bare repository" || repo_type="bare repository"
108 + [[ -n ${EGIT_LOCAL_NONBARE} ]] && repo_type="non-bare repository" || repo_type="bare repository"
109
110 if [[ ! -d ${EGIT_DIR} ]]; then
111 git-2_initial_clone
112 @@ -438,6 +445,8 @@
113 # Internal function migrating between bare and normal checkout repository.
114 # This is based on usage of EGIT_SUBMODULES, at least until they
115 # start to work with bare checkouts sanely.
116 +# This function also set some global variables that differ between
117 +# bare and non-bare checkout.
118 git-2_migrate_repository() {
119 debug-print-function ${FUNCNAME} "$@"
120
121 @@ -449,7 +458,11 @@
122 else
123 target="full"
124 fi
125 - [[ -n ${EGIT_NONBARE} ]] && target="full"
126 + # check if user didn't specify that we want non-bare repo
127 + if [[ -n ${EGIT_NONBARE} ]]; then
128 + target="full"
129 + EGIT_LOCAL_NONBARE="true"
130 + fi
131
132 # test if we already have some repo and if so find out if we have
133 # to migrate the data
134 @@ -489,19 +502,40 @@
135 # set various options to work with both targets
136 if [[ ${target} == bare ]]; then
137 debug-print "${FUNCNAME}: working in bare repository for \"${EGIT_DIR}\""
138 - EGIT_OPTIONS+=" --bare"
139 + EGIT_LOCAL_OPTIONS+="${EGIT_OPTIONS} --bare"
140 MOVE_COMMAND="git clone -l -s -n ${EGIT_DIR// /\\ }"
141 EGIT_UPDATE_CMD="git fetch -t -f -u origin ${EGIT_BRANCH}:${EGIT_BRANCH}"
142 UPSTREAM_BRANCH="${EGIT_BRANCH}"
143 else
144 debug-print "${FUNCNAME}: working in bare repository for non-bare \"${EGIT_DIR}\""
145 MOVE_COMMAND="cp -pPR ."
146 + EGIT_LOCAL_OPTIONS="${EGIT_OPTIONS}"
147 EGIT_UPDATE_CMD="git pull -f -u ${EGIT_OPTIONS}"
148 UPSTREAM_BRANCH="origin/${EGIT_BRANCH}"
149 - EGIT_NONBARE="true"
150 + EGIT_LOCAL_NONBARE="true"
151 fi
152 }
153
154 +# @FUNCTION: git-2_cleanup
155 +# @DESCRIPTION:
156 +# Internal function cleaning up all the global variables
157 +# that are not required after the unpack has been done.
158 +git-2_cleanup() {
159 + debug-print-function ${FUNCNAME} "$@"
160 +
161 + # Here we can unset only variables that are GLOBAL
162 + # defined by the eclass, BUT NOT subject to change
163 + # by user (like EGIT_PROJECT).
164 + # If ebuild writer polutes his environment it is
165 + # his problem only.
166 + unset EGIT_DIR
167 + unset MOVE_COMMAND
168 + unset EGIT_LOCAL_OPTIONS
169 + unset EGIT_UPDATE_CMD
170 + unset UPSTREAM_BRANCH
171 + unset EGIT_LOCAL_NONBARE
172 +}
173 +
174 # @FUNCTION: git-2_src_unpack
175 # @DESCRIPTION:
176 # Default git src_unpack function.
177 @@ -517,13 +551,16 @@
178 git-2_move_source
179 git-2_branch
180 git-2_bootstrap
181 + git-2_cleanup
182 echo ">>> Unpacked to ${EGIT_SOURCEDIR}"
183
184 # Users can specify some SRC_URI and we should
185 # unpack the files too.
186 - if has ${EAPI:-0} 0 1; then
187 - [[ -n ${A} ]] && unpack ${A}
188 - else
189 - default_src_unpack
190 + if [[ -z ${EGIT_NOUNPACK} ]]; then
191 + if has ${EAPI:-0} 0 1; then
192 + [[ -n ${A} ]] && unpack ${A}
193 + else
194 + default_src_unpack
195 + fi
196 fi
197 }