Resolve custom file packaging conflicts

StarlingX provides custom versions of certain files that are provided
by upstream packages. If the files are not packaged upstream as config
files, using the %config(noreplace) spec file directive, this can
cause a problem if the original package is updated on a running
system, as the custom file will be overwritten.

For certain systemd files, we can instead install these files to
directories under /etc, which will override the original installed
files at runtime without needing to modify the original files. This
handles most of the conflicts addressed by this update.

For example, instead of replacing /usr/lib/tmpfiles.d/systemd.conf in
a postinstall scriptlet with the customized file, we can install the
file to /etc/tmpfiles.d/systemd.conf to the same end effect.

In the case of the customization to /etc/rc.d/init.d/lighttpd,
however, this update addresses it by ensuring lighttpd-config copies
the customized file whenever lighttpd-config is updated. If lighttpd
is ever updated, updating lighttpd-config at the same time will ensure
the customized version of the file is maintained. Other options here
would be to update the lighttpd package to mark this script as though
it is a config file, or update how it is called by StarlingX so that
the custom file can be given a unique filename.

Change-Id: Iab1e916430c1921fd8f5399166dbfd950ce1a74c
Partial-Bug: 1850695
Signed-off-by: Don Penney <don.penney@windriver.com>
This commit is contained in:
Don Penney 2019-10-30 16:09:07 -04:00
parent 8c58678011
commit fedff3f124
6 changed files with 29 additions and 26 deletions

View File

@ -1,2 +1,2 @@
SRC_DIR="files"
TIS_PATCH_VER=1
TIS_PATCH_VER=2

View File

@ -50,12 +50,16 @@ chmod 02770 %{buildroot}%{_sysconfdir}/lighttpd
if [ $1 -eq 1 ] ; then
cp --preserve=xattr -f %{_datadir}/starlingx/lighttpd.conf %{_sysconfdir}/lighttpd/lighttpd.conf
chmod 640 %{_sysconfdir}/lighttpd/lighttpd.conf
cp --preserve=xattr -f %{_datadir}/starlingx/lighttpd.init %{_sysconfdir}/rc.d/init.d/lighttpd
chmod 755 %{_sysconfdir}/rc.d/init.d/lighttpd
cp --preserve=xattr -f %{_datadir}/starlingx/lighttpd.logrotate %{_sysconfdir}/logrotate.d/lighttpd
chmod 644 %{_sysconfdir}/logrotate.d/lighttpd
fi
# /etc/rc.d/init.d/lighttpd is not a config file, so replace it here if it doesn't match
cmp --quiet %{_datadir}/starlingx/lighttpd.init %{_sysconfdir}/rc.d/init.d/lighttpd
if [ $? -ne 0 ]; then
cp --preserve=xattr -f %{_datadir}/starlingx/lighttpd.init %{_sysconfdir}/rc.d/init.d/lighttpd
chmod 755 %{_sysconfdir}/rc.d/init.d/lighttpd
fi
%files
%defattr(-,root,root)

View File

@ -1,2 +1,2 @@
SRC_DIR="files"
TIS_PATCH_VER=0
TIS_PATCH_VER=1

View File

@ -17,6 +17,7 @@ BuildArch: noarch
Requires: openldap-servers
%define debug_package %{nil}
%define local_systemd_system %{_sysconfdir}/systemd/system
%description
StarlingX openldap configuration file
@ -28,21 +29,20 @@ StarlingX openldap configuration file
%build
%install
mkdir -p %{buildroot}%{_sysconfdir}/rc.d/init.d
install -d %{buildroot}%{local_systemd_system}
install -d %{buildroot}%{_sysconfdir}/rc.d/init.d
install -m 755 initscript %{buildroot}%{_sysconfdir}/rc.d/init.d/openldap
install -d -m 740 %{buildroot}%{_sysconfdir}/openldap
install -m 600 slapd.conf %{buildroot}%{_sysconfdir}/openldap/slapd.conf
install -m 600 initial_config.ldif %{buildroot}%{_sysconfdir}/openldap/initial_config.ldif
install -d %{buildroot}%{_datadir}/starlingx
install -m 644 slapd.service %{buildroot}%{_datadir}/starlingx/slapd.service
install -m 644 slapd.service %{buildroot}%{local_systemd_system}/slapd.service
install -m 644 slapd.sysconfig %{buildroot}%{_datadir}/starlingx/slapd.sysconfig
%post
if [ $1 -eq 1 ] ; then
cp -f %{_datadir}/starlingx/slapd.service %{_unitdir}/slapd.service
chmod 644 %{_unitdir}/slapd.service
cp -f %{_datadir}/starlingx/slapd.sysconfig %{_sysconfdir}/sysconfig/slapd
chmod 644 %{_unitdir}/slapd
fi
@ -53,5 +53,5 @@ fi
%{_sysconfdir}/rc.d/init.d/openldap
%{_sysconfdir}/openldap/slapd.conf
%{_sysconfdir}/openldap/initial_config.ldif
%{_datadir}/starlingx/slapd.service
%{local_systemd_system}/slapd.service
%{_datadir}/starlingx/slapd.sysconfig

