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