Hello community,

here is the log from the commit of package transactional-update for 
openSUSE:Factory checked in at 2017-11-08 15:10:57
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/transactional-update (Old)
 and      /work/SRC/openSUSE:Factory/.transactional-update.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "transactional-update"

Wed Nov  8 15:10:57 2017 rev:15 rq:539604 version:1.22

Changes:
--------
--- 
/work/SRC/openSUSE:Factory/transactional-update/transactional-update.changes    
    2017-10-30 21:18:24.755354750 +0100
+++ 
/work/SRC/openSUSE:Factory/.transactional-update.new/transactional-update.changes
   2017-11-08 15:13:51.565887367 +0100
@@ -1,0 +2,6 @@
+Tue Nov  7 16:34:28 CET 2017 - [email protected]
+
+- Update to version 1.22
+  - Rewrite cleanup code to be more aggressive
+
+-------------------------------------------------------------------

Old:
----
  transactional-update-1.21.tar.bz2

New:
----
  transactional-update-1.22.tar.bz2

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

Other differences:
------------------
++++++ transactional-update.spec ++++++
--- /var/tmp/diff_new_pack.zcGrip/_old  2017-11-08 15:13:52.573850574 +0100
+++ /var/tmp/diff_new_pack.zcGrip/_new  2017-11-08 15:13:52.573850574 +0100
@@ -17,7 +17,7 @@
 
 
 Name:           transactional-update
-Version:        1.21
+Version:        1.22
 Release:        0
 Summary:        Transactional Updates with btrfs and snapshots
 License:        GPL-2.0+

++++++ transactional-update-1.21.tar.bz2 -> transactional-update-1.22.tar.bz2 
++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/transactional-update-1.21/NEWS 
new/transactional-update-1.22/NEWS
--- old/transactional-update-1.21/NEWS  2017-10-27 13:51:13.000000000 +0200
+++ new/transactional-update-1.22/NEWS  2017-11-07 16:21:54.000000000 +0100
@@ -2,6 +2,9 @@
 
 Copyright (C) 2016, 2017 Thorsten Kukuk
 
+Version 1.22
+* Rewrite cleanup code
+
 Version 1.21
 * Reset salt grains if no updates are available
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/transactional-update-1.21/configure 
new/transactional-update-1.22/configure
--- old/transactional-update-1.21/configure     2017-10-27 13:51:19.000000000 
+0200
+++ new/transactional-update-1.22/configure     2017-11-07 16:22:13.000000000 
+0100
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for transactional-update 1.21.
+# Generated by GNU Autoconf 2.69 for transactional-update 1.22.
 #
 #
 # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
@@ -576,8 +576,8 @@
 # Identity of this package.
 PACKAGE_NAME='transactional-update'
 PACKAGE_TARNAME='transactional-update'
-PACKAGE_VERSION='1.21'
-PACKAGE_STRING='transactional-update 1.21'
+PACKAGE_VERSION='1.22'
+PACKAGE_STRING='transactional-update 1.22'
 PACKAGE_BUGREPORT=''
 PACKAGE_URL=''
 
