2024. 03. 09. 17:39 keltezéssel, Alexander Kanavin írta:
I think (noreplace) flag only matters when the file has been manually
edited after rpm installation and its checksum diverges from what is
registered in rpm database. Which is not a common scenario in
embedded.

So from Yocto's POV it's the same either way, right?

  If you manually edit the file on target, you might as well
manually resolve which version you want after the update as both are
available regardless of whether (noreplace) was used or not. Or
perhaps merge the manual edits into the new version.

The interesting use case here is that the configuration file
in question is generated on the machine using a GUI,
while a minimal stock version of the file is shipped by the package.


Alex

On Fri, 8 Mar 2024 at 12:20, Zoltan Boszormenyi <zbos...@gmail.com> wrote:
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








-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#196929): 
https://lists.openembedded.org/g/openembedded-core/message/196929
Mute This Topic: https://lists.openembedded.org/mt/104859795/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to