Gentoo Archives: gentoo-dev

From: Alexis Ballier <aballier@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] usr merge
Date: Tue, 05 Apr 2016 16:53:32
Message-Id: 77df966e-2305-4700-b1ac-c6e8fab704f2@gentoo.org
In Reply to: [gentoo-dev] Re: usr merge by Duncan <1i5t5.duncan@cox.net>
1 On Tuesday, April 5, 2016 2:26:53 PM CEST, Duncan wrote:
2 > Alexis Ballier posted on Tue, 05 Apr 2016 12:10:51 +0200 as excerpted:
3 >
4 >> On Tuesday, April 5, 2016 3:19:59 AM CEST, William Hubbs wrote:
5 >> [...] ...
6 >
7 > As I said in the other thread, I'm running merged /usr and bin/sbin here,
8 > except that I merged them the other way, with /usr -> . so everything in
9 > /usr is now in /.
10 >
11 > Portage has long "just worked" in that regard, tho I've no idea whether
12 > the other PMs do. Portage has enough intelligence to avoid replacing a
13 > file with a symlink pointing to it (and thus to itself once the
14 > replacement is done), regardless of which way the directory symlinks
15 > point.
16 >
17 > As such, coreutils "just works". If the two would end up in the same
18 > canonical location, the file wins and the symlink isn't installed.
19
20 What about the unlikely case with two files ?
21
22
23 > There are a few individual package bugs, including one open right now
24 > where the gcc-config ebuild does an unconditional rm -f of any old
25 > versions found in its old sbin location, even when it removes the
26 > executable it just installed into the bin location, because they're the
27 > same canonical location. (Bug number for that and other bugs in the
28 > reply on the other thread.) And cmake can get mixed up in some instances
29 > so a few packages (baloo) have problems with some cmake versions.
30 >
31 > But the bugs aren't with portage, they're with the ebuild or the upstream
32 > sources, and the number of them I've run into in the two years plus I've
33 > been running merged can fit on one hand. Certainly, they're few enough
34 > to deal with on a case-by-case basis.
35
36 Yeah, these cases need to be handled on a case by case basis, there's no
37 other choice anyway :)
38
39 If we want to move on on this, we should definitely track these properly.
40
41 [...]
42 > 1) Unless one is sure of the actual install path used and uses it, equery
43 > belongs and I assume q and similar tools with the same query, need the
44 > bare file name, not the full path, because you might use the wrong one.
45 >
46 > For instance, /bin/grep, /sbin/grep, /usr/sbin/grep, and /usr/bin/grep,
47 > are all the same file due to directory level symlinks. However, if you
48 > try equery belongs with all four paths, only one of them will return the
49 > hit you're looking for.
50 >
51 > Easily solved by simply doing equery belongs grep (no path), and letting
52 > equery supply the installed path in its results. That's actually how I
53 > find out which path a file was actually installed to, these days, as
54 > well. =:^)
55
56
57 no real issue here, and anyway, since it parses portage tree & profiles,
58 support for guessing usr-merge can be added to restore old behavior
59
60 > 2) revdep-rebuild will, in its default configuration, end up processing
61 > files using all paths. So grep, to use the same example as above, will
62 > be processed four times, one each for /bin and /sbin, /usr/bin and /usr/
63 > sbin.
64 >
65 > While it's possible to reconfigure revdep-rebuild to ignore three of
66 > those paths and only check one of them (and similarly, ignore one of
67 > /lib64 and /usr/lib64, etc), doing so will result in revdep-rebuild
68 > complaining about unowned broken binaries if they're installed using a
69 > different path than the one it processed.
70 >
71 > That's not a big problem, because equery belongs <file> (without the
72 > path) will tell you what owns it as well as the installed path it used,
73 > and then that package can be remerged manually, if needed.
74
75
76 kind of defeats the point of revdep-rebuild though :)
77
78 [...]
79 >> # Create the /usr merge compatibility symlinks for dir in /bin /sbin; do
80 >> run_command rm -rf $dir
81 >>
82 >> ---> where are the 'ln' and 'rm' taken from after this step ?
83 >> If this fails here, you're also leaving the system in a broken state.
84 >>
85 >> run_command ln -s usr/bin $dir done
86 >
87 > In my case I was using the mc binary, which continued to run after the
88 > transfer, so it wasn't an issue.
89 >
90 > But using the individual ln and rm binaries, while they'll still be on
91 > the path, you may need to run hash -r in the shell so it forgets the old
92 > location and checks the path again.
93 >
94 > Similar thing for the libs, since the lib cache will be screwed after the
95 > move, until the symlink has been created so the old paths work again, at
96 > least. In my case I was using the mc binary which continued to run and
97 > thus could be used to create the symlink, but for one-shot executables
98 > like ln, that could be an issue.
99 >
100 > One way around the problem would be to create a few static-linked
101 > executables for the purpose, and ship them in a tarball that's unpacked
102 > to an unchanging tmp location for the run, so they can be called from
103 > there to finish up regardless of whether the dynamically linked normal
104 > executables can still be invoked.
105 >
106 > Smart use of the shell's builtin read, echo and redirection could
107 > probably do some of it too, but can ln be emulated using shell builtins?
108 >
109
110
111 I'd rather use a binary that ensures everything that needs to be loaded is
112 loaded at the beginning and even better if it can enusre system consistency
113 and can do rollbacks in case of failure.
114
115 A python script would probably work if there is no dynamic import, or a C
116 version that doesnt use dlopen() nor execv() & friends. It's probably even
117 easier to check that / and /usr are on the same mount point.
118
119 Alexis.

Replies

Subject Author
[gentoo-dev] Re: usr merge Jonathan Callen <jcallen@g.o>