Hello community,

here is the log from the commit of package transactional-update for 
openSUSE:Factory checked in at 2020-09-28 14:28:33
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/transactional-update (Old)
 and      /work/SRC/openSUSE:Factory/.transactional-update.new.4249 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "transactional-update"

Mon Sep 28 14:28:33 2020 rev:61 rq:837917 version:2.26

Changes:
--------
--- 
/work/SRC/openSUSE:Factory/transactional-update/transactional-update.changes    
    2020-09-25 16:17:24.427139892 +0200
+++ 
/work/SRC/openSUSE:Factory/.transactional-update.new.4249/transactional-update.changes
      2020-09-28 14:28:34.510122149 +0200
@@ -1,0 +2,29 @@
+Sat Sep 26 14:50:12 UTC 2020 - Ignaz Forster <[email protected]>
+
+- Version 2.26
+  - Fix broken sync for second snapshot [boo#1176989]
+  - Add new options to allow separate cleanup of snapshots and overlays
+  - Check for existence of inotifywait before using it
+  - Check that mount options don't exceed maximum length
+
+-------------------------------------------------------------------
+Mon Sep 21 16:17:12 UTC 2020 - Ignaz Forster <[email protected]>
+
+- Version 2.25.1
+  - Fix inotify watcher setup
+  - Use log_{info,error} for more messages to avoid messing up Salt logs
+
+-------------------------------------------------------------------
+Mon Sep 21 14:09:41 UTC 2020 - Ignaz Forster <[email protected]>
+
+- Version 2.25
+  - Reduce number of overlays:
+    Instead of using transparent overlays for all previous layers only add the
+    previous snapshot's overlay; this will greatly reduce the number of
+    overlays while still making sure that /etc changes in the running system
+    will be visible in the next snapshot
+  - When using --drop-if-no-change synchronize potential /etc changes with
+    running system
+  - Exclude all non-root-fs mounts from inotify watcher
+
+-------------------------------------------------------------------

Old:
----
  transactional-update-2.24.1.tar.gz

New:
----
  transactional-update-2.26.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ transactional-update.spec ++++++
--- /var/tmp/diff_new_pack.yDV2t8/_old  2020-09-28 14:28:35.470122982 +0200
+++ /var/tmp/diff_new_pack.yDV2t8/_new  2020-09-28 14:28:35.470122982 +0200
@@ -17,7 +17,7 @@
 
 
 Name:           transactional-update
-Version:        2.24.1
+Version:        2.26
 Release:        0
 Summary:        Transactional Updates with btrfs and snapshots
 License:        GPL-2.0-or-later
@@ -46,6 +46,7 @@
 Requires:       rsync
 Requires:       snapper
 Requires:       zypper
+Recommends:     inotify-tools
 Recommends:     rebootmgr
 
 %description

++++++ transactional-update-2.24.1.tar.gz -> transactional-update-2.26.tar.gz 
++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/transactional-update-2.24.1/NEWS 
new/transactional-update-2.26/NEWS
--- old/transactional-update-2.24.1/NEWS        2020-08-12 12:04:41.000000000 
+0200
+++ new/transactional-update-2.26/NEWS  2020-09-26 16:29:26.000000000 +0200
@@ -2,6 +2,26 @@
 
 Copyright (C) 2016-2019 Thorsten Kukuk et al.
 
+Version 2.26
+* Fix broken sync for second snapshot [boo#1176989]
+* Add new options to allow separate cleanup of snapshots and overlays
+* Check for existence of inotifywait before using it
+* Check that mount options don't exceed maximum length
+
+Version 2.25.1
+* Fix inotify watcher setup
+* Use log_{info,error} for more messages to avoid messing up Salt logs
+
+Version 2.25
+* Reduce number of overlays:
+  Instead of using transparent overlays for all previous layers only add the
+  previous snapshot's overlay; this will greatly reduce the number of overlays
+  while still making sure that /etc changes in the running system will be
+  visible in the next snapshot
+* When using --drop-if-no-change synchronize potential /etc changes with
+  running system
+* Exclude all non-root-fs mounts from inotify watcher
+
 Version 2.24.1
 * SELinux: adjust labels for etc, fstab and grub.cfg
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/transactional-update-2.24.1/configure.ac 
new/transactional-update-2.26/configure.ac
--- old/transactional-update-2.24.1/configure.ac        2020-08-12 
12:04:41.000000000 +0200
+++ new/transactional-update-2.26/configure.ac  2020-09-26 16:29:26.000000000 
+0200
@@ -1,5 +1,5 @@
 dnl Process this file with autoconf to produce a configure script.
-AC_INIT(transactional-update, 2.24.1)
+AC_INIT(transactional-update, 2.26)
 AM_INIT_AUTOMAKE
 AC_PREFIX_DEFAULT(/usr)
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/transactional-update-2.24.1/doc/transactional-update.xml 
new/transactional-update-2.26/doc/transactional-update.xml
--- old/transactional-update-2.24.1/doc/transactional-update.xml        
2020-08-12 12:04:41.000000000 +0200
+++ new/transactional-update-2.26/doc/transactional-update.xml  2020-09-26 
16:29:26.000000000 +0200
@@ -446,21 +446,36 @@
        <filename 
class='directory'>/var/lib/overlay/&lt;snapshotnum&gt;/etc</filename>.
       </para>
       <para>
-       Each snapshot will have one associated overlay directory. The overlay
-       directories are mounted using overlay stacking, i.e. the current
-       snapshot will mount its associated overlay as the
-       <option>upperdir</option> and the previous snapshot's overlays as
-       <option>lowerdir</option>. That means that the current snapshot will
-       see all the changes accumulated in the previous snapshots, but older
-       snapshots will not see changes applied to newer snapshots.
+       Each snapshot will have one associated overlay directory. On creating
+       a new snapshot the previous snapshot's
+       <filename class='directory'>/etc</filename> state will be sychronized
+       into the new snapshot and used as a base. The overlay directories of
+       the current and the new snapshot are then mounted using overlay
+       stacking, i.e. the new snapshot's overlay will be mounted as the
+       <option>upperdir</option> and the current snapshot's overlay as
+       <option>lowerdir</option>. This way changes applied to
+       <filename class='directory'>/etc</filename> after the snapshot was
+       taken, but before the reboot takes place, will still be visible to the
+       new snapshot (Exception: If the file has been modified both in the
+       current and the new snapshot, then the file state of the new snapshot
+       will be visible).
+      </para>
+      <para>
+       If the <option>--continue</option> is used multiple times to extend a
+       new snapshot while the system has not been rebooted, and if that
+       snapshot is based on the currently active system, then the
+       synchronization will only run for the first snapshot; the additional
+       snapshot layers will be added to <option>lowerdir</option>. Again
+       this is to make sure that changes to the running system will still be
+       visible after booting into the new system.
       </para>
       <para>
        Let's have a look at an example <filename>fstab</filename> entry:
-       <programlisting>overlay  /etc  overlay  
defaults,upperdir=/sysroot/var/lib/overlay/83/etc,lowerdir=/sysroot/var/lib/overlay/81/etc:/sysroot/var/lib/overlay/80/etc:/sysroot/var/lib/overlay/77/etc:/sysroot/var/lib/overlay/76/etc:/sysroot/etc,workdir=/sysroot/var/lib/overlay/work-etc,x-systemd.requires-mounts-for=/var,x-systemd.requires-mounts-for=/var/lib/overlay,x-systemd.requires-mounts-for=/sysroot/var,x-systemd.requires-mounts-for=/sysroot/var/lib/overlay,x-initrd.mount
  0  0</programlisting>
+       <programlisting>overlay  /etc  overlay  
defaults,upperdir=/sysroot/var/lib/overlay/82/etc,lowerdir=/sysroot/var/lib/overlay/81/etc:/sysroot/var/lib/overlay/76/etc:/sysroot/etc,workdir=/sysroot/var/lib/overlay/work-etc,x-systemd.requires-mounts-for=/var,x-systemd.requires-mounts-for=/var/lib/overlay,x-systemd.requires-mounts-for=/sysroot/var,x-systemd.requires-mounts-for=/sysroot/var/lib/overlay,x-initrd.mount
  0  0</programlisting>
       </para>
       <itemizedlist>
       <listitem><para>
-       We are currently in snapshot <emphasis>83</emphasis> as indicated by the
+       We are currently in snapshot <emphasis>82</emphasis> as indicated by the
        <option>upperdir</option> directory. This can be confirmed by typing
        <command>snapper list</command> or
        <command>btrfs subvolume get-default /</command>. All changes to
@@ -468,12 +483,18 @@
        directory.
       </para></listitem>
       <listitem><para>
-       <option>lowerdir</option> contains several overlays from previous
-       snapshots. In this case it seem the snapshots were not created
-       consecutively - maybe there were a few rollbacks in between or a
-       snapshot wasn't applied by rebooting into it. The lowest snapshot is
-       always <filename class='directory'>/sysroot/etc</filename>, containing
-       the root file system's contents.
+       <option>lowerdir</option> contains two numbered overlay directories.
+       The later directory with number <emphasis>76</emphasis> indicates the
+       snapshot which was used as a base. This snapshot's
+       <filename class='directory'>/etc</filename> state was also synchronized
+       into the read-only root file system of snapshot 82. As the
+       <option>lowerdir</option> contains a second entry with number
+       <emphasis>81</emphasis> it means that the <option>--continue</option>
+       has been used before the system was rebooted. Gaps in the number such
+       as seen here may indicate that those snapshots were discarded or a
+       rollback to snapshot 76 was performed. The lowest snapshot is always
+       <filename class='directory'>/sysroot/etc</filename>, containing the
+       root file system's contents.
       </para></listitem>
       <listitem><para>
        As <filename class='directory'>/etc</filename> is mounted by
@@ -484,16 +505,8 @@
       </para></listitem>
       </itemizedlist>
       <para>
-       To prevent the <filename class='directory'>/etc</filename> overlays
-       from growing infinitely they will be synced into the root file system if
-       no snapshot is referencing them any more. So please be aware that the
-       root file system's <filename class='directory'>/etc</filename> state by
-       itself does neither contain the original package contents nor the
-       snapshot's current state. Only the snapshot plus all overlay layers
-       represents the state of <filename class='directory'>/etc</filename>
-       correctly. Overlays no longer needed because they have been merged into
-       all snapshots will be deleted during the <command>transactional-update
-       cleanup</command> run.
+       Overlays no longer referenced by any snapshots will be deleted during
+       the <command>transactional-update cleanup-overlays</command> run.
       </para>
     </section>
 <!--
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/transactional-update-2.24.1/man/transactional-update.8.xml 
new/transactional-update-2.26/man/transactional-update.8.xml
--- old/transactional-update-2.24.1/man/transactional-update.8.xml      
2020-08-12 12:04:41.000000000 +0200
+++ new/transactional-update-2.26/man/transactional-update.8.xml        
2020-09-26 16:29:26.000000000 +0200
@@ -104,12 +104,12 @@
 <filename class='directory'>/var/lib/overlay</filename>. As configuration files
 may be modified after a snapshot was created and before a reboot is performed
 (e.g. via configuration management software) the overlay file system will use
-multiple lower layers, i.e. changes in older layers will be visible in newer
-snapshots, but not vice versa. To keep the number of layers at a minimum and 
the
-amount of data stored in the overlays low the
-<filename class='directory'>/etc</filename> state of the oldest still available
-snapshot is synchronized into the new root file system; unused overlays will be
-removed at a later time (see the <option>cleanup</option> option).
+multiple lower layers, i.e. configuration file changes applied to the currently
+running system will be visible in the new system, but not vice versa. To keep
+the number of layers at a minimum the
+<filename class='directory'>/etc</filename> state of the previous snapshot is
+synchronized into the new root file system; unused overlays will be
+removed at a later time (see the <option>cleanup-overlays</option> option).
 </para>
 <warning>
 If a file in <filename class='directory'>/etc</filename> has been changed
@@ -157,6 +157,14 @@
   <varlistentry>
     <term><option>cleanup</option></term>
     <listitem>
+      <para>Identical to calling both <option>cleanup-snapshots</option> and
+      <option>cleanup-overlays</option>.
+      </para>
+    </listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><option>cleanup-snapshots</option></term>
+    <listitem>
       <para>If the current root filesystem is identical to the active root
       filesystem (means after a reboot, before
       <command>transactional-update</command> creates a new snapshot with
@@ -165,8 +173,13 @@
       by snapper. See the section about cleanup algorithms in
       <citerefentry 
project='snapper'><refentrytitle>snapper</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
       </para>
+    </listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><option>cleanup-overlays</option></term>
+    <listitem>
       <para>
-       Also removes all unreferenced (and thus unused)
+       Removes all unreferenced (and thus unused)
        <filename class='directory'>/etc</filename> overlay directories in
        <filename class='directory'>/var/lib/overlay</filename>.
       </para>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/transactional-update-2.24.1/sbin/transactional-update.in 
new/transactional-update-2.26/sbin/transactional-update.in
--- old/transactional-update-2.24.1/sbin/transactional-update.in        
2020-08-12 12:04:41.000000000 +0200
+++ new/transactional-update-2.26/sbin/transactional-update.in  2020-09-26 
16:29:26.000000000 +0200
@@ -31,7 +31,8 @@
 REWRITE_GRUB_CFG=0
 REWRITE_INITRD=0
 REBUILD_KDUMP_INITRD=0
-DO_CLEANUP=0
+DO_CLEANUP_OVERLAYS=0
+DO_CLEANUP_SNAPSHOTS=0
 DO_MIGRATION=0
 DO_DUP=0
 DO_ROLLBACK=0
@@ -82,6 +83,7 @@
 SNAPPER_NO_DBUS=""
 TMPFILE=""
 ETC_OVERLAY_DIR=""
+ETC_OVERLAY_DIR_PREV=""
 ETC_OVERLAY_WORK_DIR=""
 INOTIFY_PID=""
 
@@ -127,7 +129,9 @@
     echo "system."
     echo ""
     echo "General Commands:"
-    echo "cleanup                    Mark unused snapshots for snapper removal"
+    echo "cleanup                    Run both cleanup-snapshots and 
cleanup-overlays"
+    echo "cleanup-snapshots          Mark unused snapshots for snapper removal"
+    echo "cleanup-overlays           Remove unused overlay layers"
     echo "grub.cfg                   Regenerate grub.cfg"
     echo "bootloader                 Reinstall the bootloader"
     echo "initrd                     Regenerate initrd"
@@ -170,14 +174,14 @@
 log_info() {
     echo `date "+%Y-%m-%d %H:%M"` "$@" >> ${LOGFILE}
     if [ ${VERBOSITY} -ge 2 ]; then
-       echo "$@"
+       echo -e "$@"
     fi
 }
 
 log_error() {
     TELEM_PAYLOAD="${TELEM_PAYLOAD}\nmessage=$@"
     echo `date "+%Y-%m-%d %H:%M"` "$@" >> ${LOGFILE}
-    echo "$@" 1>&4
+    echo -e "$@" 1>&4
 }
 
 bashlock() {
@@ -264,11 +268,11 @@
     done
 
     if [ -n "${SNAPSHOT_ID}" ] ; then
-       log_error "Removing snapshot #${SNAPSHOT_ID}..."
+       log_info "Removing snapshot #${SNAPSHOT_ID}..."
        snapper ${SNAPPER_NO_DBUS} delete ${SNAPSHOT_ID} |& tee -a ${LOGFILE}
     fi
     if [ -n "${ETC_OVERLAY_DIR}" ] ; then
-       log_error "Removing overlay directory ${ETC_OVERLAY_DIR%/*}..."
+       log_info "Removing overlay directory ${ETC_OVERLAY_DIR%/*}..."
        if findmnt "${ETC_OVERLAY_DIR}" >/dev/null; then
            umount "${ETC_OVERLAY_DIR}"
        fi
@@ -290,6 +294,13 @@
        kill ${INOTIFY_PID}
        log_info "The snapshot does not contain any changed files."
        INOTIFY_PID=""
+
+       # Even if the snapshot itself did not contain any changes,
+       # /etc may do so. Changes in /etc may be applied immediately,
+       # so merge them back into the running system.
+       log_info "Merging overlay directory ${SNAPSHOT_DIR}/etc into /etc..."
+       rsync --archive --inplace --xattrs --acls --exclude 'fstab' --delete 
--quiet "${SNAPSHOT_DIR}/etc/" /etc
+
        quit 0
     fi
 
@@ -431,10 +442,9 @@
     local option lowerdir overlay_id
 
     fstab=""
-    fstab_active_lowerdirs=()
     fstab_lowerdirs=()
     fstab_upper=""
-    fstab_oldest_active_snapshot=""
+    fstab_previous_snapshot=""
     fstab_otheroptions=""
 
     # Check for /etc overlay
@@ -455,18 +465,8 @@
                for lowerdir in `echo ${option#*=} | tr ':' ' '`; do
                    overlay_id=`echo "${lowerdir#/sysroot}" | sed -n 
's#^/var/lib/overlay/\([[:digit:]]\+\)/etc$#\1#p'`
 
-                   # Special handling for old overlay location
-                   if [ "${lowerdir}" = "/sysroot/var/lib/overlay/etc" ]; then
-                       if [ "${fstab_lowerdirs[*]}" = 
"${fstab_active_lowerdirs[*]}" ]; then
-                           fstab_active_lowerdirs+=("${lowerdir}")
-                       fi
-                   # Add common directories and directories of existing 
snapshots
-                   elif [ -z "${overlay_id}" -o -e 
"/.snapshots/${overlay_id}/snapshot" ]; then
-                       if [ -n "${overlay_id}" ]; then
-                           
fstab_oldest_active_snapshot="/.snapshots/${overlay_id}/snapshot"
-                           fstab_active_lowerdirs=("${fstab_lowerdirs[@]}")
-                       fi
-                       fstab_active_lowerdirs+=("${lowerdir}")
+                   if [ -z "${fstab_previous_snapshot}" -a -n "${overlay_id}" 
]; then
+                       
fstab_previous_snapshot="/.snapshots/${overlay_id}/snapshot"
                    fi
                    fstab_lowerdirs+=("${lowerdir}")
                done
@@ -480,7 +480,6 @@
                ;;
        esac
     done
-    
fstab_oldest_active_snapshot="${fstab_oldest_active_snapshot:-/.snapshots/${CURRENT_SNAPSHOT_ID}/snapshot}"
 }
 
 # Replace all /sysroot prefixes from /etc fstab entry; for the overlays in /var
@@ -498,20 +497,11 @@
 
     get_etc_overlay_from "$1"
 
-    # After fresh installations there's no overlay to sync yet
-    if [ ${#fstab_lowerdirs[@]} -le 1 ]; then
-       return
-    fi
-    log_info "Syncing /etc of oldest snapshot $1 as base into new snapshot $2"
+    log_info "Syncing /etc of previous snapshot $1 as base into new snapshot 
$2"
 
     mount_opts="defaults,"
     mount_opts+="lowerdir="
-    # Special case: If the current in-use snapshot is the oldest snapshot
-    # already it will be added as a lowerdir, so don't mount it for
-    # syncing (it may change at any time anyway).
-    if [ "${fstab_upper}" != "${current_upper}" ]; then
-       mount_opts+="${fstab_upper#/sysroot}:"
-    fi
+    mount_opts+="${fstab_upper#/sysroot}:"
     mount_opts+="`parse_lowerdirs_for_mount $1`"
     mount -t overlay overlay "${ETC_OVERLAY_DIR}" -o ${mount_opts}
     if [ $? -ne 0 ]; then
@@ -519,7 +509,7 @@
        quit 1
     fi
 
-    rsync --archive --inplace --xattrs --filter='-x security.selinux' --acls 
--delete --quiet "${ETC_OVERLAY_DIR}" "$2"
+    rsync --archive --inplace --xattrs --acls --delete --quiet 
"${ETC_OVERLAY_DIR}" "$2"
     if [ $? -ne 0 ]; then
        log_error "ERROR: syncing $1 into snapshot $2 failed!"
        quit 1
@@ -527,6 +517,17 @@
     umount "${ETC_OVERLAY_DIR}"
 }
 
+# Return the optimized list of mount points
+root_mount_points() {
+    local prev=0
+    for mount in $(findmnt --noheadings --submounts --target / --output TARGET 
--raw | sort | tail -n +2); do
+       if [ "${prev}/" != "${mount:0:$((${#prev}+1))}" ]; then
+           echo "${mount}"
+           prev="${mount}"
+       fi
+    done
+}
+
 ORIG_ARGS=("$@")
 
 while [ 1 ]; do
@@ -536,7 +537,16 @@
 
     case "$1" in
        cleanup)
-           DO_CLEANUP=1
+           DO_CLEANUP_OVERLAYS=1
+           DO_CLEANUP_SNAPSHOTS=1
+           shift
+           ;;
+       cleanup-snapshots)
+           DO_CLEANUP_SNAPSHOTS=1
+           shift
+           ;;
+       cleanup-overlays)
+           DO_CLEANUP_OVERLAYS=1
            shift
            ;;
        dup)
