From 707296034f6f3d204edd72d935a4f364f211715f8c37b0057af1cd7572a18ee3 Mon Sep 17 00:00:00 2001 From: ZYpp Developers Date: Wed, 31 Aug 2022 09:56:16 +0000 Subject: [PATCH] Update to last successful build d2cd1341430c39d03e69f4576cc1f937d9e7f30f UsrEtc: Store logrotate files in %{_distconfdir} if defined (fixes #402) OBS-URL: https://build.opensuse.org/package/show/zypp:Head/libzypp?expand=0&rev=2486 --- libzypp-17.31.0.tar.bz2 | 4 +- libzypp.spec | 86 ++++++++++++----------------------------- 2 files changed, 27 insertions(+), 63 deletions(-) diff --git a/libzypp-17.31.0.tar.bz2 b/libzypp-17.31.0.tar.bz2 index 9fb2419..aeb3a12 100644 --- a/libzypp-17.31.0.tar.bz2 +++ b/libzypp-17.31.0.tar.bz2 @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d54863c526c8aedd0300fb40475b8d0a3cc1866bf084146ad15c87b8aa64440f -size 5490444 +oid sha256:9c7bf6f428aad92d77f187f2e44d0f1dbfe2dfda9e97e3e1d485757940b2f9e7 +size 5490613 diff --git a/libzypp.spec b/libzypp.spec index 727fdc0..4f8e976 100644 --- a/libzypp.spec +++ b/libzypp.spec @@ -314,74 +314,34 @@ cd .. # Create filelist with translations %{find_lang} zypp +%if %{defined _distconfdir} +# Move logratate files form /etc/logrotate.d to /usr/etc/logrotate.d +mkdir -p %{buildroot}/%{_distconfdir}/logrotate.d +mv %{buildroot}/%{_sysconfdir}/logrotate.d/zypp-history.lr %{buildroot}%{_distconfdir}/logrotate.d +%endif + %check pushd build/tests LD_LIBRARY_PATH="$(pwd)/../zypp:$LD_LIBRARY_PATH" ctest --output-on-failure . popd -%post -/sbin/ldconfig -if [ -f /var/cache/zypp/zypp.db ]; then rm /var/cache/zypp/zypp.db; fi +%if %{defined _distconfdir} +%pre +# Prepare for migration to /usr/etc; save any old .rpmsave +for i in logrotate.d/zypp-history.lr; do + test -f %{_sysconfdir}/${i}.rpmsave && mv -v %{_sysconfdir}/${i}.rpmsave %{_sysconfdir}/${i}.rpmsave.old ||: +done +%endif -# convert old lock file to new -# TODO make this a separate file? -# TODO run the sript only when updating form pre-11.0 libzypp versions -LOCKSFILE=%{_sysconfdir}/zypp/locks -OLDLOCKSFILE=%{_sysconfdir}/zypp/locks.old +%if %{defined _distconfdir} +%posttrans +# Migration to /usr/etc, restore just created .rpmsave +for i in logrotate.d/zypp-history.lr; do + test -f %{_sysconfdir}/${i}.rpmsave && mv -v %{_sysconfdir}/${i}.rpmsave %{_sysconfdir}/${i} ||: +done +%endif -is_old(){ - # if no such file, exit with false (1 in bash) - test -f ${LOCKSFILE} || return 1 - TEMP_FILE=`mktemp` - cat ${LOCKSFILE} | sed '/^\#.*/ d;/.*:.*/d;/^[^[a-zA-Z\*?.0-9]*$/d' > ${TEMP_FILE} - if [ -s ${TEMP_FILE} ] - then - RES=0 - else - RES=1 - fi - rm -f ${TEMP_FILE} - return ${RES} -} - -append_new_lock(){ - case "$#" in - 1 ) - echo " -solvable_name: $1 -match_type: glob -" >> ${LOCKSFILE} -;; - 2 ) #TODO version - echo " -solvable_name: $1 -match_type: glob -Version: $2 -" >> ${LOCKSFILE} -;; - 3 ) #TODO version - echo " -solvable_name: $1 -match_type: glob -Version: $2 $3 -" >> ${LOCKSFILE} - ;; -esac -} - -die() { - echo $1 - exit 1 -} - -if is_old ${LOCKSFILE} - then - mv -f ${LOCKSFILE} ${OLDLOCKSFILE} || die "cannot backup old locks" - cat ${OLDLOCKSFILE}| sed "/^\#.*/d"| while read line - do - append_new_lock $line - done -fi +%post -p /sbin/ldconfig %postun -p /sbin/ldconfig @@ -406,7 +366,11 @@ fi %dir %{_sysconfdir}/zypp/credentials.d %config(noreplace) %{_sysconfdir}/zypp/zypp.conf %config(noreplace) %{_sysconfdir}/zypp/systemCheck +%if %{defined _distconfdir} +%{_distconfdir}/logrotate.d/zypp-history.lr +%else %config(noreplace) %{_sysconfdir}/logrotate.d/zypp-history.lr +%endif %dir %{_var}/lib/zypp %if "%{_libexecdir}" != "%{_prefix}/lib" %dir %{_libexecdir}/zypp