@@ -1211,7 +1211,7 @@
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures transactional-update 1.21 to adapt to many kinds of 
systems.
+\`configure' configures transactional-update 1.22 to adapt to many kinds of 
systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1278,7 +1278,7 @@
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of transactional-update 1.21:";;
+     short | recursive ) echo "Configuration of transactional-update 1.22:";;
    esac
   cat <<\_ACEOF
 
@@ -1358,7 +1358,7 @@
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-transactional-update configure 1.21
+transactional-update configure 1.22
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1375,7 +1375,7 @@
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by transactional-update $as_me 1.21, which was
+It was created by transactional-update $as_me 1.22, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -2238,7 +2238,7 @@
 
 # Define the identity of the package.
  PACKAGE='transactional-update'
- VERSION='1.21'
+ VERSION='1.22'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -3097,7 +3097,7 @@
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by transactional-update $as_me 1.21, which was
+This file was extended by transactional-update $as_me 1.22, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -3150,7 +3150,7 @@
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; 
s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-transactional-update config.status 1.21
+transactional-update config.status 1.22
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/transactional-update-1.21/configure.ac 
new/transactional-update-1.22/configure.ac
--- old/transactional-update-1.21/configure.ac  2017-10-27 13:50:14.000000000 
+0200
+++ new/transactional-update-1.22/configure.ac  2017-11-07 16:22:09.000000000 
+0100
@@ -1,5 +1,5 @@
 dnl Process this file with autoconf to produce a configure script.
-AC_INIT(transactional-update, 1.21)
+AC_INIT(transactional-update, 1.22)
 AM_INIT_AUTOMAKE
 AC_CONFIG_SRCDIR([sbin/transactional-update.in])
 AC_PREFIX_DEFAULT(/usr)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/transactional-update-1.21/sbin/transactional-update.in 
new/transactional-update-1.22/sbin/transactional-update.in
--- old/transactional-update-1.21/sbin/transactional-update.in  2017-10-27 
13:41:59.000000000 +0200
+++ new/transactional-update-1.22/sbin/transactional-update.in  2017-11-07 
13:11:47.000000000 +0100
@@ -95,7 +95,7 @@
   }
 
 save_state_file() {
-    echo "LAST_WORKING_SNAPSHOT_ID=${LAST_WORKING_SNAPSHOT_ID}" > ${STATE_FILE}
+    echo "LAST_WORKING_SNAPSHOTS=\"${LAST_WORKING_SNAPSHOTS}\"" > ${STATE_FILE}
     echo "UNUSED_SNAPSHOTS=\"${UNUSED_SNAPSHOTS}\"" >>  ${STATE_FILE}
 
     if [ $1 -ne 0 ]; then
@@ -150,6 +150,17 @@
     exit $1
 }
 
+add_unique_id() {
+    local NEW_ID="$1"
+
+    for snap in ${LAST_WORKING_SNAPSHOTS}; do
+       if [ ${snap} -eq ${NEW_ID} ]; then
+           return
+       fi
+    done
+    LAST_WORKING_SNAPSHOTS="${NEW_ID} ${LAST_WORKING_SNAPSHOTS}"
+}
+
 ORIG_ARGS="$@"
 
 # if no option is given, assume "up"
@@ -296,7 +307,7 @@
   log_error "WARNING: it looks like your installation isn't recent enough."
 fi
 
-ORIG_SNAPSHOT_ID=`grep subvol=/@/.snapshots/ /proc/mounts | grep "/ btrfs" | 
sed -e 's|.*.snapshots/\(.*\)/snapshot.*|\1|g'`
+CURRENT_SNAPSHOT_ID=`grep subvol=/@/.snapshots/ /proc/mounts | grep "/ btrfs" 
| sed -e 's|.*.snapshots/\(.*\)/snapshot.*|\1|g'`
 DEFAULT_SNAPSHOT_ID=`btrfs subvolume get-default / | sed -e 