@@ -724,7 +734,8 @@
 
 # If no commands were given, assume "up"
 if [ -z "${ZYPPER_ARG}" -a -z "${TELEM_CLASS}" -a "${REBOOT_AFTERWARDS}" -eq 0 
\
-       -a "${DO_REGISTRATION}" -eq 0 -a "${DO_CLEANUP}" -eq 0 ]; then
+       -a "${DO_REGISTRATION}" -eq 0 -a "${DO_CLEANUP_OVERLAYS}" -eq 0 \
+       -a "${DO_CLEANUP_SNAPSHOTS}" -eq 0 ]; then
     ZYPPER_ARG="up"
     TELEM_CLASS="update"
 fi
@@ -734,7 +745,7 @@
 if [ -z "${TA_UPDATE_TMPFILE}" ]; then
     bashlock
     if [ $? -ne 0 ]; then
-       echo "Couldn't get lock, is another instance already running?"
+       log_error "Couldn't get lock, is another instance already running?"
        exit 1
     fi
     self_update "${ORIG_ARGS[@]}"
@@ -757,12 +768,18 @@
 
 SNAPPER_VERSION=`snapper --version | head -1 | cut -d ' ' -f 2`
 if [ -n "${BASE_SNAPSHOT_ID}" -a $(zypper --terse versioncmp $SNAPPER_VERSION 
0.8.4) -lt 0 ]; then
-    echo "ERROR: snapper >= 0.8.4 required for --continue option!"
+    log_error "ERROR: snapper >= 0.8.4 required for --continue option!"
     log_info "transactional-update finished"
     telem_finish 1
     exit 1
 fi
 
