1 |
commit: 94fbabcc3cae8163225dc9f97c25770cfc57d806 |
2 |
Author: Tomas Chvatal <scarabeus <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Mar 23 00:37:26 2011 +0000 |
4 |
Commit: Tomas Chvatal <scarabeus <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Mar 23 00:37:26 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/kde.git;a=commit;h=94fbabcc |
7 |
|
8 |
Fix blurb |
9 |
Use :- instead of := during var assignment |
10 |
Remove redundant quoting |
11 |
Do not hide stderr with push/pop |
12 |
Remove dots in die msgs |
13 |
Remove not required SANDBOX_WRITE variable |
14 |
Change rsync usage over to cp usage |
15 |
Various whitespace fixes |
16 |
Initialy set EGIT_REPO_URI_SELECTED to empty string |
17 |
|
18 |
Basically implements all points reported by Mike on g-dev. |
19 |
|
20 |
--- |
21 |
eclass/git-2.eclass | 80 +++++++++++++++++++++++++-------------------------- |
22 |
1 files changed, 39 insertions(+), 41 deletions(-) |
23 |
|
24 |
diff --git a/eclass/git-2.eclass b/eclass/git-2.eclass |
25 |
index dc7fa7c..5b46ec6 100644 |
26 |
--- a/eclass/git-2.eclass |
27 |
+++ b/eclass/git-2.eclass |
28 |
@@ -5,8 +5,7 @@ |
29 |
# @ECLASS: git-2.eclass |
30 |
# @MAINTAINER: |
31 |
# Tomas Chvatal <scarabeus@g.o> |
32 |
-# @BLURB: |
33 |
-# This eclass provides functions for fetching and unpacking git repositories. |
34 |
+# @BLURB: Eclass for fetching and unpacking git repositories. |
35 |
# @DESCRIPTION: |
36 |
# Eclass for easing maitenance of live ebuilds using git as remote repository. |
37 |
# Eclass support working with git submodules and branching. |
38 |
@@ -70,7 +69,7 @@ git-2_init_variables() { |
39 |
# EGIT_REPO_URI="git://a/b.git http://c/d.git" |
40 |
eval x="\$${PN//[-+]/_}_LIVE_REPO" |
41 |
EGIT_REPO_URI=${x:-${EGIT_REPO_URI}} |
42 |
- [[ -z ${EGIT_REPO_URI} ]] && die "EGIT_REPO_URI must have some value." |
43 |
+ [[ -z ${EGIT_REPO_URI} ]] && die "EGIT_REPO_URI must have some value" |
44 |
|
45 |
# @ECLASS-VARIABLE: EVCS_OFFLINE |
46 |
# @DESCRIPTION: |
47 |
@@ -83,13 +82,13 @@ git-2_init_variables() { |
48 |
# @DESCRIPTION: |
49 |
# Specify the branch we want to check out from the repository |
50 |
eval x="\$${PN//[-+]/_}_LIVE_BRANCH" |
51 |
- EGIT_BRANCH=${x:-${EGIT_BRANCH:=${EGIT_MASTER}}} |
52 |
+ EGIT_BRANCH=${x:-${EGIT_BRANCH:-${EGIT_MASTER}}} |
53 |
|
54 |
# @ECLASS-VARIABLE: EGIT_COMMIT |
55 |
# @DESCRIPTION: |
56 |
# Specify commit we want to check out from the repository. |
57 |
eval x="\$${PN//[-+]/_}_LIVE_COMMIT" |
58 |
- EGIT_COMMIT=${x:-${EGIT_COMMIT:=${EGIT_BRANCH}}} |
59 |
+ EGIT_COMMIT=${x:-${EGIT_COMMIT:-${EGIT_BRANCH}}} |
60 |
|
61 |
# @ECLASS-VARIABLE: EGIT_REPACK |
62 |
# @DESCRIPTION: |
63 |
@@ -111,21 +110,20 @@ git-2_init_variables() { |
64 |
git-2_submodules() { |
65 |
debug-print-function ${FUNCNAME} "$@" |
66 |
|
67 |
- [[ "$#" -ne 1 ]] && die "${FUNCNAME}: requires 1 argument (path)" |
68 |
+ [[ $# -ne 1 ]] && die "${FUNCNAME}: requires exactly 1 argument (path)" |
69 |
|
70 |
debug-print "${FUNCNAME}: working in \"${1}\"" |
71 |
- pushd "${1}" &> /dev/null |
72 |
+ pushd "${1}" > /dev/null |
73 |
|
74 |
# for submodules operations we need to be online |
75 |
if [[ -z ${EVCS_OFFLINE} && -n ${EGIT_HAS_SUBMODULES} ]]; then |
76 |
export GIT_DIR=${EGIT_DIR} |
77 |
debug-print "${FUNCNAME}: git submodule init" |
78 |
- git submodule init \ |
79 |
- || die "${FUNCNAME}: git submodule initialisation failed" |
80 |
+ git submodule init || die |
81 |
debug-print "${FUNCNAME}: git submodule sync" |
82 |
- git submodule sync "" die "${FUNCNAME}: git submodule sync failed" |
83 |
+ git submodule sync "" die |
84 |
debug-print "${FUNCNAME}: git submodule update" |
85 |
- git submodule update || die "${FUNCNAME}: git submodule update failed" |
86 |
+ git submodule update || die |
87 |
unset GIT_DIR |
88 |
fi |
89 |
|
90 |
@@ -140,10 +138,10 @@ git-2_branch() { |
91 |
debug-print-function ${FUNCNAME} "$@" |
92 |
|
93 |
debug-print "${FUNCNAME}: working in \"${EGIT_SOURCEDIR}\"" |
94 |
- pushd "${EGIT_SOURCEDIR}" &> /dev/null |
95 |
+ pushd "${EGIT_SOURCEDIR}" > /dev/null |
96 |
|
97 |
local branchname=branch-${EGIT_BRANCH} src=origin/${EGIT_BRANCH} |
98 |
- if [[ "${EGIT_COMMIT}" != "${EGIT_BRANCH}" ]]; then |
99 |
+ if [[ ${EGIT_COMMIT} != ${EGIT_BRANCH} ]]; then |
100 |
branchname=tree-${EGIT_COMMIT} |
101 |
src=${EGIT_COMMIT} |
102 |
fi |
103 |
@@ -162,7 +160,7 @@ git-2_branch() { |
104 |
git-2_gc() { |
105 |
debug-print-function ${FUNCNAME} "$@" |
106 |
|
107 |
- pushd "${EGIT_DIR}" &> /dev/null |
108 |
+ pushd "${EGIT_DIR}" > /dev/null |
109 |
if [[ -n ${EGIT_REPACK} || -n ${EGIT_PRUNE} ]]; then |
110 |
ebegin "Garbage collecting the repository" |
111 |
local args |
112 |
@@ -171,7 +169,7 @@ git-2_gc() { |
113 |
git gc ${args} |
114 |
eend $? |
115 |
fi |
116 |
- popd &> /dev/null |
117 |
+ popd > /dev/null |
118 |
} |
119 |
|
120 |
# @FUNCTION: git-2_prepare_storedir |
121 |
@@ -182,16 +180,14 @@ git-2_prepare_storedir() { |
122 |
debug-print-function ${FUNCNAME} "$@" |
123 |
|
124 |
local clone_dir |
125 |
- local save_sandbox_write=${SANDBOX_WRITE} |
126 |
|
127 |
# initial clone, we have to create master git storage directory and play |
128 |
# nicely with sandbox |
129 |
- if [[ ! -d "${EGIT_STORE_DIR}" ]] ; then |
130 |
+ if [[ ! -d ${EGIT_STORE_DIR} ]]; then |
131 |
debug-print "${FUNCNAME}: Creating git main storage directory" |
132 |
addwrite / |
133 |
mkdir -p "${EGIT_STORE_DIR}" \ |
134 |
- || die "${FUNCNAME}: can't mkdir \"${EGIT_STORE_DIR}\"." |
135 |
- SANDBOX_WRITE=${save_sandbox_write} |
136 |
+ || die "${FUNCNAME}: can't mkdir \"${EGIT_STORE_DIR}\"" |
137 |
fi |
138 |
|
139 |
cd -P "${EGIT_STORE_DIR}" \ |
140 |
@@ -206,14 +202,14 @@ git-2_prepare_storedir() { |
141 |
|
142 |
# we can not jump between using and not using SUBMODULES so we need to |
143 |
# refetch the source when needed |
144 |
- if [[ -d "${EGIT_DIR}" && ! -d "${EGIT_DIR}"/.git ]]; then |
145 |
+ if [[ -d ${EGIT_DIR} && ! -d ${EGIT_DIR}/.git ]]; then |
146 |
debug-print "${FUNCNAME}: \"${clone_dir}\" was bare copy moving..." |
147 |
mv "${EGIT_DIR}" "${EGIT_DIR}.bare" \ |
148 |
- || die "${FUNCNAME}: Moving the bare sources failed." |
149 |
+ || die "${FUNCNAME}: Moving the bare sources failed" |
150 |
|
151 |
fi |
152 |
# Tell user that he can remove his bare repository. It is not used. |
153 |
- if [[ -d "${EGIT_DIR}.bare" ]]; then |
154 |
+ if [[ -d ${EGIT_DIR}.bare ]]; then |
155 |
einfo "Found GIT bare repository at \"${EGIT_DIR}.bare\"." |
156 |
einfo "This folder can be safely removed to save space." |
157 |
fi |
158 |
@@ -225,11 +221,11 @@ git-2_prepare_storedir() { |
159 |
git-2_move_source() { |
160 |
debug-print-function ${FUNCNAME} "$@" |
161 |
|
162 |
- pushd "${EGIT_DIR}" &> /dev/null |
163 |
+ pushd "${EGIT_DIR}" > /dev/null |
164 |
debug-print "${FUNCNAME}: rsync -rlpgo . \"${EGIT_SOURCEDIR}\"" |
165 |
- rsync -rlpgo . "${EGIT_SOURCEDIR}" \ |
166 |
+ cp -pPR . "${EGIT_SOURCEDIR}" \ |
167 |
|| die "${FUNCNAME}: sync to \"${EGIT_SOURCEDIR}\" failed" |
168 |
- popd &> /dev/null |
169 |
+ popd > /dev/null |
170 |
} |
171 |
|
172 |
# @FUNCTION: git-2_initial_clone |
173 |
@@ -240,6 +236,7 @@ git-2_initial_clone() { |
174 |
|
175 |
local repo_uri |
176 |
|
177 |
+ EGIT_REPO_URI_SELECTED="" |
178 |
for repo_uri in ${EGIT_REPO_URI}; do |
179 |
debug-print "${FUNCNAME}: ${EGIT_FETCH_CMD} ${EGIT_OPTIONS} \"${repo_uri}\" \"${EGIT_DIR}\"" |
180 |
${EGIT_FETCH_CMD} ${EGIT_OPTIONS} "${repo_uri}" "${EGIT_DIR}" |
181 |
@@ -252,7 +249,7 @@ git-2_initial_clone() { |
182 |
done |
183 |
|
184 |
if [[ -z ${EGIT_REPO_URI_SELECTED} ]]; then |
185 |
- die "${FUNCNAME}: can't fetch from ${EGIT_REPO_URI}." |
186 |
+ die "${FUNCNAME}: can't fetch from ${EGIT_REPO_URI}" |
187 |
fi |
188 |
} |
189 |
|
190 |
@@ -266,11 +263,12 @@ git-2_update_repo() { |
191 |
|
192 |
# checkout master branch and drop all other local branches |
193 |
git checkout ${EGIT_MASTER} |
194 |
- for x in $(git branch |grep -v "* ${EGIT_MASTER}" |tr '\n' ' '); do |
195 |
+ for x in $(git branch | grep -v "* ${EGIT_MASTER}" | tr '\n' ' '); do |
196 |
debug-print "${FUNCNAME}: git branch -D ${x}" |
197 |
git branch -D ${x} |
198 |
done |
199 |
|
200 |
+ EGIT_REPO_URI_SELECTED="" |
201 |
for repo_uri in ${EGIT_REPO_URI}; do |
202 |
# git urls might change, so reset it |
203 |
git config remote.origin.url "${repo_uri}" |
204 |
@@ -287,7 +285,7 @@ git-2_update_repo() { |
205 |
done |
206 |
|
207 |
if [[ -z ${EGIT_REPO_URI_SELECTED} ]]; then |
208 |
- die "${FUNCNAME}: can't update from ${EGIT_REPO_URI_SELECTED}." |
209 |
+ die "${FUNCNAME}: can't update from ${EGIT_REPO_URI}" |
210 |
fi |
211 |
} |
212 |
|
213 |
@@ -302,25 +300,25 @@ git-2_fetch() { |
214 |
|
215 |
upstream_branch=origin/${EGIT_BRANCH} |
216 |
|
217 |
- if [[ ! -d ${EGIT_DIR} ]] ; then |
218 |
+ if [[ ! -d ${EGIT_DIR} ]]; then |
219 |
git-2_initial_clone |
220 |
- pushd "${EGIT_DIR}" &> /dev/null |
221 |
+ pushd "${EGIT_DIR}" > /dev/null |
222 |
cursha=$(git rev-parse ${upstream_branch}) |
223 |
einfo "GIT NEW clone -->" |
224 |
einfo " repository: ${EGIT_REPO_URI_SELECTED}" |
225 |
einfo " at the commit: ${cursha}" |
226 |
|
227 |
git-2_submodules "${EGIT_DIR}" |
228 |
- popd &> /dev/null |
229 |
- elif [[ -n ${EVCS_OFFLINE} ]] ; then |
230 |
- pushd "${EGIT_DIR}" &> /dev/null |
231 |
+ popd > /dev/null |
232 |
+ elif [[ -n ${EVCS_OFFLINE} ]]; then |
233 |
+ pushd "${EGIT_DIR}" > /dev/null |
234 |
cursha=$(git rev-parse ${upstream_branch}) |
235 |
einfo "GIT offline update -->" |
236 |
einfo " repository: $(git config remote.origin.url)" |
237 |
einfo " at the commit: ${cursha}" |
238 |
- popd &> /dev/null |
239 |
+ popd > /dev/null |
240 |
else |
241 |
- pushd "${EGIT_DIR}" &> /dev/null |
242 |
+ pushd "${EGIT_DIR}" > /dev/null |
243 |
oldsha=$(git rev-parse ${upstream_branch}) |
244 |
git-2_update_repo |
245 |
cursha=$(git rev-parse ${upstream_branch}) |
246 |
@@ -340,12 +338,12 @@ git-2_fetch() { |
247 |
|
248 |
# print nice statistic of what was changed |
249 |
git --no-pager diff --stat ${oldsha}..${upstream_branch} |
250 |
- popd &> /dev/null |
251 |
+ popd > /dev/null |
252 |
fi |
253 |
# export the version the repository is at |
254 |
export EGIT_VERSION="${cursha1}" |
255 |
# log the repo state |
256 |
- [[ "${EGIT_COMMIT}" != "${EGIT_BRANCH}" ]] \ |
257 |
+ [[ ${EGIT_COMMIT} != ${EGIT_BRANCH} ]] \ |
258 |
&& einfo " commit: ${EGIT_COMMIT}" |
259 |
einfo " branch: ${EGIT_BRANCH}" |
260 |
einfo " storage directory: \"${EGIT_DIR}\"" |
261 |
@@ -364,8 +362,8 @@ git-2_bootstrap() { |
262 |
# enviroment the package will fail if there is no update, thus in |
263 |
# combination with --keep-going it would lead in not-updating |
264 |
# pakcages that are up-to-date. |
265 |
- if [[ -n ${EGIT_BOOTSTRAP} ]] ; then |
266 |
- pushd "${EGIT_SOURCEDIR}" &> /dev/null |
267 |
+ if [[ -n ${EGIT_BOOTSTRAP} ]]; then |
268 |
+ pushd "${EGIT_SOURCEDIR}" > /dev/null |
269 |
einfo "Starting bootstrap" |
270 |
|
271 |
if [[ -f ${EGIT_BOOTSTRAP} ]]; then |
272 |
@@ -378,14 +376,14 @@ git-2_bootstrap() { |
273 |
else |
274 |
eerror "\"${EGIT_BOOTSTRAP}\" is not executable." |
275 |
eerror "Report upstream, or bug ebuild maintainer to remove bootstrap command." |
276 |
- die "\"${EGIT_BOOTSTRAP}\" is not executable." |
277 |
+ die "\"${EGIT_BOOTSTRAP}\" is not executable" |
278 |
fi |
279 |
else |
280 |
# we execute some system command |
281 |
debug-print "${FUNCNAME}: bootstraping with commands \"${EGIT_BOOTSTRAP}\"" |
282 |
|
283 |
eval "${EGIT_BOOTSTRAP}" \ |
284 |
- || die "${FUNCNAME}: bootstrap commands failed." |
285 |
+ || die "${FUNCNAME}: bootstrap commands failed" |
286 |
fi |
287 |
|
288 |
einfo "Bootstrap finished" |