1 |
Hello, all. |
2 |
|
3 |
After a few days of thinking, discovering and working, here it is. |
4 |
The first working draft of new git eclass codenamed 'git-r3'. |
5 |
|
6 |
First of all, the name is not final. I'm open to ideas. I'm open to |
7 |
naming it 'git-r1' to put it in line with my other -r1 eclasses :). |
8 |
I'd definitely like to avoid 'git-3' though, since that version-like |
9 |
naming was a mistake as almost-'python-2' eclass shown. |
10 |
|
11 |
Secondly, it's not even final that there will be a new eclass. Most |
12 |
likely I will commit it as a new eclass since that way is easier for us |
13 |
but if you prefer I may try to get it and git-2 more API-friendly |
14 |
and work on making it a almost-drop-in replacement. Since, after all, |
15 |
internals have actually changed much more than the API. |
16 |
|
17 |
|
18 |
And now for the major changes: |
19 |
|
20 |
1. The code has been split into clean 'fetch' and 'checkout' pieces. |
21 |
|
22 |
That is, it is suited for distinct src_fetch() and src_unpack() phases |
23 |
that we'll hopefully have in EAPI 6. What's important, the checkout |
24 |
code does not rely on passing *any* environment variables from fetching |
25 |
code. It is also made with concurrency in mind, so multiple ebuilds |
26 |
using the same repository at the same time shouldn't be a problem. |
27 |
|
28 |
2. Public fetch/checkout API. |
29 |
|
30 |
git-2 has a lot of private functions and just src_unpack(). git-r3 has |
31 |
git-r3_fetch() and git-r3_checkout() which are public API intended to |
32 |
used in ebuilds that need more than plain fetch+unpack. While this |
33 |
isn't exactly what multi-repo support pursuers wanted, it should make |
34 |
supporting multiple repos in one ebuild much cleaner. |
35 |
|
36 |
3. Clean submodule support with bare clones. |
37 |
|
38 |
Since the submodules are very straightforward in design, I have decided |
39 |
to move their support into the eclass directly. As a result, the new |
40 |
eclass cleanly supports submodules, treating them as additional |
41 |
repositories and doing submodule fetch/checkout recursively. There is |
42 |
no need for non-bare clones anymore (and therefore their support has |
43 |
been removed to make code simpler), and submodules work fine with |
44 |
EVCS_OFFLINE=1. |
45 |
|
46 |
4. 'Best-effort' shallow clones support. |
47 |
|
48 |
I did my best to support shallow clones in the eclass. The code is |
49 |
specifically designed to handle them whenever possible. However, since |
50 |
shallow clones have a few limitations: |
51 |
|
52 |
a) only branch/tag-based fetches support shallow clones. Fetching by |
53 |
commit id forces complete clone (this is what submodules do BTW). |
54 |
|
55 |
b) there's EGIT_NONSHALLOW option for users who prefer to have full |
56 |
clones, and possibly for ebuilds that fail with shallow clones. |
57 |
|
58 |
c) if shallow clones cause even more trouble than that, I will simply |
59 |
remove their support from the eclass :). |
60 |
|
61 |
[see notes about testing at the end] |
62 |
|
63 |
5. Safer default EGIT_DIR choice. EGIT_PROJECT removed. |
64 |
|
65 |
Since submodules are cloned as separate repositories as well, we can't |
66 |
afford having EGIT_PROJECT to change the clone dir. Instead, the eclass |
67 |
uses full path from first repo URI (with some preprocessing) to |
68 |
determine the clone location. This should ensure non-colliding clones |
69 |
with most likeliness that two ebuilds using the same repo will use |
70 |
the same clone without any special effort from the maintainer. |
71 |
|
72 |
6. Safer default checkout dir. EGIT_SOURCEDIR removed. |
73 |
|
74 |
git-2 used to default EGIT_SOURCEDIR=${S}. This kinda sucked since if |
75 |
one wanted to use subdirectory of the git repo, he needed to both set |
76 |
EGIT_SOURCEDIR and S. Now, the checkout is done to ${WORKDIR}/${P} |
77 |
by default and ebuilds can safely do S=${WORKDIR}/${P}/foo. I may |
78 |
provide EGIT_SOURCEDIR if someone still finds it useful. |
79 |
|
80 |
|
81 |
API/variables removed: |
82 |
|
83 |
1. EGIT_SOURCEDIR: |
84 |
|
85 |
a) if you need it for multiple repos, use the fetch/checkout functions |
86 |
instead, |
87 |
|
88 |
b) otherwise, play with S instead, |
89 |
|
90 |
c) if you really need it, lemme know and I'll put it back. |
91 |
|
92 |
2. EGIT_HAS_SUBMODULES -> no longer necessary, we autodetect them |
93 |
(and we don't need that much special magic like we used to). |
94 |
|
95 |
3. EGIT_OPTIONS -> interfered too much with eclass internals. |
96 |
|
97 |
4. EGIT_MASTER -> people misused it all the time, and it caused issues |
98 |
for projects that used different default branch. Now we just respect |
99 |
upstream's default branch. |
100 |
|
101 |
5. EGIT_PROJECT -> should be no longer necessary. |
102 |
|
103 |
6. EGIT_DIR -> still exported, but no longer respects user setting it. |
104 |
|
105 |
7. EGIT_REPACK, EGIT_PRUNE -> I will probably reintroduce it, or just |
106 |
provide the ability to set git auto-cleanup options. |
107 |
|
108 |
8. EGIT_NONBARE -> only bare clones are supported now. |
109 |
|
110 |
9. EGIT_NOUNPACK -> git-2 is only eclass calling the default. Does |
111 |
anyone actually need this? Is adding custom src_unpack() that hard? |
112 |
|
113 |
10. EGIT_BOOTSTRAP -> this really belongs in *your* src_prepare(). |
114 |
|
115 |
|
116 |
I've tested the eclass on 113 live packages I'm using. Most of them |
117 |
work just fine (I've replaced git-2 with the new eclass). Some |
118 |
of them only require removing the old variables, some need having S |
119 |
changed. However, I noticed the following issues as well: |
120 |
|
121 |
1. code.google fails with 500 when trying to do a shallow clone |
122 |
(probably they implemented their own dumb git server), |
123 |
|
124 |
2. sys-apps/portage wants to play with 'git log' for ChangeLogs. That's |
125 |
something that definitely is not going to work with shallow clones ;). |
126 |
Not that I understand why someone would like a few megs of detailed git |
127 |
backlog. |
128 |
|
129 |
3. sys-fs/bedup's btrfs-progs submodule says the given commit id is |
130 |
'not a valid branch point'. Need to investigate what this means. |
131 |
|
132 |
4. 'git fetch --depth 1' seems to be refetching stuff even when nothing |
133 |
changed. Need to investigate it. It may be enough to do an additional |
134 |
'did anything change?' check. |
135 |
|
136 |
|
137 |
I will try to look into those issues tomorrow. In the meantime, please |
138 |
review this eclass and give me your thoughts. Especially if someone has |
139 |
some more insight on shallow clones. Thanks. |
140 |
|
141 |
And a fun fact: LLVM subversion checkout (in svn-src) has around ~2.4k |
142 |
files which consume around 220M on btrfs. LLVM git shallow clone takes |
143 |
17M. |
144 |
|
145 |
-- |
146 |
Best regards, |
147 |
Michał Górny |