+if [ $DROP_IF_NO_CHANGE -eq 1 ] && ! command -v inotifywait &> /dev/null; then
+    log_error "ERROR: 'inotifywait' is required for --drop-if-no-change 
option!"
+    log_info "transactional-update finished"
+    exit 1
+fi
+
 if [ "`stat -f -c %T /`" != "btrfs" ]; then
   log_error "ERROR: not using btrfs as root file system!"
   log_info "transactional-update finished"
@@ -856,7 +873,7 @@
        NEED_REBOOT_WARNING=1
     fi
     if [ ${NEED_REBOOT_WARNING} -eq 1 ]; then
-       echo "Please reboot to finish rollback!"
+       log_error "Please reboot to finish rollback!"
     fi
     telem_finish 0
     exit 0
@@ -865,7 +882,7 @@
 #
 # Cleanup part: make sure old root file systems will be removed after they are 
no longer active.
 #
-if [ ${DO_CLEANUP} -eq 1 ]; then
+if [ ${DO_CLEANUP_SNAPSHOTS} -eq 1 ]; then
     # If there is a list of working snapshots, go through it and mark any 
snapshot for deletion, if it is
     # not the currently used one or the active one.
     if [ -n "${LAST_WORKING_SNAPSHOTS}" ]; then
@@ -930,7 +947,9 @@
        UNUSED_SNAPSHOTS="${_new_unused}"
        save_state_file 0
     fi
