Gentoo Archives: gentoo-dev

From: Kent Fredric <kentnl@g.o>
To: gentoo-dev@l.g.o
Subject: [gentoo-dev] Proposed future EAPI feature: FILES whitelist
Date: Fri, 16 Sep 2016 12:31:36
Message-Id: 20160917003031.2f332748@katipo2.lan
1 Just an idea that seemed obvious enough and obviously missing.
2
3 1. Have, in a future EAPI, a variable (I'm going to call it "FILES" as
4 a stand-in for now ).
5
6 2. FILES contains an array (or perhaps whitespace delimited string) of
7 entries (or perhaps expressions) relative to
8 ${repository_location}/${CATEGORY}/${PN}/files/
9
10 3. Each entry in FILES dictates that the given file is "Used by" the
11 ebuild.
12
13 4. the FILES variable is expanded and interpreted during package
14 sourcing
15
16 5. "repoman full" and "repoman ci" must ensure any entry listed in FILES
17 exists
18
19 6. "repoman full" and "repoman ci" must ensure any use of ${FILESDIR}
20 without a declared FILES variable is a failure.
21
22 7. Under this future EAPI, the location of where ${FILESDIR} expands to
23 changes to a location within
24 ${PORTAGE_TEMPDIR}/portage/${CATEGORY}/${PF}/files
25
26 8. The contents of ${PORTAGE_TEMPDIR}/portage/${CATEGORY}/${PF}/files
27 is generated from the source-time $FILES entry by mapping entries from
28 ${repostory_location}, either by symlink or by copy (though copy is
29 preferred to avoid potential side effects), mapping their heirachy
30 exactly ( that is, preserving directory structure )
31
32 9. Files not listed in/indicated by $FILES are thus unavailable to the
33 ebuild at runtime and will not be seen in ${FILESDIR}, even if they are
34 in ${repository_location}
35
36
37
38 :: Benefits ::
39
40 1. Referential integrity of this field means basic tooling like repoman
41 can verify in advance the presence of things that are deemed necessary
42 for the ebuild to function, and can check for their absense.
43
44 2. Said referential integrity can propagate failures to mirror
45 properly and mistakes by ebuild authors (specifically, naughty ones who
46 side-step repoman) to escallate to being errors long before the files
47 are needed by executable code.
48
49 3. Due to point 2, the risk of silent failures due to lack of explicit
50 handling for the files being missing is reduced.
51
52 4. Due to referential integrity, it should be trivial to identify which
53 files are needed by a given ebuild, and which files are now redundant,
54 assisting with keeping the tree pruned.
55
56 5. When maintaining a given ebuild, the use of a variable means that
57 one can consult the list of files a given ebuild uses canonically, and
58 thus know which files may need oversight when performing changes, as
59 the canonical form of the variable can theoretically be computed during
60 metadata/ generation. ( but probably not wise to just flop that in
61 there, unless we can guarantee that this subtle change to the md5
62 format won't cause problems elsewhere ), but tooling can still be
63 written to spit out a list of FILES= entries. ( Currently, you must
64 grep the ebuild or approximate grep with your eyes, and that is prone
65 to errors, especially in cases of anything that uses horror shows like
66 eblits )
67
68 6. Due to this introducing a concept of connectedness between .ebuild/
69 and files/, this opens a door to a potential emerge feature of
70 --reinstall-if-files-changed , which would allow people to trigger a
71 rebuild for any ebuild which may have been subtly changed due to
72 patches to any of its dependency files. ( Though I'd expect to see
73 little use of this feature if added, except for weird anal people like
74 me who disable dynamic deps ;) )
75
76 :: Mixed Change/Benefit Cases ::
77
78 1. Some eclasses presently support a PATCHES= variable, which contain
79 an ordered list of patches that may be applied, stating the order of
80 application.
81
82 Here, in many cases, PATCHES could be dropped from need and a more
83 universal syntax of `eapply $( echo ${FILESDIR}/*.patch | sort )` as
84 generic logic in the default src_patch
85
86 Due to the ${FILESDIR} being a synthetic location constructed from the
87 contents of the FILES= variable, you can get away with doing a lot of
88 tricks that would otherwise be undesirable in the current situation.
89
90 For instance:
91
92 use foo-feature && eapply ${FILESDIR}/foo-feature/*.patch
93
94 Because the nature of what "FILESDIR" contained is already strictly
95 regulated elsewhere in the ebuild and validated long before the patch
96 phase.
97
98
99 :: Possible Future Abuses ::
100
101 FILES=$( cat ${FIlEDIR}/$PV/series )
102
103 Though this would stil be validated by repoman to make sure all entries
104 in "series" exists, and assuming the data was staticised to the md5
105 metadata cache, would not be so bad. But .... probably should have
106 people shot for doing this.
107
108
109 As always, this feature probably exists in some package manager other
110 than portage for ebuilds in EAPIs other than the one portage support,
111 but I have not checked those for feature comparison.

Replies