Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

Per-Product_Configuration.txt 6.5 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
  1. = Per-product Configuration Packaging
  2. In the Fedora.next world,
  3. we have a set of curated Fedora Products as well as the availability of classic Fedora.
  4. Historically, we have maintained a single set of configuration defaults
  5. for all Fedora installs,
  6. but different target use-cases have different needs.
  7. The goal of this document
  8. is to set out the guidelines for creating per-Product configuration defaults.
  9. We want to ensure that all packages have sensible defaults
  10. for whichever Product on which they are installed,
  11. while also avoiding situations where users would have some packages installed
  12. with one Product's defaults and some packages with another.
  13. == Requirements
  14. * All packages MUST have a global default configuration.
  15. This configuration will be used
  16. whenever a Product-specific default configuration is not required.
  17. (For example, if a non-Product install is in use
  18. or only Fedora Cloud has a custom configuration
  19. and Fedora Workstation was installed).
  20. * Any package that requires a per-product default configuration
  21. MUST provide all alternate configuration files in the same package.
  22. * Any package that requires a configuration that differs between Products
  23. MUST obtain permission from that Product's Working Group before packaging it.
  24. == Global Default Configuration
  25. * The global default configuration
  26. MUST be provided by the package that requires it.
  27. * The global default configuration
  28. MUST be named based on the package's normal naming scheme,
  29. with the main part of the name being suffixed by -default.
  30. For example, if the package normally uses `+foo.conf+`,
  31. then the global default configuration
  32. MUST be named `+foo-default.conf+`.
  33. == Per-Product Default Configuration
  34. * For each Product requiring a unique default configuration,
  35. the packager MUST provide a copy of the default configuration file,
  36. modified as appropriate for the specific product.
  37. * The product-specific configuration file
  38. MUST be named based on the package's normal naming scheme,
  39. with the main part of the name being suffixed by a dash
  40. followed by the name of the product.
  41. For example, if the package normally uses `+foo.conf+`,
  42. then the Server version MUST be named `+foo-server.conf+`.
  43. * If the configuration will be symlinked in place,
  44. the product-specific configuration file
  45. MUST be located in an appropriate part of the `+/etc+` hierarchy.
  46. The divergent config file
  47. MUST be specified as `+%config(noreplace)+` in `+%files+`
  48. as per the usual `+/etc+` packaging guidelines.
  49. * If the configuration will be copied in place,
  50. the product-specific configuration file
  51. MUST be located in an appropriate part of the `+/usr/share+` hierarchy.
  52. The divergent config file
  53. MUST be specified as a normal file in the `+%files+` section.
  54. == Applying Configuration
  55. In order to apply the configuration,
  56. the packager MUST implement a mechanism
  57. in the `+%posttrans+` section of the specfile that behaves as follows:
  58. * It MUST first check whether the final config file already exists.
  59. If so, the script MUST make no changes.
  60. +
  61. [source, rpm-spec]
  62. ----
  63. %posttrans
  64. if [ ! -e %{_sysconfdir}/foo/foo.conf ]; then
  65. ...
  66. fi
  67. ----
  68. * Then it MUST use the value of the Fedora `+VARIANT_ID+`
  69. to symlink or copy one of the divergent config files
  70. (or the default) to the final config file location.
  71. It will get this value
  72. by importing the contents of `+/etc/os-release+` as shell values.
  73. Known values of this field at the time of this writing are
  74. "atomichost", "cloud", "server" and "workstation".
  75. For more detail, see
  76. https://www.freedesktop.org/software/systemd/man/os-release.html#VARIANT_ID=[the os-release(5) man page].
  77. +
  78. [source, rpm-spec]
  79. ----
  80. . /etc/os-release || :
  81. case "$VARIANT_ID" in
  82. server)
  83. ln -sf foo-server.conf %{_sysconfdir}/foo/foo.conf || :
  84. ;;
  85. *)
  86. ln -sf foo-default.conf %{_sysconfdir}/foo/foo.conf || :
  87. ;;
  88. esac
  89. ----
  90. * Lastly, the final config file location
  91. MUST be listed in the `+%files+` section with `+%ghost+`:
  92. +
  93. [source, rpm-spec]
  94. ----
  95. %ghost %config(noreplace) %{_sysconfdir}/foo/foo.conf
  96. ----
  97. * For tracking purposes,
  98. the package providing the various configuration files
  99. MUST also contain a virtual `+Provides:+`
  100. for each variant configuration that may be applied:
  101. +
  102. [source, rpm-spec]
  103. ----
  104. Provides: variant_config(Atomic.host)
  105. Provides: variant_config(Cloud)
  106. Provides: variant_config(Server)
  107. Provides: variant_config(Workstation)
  108. ----
  109. == Example (firewalld)
  110. We will assume for the sake of demonstration
  111. that firewalld will need a custom configuration
  112. for Fedora Server and Fedora Workstation,
  113. but that Fedora Cloud will not require any changes from the global default.
  114. [source, rpm-spec]
  115. ----
  116. ...
  117. Provides: variant_config(Server)
  118. Provides: variant_config(Workstation)
  119. ...
  120. %posttrans
  121. # If we don't yet have a symlink or existing file for firewalld.conf,
  122. # create it. Note: this will intentionally reset the policykit policy
  123. # at the same time, so they are in sync.
  124. if [ ! -e %{_sysconfdir}/firewalld/firewalld.conf ]; then
  125. # Import /etc/os-release to get the variant definition
  126. . /etc/os-release || :
  127. case "$VARIANT_ID" in
  128. server)
  129. ln -sf firewalld-server.conf %{_sysconfdir}/firewalld/firewalld.conf || :
  130. ln -sf org.fedoraproject.FirewallD1.server.policy \
  131. %{_datadir}/polkit-1/actions/org.fedoraproject.FirewallD1.policy || :
  132. ;;
  133. workstation)
  134. ln -sf firewalld-workstation.conf %{_sysconfdir}/firewalld/firewalld.conf || :
  135. ln -sf org.fedoraproject.FirewallD1.desktop.policy \
  136. %{_datadir}/polkit-1/actions/org.fedoraproject.FirewallD1.policy || :
  137. ;;
  138. *)
  139. ln -sf firewalld-default.conf %{_sysconfdir}/firewalld/firewalld.conf || :
  140. # The default firewall policy will be the same as Server
  141. ln -sf org.fedoraproject.FirewallD1.server.policy \
  142. %{_datadir}/polkit-1/actions/org.fedoraproject.FirewallD1.policy || :
  143. ;;
  144. esac
  145. fi
  146. ...
  147. %files -f %{name}.lang
  148. ...
  149. %attr(0750,root,root) %dir %{_sysconfdir}/firewalld
  150. %ghost %config(noreplace) %{_sysconfdir}/firewalld/firewalld.conf
  151. %config(noreplace) %{_sysconfdir}/firewalld/firewalld-default.conf
  152. %config(noreplace) %{_sysconfdir}/firewalld/firewalld-server.conf
  153. %config(noreplace) %{_sysconfdir}/firewalld/firewalld-workstation.conf
  154. ...
  155. %ghost %{_datadir}/polkit-1/actions/org.fedoraproject.FirewallD1.policy
  156. %{_datadir}/polkit-1/actions/org.fedoraproject.FirewallD1.desktop.policy
  157. %{_datadir}/polkit-1/actions/org.fedoraproject.FirewallD1.server.policy
  158. ----
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...