1 |
On Tue, 24 Jun 2003, Seemant Kulleen wrote: |
2 |
|
3 |
> no I meant rsync on the local filesystem |
4 |
|
5 |
Ah, I see what you mean. Here's a patch to do that. The first time it |
6 |
runs, it takes my machine ~ 3 minutes (compared to 4.5 in past) and after |
7 |
that usually <1 minute (30 seconds if there aren't many updates to to the |
8 |
tree). |
9 |
|
10 |
If people are interested in testing this out and/or providing feedback |
11 |
please do. I've been using it all day without anything breaking (i wish |
12 |
you luck too) ;). |
13 |
|
14 |
Ross Girshick |
15 |
|
16 |
--- emerge.orig 2003-06-24 15:51:10.000000000 -0400 |
17 |
+++ emerge 2003-06-24 17:40:26.000000000 -0400 |
18 |
@@ -1656,31 +1656,55 @@ |
19 |
sys.exit(1) |
20 |
if os.path.exists(myportdir+"/metadata/cache"): |
21 |
print "\n>>> Updating Portage cache... ", |
22 |
- os.umask(0002) |
23 |
- if os.path.exists(portage.dbcachedir): |
24 |
- portage.spawn("rm -Rf "+portage.dbcachedir,free=1) |
25 |
- try: |
26 |
- os.mkdir(portage.dbcachedir) |
27 |
- os.chown(portage.dbcachedir, os.getuid(), portage.portage_gid) |
28 |
- os.chmod(portage.dbcachedir, 06775) |
29 |
- os.umask(002) |
30 |
- except: |
31 |
- pass |
32 |
- mynodes=portage.portdb.cp_all() |
33 |
+ sys.stdout.flush() |
34 |
+ # We shouldn't have to worry about this because when portage is imported dbcachedir is created if it's missing |
35 |
+ if not os.path.exists(portage.dbcachedir): |
36 |
+ print "!!! Cache Directory " + portage.dbcachedir + " does not exist. Re-running emerge should fix this" |
37 |
+ sys.exit(1) |
38 |
+ # XXX If we don't --delete, then we don't have to regenerate the cache files...what danger does this create? |
39 |
+ # maybe it's sufficient to use --delete only every N syncs??? XXX |
40 |
+ #update_cache_command = "/usr/bin/rsync -rlptD --delete --delete-after "... |
41 |
+ update_cache_command = "/usr/bin/rsync -rlptD " + myportdir + "/metadata/cache/ " + portage.dbcachedir |
42 |
+ exitcode = portage.spawn(update_cache_command, free=1) |
43 |
+ # print update_cache_command |
44 |
+ if (exitcode > 0): |
45 |
+ ## more error info might be good |
46 |
+ print "!!! local rsync error (cache update failed): " + exitcode + "\n" |
47 |
+ sys.exit(1) |
48 |
+ mynodes = portage.portdb.cp_all() |
49 |
for x in mynodes: |
50 |
- myxsplit=x.split("/") |
51 |
- if not os.path.exists(portage.dbcachedir+"/"+myxsplit[0]): |
52 |
- os.mkdir(portage.dbcachedir+"/"+myxsplit[0]) |
53 |
- os.chown(portage.dbcachedir+"/"+myxsplit[0], os.getuid(), portage.portage_gid) |
54 |
- os.chmod(portage.dbcachedir+"/"+myxsplit[0], 06775) |
55 |
- mymatches=portage.portdb.xmatch("match-all",x) |
56 |
+ mymatches = portage.portdb.xmatch("match-all", x) |
57 |
for y in mymatches: |
58 |
update_spinner() |
59 |
+ mydbkey = portage.dbcachedir+y |
60 |
+ myebuild, in_overlay = portage.portdb.findname2(y) |
61 |
+ myebuild_mtime = os.stat(myebuild)[ST_MTIME] |
62 |
try: |
63 |
- ignored=portage.portdb.aux_get(y,[],metacachedir=myportdir+"/metadata/cache") |
64 |
- except: |
65 |
- pass |
66 |
- portage.spawn("chmod -R g+rw "+portage.dbcachedir, free=1) |
67 |
+ mydbkeystat = os.stat(mydbkey) |
68 |
+ if mydbkeystat[ST_SIZE] == 0 or myebuild_mtime != mydbkeystat[ST_MTIME]: |
69 |
+ doregen = 1 |
70 |
+ else: |
71 |
+ doregen = 0 |
72 |
+ except OSError: |
73 |
+ doregen = 1 |
74 |
+ |
75 |
+ if doregen: |
76 |
+ ##print "doregen " + mydbkey + "\n" |
77 |
+ try: |
78 |
+ os.unlink(mydbkey) |
79 |
+ except: |
80 |
+ pass |
81 |
+ # regenerate the dep cache file using doebuild interface |
82 |
+ if portage.doebuild(myebuild, "depend", "/"): |
83 |
+ #depend returned non-zero exit code... |
84 |
+ sys.stderr.write(str(red("\nemerge sync:")+" (0) Error in "+y+" ebuild.\n" |
85 |
+ " Check for syntax error or corruption in the ebuild. (--debug)\n\n")) |
86 |
+ try: |
87 |
+ os.utime(mydbkey, (myebuild_mtime, myebuild_mtime)) |
88 |
+ except (IOError, OSError): |
89 |
+ sys.stderr.write(str(red("\nemerge sync:")+" (1) Error in "+y+" ebuild.\n" |
90 |
+ " Check for syntax error or corruption in the ebuild. (--debug)\n\n")) |
91 |
+ ##portage.spawn("chmod -R g+rw "+portage.dbcachedir, free=1) |
92 |
sys.stdout.write("\b\b ...done!\n\n") |
93 |
sys.stdout.flush() |
94 |
|
95 |
|
96 |
|
97 |
-- |
98 |
gentoo-dev@g.o mailing list |