+fi
 
+if [ ${DO_CLEANUP_OVERLAYS} -eq 1 ]; then
     # Clean up old unused overlays
     if [ ${RO_ROOT} == "true" ]; then
        shopt -s nullglob
@@ -998,11 +1017,15 @@
 
        get_etc_overlay_from /
        current_upper="${fstab_upper}"
-
-       # Copy the contents of oldest /etc layer into snapshot
-       sync_etc "${fstab_oldest_active_snapshot}" "${SNAPSHOT_DIR}"
        get_etc_overlay_from "/.snapshots/${BASE_SNAPSHOT_ID}/snapshot"
 
+       # Copy the previous snapshot's /etc state into new snapshot (if it
+       # hasn't been synced in a previous layer already)
+       if [ -n "${fstab_previous_snapshot}" ] && [[ ${fstab_lowerdirs[@]} != 
*"${current_upper}"* ]]; then
+           sync_etc "${fstab_previous_snapshot}" "${SNAPSHOT_DIR}"
+           get_etc_overlay_from "/.snapshots/${BASE_SNAPSHOT_ID}/snapshot"
+       fi
+
        # Special handling /etc/fstab{.sys}: dracut needs the *current* version
        # of the files in the snapshot, as the overlay is not yet mounted
        # during early boot - in fact the files are required to be able to
