1 |
Hello, |
2 |
|
3 |
I've updated the autodep and testing it now. |
4 |
|
5 |
I've fixed a problem with the integration of autodep in the newest version |
6 |
of Portage, but I think I did it in a hackish way. I want to ask if it is |
7 |
possble to solve it better. |
8 |
|
9 |
First, some words about the architecture of autodep. Autodep consists of |
10 |
two parts: |
11 |
1) A library, injected with LD_PRELOAD, which intercepting glibc functions |
12 |
like open, read, write, etc. The library connects using unix socket with a |
13 |
server part and asks this server about each file operation. The server can |
14 |
say to permit or to block an operation. |
15 |
2) The server part, which logs requests from clients and answers them. |
16 |
|
17 |
The integration with the portage is made, using two hooks on |
18 |
build(EbuildBuild.py): |
19 |
build = EbuildExecuter(background=self.background, pkg=pkg, |
20 |
scheduler=scheduler, settings=settings) |
21 |
|
22 |
build.addStartListener(self._build_start) |
23 |
build.addExitListener(self._build_stop) |
24 |
|
25 |
self._start_task(build, self._build_exit) |
26 |
|
27 |
The _build_start creates the server thread, and passes a unix-socket path |
28 |
using LOG_SOCKET environment variable. |
29 |
|
30 |
self.logserver.start() |
31 |
|
32 |
# Copy socket path to LOG_SOCKET environment variable |
33 |
env=self.settings.configdict["pkg"] |
34 |
env['LOG_SOCKET'] = self.logserver.socket_name |
35 |
|
36 |
The _build_stop stops the server and removes LOG_SOCKET environment |
37 |
variable. |
38 |
env=self.settings.configdict["pkg"] |
39 |
if 'LOG_SOCKET' in env: |
40 |
del env['LOG_SOCKET'] |
41 |
|
42 |
events=self.logserver.stop() |
43 |
self.logserver=None |
44 |
|
45 |
If LOG_SOCKET env var is set then the new processes(like ebuild.sh <stage>) |
46 |
are started with my library injected using LD_PRELOAD trick. |
47 |
|
48 |
The problem: on newer portage versions packages are merged in a subprocess |
49 |
to allow the Scheduler run in main thread while files are moved or copied |
50 |
asynchronously(file _MergeProcess.py). This subprocess is created before |
51 |
the _build_stop is called, so it still has a copy of settings with |
52 |
LOG_SOCKET set. When _build_stop is called the server stops and merging |
53 |
fails because the unix-socket is closed. |
54 |
|
55 |
To solve this I added this code before forking in _MergeProcess.py: |
56 |
# Delete LOG_SOCKET from environment |
57 |
env=self.settings.configdict["pkg"] |
58 |
if 'LOG_SOCKET' in env: |
59 |
del env['LOG_SOCKET'] |
60 |
|
61 |
But I think this can be done better. Do you know a better way? |
62 |
|
63 |
P.S. The old variant of integration patch is available here: |
64 |
http://git.overlays.gentoo.org/gitweb/?p=proj/autodep.git;a=blob;f=integration_with_portage.patch;h=ff8f487306e85cbc6ba9e69be6fe613e99b39b53;hb=HEAD |
65 |
|
66 |
Best, |
67 |
Alexander Bersenev |
68 |
|
69 |
2014-02-14 14:08 GMT+06:00 Александр Берсенев <bay@×××××××××.ru>: |
70 |
|
71 |
> Aleksandr |
72 |
> |
73 |
> |
74 |
> 2014-02-14 13:50 GMT+06:00 Greg Turner <gmt@×××××.us>: |
75 |
> |
76 |
> Holy crap, that looks awesome! How does one pronounce your name, |
77 |
>> Александр? |
78 |
>> |
79 |
>> On Thu, Feb 13, 2014 at 11:28 PM, Александр Берсенев <bay@×××××××××.ru> |
80 |
>> wrote: |
81 |
>> > Ok, I'll work on it. |
82 |
>> > |
83 |
>> > |
84 |
>> > 2014-02-13 23:00 GMT+06:00 Rich Freeman <rich0@g.o>: |
85 |
>> > |
86 |
>> >> On Thu, Feb 13, 2014 at 11:07 AM, Brian Dolbec <dolsen@g.o> |
87 |
>> wrote: |
88 |
>> >> > Yes, if you can please work on updating it. Please contact us on the |
89 |
>> >> > gentoo-portage-dev mail list or irc #gentoo-portage for changes to |
90 |
>> >> > portage that will help keep it working in the future. I started |
91 |
>> >> > development of a public_api branch long ago just for having a stable |
92 |
>> >> > API for apps to use. Perhaps some of what you need can be integrated |
93 |
>> >> > there. |
94 |
>> >> |
95 |
>> >> Seems like a valuable tool. It would be best if it could either use |
96 |
>> >> portage APIs where available, or if effort could be directed at |
97 |
>> >> incorporating the necessary features into portage or its APIs so that |
98 |
>> >> you're not stuck maintaining a fork. I'm sure the portage team will |
99 |
>> >> help where they can. |
100 |
>> >> |
101 |
>> >> Rich |
102 |
>> >> |
103 |
>> > |
104 |
>> |
105 |
>> |
106 |
> |