1 |
In bug 434746 it has been suggested that ${WORKDIR} should look like a |
2 |
bzr branch or checkout. Proposed changes for bzr.eclass are included |
3 |
below, comprising the following: |
4 |
|
5 |
- bzr_fetch can optionally call bzr checkout --lightweight instead of |
6 |
bzr export. The default behaviour won't change, the new behaviour |
7 |
can be enabled with: |
8 |
- New variable EBZR_WORKDIR_CHECKOUT, (Or can anyone come up with a |
9 |
better/shorter name?) |
10 |
- New variable EBZR_CHECKOUT_CMD. |
11 |
- The sandbox environment is now always restored; before it was only |
12 |
restored if ${EBZR_STORE_DIR} didn't exist. This is to prevent the |
13 |
package's build system from writing to ${EBZR_STORE_DIR} when it's |
14 |
calling bzr (which wasn't an issue for an export, but could be for |
15 |
a checkout). |
16 |
- Unrelated to the above, some old cleanup code (around line 220) is |
17 |
removed. |
18 |
|
19 |
The updated bzr.eclass is available in the emacs overlay, along with |
20 |
an app-editors/emacs-vcs ebuild that I've used for testing. |
21 |
|
22 |
Ulrich |
23 |
|
24 |
|
25 |
--- bzr.eclass 18 Jul 2012 15:12:54 -0000 1.18 |
26 |
+++ bzr.eclass 14 Sep 2012 08:02:08 -0000 |
27 |
@@ -61,6 +61,11 @@ |
28 |
# The Bazaar command to export a branch. |
29 |
: ${EBZR_EXPORT_CMD:="bzr export"} |
30 |
|
31 |
+# @ECLASS-VARIABLE: EBZR_CHECKOUT_CMD |
32 |
+# @DESCRIPTION: |
33 |
+# The Bazaar command to checkout a branch. |
34 |
+: ${EBZR_CHECKOUT_CMD:="bzr checkout --lightweight -q"} |
35 |
+ |
36 |
# @ECLASS-VARIABLE: EBZR_REVNO_CMD |
37 |
# @DESCRIPTION: |
38 |
# The Bazaar command to list a revision number of the branch. |
39 |
@@ -145,6 +150,12 @@ |
40 |
# by users. |
41 |
: ${EBZR_OFFLINE=${EVCS_OFFLINE}} |
42 |
|
43 |
+# @ECLASS-VARIABLE: EBZR_WORKDIR_CHECKOUT |
44 |
+# @DEFAULT_UNSET |
45 |
+# @DESCRIPTION: |
46 |
+# If this variable is set to a non-empty value, EBZR_CHECKOUT_CMD will |
47 |
+# be used instead of EBZR_EXPORT_CMD to copy the sources to WORKDIR. |
48 |
+ |
49 |
# @FUNCTION: bzr_initial_fetch |
50 |
# @USAGE: <repository URI> <branch directory> |
51 |
# @DESCRIPTION: |
52 |
@@ -196,11 +207,11 @@ |
53 |
# working copy. |
54 |
bzr_fetch() { |
55 |
local repo_dir branch_dir |
56 |
+ local save_sandbox_write=${SANDBOX_WRITE} |
57 |
|
58 |
[[ -n ${EBZR_REPO_URI} ]] || die "${EBZR}: EBZR_REPO_URI is empty" |
59 |
|
60 |
if [[ ! -d ${EBZR_STORE_DIR} ]] ; then |
61 |
- local save_sandbox_write=${SANDBOX_WRITE} |
62 |
addwrite / |
63 |
mkdir -p "${EBZR_STORE_DIR}" \ |
64 |
|| die "${EBZR}: can't mkdir ${EBZR_STORE_DIR}" |
65 |
@@ -215,19 +226,6 @@ |
66 |
|
67 |
addwrite "${EBZR_STORE_DIR}" |
68 |
|
69 |
- # Clean up if the existing local copy is a checkout (as was the case |
70 |
- # with an older version of bzr.eclass). |
71 |
- # This test can be removed after 1 Mar 2012. |
72 |
- if [[ ${EBZR_FETCH_CMD} != *checkout* && -d ${repo_dir}/.bzr/checkout ]] |
73 |
- then |
74 |
- local tmpname=$(mktemp -u "${repo_dir}._old_.XXXXXX") |
75 |
- ewarn "checkout from old version of ${EBZR} found, moving it to:" |
76 |
- ewarn "${tmpname}" |
77 |
- ewarn "you may manually remove it" |
78 |
- mv "${repo_dir}" "${tmpname}" \ |
79 |
- || die "${EBZR}: can't move old checkout out of the way" |
80 |
- fi |
81 |
- |
82 |
if [[ ! -d ${branch_dir}/.bzr ]]; then |
83 |
if [[ ${repo_dir} != "${branch_dir}" && ! -d ${repo_dir}/.bzr ]]; then |
84 |
einfo "creating shared bzr repository: ${repo_dir}" |
85 |
@@ -252,14 +250,23 @@ |
86 |
bzr_update "${EBZR_REPO_URI}" "${branch_dir}" |
87 |
fi |
88 |
|
89 |
+ # Restore sandbox environment |
90 |
+ SANDBOX_WRITE=${save_sandbox_write} |
91 |
+ |
92 |
cd "${branch_dir}" || die "${EBZR}: can't chdir to ${branch_dir}" |
93 |
|
94 |
# Save revision number in environment. #311101 |
95 |
export EBZR_REVNO=$(${EBZR_REVNO_CMD}) |
96 |
|
97 |
- einfo "exporting ..." |
98 |
- ${EBZR_EXPORT_CMD} ${EBZR_REVISION:+-r ${EBZR_REVISION}} \ |
99 |
- "${WORKDIR}/${P}" . || die "${EBZR}: export failed" |
100 |
+ if [[ -n ${EBZR_WORKDIR_CHECKOUT} ]]; then |
101 |
+ einfo "checking out ..." |
102 |
+ ${EBZR_CHECKOUT_CMD} ${EBZR_REVISION:+-r ${EBZR_REVISION}} \ |
103 |
+ . "${WORKDIR}/${P}" || die "${EBZR}: checkout failed" |
104 |
+ else |
105 |
+ einfo "exporting ..." |
106 |
+ ${EBZR_EXPORT_CMD} ${EBZR_REVISION:+-r ${EBZR_REVISION}} \ |
107 |
+ "${WORKDIR}/${P}" . || die "${EBZR}: export failed" |
108 |
+ fi |
109 |
einfo "revision ${EBZR_REVISION:-${EBZR_REVNO}} is now in ${WORKDIR}/${P}" |
110 |
|
111 |
popd > /dev/null |