View File

@ -1,2 +1,2 @@
SRC_DIR="files"
TIS_PATCH_VER=0
TIS_PATCH_VER=1

View File

@ -18,6 +18,9 @@ BuildRequires: systemd = 219-62.el7_6.5
Requires: systemd
%define debug_package %{nil}
%define local_udev_rules_d %{_sysconfdir}/udev/rules.d
%define local_tmpfiles_d %{_sysconfdir}/tmpfiles.d
%define local_systemd_system %{_sysconfdir}/systemd/system
%description
StarlingX systemd configuration file
@ -30,31 +33,27 @@ StarlingX systemd configuration file
%install
install -d %{buildroot}%{_datadir}/starlingx
install -m644 60-persistent-storage.rules %{buildroot}%{_datadir}/starlingx/60-persistent-storage.rules
install -d %{buildroot}%{local_udev_rules_d}
install -d %{buildroot}%{local_tmpfiles_d}
install -d %{buildroot}%{local_systemd_system}
install -m644 60-persistent-storage.rules %{buildroot}%{local_udev_rules_d}/60-persistent-storage.rules
install -m644 journald.conf %{buildroot}%{_datadir}/starlingx/journald.conf
install -m644 systemd.conf.tmpfiles.d %{buildroot}%{_datadir}/starlingx/systemd.conf.tmpfiles.d
install -m644 tmp.conf.tmpfiles.d %{buildroot}%{_datadir}/starlingx/tmp.conf.tmpfiles.d
install -m644 tmp.mount %{buildroot}%{_datadir}/starlingx/tmp.mount
install -m644 systemd.conf.tmpfiles.d %{buildroot}%{local_tmpfiles_d}/systemd.conf
install -m644 tmp.conf.tmpfiles.d %{buildroot}%{local_tmpfiles_d}/tmp.conf
install -m644 tmp.mount %{buildroot}%{local_systemd_system}/tmp.mount
%post
if [ $1 -eq 1 ] ; then
cp -f %{_datadir}/starlingx/60-persistent-storage.rules %{_udevrulesdir}/
chmod 644 %{_udevrulesdir}/60-persistent-storage.rules
cp -f %{_datadir}/starlingx/journald.conf %{_sysconfdir}/systemd
chmod 644 %{_sysconfdir}/systemd/journald.conf
cp -f %{_datadir}/starlingx/systemd.conf.tmpfiles.d %{_usr}/lib/tmpfiles.d/systemd.conf
chmod 644 %{_usr}/lib/tmpfiles.d/systemd.conf
cp -f %{_datadir}/starlingx/tmp.conf.tmpfiles.d %{_usr}/lib/tmpfiles.d/tmp.conf
chmod 644 %{_usr}/lib/tmpfiles.d/tmp.conf
cp -f %{_datadir}/starlingx/tmp.mount %{_unitdir}/
chmod 644 %{_unitdir}/tmp.mount
fi
%files
%defattr(-,root,root)
%license LICENSE
%{_datadir}/starlingx/60-persistent-storage.rules
%{local_udev_rules_d}/60-persistent-storage.rules
%{_datadir}/starlingx/journald.conf
%{_datadir}/starlingx/systemd.conf.tmpfiles.d
%{_datadir}/starlingx/tmp.conf.tmpfiles.d
%{_datadir}/starlingx/tmp.mount
%{local_tmpfiles_d}/systemd.conf
%{local_tmpfiles_d}/tmp.conf
%{local_systemd_system}/tmp.mount