@@ -1025,16 +1048,31 @@
            gawk -i inplace '$3 == "overlay" && $4 ~ 
"=/sysroot/var/lib/overlay/" { $4 = 
$4",x-systemd.requires-mounts-for=/var,x-systemd.requires-mounts-for=/var/lib/overlay,x-systemd.requires-mounts-for=/sysroot/var,x-systemd.requires-mounts-for=/sysroot/var/lib/overlay,x-initrd.mount";
 } 1' "${SNAPSHOT_DIR}/etc/fstab"
        fi
 
+       # Check whether the new snapshot is based on the currently running
+       # one - if so, then keep the overlay stack to not loose changes
+       # applied until reboot
+       if [[ ${fstab_lowerdirs[@]} == *"${current_upper}"* ]]; then
+           lowerdirs="${fstab_upper}:$(echo ${fstab_lowerdirs[@]} | tr ' ' 
':')"
+       else
+           lowerdirs="${fstab_upper}:/sysroot/etc"
+       fi
+
        # Update fstab{,.sys} entries for /etc overlays
-       fstab_line="overlay /etc overlay ${fstab_otheroptions}"
-       fstab_line+="upperdir=/sysroot${ETC_OVERLAY_DIR},"
-       fstab_line+="lowerdir=${fstab_upper}:`echo ${fstab_active_lowerdirs[@]} 
| tr ' ' ':'`,"
-       fstab_line+="workdir=/sysroot/var/lib/overlay/work-etc,"
-       fstab_line+="x-systemd.requires-mounts-for=/var,"
-       fstab_line+="x-systemd.requires-mounts-for=/var/lib/overlay,"
-       fstab_line+="x-systemd.requires-mounts-for=/sysroot/var,"
-       fstab_line+="x-systemd.requires-mounts-for=/sysroot/var/lib/overlay,"
-       fstab_line+="x-initrd.mount 0 0"
+       fstab_options="${fstab_otheroptions}"
+       fstab_options+="upperdir=/sysroot${ETC_OVERLAY_DIR},"
+       fstab_options+="lowerdir=${lowerdirs},"
+       fstab_options+="workdir=/sysroot/var/lib/overlay/work-etc,"
+       fstab_options+="x-systemd.requires-mounts-for=/var,"
+       fstab_options+="x-systemd.requires-mounts-for=/var/lib/overlay,"
+       fstab_options+="x-systemd.requires-mounts-for=/sysroot/var,"
+       fstab_options+="x-systemd.requires-mounts-for=/sysroot/var/lib/overlay,"
+       fstab_options+="x-initrd.mount"
+       if [ ${#fstab_options} -ge $(getconf PAGE_SIZE) ]; then
+           log_error "ERROR: Exceeding maximum length of mount options; please 
boot into the new"
+           log_error "       snapshot before proceeding."
+           quit 1
+       fi
+       fstab_line="overlay /etc overlay ${fstab_options} 0 0"
        sed -i "/${ETC_OVERLAY_PATTERN}/c ${fstab_line}" 
"${SNAPSHOT_DIR}/etc/fstab"
 
        # Prettify fstab
@@ -1097,11 +1135,16 @@
 
     if [ ${ETC_IS_OVERLAY} -eq 1 ]; then
        lowerdir="${fstab_upper///sysroot\/var//var}:"
-       lowerdir+="`parse_lowerdirs_for_mount 
"/.snapshots/${BASE_SNAPSHOT_ID}/snapshot"`"
-       # Check whether the current upper directory is part of the snapshot's 
lower
-       # directory stack; if so use reuse /etc directly instead, as mounting
-       # the same upper directory multiple times is not supported by overlayfs
-       lowerdir="${lowerdir/${current_upper#/sysroot}*/\/etc}"
+       # Is the snapshot based on the currently running system?
+       if [[ ${fstab_lowerdirs[@]} == *"${current_upper}"* ]]; then
+           lowerdir+="$(parse_lowerdirs_for_mount 
"/.snapshots/${BASE_SNAPSHOT_ID}/snapshot")"
+           # Mounting an already used overlay directory again is not
+           # supported by overlayfs - use the old mount point instead
+           lowerdir="${lowerdir/${current_upper#/sysroot}*/\/etc}"
+       else
+           # Use the (synced) /etc directory of the new snapshot as base
+           lowerdir+="/.snapshots/${SNAPSHOT_ID}/snapshot/etc"
+       fi
 
        etc_opts="defaults,"
        etc_opts+="lowerdir=${lowerdir},"
@@ -1171,8 +1214,8 @@
 
     if [ $DROP_IF_NO_CHANGE -eq 1 ]; then
        #TODO: Handle directories with special characters (space, newline, 
apostrophe etc)
-       for snapmount in `findmnt --noheadings --submounts --target 
"${SNAPSHOT_DIR}" --output TARGET --raw | grep "${SNAPSHOT_DIR}"`; do
-           INOTIFY_EXCLUDES="${INOTIFY_EXCLUDES} @${snapmount}"
+       for snapmount in $(root_mount_points); do
+           INOTIFY_EXCLUDES="${INOTIFY_EXCLUDES} @${SNAPSHOT_DIR}${snapmount}"
        done
        INOTIFY_PID=$( ( inotifywait -r -e modify -e move -e create -e delete 
-e attrib "${SNAPSHOT_DIR}" ${INOTIFY_EXCLUDES} 2>&1 & echo "PID: $!" ) | ( 
grep -m1 '^PID: ' | cut -d ' ' -f 2 && grep -q "Watches established" ) )
     fi
@@ -1240,7 +1283,7 @@
        else
            log_error "ERROR: zypper ${ZYPPER_ARG} on ${MOUNT_DIR} failed with 
exit code ${RETVAL}!"
            if [ -n "${ZYPPER_NONINTERACTIVE}" ]; then
-               echo "Use '--interactive' for manual problem resolution."
+               log_error "Use '--interactive' for manual problem resolution."
            fi
            EXITCODE=1
        fi
@@ -1289,7 +1332,7 @@
     fi
 
     if [ ${RUN_SHELL} -eq 1 ]; then
-       echo "Opening chroot in snapshot ${SNAPSHOT_ID}, continue with 'exit'"
+       log_info "Opening chroot in snapshot ${SNAPSHOT_ID}, continue with 
'exit'"
        env PS1="transactional update # " chroot ${MOUNT_DIR} bash 2>&4
     fi
 
@@ -1365,8 +1408,7 @@
     if [ ${EXITCODE} -ne 0 ]; then
        quit ${EXITCODE}
     elif [ $REBOOT_AFTERWARDS -eq 0 ]; then
-       echo
-       echo "Please reboot your machine to activate the changes and avoid data 
loss."
+       log_error "\nPlease reboot your machine to activate the changes and 
avoid data loss."
        touch "${NEEDS_RESTARTING_FILE}"
     fi
 
@@ -1400,8 +1442,8 @@
                reboot_autodetect
                ;;
        esac
-       echo "The system couldn't be rebooted using method '${REBOOT_METHOD}'. 
Please reboot the system"
-       echo "manually."
+       log_error "The system couldn't be rebooted using method 
'${REBOOT_METHOD}'. Please reboot the system"
+       log_error "manually."
     fi
 fi
 


Reply via email to