Do not remove modified config files

Our config files in /etc/ were marked as %config(noreplace). This means that the
would not be replaced on upgraded if local modifications have been made. But
when we moved them to /usr/lib, they would be be renamed to .rpmsave, if they
had local modifications. This is not what I expected, but what rpm apparently
does. So we need to add them as %ghost to prevent the removal. This is probably
for the better anyway.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2023-12-13 13:02:45 +01:00
parent 3a8edc7540
commit 4c7acded2a
2 changed files with 27 additions and 7 deletions

View File

@ -240,17 +240,18 @@ for file in files(buildroot):
o = outputs['main'] o = outputs['main']
if n in known_files: if n in known_files:
prefix = ' '.join(known_files[n].split()[:-1]) prefix = known_files[n].split()[:-1]
if prefix:
prefix += ' '
elif file.is_dir() and not file.is_symlink(): elif file.is_dir() and not file.is_symlink():
prefix = '%dir ' prefix = ['%dir']
elif 'README' in n: elif 'README' in n:
prefix = '%doc ' prefix = ['%doc']
elif n.startswith('/etc'): elif n.startswith('/etc'):
prefix = '%config(noreplace) ' prefix = ['%config(noreplace)']
if file.stat().st_size == 0:
prefix += ['%ghost']
else: else:
prefix = '' prefix = []
prefix = ' '.join(prefix + ['']) if prefix else ''
suffix = '*' if '/man/' in n else '' suffix = '*' if '/man/' in n else ''

View File

@ -731,6 +731,25 @@ ln -sf ../bin/udevadm %{buildroot}%{_sbindir}/udevadm
touch %{buildroot}/etc/crypttab touch %{buildroot}/etc/crypttab
chmod 600 %{buildroot}/etc/crypttab chmod 600 %{buildroot}/etc/crypttab
# Config files that were moved under /usr.
# We need to %ghost them so that they are not removed on upgrades.
touch %{buildroot}/etc/systemd/coredump.conf \
%{buildroot}/etc/systemd/homed.conf \
%{buildroot}/etc/systemd/journald.conf \
%{buildroot}/etc/systemd/journal-remote.conf \
%{buildroot}/etc/systemd/journal-upload.conf \
%{buildroot}/etc/systemd/logind.conf \
%{buildroot}/etc/systemd/networkd.conf \
%{buildroot}/etc/systemd/oomd.conf \
%{buildroot}/etc/systemd/pstore.conf \
%{buildroot}/etc/systemd/resolved.conf \
%{buildroot}/etc/systemd/sleep.conf \
%{buildroot}/etc/systemd/system.conf \
%{buildroot}/etc/systemd/timesyncd.conf \
%{buildroot}/etc/systemd/user.conf \
%{buildroot}/etc/udev/udev.conf \
%{buildroot}/etc/udev/iocost.conf
# /etc/initab # /etc/initab
install -Dm0644 -t %{buildroot}/etc/ %{SOURCE5} install -Dm0644 -t %{buildroot}/etc/ %{SOURCE5}