Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o, Andrew Savchenko <bircoph@g.o>
Subject: Re: [gentoo-dev] [PATCH] acct-*.eclass: Create sysusers.d files
Date: Mon, 14 Sep 2020 10:31:40
Message-Id: 787F704A-6283-4D0D-BD0B-A43D455BB953@gentoo.org
In Reply to: Re: [gentoo-dev] [PATCH] acct-*.eclass: Create sysusers.d files by Andrew Savchenko
1 Dnia September 13, 2020 11:21:28 AM UTC, Andrew Savchenko <bircoph@g.o> napisał(a):
2 >On Sat, 29 Aug 2020 21:53:45 +0200 Michał Górny wrote:
3 >> Thanks to David Michael for the initial patch and upstream fixes.
4 >>
5 >> Signed-off-by: Michał Górny <mgorny@g.o>
6 >> ---
7 >> eclass/acct-group.eclass | 16 +++++++++++++++-
8 >> eclass/acct-user.eclass | 16 +++++++++++++++-
9 >> 2 files changed, 30 insertions(+), 2 deletions(-)
10 >>
11 >> diff --git a/eclass/acct-group.eclass b/eclass/acct-group.eclass
12 >> index 5550e4a2fb10..dc1562974870 100644
13 >> --- a/eclass/acct-group.eclass
14 >> +++ b/eclass/acct-group.eclass
15 >> @@ -80,7 +80,7 @@ S=${WORKDIR}
16 >>
17 >>
18 >> # << Phase functions >>
19 >> -EXPORT_FUNCTIONS pkg_pretend pkg_preinst
20 >> +EXPORT_FUNCTIONS pkg_pretend src_install pkg_preinst
21 >>
22 >> # @FUNCTION: acct-group_pkg_pretend
23 >> # @DESCRIPTION:
24 >> @@ -116,6 +116,20 @@ acct-group_pkg_pretend() {
25 >> fi
26 >> }
27 >>
28 >> +# @FUNCTION: acct-group_src_install
29 >> +# @DESCRIPTION:
30 >> +# Installs sysusers.d file for the group.
31 >> +acct-group_src_install() {
32 >> + debug-print-function ${FUNCNAME} "${@}"
33 >> +
34 >> + insinto /usr/lib/sysusers.d
35 >> + newins - ${CATEGORY}-${ACCT_GROUP_NAME}.conf < <(
36 >> + printf "g\t%q\t%q\n" \
37 >> + "${ACCT_GROUP_NAME}" \
38 >> + "${ACCT_GROUP_ID/#-*/-}"
39 >> + )
40 >> +}
41 >> +
42 >> # @FUNCTION: acct-group_pkg_preinst
43 >> # @DESCRIPTION:
44 >> # Creates the group if it does not exist yet.
45 >> diff --git a/eclass/acct-user.eclass b/eclass/acct-user.eclass
46 >> index e82f3c56dbbe..f9772c3cb111 100644
47 >> --- a/eclass/acct-user.eclass
48 >> +++ b/eclass/acct-user.eclass
49 >> @@ -312,7 +312,7 @@ acct-user_pkg_pretend() {
50 >> # @FUNCTION: acct-user_src_install
51 >> # @DESCRIPTION:
52 >> # Installs a keep-file into the user's home directory to ensure it
53 >is
54 >> -# owned by the package.
55 >> +# owned by the package, and sysusers.d file.
56 >> acct-user_src_install() {
57 >> debug-print-function ${FUNCNAME} "${@}"
58 >>
59 >> @@ -321,6 +321,20 @@ acct-user_src_install() {
60 >> # created yet
61 >> keepdir "${ACCT_USER_HOME}"
62 >> fi
63 >> +
64 >> + insinto /usr/lib/sysusers.d
65 >> + newins - ${CATEGORY}-${ACCT_USER_NAME}.conf < <(
66 >> + printf "u\t%q\t%q\t%q\t%q\t%q\n" \
67 >> + "${ACCT_USER_NAME}" \
68 >> + "${ACCT_USER_ID/#-*/-}:${ACCT_USER_GROUPS[0]}" \
69 >> + "${DESCRIPTION//[:,=]/;}" \
70 >> + "${ACCT_USER_HOME}" \
71 >> + "${ACCT_USER_SHELL/#-*/-}"
72 >> + if [[ ${#ACCT_USER_GROUPS[@]} -gt 1 ]]; then
73 >> + printf "m\t${ACCT_USER_NAME}\t%q\n" \
74 >> + "${ACCT_USER_GROUPS[@]:1}"
75 >> + fi
76 >> + )
77 >> }
78 >
79 >Why these files are installed unconditionally?
80 >
81 >Of course we have a common "small files" policy that USE flags
82 >should not control small files in packages, such rule was designed
83 >for common packages where:
84 > 1) small files are insignificant disk usage compared to a whole
85 >package;
86 > 2) an average package takes significant time to rebuild and mass
87 >rebuild will cause problems during USE flip.
88 >
89 >While both arguments are valid for a common packages which provide
90 >real software, this is not true for very special acct-* packages:
91 > 1) They may (and usually do) have zero size of installed files,
92 >this makes sysusers.d stuff an infinite times larger than a
93 >whole typical acct-* package (it will still be much larger if one
94 >will consider size of new passw/group records).
95
96 Did you realize that your mail is infinite times larger than if you never wrote it?
97
98 > 2) acct-* packages are very fast to rebuild, so such price will
99 >be small compared to other changes necessary when USE="systemd" is
100 >being flipped.
101
102 The price of reading it is also infinite times larger. Not to mention actually addressing it.
103
104 >
105 >So it will be reasonable to add USE="systemd" to acct-* eclasses
106 >to control the changes proposed above.
107 >
108 >Best regards,
109 >Andrew Savchenko
110
111
112 --
113 Best regards,
114 Michał Górny