's|.*.snapshots/\(.*\)/snapshot|\1|g'`
 RO_ROOT=`btrfs property get / ro | sed -e 's|ro=||'`
 
@@ -304,7 +315,7 @@
     NEED_REBOOT_WARNING=1
 
     if [ ${ROLLBACK_SNAPSHOT} -eq 0 ]; then
-       ROLLBACK_SNAPSHOT=${ORIG_SNAPSHOT_ID}
+       ROLLBACK_SNAPSHOT=${CURRENT_SNAPSHOT_ID}
        NEED_REBOOT_WARNING=0
     fi
 
@@ -338,41 +349,56 @@
 # Cleanup part: make sure old root filesystem will be removed after it is no 
longer active.
 #
 if [ ${DO_CLEANUP} -eq 1 ]; then
-    # if our current snapshot is identical to the original snapshot, we did a 
reboot after the
-    # last transactional snapshot and try to cleanup old snapshots
-    if [ ${ORIG_SNAPSHOT_ID} -eq ${DEFAULT_SNAPSHOT_ID} ]; then
-       if [ -n "${LAST_WORKING_SNAPSHOT_ID}" ]; then
-           log_info "Add cleanup algorithm to snapshot 
#${LAST_WORKING_SNAPSHOT_ID}"
-           snapper modify -c number ${LAST_WORKING_SNAPSHOT_ID} |& tee -a 
${LOGFILE}
-           if [ ${PIPESTATUS[0]} -ne 0 ]; then
-               log_error "ERROR: cannot set cleanup algorithm for snapshot 
#${LAST_WORKING_SNAPSHOT_ID}"
-           fi
-           # if the old snapshot is read-write, we have already a mandatory 
snapshot and this one can deleted
-           # earlier. If not, mark is as important, so that it will not get 
deleted to fast.
-           if [ ${RO_ROOT} == "true" ]; then
-               log_info "Add \"important=yes\" to snapshot 
#${LAST_WORKING_SNAPSHOT_ID}"
-               snapper modify -u "important=yes" ${LAST_WORKING_SNAPSHOT_ID} 
|& tee -a ${LOGFILE}
+    # if there is a list of working snapshots, go through it and mark any 
snapshot for deletion, if it is
+    # not the current used one or the active one.
+    if [ -n "${LAST_WORKING_SNAPSHOTS}" ]; then
+       for snap in ${LAST_WORKING_SNAPSHOTS}; do
+           if [ ${CURRENT_SNAPSHOT_ID} -ne ${snap} ]; then
+               log_info "Add cleanup algorithm to snapshot #${snap}"
+               snapper modify -c number ${snap} |& tee -a ${LOGFILE}
                if [ ${PIPESTATUS[0]} -ne 0 ]; then
-                   log_error "ERROR: cannot set \"important=yes for snapshot\" 
#${LAST_WORKING_SNAPSHOT_ID}"
+                   log_error "ERROR: cannot set cleanup algorithm for snapshot 
#${snap}"
                fi
-           fi
-           LAST_WORKING_SNAPSHOT_ID=""
-           save_state_file 0
-       fi
-       if [ -n "${UNUSED_SNAPSHOTS}" ]; then
-           for snap in ${UNUSED_SNAPSHOTS}; do
-               # Don't mark our current in use snapshot for deletion
-               if [ ${snap} -ne ${ORIG_SNAPSHOT_ID} ]; then
-                   log_info "Mark not used snapshot #${snap} for deletion"
-                   snapper modify -c number ${snap} |& tee -a ${LOGFILE}
+               # if the old snapshot is read-write, we have already a 
mandatory snapshot and this one can deleted
+               # earlier. If not, mark is as important, so that it will not 
get deleted to fast.
+               if [ ${RO_ROOT} == "true" ]; then
+                   log_info "Add \"important=yes\" to snapshot #${snap}"
+                   snapper modify -u "important=yes" ${snap} |& tee -a 
${LOGFILE}
                    if [ ${PIPESTATUS[0]} -ne 0 ]; then
-                       log_error "ERROR: cannot set cleanup algorithm for 
snapshot #${LAST_WORKING_SNAPSHOT_ID}"
+                       log_error "ERROR: cannot set \"important=yes for 
snapshot\" #${snap}"
                    fi
                fi
-           done
-           UNUSED_SNAPSHOTS=""
-           save_state_file 0
-       fi
+           else
+               NEW_LIST="${snap} ${NEW_LIST}"
+           fi
+       done
+       LAST_WORKING_SNAPSHOTS="${NEW_LIST}"
+       save_state_file 0
+    fi
+
+    # we try to cleanup always all snapshots. We only need to keep the current 
snapshot
+    # and the new default one.
+    if [ -n "${UNUSED_SNAPSHOTS}" ]; then
+       _new_unused=""
+       for snap in ${UNUSED_SNAPSHOTS}; do
+           # Don't mark our current in use snapshot for deletion
+           if [ ${snap} -ne ${CURRENT_SNAPSHOT_ID} ] && \
+               [ ${snap} -ne ${DEFAULT_SNAPSHOT_ID} ]; then
+               log_info "Mark not used snapshot #${snap} for deletion"
+               snapper modify -c number ${snap} |& tee -a ${LOGFILE}
+               if [ ${PIPESTATUS[0]} -ne 0 ]; then
+                   log_error "ERROR: cannot set cleanup algorithm for snapshot 
#${snap}"
+                   # Keep the snapshot in the list
+                   _new_unused="${snap} ${_new_unused}"
+               fi
+           elif [ ${snap} -ne ${CURRENT_SNAPSHOT_ID} ]; then
+               # We currently still need the snapshot, so keep it in the
+               # list. Else we will never clean it up later.
+               _new_unused="${snap} ${_new_unused}"
+           fi
+       done
+       UNUSED_SNAPSHOTS="${_new_unused}"
+       save_state_file 0
     fi
 fi
 
@@ -409,8 +435,8 @@
     # If the current root filesystem is not read-only, we need to create a 
read-only copy for rollback.
     # The rw subvolume is not shown in grub2.
     if [ ${RO_ROOT} == "false" ]; then
-       log_info "Create read-only snapshot of current read-write root 
filesystem (#${ORIG_SNAPSHOT_ID})"
-       SECOND_SNAPSHOT_ID=`snapper create -p -c number -u "important=yes" -d 
"RO-Clone of #${ORIG_SNAPSHOT_ID}"`
+       log_info "Create read-only snapshot of current read-write root 
filesystem (#${CURRENT_SNAPSHOT_ID})"
+       SECOND_SNAPSHOT_ID=`snapper create -p -c number -u "important=yes" -d 
"RO-Clone of #${CURRENT_SNAPSHOT_ID}"`
        if [ $? -ne 0 ]; then
            log_error "ERROR: snapper create failed!"
            exit 1
@@ -587,7 +613,8 @@
                log_error "ERROR: btrfs set-default $BTRFS_ID failed!"
                EXITCODE=1;
            else
-               LAST_WORKING_SNAPSHOT_ID=${ORIG_SNAPSHOT_ID}
+               # save the old snapshot, else it will go lost
+               add_unique_id ${CURRENT_SNAPSHOT_ID}
                save_state_file ${SNAPSHOT_ID}
            fi
        fi


Reply via email to