Gentoo Archives: gentoo-dev

From: William Hubbs <williamh@g.o>
To: gentoo-dev@l.g.o
Cc: mgorny@g.o
Subject: Re: [gentoo-dev] rfc: usrmerge script
Date: Wed, 24 Mar 2021 05:20:56
Message-Id: YFrMLDaRqac8aIME@linux1.home
In Reply to: Re: [gentoo-dev] rfc: usrmerge script by "Michał Górny"
1 On Tue, Mar 23, 2021 at 10:23:11AM +0100, Michał Górny wrote:
2 > On Sun, 2021-03-21 at 12:39 -0500, William Hubbs wrote:
3 > > All,
4 > >
5 > > the following is a script which will migrate a Gentoo system to the usr
6 > > merge layout. This is similar to the unsymlink-lib tool used to migrate
7 > > a system from the 17.0 to the 17.1 profiles.
8 > >
9 > > I'm attaching it here to get some comments before I package it, so
10 > > please let me know if I have missed something.
11 >
12 > To be honest, I don't think critical system modifications should be done
13 > in shell script, and especially not via a fringe non-standards complaint
14 > shell implementation in busybox. Even if you can assume you make no
15 > mistakes, shell is unreliable by design. For example, your script may
16 > start behaving in unexpected ways if you run out of space.
17
18 I went with busybox shell in this case because busybox is a static
19 binary and I figured with everything being moved around on the system it
20 would be a good choice.
21
22 I could pretty easily go with straight sh/bash, I just was focusing on
23 bb since the commands are built in.
24
25 You are right about shell behaving in weird ways if you run out of
26 space, but that's true for anything that happens to be running when a
27 system runs out of space.
28
29 That is why I put the rollback directory in /var by
30 default figuring there is more space there than in /, especially on
31 systems with separate /var.
32
33 The run_command wrapper in the script causes an immediate exit when the
34 command it runs fails so things don't go any
35 further than the failing command, so I'm not sure what else I can do
36 with this situation. One option is to always echo the command we are
37 about to run then just not run it if -d is specified. That means you
38 would always see the commands the script is running.
39
40 > You don't seem to be handling file collisions at all. Even today we
41 > have files like /bin/bzip2 and /usr/bin/bzip2, not to mention shared
42 > libraries. Silently ignoring the problem or requiring the users to
43 > manually ensure their system is clean is not going to solve it.
44
45 I have added -i to the cp commands in my latest version of this so I'll
46 see when we have duplicate names, and yes that is an issue, even without
47 the /usr merge.
48 I'm curious why we are duplicating all of these names in the first
49 place honestly.
50
51 One example of this is in coreutils, and we even say in the ebuild
52 comment that we need to figure out why we are doing it.
53
54 There are a couple of ways forward for this.
55
56 1) attempt to open bugs on the packages and remove the duplicate names
57 by dropping symlinks and putting the files in their cannonical
58 locations. this could lead to breakages if one of the alternate names is
59 expected by something until the /usr merge is done.
60
61 2) try to guess at resolving the duplicate names as part of the
62 usr merge process.
63
64 a. symmlinks in /bin or /sbin that point to the same name in /usr/bin or
65 /usr/sbin should be removed.
66 b. symlinks in /usr/bin or /usr/sbin that point to the same name in /
67 should be removed.
68 c. Other symlinks that I can think of should be preserved.
69
70 Which path for handling this is best? Do you have any thoughts?
71
72 > You don't seem to provide any helpful messages. When things fail, user
73 > will be left in the blue with an error message from some system tool (or
74 > rather, cheap-ass busybox rewrite, I guess).
75
76 If the rollback directory is populated, you can use -r to recover,
77 and the script will not let you perform the /usr merge if the rollback
78 directory is not populated.
79
80 > Also, have you verified that busybox's cp(1) actually preserves all file
81 > properties (including xattrs, ACLs, caps...)?
82
83 The documentation for busybox states that -p preserves file attributes
84 if possible, and by doing ls -l in the chroot I can see that
85 ownership/permissions are preserved. So, logically I would guess it
86 preserves the others.
87
88 If switching back to non-busybox is fine for this operation, I have no
89 problem doing that either.
90
91 > Please don't forget to include tests with it. Docker's good for testing
92 > stuff like this.
93
94 Docker can't be used during src_test that I'm aware of, so I'm not sure
95 how Docker could be used to test this.
96
97 William

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies

Subject Author
Re: [gentoo-dev] rfc: usrmerge script "Michał Górny" <mgorny@g.o>