Hello community, here is the log from the commit of package transactional-update for openSUSE:Factory checked in at 2020-02-29 21:21:43 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/transactional-update (Old) and /work/SRC/openSUSE:Factory/.transactional-update.new.26092 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "transactional-update" Sat Feb 29 21:21:43 2020 rev:49 rq:779347 version:2.20.2 Changes: -------- --- /work/SRC/openSUSE:Factory/transactional-update/transactional-update.changes 2020-01-10 18:40:26.783492216 +0100 +++ /work/SRC/openSUSE:Factory/.transactional-update.new.26092/transactional-update.changes 2020-02-29 21:21:47.530193255 +0100 @@ -1,0 +2,8 @@ +Wed Feb 26 09:58:23 UTC 2020 - Ignaz Forster <ifors...@suse.com> + +- Update to version 2.20.2 + - Use full names for zypper options [bsc#1164543] + - Ignore /var/lib/rpm in shadowed file output + - Optimize create-dirs-from-rpmdb + +------------------------------------------------------------------- Old: ---- transactional-update-2.20.1.tar.gz New: ---- transactional-update-2.20.2.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ transactional-update.spec ++++++ --- /var/tmp/diff_new_pack.51n1Gn/_old 2020-02-29 21:21:48.542195258 +0100 +++ /var/tmp/diff_new_pack.51n1Gn/_new 2020-02-29 21:21:48.546195265 +0100 @@ -17,7 +17,7 @@ Name: transactional-update -Version: 2.20.1 +Version: 2.20.2 Release: 0 Summary: Transactional Updates with btrfs and snapshots License: GPL-2.0-or-later ++++++ transactional-update-2.20.1.tar.gz -> transactional-update-2.20.2.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/transactional-update-2.20.1/NEWS new/transactional-update-2.20.2/NEWS --- old/transactional-update-2.20.1/NEWS 2020-01-07 11:42:35.000000000 +0100 +++ new/transactional-update-2.20.2/NEWS 2020-02-26 10:50:25.000000000 +0100 @@ -2,6 +2,11 @@ Copyright (C) 2016-2019 Thorsten Kukuk et al. +Version 2.20.2 +* Use full names for zypper options [bsc#1164543] +* Ignore /var/lib/rpm in shandowed file output +* Optimize create-dirs-from-rpmdb + Version 2.20.1 * Add missing documentation about --continue option * Avoid error message about missing fstab file on first snapshot creation. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/transactional-update-2.20.1/configure.ac new/transactional-update-2.20.2/configure.ac --- old/transactional-update-2.20.1/configure.ac 2020-01-07 11:42:35.000000000 +0100 +++ new/transactional-update-2.20.2/configure.ac 2020-02-26 10:50:25.000000000 +0100 @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_INIT(transactional-update, 2.20.1) +AC_INIT(transactional-update, 2.20.2) 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-2.20.1/sbin/create_dirs_from_rpmdb.c new/transactional-update-2.20.2/sbin/create_dirs_from_rpmdb.c --- old/transactional-update-2.20.1/sbin/create_dirs_from_rpmdb.c 2020-01-07 11:42:35.000000000 +0100 +++ new/transactional-update-2.20.2/sbin/create_dirs_from_rpmdb.c 2020-02-26 10:50:25.000000000 +0100 @@ -21,6 +21,7 @@ #include <config.h> #endif +#include <fcntl.h> #include <sys/types.h> #include <pwd.h> #include <grp.h> @@ -67,18 +68,29 @@ uid_t user_id; gid_t group_id; time_t fmtime; - struct node *next; }; struct node *dir_list = NULL; +size_t dir_list_size = 0, dir_list_capacity = 0; /* A utility function to insert a node at the beginning of linked list */ void -insert_node (struct node** head_ref, const char *dirname, rpm_mode_t fmode, +insert_node (const char *dirname, rpm_mode_t fmode, uid_t user_id, gid_t group_id, time_t fmtime) { - /* allocate node */ - struct node* new_node = malloc(sizeof(struct node)); + /* allocate space for the new node */ + dir_list_size += 1; + size_t new_capacity = dir_list_capacity ? dir_list_capacity : 1; + while (new_capacity < dir_list_size) + new_capacity *= 2; + + if (new_capacity != dir_list_capacity) + { + dir_list = realloc(dir_list, new_capacity * sizeof(struct node)); + dir_list_capacity = new_capacity; + } + + struct node *new_node = &dir_list[dir_list_size - 1]; /* put in the data */ new_node->dirname = strdup (dirname); @@ -86,112 +98,12 @@ new_node->user_id = user_id; new_node->group_id = group_id; new_node->fmtime = fmtime; - - /* link the old list off the new node */ - new_node->next = (*head_ref); - - /* move the head to point to the new node */ - (*head_ref) = new_node; -} - -/* Returns the last node of the list */ -struct node * -get_last_node (struct node *cur) -{ - while (cur != NULL && cur->next != NULL) - cur = cur->next; - return cur; -} - -/* Partitions the list taking the last element as the pivot */ -struct node * -partition(struct node *head, struct node *end, - struct node **newHead, struct node **newEnd) -{ - struct node *pivot = end; - struct node *prev = NULL, *cur = head, *tail = pivot; - - /* During partition, both the head and end of the list might change - which is updated in the newHead and newEnd variables */ - while (cur != pivot) - { - if (strcmp (cur->dirname, pivot->dirname) < 0) - { - /* First node that has a value less than the pivot - becomes - the new head */ - if ((*newHead) == NULL) - (*newHead) = cur; - - prev = cur; - cur = cur->next; - } - else /* If cur node is greater than pivot */ - { - /* Move cur node to next of tail, and change tail */ - if (prev) - prev->next = cur->next; - struct node *tmp = cur->next; - cur->next = NULL; - tail->next = cur; - tail = cur; - cur = tmp; - } - } - - /* If the pivot data is the smallest element in the current list, - pivot becomes the head */ - if ((*newHead) == NULL) - (*newHead) = pivot; - - (*newEnd) = tail; - - return pivot; } - -struct node * -quicksort_rec(struct node *head, struct node *end) -{ - struct node *newHead = NULL, *newEnd = NULL; - struct node *pivot; - - if (!head || head == end) - return head; - - /* Partition the list, newHead and newEnd will be updated - by the partition function */ - pivot = partition(head, end, &newHead, &newEnd); - - /* If pivot is the smallest element - no need to recur for - the left part. */ - if (newHead != pivot) - { - /* Set the node before the pivot node as NULL */ - struct node *tmp = newHead; - while (tmp->next != pivot) - tmp = tmp->next; - tmp->next = NULL; - - newHead = quicksort_rec(newHead, tmp); - - /* Change next of last node of the left half to pivot */ - tmp = get_last_node(newHead); - tmp->next = pivot; - } - - /* Recur for the list after the pivot element */ - pivot->next = quicksort_rec(pivot->next, newEnd); - - return newHead; -} - -/* The main function for quick sort. This is a wrapper over recursive - function quicksort_rec() */ -void -quicksort (struct node **headRef) +int +nodecmp (const void *p1, const void *p2) { - (*headRef) = quicksort_rec(*headRef, get_last_node(*headRef)); - return; + return strcmp(((const struct node*)p1)->dirname, ((const struct node*)p2)->dirname); } static char * @@ -318,7 +230,7 @@ user_id = pwd->pw_uid; group_id = grp->gr_gid; - insert_node (&dir_list, fn, fmode, user_id, group_id, fmtime); + insert_node (fn, fmode, user_id, group_id, fmtime); } } } @@ -331,11 +243,11 @@ } int -create_dirs (struct node *node) +create_dirs (struct node *node, size_t size) { - int rc = 0; + int rc = 0, i; - while (node != NULL) + for(i = 0; i < size; ++i, ++node) { struct timeval stamps[2] = { { .tv_sec = node->fmtime, .tv_usec = 0 }, @@ -349,7 +261,7 @@ { fprintf (stderr, "Failed to create directory '%s': %m\n", node->dirname); rc = 1; - goto exit; + continue; } rc = chown (node->dirname, node->user_id, node->group_id); @@ -359,17 +271,56 @@ /* wrong permissions are bad, remove dir and continue */ rmdir (node->dirname); rc = 1; - goto exit; + continue; } /* ignore errors here, time stamps are not critical */ utimes (node->dirname, stamps); - exit: - node = node->next; } return rc; } +int +rpmCookieUnchanged (const char *rpmdb_cookie) +{ + int unchanged = 0, size = 0; + char *oldcookie = NULL; + FILE *cookiefile = fopen("/var/lib/create-dirs-from-rpmdb/cookie", "rb"); + + if (!cookiefile || fseek(cookiefile, 0, SEEK_END) != 0 || (size = ftell(cookiefile)) < 1 || fseek(cookiefile, 0, SEEK_SET) != 0) + goto end; + + if (size == strlen(rpmdb_cookie)) + { + oldcookie = malloc(size); + if (oldcookie && fread(oldcookie, size, 1, cookiefile) == 1) + unchanged = (strncmp(rpmdb_cookie, oldcookie, size) == 0); + } + + end: + + if (oldcookie) + free (oldcookie); + + if (cookiefile) + fclose(cookiefile); + + return unchanged; +} + +void +rpmCookieWrite (const char *rpmdb_cookie) +{ + mkdir("/var/lib", 0755); + mkdir("/var/lib/create-dirs-from-rpmdb", 0755); + FILE *cookief = fopen("/var/lib/create-dirs-from-rpmdb/cookie", "w"); + if(!cookief) + return; + + fwrite(rpmdb_cookie, strlen(rpmdb_cookie), 1, cookief); + fclose(cookief); +} + int main (int argc, char *argv[]) @@ -377,6 +328,7 @@ Header h; rpmts ts = NULL; int ec = 0; + const char *rpmdb_cookie = NULL; while (1) @@ -436,6 +388,18 @@ ts = rpmtsCreate (); rpmtsSetRootDir (ts, rpmcliRootDir); + rpmtsOpenDB (ts, O_RDONLY); + rpmdbOpenAll (rpmtsGetRdb (ts)); + rpmdb_cookie = rpmdbCookie (rpmtsGetRdb (ts)); + rpmtsCloseDB (ts); + if (rpmdb_cookie && rpmCookieUnchanged(rpmdb_cookie)) + { + if (verbose_flag) + puts("RPM cookie unchanged, not doing anything"); + rpmtsFree (ts); + return 0; + } + rpmdbMatchIterator mi = rpmtsInitIterator (ts, RPMDBI_PACKAGES, NULL, 0); if (mi == NULL) return 1; @@ -451,13 +415,17 @@ if (dir_list != NULL) { int rc; - quicksort (&dir_list); - if ((rc = create_dirs (dir_list)) != 0) + qsort (dir_list, dir_list_size, sizeof(struct node), nodecmp); + if ((rc = create_dirs (dir_list, dir_list_size)) != 0) ec = rc; } /* XXX missing: free list */ + /* Can't do anything if this fails anyway. */ + if (rpmdb_cookie) + rpmCookieWrite(rpmdb_cookie); + rpmdbFreeIterator (mi); rpmtsFree (ts); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/transactional-update-2.20.1/sbin/transactional-update.in new/transactional-update-2.20.2/sbin/transactional-update.in --- old/transactional-update-2.20.1/sbin/transactional-update.in 2020-01-07 11:42:35.000000000 +0100 +++ new/transactional-update-2.20.2/sbin/transactional-update.in 2020-02-26 10:50:25.000000000 +0100 @@ -55,7 +55,7 @@ LOCKFILE="/var/run/transactional-update.pid" ZYPPER_AUTO_IMPORT_KEYS=0 ETC_OVERLAY_PATTERN='^[^[:space:]]\+[[:space:]]\+\/etc[[:space:]]\+overlay[[:space:]]\+\([^[:space:]]*,\|\)workdir=\/sysroot\/var\/lib\/overlay\/work-etc[,[:space:]]' -NON_ROOTFS_WHITELIST=("/var/lib/systemd/migrated" "/var/run/zypp.pid") +NON_ROOTFS_WHITELIST=("/var/lib/rpm" "/var/lib/systemd/migrated" "/var/run/zypp.pid") # Load config if [ -r ${SYSTEMCONFFILE} ]; then @@ -1189,7 +1189,7 @@ else # Check if there are updates at all. TMPFILE=`mktemp /tmp/transactional-update.XXXXXXXXXX` - zypper -R ${MOUNT_DIR} --xml ${ZYPPER_ARG} -y --auto-agree-with-product-licenses --dry-run "${ZYPPER_ARG_PKGS[@]}" > ${TMPFILE} + zypper -R ${MOUNT_DIR} --xmlout ${ZYPPER_ARG} -y --auto-agree-with-product-licenses --dry-run "${ZYPPER_ARG_PKGS[@]}" > ${TMPFILE} PACKAGE_UPDATES=`grep "install-summary download-size" ${TMPFILE} | sed -e 's|.*install-summary download-size=\"\(.*\)\" space-usage-diff.*|\1|g'` SIZE_OF_UPDATES=`grep "install-summary.*space-usage-diff" ${TMPFILE} | sed -e 's|.*install-summary.*space-usage-diff=\"\([^"]*\)\".*|\1|g'` NUM_OF_UPDATES=`grep "install-summary.*packages-to-change" ${TMPFILE} | sed -e 's|.*install-summary.*packages-to-change=\"\([^"]*\)\".*|\1|g'`