openembedded-core.lists.openembedded.org archive mirror
 help / color / mirror / Atom feed
* Yocto rpm packages do not keep the modified CONFFILES (was: BB Equivalent for %config(noreplace))
@ 2024-03-08 11:20 Böszörményi Zoltán
  2024-03-08 11:32 ` Patchtest results for " patchtest
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Böszörményi Zoltán @ 2024-03-08 11:20 UTC (permalink / raw)
  To: openembedded-core

Hi,

I just found out that if an updated package ships a modified
configuration file, then the Yocto package upgrade does this:

* rename the edited conffile to conffile.rpmsave
* install the new, modified one from the package

instead of:

* keep the edited conffile intact
* install the new, modified one from the package as conffile.rpmnew

I think this is what was asked in 2017 here:
https://docs.yoctoproject.org/pipermail/yocto/2017-May/036031.html

The answer was a little uninformed about saying that using
CONFFILES is the fix, because rpm can behave two ways, see above.

Yocto, to this day, uses "%config /path/to/conffile" instead of
"%config(noreplace) /path/to/conffile" in package_rpm.bbclass.
The latter would behave as "keep modified conffile + install conffile.rpmnew".

What's the official stance on this behaviour?
Is it a known issue?
Is this what the project would expect from a package upgrade?

FWIW, this one liner would change the behaviour:

diff --git a/meta/classes-global/package_rpm.bbclass b/meta/classes-global/package_rpm.bbclass
index 2e3e4e8c79..6610115849 100644
--- a/meta/classes-global/package_rpm.bbclass
+++ b/meta/classes-global/package_rpm.bbclass
@@ -256,7 +256,7 @@ python write_specfile () {
                  attr = get_attr(file)
                  p = path + '/' + file
                  if conffiles.count(p):
-                    target.append(attr + '%config "' + escape_chars(p) + '"')
+                    target.append(attr + '%config(noreplace) "' + escape_chars(p) + '"')
                  else:
                      target.append(attr + '"' + escape_chars(p) + '"')


Maybe it's better to make it conditional on a different variable:

CONFFILES_MODE = "keepold"
vs
CONFFILES_MODE = "installnew"

and the patch would be something like this below (untested),
keeping the current behaviour as default:

diff --git a/meta/classes-global/package_rpm.bbclass b/meta/classes-global/package_rpm.bbclass
index 2e3e4e8c79..f0651d69ba 100644
--- a/meta/classes-global/package_rpm.bbclass
+++ b/meta/classes-global/package_rpm.bbclass
@@ -191,7 +191,7 @@ python write_specfile () {
                  if not len(depends_dict[dep]):
                      array.append("%s: %s" % (tag, dep))

-    def walk_files(walkpath, target, conffiles, dirfiles):
+    def walk_files(d, walkpath, target, conffiles, dirfiles):
          # We can race against the ipk/deb backends which create CONTROL or DEBIAN 
directories
          # when packaging. We just ignore these files which are created in
          # packages-split/ and not package/
@@ -250,13 +250,19 @@ python write_specfile () {
                  if (not files and not dirs) or path in dirfiles:
                      target.append(attr + '%dir "' + escape_chars(path) + '"')

+            conffiles_mode = d.getVar("CONFFILES_MODE") or "installnew"
+            if conffiles_mode != "installnew" and conffiles_mode != "keepold":
+                conffiles_mode = "installnew"
              for file in files:
                  if file == "CONTROL" or file == "DEBIAN":
                      continue
                  attr = get_attr(file)
                  p = path + '/' + file
                  if conffiles.count(p):
-                    target.append(attr + '%config "' + escape_chars(p) + '"')
+                    if conffiles_mode == "keepold":
+                        target.append(attr + '%config(noreplace) "' + escape_chars(p) + '"')
+                    else:
+                        target.append(attr + '%config "' + escape_chars(p) + '"')
                  else:
                      target.append(attr + '"' + escape_chars(p) + '"')

@@ -430,7 +436,7 @@ python write_specfile () {
              srcrpostrm     = splitrpostrm

              file_list = []
-            walk_files(root, file_list, conffiles, dirfiles)
+            walk_files(localdata, root, file_list, conffiles, dirfiles)
              if not file_list and localdata.getVar('ALLOW_EMPTY', False) != "1":
                  bb.note("Not creating empty RPM package for %s" % splitname)
              else:
@@ -522,7 +528,7 @@ python write_specfile () {

          # Now process files
          file_list = []
-        walk_files(root, file_list, conffiles, dirfiles)
+        walk_files(localdata, root, file_list, conffiles, dirfiles)
          if not file_list and localdata.getVar('ALLOW_EMPTY', False) != "1":
              bb.note("Not creating empty RPM package for %s" % splitname)
          else:

Best regards,
Zoltán Böszörményi



^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-03-12 13:26 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-08 11:20 Yocto rpm packages do not keep the modified CONFFILES (was: BB Equivalent for %config(noreplace)) Böszörményi Zoltán
2024-03-08 11:32 ` Patchtest results for " patchtest
2024-03-08 23:48 ` [OE-core] " Richard Purdie
2024-03-09 16:39 ` Alexander Kanavin
2024-03-11  9:30   ` [OE-core] Yocto rpm packages do not keep the modified CONFFILES Böszörményi Zoltán
2024-03-11  9:37     ` Alexander Kanavin
2024-03-11 10:09       ` Böszörményi Zoltán
2024-03-11 10:19         ` Alexander Kanavin
2024-03-12  1:57           ` Chen, Qi
2024-03-12 13:26             ` Alexander Kanavin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).