Hello community,
here is the log from the commit of package transactional-update for
openSUSE:Factory checked in at 2018-05-03 12:33:10
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/transactional-update (Old)
and /work/SRC/openSUSE:Factory/.transactional-update.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "transactional-update"
Thu May 3 12:33:10 2018 rev:28 rq:603009 version:2.2
Changes:
--------
---
/work/SRC/openSUSE:Factory/transactional-update/transactional-update.changes
2018-04-30 22:59:21.403545871 +0200
+++
/work/SRC/openSUSE:Factory/.transactional-update.new/transactional-update.changes
2018-05-03 12:33:12.342520493 +0200
@@ -1,0 +2,8 @@
+Wed May 2 08:39:18 UTC 2018 - [email protected]
+
+- Update to version 2.2
+ - Fix security issue in self update [boo#1091316]
+ - Create dirs in /var more reliably by sorting the list
+- Rebuild initrd (needed since 2.0)
+
+-------------------------------------------------------------------
Old:
----
transactional-update-2.1.tar.bz2
New:
----
transactional-update-2.2.tar.bz2
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ transactional-update.spec ++++++
--- /var/tmp/diff_new_pack.oAgYww/_old 2018-05-03 12:33:13.234488724 +0200
+++ /var/tmp/diff_new_pack.oAgYww/_new 2018-05-03 12:33:13.238488582 +0200
@@ -17,7 +17,7 @@
Name: transactional-update
-Version: 2.1
+Version: 2.2
Release: 0
Summary: Transactional Updates with btrfs and snapshots
License: GPL-2.0-or-later
@@ -28,6 +28,7 @@
BuildRequires: gcc-c++
BuildRequires: pkgconfig
BuildRequires: rpm-devel
+BuildRequires: suse-module-tools
BuildRequires: pkgconfig(libzypp)
Requires: logrotate
Requires: lsof
@@ -58,12 +59,17 @@
%post
%service_add_post %{name}.service %{name}.timer create-dirs-from-rpmdb.service
+%regenerate_initrd_post
+
+%posttrans
+%regenerate_initrd_posttrans
%preun
%service_del_preun %{name}.service %{name}.timer create-dirs-from-rpmdb.service
%postun
%service_del_postun %{name}.service %{name}.timer
create-dirs-from-rpmdb.service
+%regenerate_initrd_post
%files
%license COPYING
++++++ transactional-update-2.1.tar.bz2 -> transactional-update-2.2.tar.bz2
++++++
++++ 2976 lines of diff (skipped)
++++ retrying with extended exclude list
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh
old/transactional-update-2.1/NEWS new/transactional-update-2.2/NEWS
--- old/transactional-update-2.1/NEWS 2018-04-26 15:00:29.000000000 +0200
+++ new/transactional-update-2.2/NEWS 2018-05-02 10:30:45.000000000 +0200
@@ -2,6 +2,10 @@
Copyright (C) 2016, 2017, 2018 Thorsten Kukuk
+Version 2.2
+* Fix security issue in self update
+* Create dirs in /var more reliably by sorting the list
+
Version 2.1
* Cleanup /etc cleanup
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh
old/transactional-update-2.1/compile new/transactional-update-2.2/compile
--- old/transactional-update-2.1/compile 1970-01-01 01:00:00.000000000
+0100
+++ new/transactional-update-2.2/compile 2018-04-30 13:54:06.000000000
+0200
@@ -0,0 +1,348 @@
+#! /bin/sh
+# Wrapper for compilers which do not understand '-c -o'.
+
+scriptversion=2016-01-11.22; # UTC
+
+# Copyright (C) 1999-2017 Free Software Foundation, Inc.
+# Written by Tom Tromey <[email protected]>.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# This file is maintained in Automake, please report
+# bugs to <[email protected]> or send patches to
+# <[email protected]>.
+
+nl='
+'
+
+# We need space, tab and new line, in precisely that order. Quoting is
+# there to prevent tools from complaining about whitespace usage.
+IFS=" "" $nl"
+
+file_conv=
+
+# func_file_conv build_file lazy
+# Convert a $build file to $host form and store it in $file
+# Currently only supports Windows hosts. If the determined conversion
+# type is listed in (the comma separated) LAZY, no conversion will
+# take place.
+func_file_conv ()
+{
+ file=$1
+ case $file in
+ / | /[!/]*) # absolute file, and not a UNC file
+ if test -z "$file_conv"; then
+ # lazily determine how to convert abs files
+ case `uname -s` in
+ MINGW*)
+ file_conv=mingw
+ ;;
+ CYGWIN*)
+ file_conv=cygwin
+ ;;
+ *)
+ file_conv=wine
+ ;;
+ esac
+ fi
+ case $file_conv/,$2, in
+ *,$file_conv,*)
+ ;;
+ mingw/*)
+ file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
+ ;;
+ cygwin/*)
+ file=`cygpath -m "$file" || echo "$file"`
+ ;;
+ wine/*)
+ file=`winepath -w "$file" || echo "$file"`
+ ;;
+ esac
+ ;;
+ esac
+}
+
+# func_cl_dashL linkdir
+# Make cl look for libraries in LINKDIR
+func_cl_dashL ()
+{
+ func_file_conv "$1"
+ if test -z "$lib_path"; then
+ lib_path=$file
+ else
+ lib_path="$lib_path;$file"
+ fi
+ linker_opts="$linker_opts -LIBPATH:$file"
+}
+
+# func_cl_dashl library
+# Do a library search-path lookup for cl
+func_cl_dashl ()
+{
+ lib=$1
+ found=no
+ save_IFS=$IFS
+ IFS=';'
+ for dir in $lib_path $LIB
+ do
+ IFS=$save_IFS
+ if $shared && test -f "$dir/$lib.dll.lib"; then
+ found=yes
+ lib=$dir/$lib.dll.lib
+ break
+ fi
+ if test -f "$dir/$lib.lib"; then
+ found=yes
+ lib=$dir/$lib.lib
+ break
+ fi
+ if test -f "$dir/lib$lib.a"; then
+ found=yes
+ lib=$dir/lib$lib.a
+ break
+ fi
+ done
+ IFS=$save_IFS
+
+ if test "$found" != yes; then
+ lib=$lib.lib
+ fi
+}
+
+# func_cl_wrapper cl arg...
+# Adjust compile command to suit cl
+func_cl_wrapper ()
+{
+ # Assume a capable shell
+ lib_path=
+ shared=:
+ linker_opts=
+ for arg
+ do
+ if test -n "$eat"; then
+ eat=
+ else
+ case $1 in
+ -o)
+ # configure might choose to run compile as 'compile cc -o foo foo.c'.
+ eat=1
+ case $2 in
+ *.o | *.[oO][bB][jJ])
+ func_file_conv "$2"
+ set x "$@" -Fo"$file"
+ shift
+ ;;
+ *)
+ func_file_conv "$2"
+ set x "$@" -Fe"$file"
+ shift
+ ;;
+ esac
+ ;;
+ -I)
+ eat=1
+ func_file_conv "$2" mingw
+ set x "$@" -I"$file"
+ shift
+ ;;
+ -I*)
+ func_file_conv "${1#-I}" mingw
+ set x "$@" -I"$file"
+ shift
+ ;;
+ -l)
+ eat=1
+ func_cl_dashl "$2"
+ set x "$@" "$lib"
+ shift
+ ;;
+ -l*)
+ func_cl_dashl "${1#-l}"
+ set x "$@" "$lib"
+ shift
+ ;;
+ -L)
+ eat=1
+ func_cl_dashL "$2"
+ ;;
+ -L*)
+ func_cl_dashL "${1#-L}"
+ ;;
+ -static)
+ shared=false
+ ;;
+ -Wl,*)
+ arg=${1#-Wl,}
+ save_ifs="$IFS"; IFS=','
+ for flag in $arg; do
+ IFS="$save_ifs"
+ linker_opts="$linker_opts $flag"
+ done
+ IFS="$save_ifs"
+ ;;
+ -Xlinker)
+ eat=1
+ linker_opts="$linker_opts $2"
+ ;;
+ -*)
+ set x "$@" "$1"
+ shift
+ ;;
+ *.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
+ func_file_conv "$1"
+ set x "$@" -Tp"$file"
+ shift
+ ;;
+ *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
+ func_file_conv "$1" mingw
+ set x "$@" "$file"
+ shift
+ ;;
+ *)
+ set x "$@" "$1"
+ shift
+ ;;
+ esac
+ fi
+ shift
+ done
+ if test -n "$linker_opts"; then
+ linker_opts="-link$linker_opts"
+ fi
+ exec "$@" $linker_opts
+ exit 1
+}
+
+eat=
+
+case $1 in
+ '')
+ echo "$0: No command. Try '$0 --help' for more information." 1>&2
+ exit 1;
+ ;;
+ -h | --h*)
+ cat <<\EOF
+Usage: compile [--help] [--version] PROGRAM [ARGS]
+
+Wrapper for compilers which do not understand '-c -o'.
+Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
+arguments, and rename the output as expected.
+
+If you are trying to build a whole package this is not the
+right script to run: please start by reading the file 'INSTALL'.
+
+Report bugs to <[email protected]>.
+EOF
+ exit $?
+ ;;
+ -v | --v*)
+ echo "compile $scriptversion"
+ exit $?
+ ;;
+ cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \
+ icl | *[/\\]icl | icl.exe | *[/\\]icl.exe )
+ func_cl_wrapper "$@" # Doesn't return...
+ ;;
+esac
+
+ofile=
+cfile=
+
+for arg
+do
+ if test -n "$eat"; then
+ eat=
+ else
+ case $1 in
+ -o)
+ # configure might choose to run compile as 'compile cc -o foo foo.c'.
+ # So we strip '-o arg' only if arg is an object.
+ eat=1
+ case $2 in
+ *.o | *.obj)
+ ofile=$2
+ ;;
+ *)
+ set x "$@" -o "$2"
+ shift
+ ;;
+ esac
+ ;;
+ *.c)
+ cfile=$1
+ set x "$@" "$1"
+ shift
+ ;;
+ *)
+ set x "$@" "$1"
+ shift
+ ;;
+ esac
+ fi
+ shift
+done
+
+if test -z "$ofile" || test -z "$cfile"; then
+ # If no '-o' option was seen then we might have been invoked from a
+ # pattern rule where we don't need one. That is ok -- this is a
+ # normal compilation that the losing compiler can handle. If no
+ # '.c' file was seen then we are probably linking. That is also
+ # ok.
+ exec "$@"
+fi
+
+# Name of file we expect compiler to create.
+cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
+
+# Create the lock directory.
+# Note: use '[/\\:.-]' here to ensure that we don't use the same name
+# that we are using for the .o file. Also, base the name on the expected
+# object file name, since that is what matters with a parallel build.
+lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
+while true; do
+ if mkdir "$lockdir" >/dev/null 2>&1; then
+ break
+ fi
+ sleep 1
+done
+# FIXME: race condition here if user kills between mkdir and trap.
+trap "rmdir '$lockdir'; exit 1" 1 2 15
+
+# Run the compile.
+"$@"
+ret=$?
+
+if test -f "$cofile"; then
+ test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
+elif test -f "${cofile}bj"; then
+ test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
+fi
+
+rmdir "$lockdir"
+exit $ret
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC0"
+# time-stamp-end: "; # UTC"
+# End:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh
old/transactional-update-2.1/configure.ac
new/transactional-update-2.2/configure.ac
--- old/transactional-update-2.1/configure.ac 2018-04-26 15:13:51.000000000
+0200
+++ new/transactional-update-2.2/configure.ac 2018-05-02 10:31:13.000000000
+0200
@@ -1,5 +1,5 @@
dnl Process this file with autoconf to produce a configure script.
-AC_INIT(transactional-update, 2.1)
+AC_INIT(transactional-update, 2.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' --exclude Makefile.in --exclude configure --exclude
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh
old/transactional-update-2.1/doc/transactional-update.xml
new/transactional-update-2.2/doc/transactional-update.xml
--- old/transactional-update-2.1/doc/transactional-update.xml 2018-01-29
17:23:19.000000000 +0100
+++ new/transactional-update-2.2/doc/transactional-update.xml 2018-04-30
13:48:03.000000000 +0200
@@ -10,6 +10,11 @@
<surname>Kukuk</surname>
<email>[email protected]</email>
</author>
+ <author>
+ <firstname>Ignaz</firstname>
+ <surname>Forster</surname>
+ <email>[email protected]</email>
+ </author>
</authorgroup>
<releaseinfo>Version 0.1, 15. December 2017</releaseinfo>
<abstract>
@@ -29,21 +34,21 @@
<emphasis remap='B'>transactional-update</emphasis>
is an application that allows to apply intrusive updates to a running
system in an <emphasis>atomic</emphasis> way without influencing the
- running system, taking the system down for a longer period or blocks
- the boot process. It is not a package manager, while implemented for
+ running system, taking the system down for a longer period or blocking
+ the boot process. It is not a package manager - while implemented for
zypper with RPMs, it can be changed to use other package managers
- and package formats. The idea and reason for this is, that you can
- continue to use your existing packages and tool chain to deliver
+ and package formats. The idea and reason for this is being able to
+ continue using your existing packages and tool chain to deliver
and apply updates.
</para>
<para>
- To archive this, <emphasis remap='B'>transactional-update</emphasis>
- creates for every update a new snapshot with
+ To achieve this, <emphasis remap='B'>transactional-update</emphasis>
+ every update will create a new snapshot with
<emphasis>btrfs</emphasis> and updates this to the latest version of
the product. Since snapshots contain only the difference between two
- versions and thus are mostly very small, this is very space efficient.
- Which also means you can have more parallel installations than just
- two bootable root partitions.
+ versions this is very space efficient as updates are usually very
+ small. This also means there is no limit to two bootable root
+ partitions as there can be any number of parallel snapshots.
</para>
</section>
@@ -81,7 +86,7 @@
<para>
if the upgrade fails or if the newer software
version is not compatible with your infrastructure, you can
- quickly restore the situation as it was before the upgrade.
+ quickly restore the situation as it was before the upgrade.
</para>
</listitem>
</itemizedlist>
@@ -330,7 +335,7 @@
</chapter>
<chapter id="tu-setup">
- <title> Setup of system </title>
+ <title>Setup of system</title>
<para>
Read-only root filesystem or Read-Write filesystem? Requirements for
RPMs, what is allowed and what not. Config files in /etc with
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh
old/transactional-update-2.1/man/transactional-update.8
new/transactional-update-2.2/man/transactional-update.8
--- old/transactional-update-2.1/man/transactional-update.8 2018-04-20
13:14:21.000000000 +0200
+++ new/transactional-update-2.2/man/transactional-update.8 2018-04-17
16:40:32.000000000 +0200
@@ -2,12 +2,12 @@
.\" Title: transactional-update
.\" Author: Thorsten Kukuk <[email protected]>
.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
-.\" Date: 04/20/2018
+.\" Date: 04/17/2018
.\" Manual: transactional-update
.\" Source: transactional-update
.\" Language: English
.\"
-.TH "TRANSACTIONAL\-UPDAT" "8" "04/20/2018" "transactional-update"
"transactional-update"
+.TH "TRANSACTIONAL\-UPDAT" "8" "04/17/2018" "transactional-update"
"transactional-update"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh
old/transactional-update-2.1/man/transactional-update.conf.5
new/transactional-update-2.2/man/transactional-update.conf.5
--- old/transactional-update-2.1/man/transactional-update.conf.5
2018-03-12 13:17:34.000000000 +0100
+++ new/transactional-update-2.2/man/transactional-update.conf.5
2018-04-09 13:34:09.000000000 +0200
@@ -2,12 +2,12 @@
.\" Title: transactional-update.conf
.\" Author: Ignaz Forster <[email protected]>
.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
-.\" Date: 03/12/2018
+.\" Date: 04/09/2018
.\" Manual: transactional-update.conf
.\" Source: transactional-update
.\" Language: English
.\"
-.TH "TRANSACTIONAL\-UPDAT" "5" "03/12/2018" "transactional-update"
"transactional-update.conf"
+.TH "TRANSACTIONAL\-UPDAT" "5" "04/09/2018" "transactional-update"
"transactional-update.conf"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh
old/transactional-update-2.1/missing new/transactional-update-2.2/missing
--- old/transactional-update-2.1/missing 2018-04-20 13:36:30.000000000
+0200
+++ new/transactional-update-2.2/missing 2018-04-30 13:54:06.000000000
+0200
@@ -1,9 +1,9 @@
#! /bin/sh
# Common wrapper for a few potentially missing GNU programs.
-scriptversion=2012-06-26.16; # UTC
+scriptversion=2016-01-11.22; # UTC
-# Copyright (C) 1996-2013 Free Software Foundation, Inc.
+# Copyright (C) 1996-2017 Free Software Foundation, Inc.
# Originally written by Fran,cois Pinard <[email protected]>, 1996.
# This program is free software; you can redistribute it and/or modify
@@ -160,7 +160,7 @@
;;
autom4te*)
echo "You might have modified some maintainer files that require"
- echo "the 'automa4te' program to be rebuilt."
+ echo "the 'autom4te' program to be rebuilt."
program_details 'autom4te'
;;
bison*|yacc*)
@@ -210,6 +210,6 @@
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-time-zone: "UTC"
+# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh
old/transactional-update-2.1/sbin/create_dirs_from_rpmdb.c
new/transactional-update-2.2/sbin/create_dirs_from_rpmdb.c
--- old/transactional-update-2.1/sbin/create_dirs_from_rpmdb.c 2018-04-24
14:06:06.000000000 +0200
+++ new/transactional-update-2.2/sbin/create_dirs_from_rpmdb.c 2018-04-30
13:47:58.000000000 +0200
@@ -25,8 +25,10 @@
#include <pwd.h>
#include <grp.h>
#include <time.h>
+#include <string.h>
#include <unistd.h>
#include <getopt.h>
+#include <malloc.h>
#include <rpm/rpmcli.h>
#include <rpm/rpmts.h>
#include <rpm/rpmdb.h>
@@ -55,6 +57,143 @@
}
+/* Quicksort code to sort the directories before creating them. Else we could
run into the case,
+ that we have to create sub-directories and the parents don't exist yet. */
+
+struct node
+{
+ const char *dirname;
+ rpm_mode_t fmode;
+ uid_t user_id;
+ gid_t group_id;
+ time_t fmtime;
+ struct node *next;
+};
+
+struct node *dir_list = NULL;
+
+/* 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,
+ uid_t user_id, gid_t group_id, time_t fmtime)
+{
+ /* allocate node */
+ struct node* new_node = malloc(sizeof(struct node));
+
+ /* put in the data */
+ new_node->dirname = strdup (dirname);
+ new_node->fmode = fmode;
+ 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)
+{
+ (*headRef) = quicksort_rec(*headRef, get_last_node(*headRef));
+ return;
+}
+
static char *
fmode2str (int mode)
{
@@ -136,7 +275,6 @@
strncmp (prefixes[i], fn, strlen (prefixes[i]))== 0 &&
access (fn, F_OK) == -1)
{
- int rc = 0;
struct tm * tm;
char timefield[100];
rpm_time_t fmtime = rpmfiFMtime(fi);
@@ -147,10 +285,6 @@
gid_t group_id;
struct passwd *pwd;
struct group *grp;
- struct timeval stamps[2] = {
- { .tv_sec = mtime, .tv_usec = 0 },
- { .tv_sec = mtime, .tv_usec = 0 }};
-
if (debug_flag)
{
@@ -165,28 +299,18 @@
(void)strftime(timefield, sizeof(timefield) - 1, fmt,
tm);
}
- printf ("Create %s (%s,%s,%s,%s)\n", fn, perms, fuser,
+ printf ("Missing %s (%s,%s,%s,%s)\n", fn, perms, fuser,
fgroup, timefield);
free (perms);
}
- else if (verbose_flag)
- printf ("Create %s\n", fn);
-
- rc = mkdir (fn, fmode);
- if (rc < 0)
- {
- fprintf (stderr, "Failed to create directory '%s':
%m\n", fn);
- ec = 1;
- goto exit;
- }
pwd = getpwnam (fuser);
grp = getgrnam (fgroup);
if (pwd == NULL || grp == NULL)
{
- fprintf (stderr, "Failed to resolve %s/%s\n", fuser,
fgroup);
- rmdir (fn);
+ fprintf (stderr, "Failed to resolve %s/%s\n",
+ fuser, fgroup);
ec = 1;
goto exit;
}
@@ -194,17 +318,7 @@
user_id = pwd->pw_uid;
group_id = grp->gr_gid;
- rc = chown (fn, user_id, group_id);
- if (rc < 0)
- {
- fprintf (stderr, "Failed to set owner/group for '%s':
%m\n", fn);
- /* wrong permissions are bad, remove dir and continue */
- rmdir (fn);
- ec = 1;
- goto exit;
- }
- /* ignore errors here, time stamps are not critical */
- utimes (fn, stamps);
+ insert_node (&dir_list, fn, fmode, user_id, group_id, fmtime);
}
}
}
@@ -217,6 +331,47 @@
}
int
+create_dirs (struct node *node)
+{
+ int rc = 0;
+
+ while (node != NULL)
+ {
+ struct timeval stamps[2] = {
+ { .tv_sec = node->fmtime, .tv_usec = 0 },
+ { .tv_sec = node->fmtime, .tv_usec = 0 }};
+
+ if (verbose_flag)
+ printf ("Create %s\n", node->dirname);
+
+ rc = mkdir (node->dirname, node->fmode);
+ if (rc < 0)
+ {
+ fprintf (stderr, "Failed to create directory '%s': %m\n",
node->dirname);
+ rc = 1;
+ goto exit;
+ }
+
+ rc = chown (node->dirname, node->user_id, node->group_id);
+ if (rc < 0)
+ {
+ fprintf (stderr, "Failed to set owner/group for '%s': %m\n",
node->dirname);
+ /* wrong permissions are bad, remove dir and continue */
+ rmdir (node->dirname);
+ rc = 1;
+ goto exit;
+ }
+ /* ignore errors here, time stamps are not critical */
+ utimes (node->dirname, stamps);
+ exit:
+ node = node->next;
+ }
+
+ return rc;
+}
+
+
+int
main (int argc, char *argv[])
{
Header h;
@@ -293,6 +448,16 @@
ec = rc;
}
+ if (dir_list != NULL)
+ {
+ int rc;
+ quicksort (&dir_list);
+ if ((rc = create_dirs (dir_list)) != 0)
+ ec = rc;
+ }
+
+ /* XXX missing: free list */
+
rpmdbFreeIterator (mi);
rpmtsFree (ts);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh
old/transactional-update-2.1/sbin/transactional-update.in
new/transactional-update-2.2/sbin/transactional-update.in
--- old/transactional-update-2.1/sbin/transactional-update.in 2018-04-30
09:44:56.000000000 +0200
+++ new/transactional-update-2.2/sbin/transactional-update.in 2018-04-30
13:53:13.000000000 +0200
@@ -70,12 +70,16 @@
echo "Checking for newer version."
if zypper info transactional-update | grep -q '^Status *: out-of-date';
then
echo "New version found - updating..."
- export TA_UPDATE_TMPFILE="`mktemp -d
/tmp/transactional-update.XXXXXXXXXX`"
+ TA_UPDATE_TMPFILE="`mktemp -d /tmp/transactional-update.XXXXXXXXXX`"
+ if [ $? -ne 0 ]; then
+ quit 1;
+ fi
+ export TA_UPDATE_TMPFILE
cd "${TA_UPDATE_TMPFILE}"
zypper --pkg-cache-dir "${TA_UPDATE_TMPFILE}" download
transactional-update
find . -name transactional-update*.rpm -exec rpm2cpio {} \; | cpio
-idmv >/dev/null
rm -f "${LOCKFILE}"
- exec "${TA_UPDATE_TMPFILE}/usr/sbin/transactional-update" $@
+ exec "${TA_UPDATE_TMPFILE}/usr/sbin/transactional-update" "$@"
fi
}